mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
save_user_image ---> save_profile_image so it works for groups too
This commit is contained in:
parent
35067c438f
commit
7721c69499
@ -46,10 +46,9 @@ function ImageCopyBicubic ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function save_user_image($userid, $filename) {
|
||||
function save_profile_image($id, $filename, $dir="users") {
|
||||
// Given a filename to a known image, this function scales and crops
|
||||
// it and saves it in the right place to be a user image.
|
||||
// it and saves it in the right place to be a "user" or "group" image.
|
||||
|
||||
global $CFG;
|
||||
|
||||
@ -59,19 +58,19 @@ function save_user_image($userid, $filename) {
|
||||
|
||||
umask(0000);
|
||||
|
||||
if (!file_exists("$CFG->dataroot/users")) {
|
||||
if (! mkdir("$CFG->dataroot/users", $CFG->directorypermissions)) {
|
||||
if (!file_exists("$CFG->dataroot/$dir")) {
|
||||
if (! mkdir("$CFG->dataroot/$dir", $CFG->directorypermissions)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists("$CFG->dataroot/users/$userid")) {
|
||||
if (! mkdir("$CFG->dataroot/users/$userid", $CFG->directorypermissions)) {
|
||||
if (!file_exists("$CFG->dataroot/$dir/$id")) {
|
||||
if (! mkdir("$CFG->dataroot/$dir/$id", $CFG->directorypermissions)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$originalfile = "$CFG->dataroot/users/$userid/original";
|
||||
$originalfile = "$CFG->dataroot/$dir/$id/original";
|
||||
|
||||
if (!move_uploaded_file($filename, $originalfile)) {
|
||||
return false;
|
||||
@ -157,10 +156,10 @@ function save_user_image($userid, $filename) {
|
||||
ImageLine ($im2, 34, 34, 34, 0, $black2);
|
||||
ImageLine ($im2, 34, 0, 0, 0, $black2);
|
||||
|
||||
if (ImageJpeg($im1, "$CFG->dataroot/users/$userid/f1.jpg", 90) and
|
||||
ImageJpeg($im2, "$CFG->dataroot/users/$userid/f2.jpg", 95) ) {
|
||||
@chmod("$CFG->dataroot/users/$userid/f1.jpg", 0666);
|
||||
@chmod("$CFG->dataroot/users/$userid/f2.jpg", 0666);
|
||||
if (ImageJpeg($im1, "$CFG->dataroot/$dir/$id/f1.jpg", 90) and
|
||||
ImageJpeg($im2, "$CFG->dataroot/$dir/$id/f2.jpg", 95) ) {
|
||||
@chmod("$CFG->dataroot/$dir/$id/f1.jpg", 0666);
|
||||
@chmod("$CFG->dataroot/$dir/$id/f2.jpg", 0666);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -68,7 +68,7 @@
|
||||
|
||||
if (find_form_errors($user, $usernew, $err)) {
|
||||
if ($filename = valid_uploaded_file($_FILES['imagefile'])) {
|
||||
$usernew->picture = save_user_image($user->id, $filename);
|
||||
$usernew->picture = save_profile_image($user->id, $filename);
|
||||
}
|
||||
|
||||
$user = $usernew;
|
||||
@ -77,7 +77,7 @@
|
||||
$timenow = time();
|
||||
|
||||
if ($filename = valid_uploaded_file($_FILES['imagefile'])) {
|
||||
$usernew->picture = save_user_image($user->id, $filename);
|
||||
$usernew->picture = save_profile_image($user->id, $filename);
|
||||
} else {
|
||||
$usernew->picture = $user->picture;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user