Merge branch 'MDL-69342-310_profile_picture_deletion' of https://github.com/vtos/moodle into MOODLE_310_STABLE
This commit is contained in:
+27
-25
@@ -601,34 +601,36 @@ class core_user {
|
||||
// The user has chosen to delete the selected users picture.
|
||||
$fs->delete_area_files($context->id, 'user', 'icon'); // Drop all images in area.
|
||||
$newpicture = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Save newly uploaded file, this will avoid context mismatch for newly created users.
|
||||
file_save_draft_area_files($usernew->imagefile, $context->id, 'user', 'newicon', 0, $filemanageroptions);
|
||||
if (($iconfiles = $fs->get_area_files($context->id, 'user', 'newicon')) && count($iconfiles) == 2) {
|
||||
// Get file which was uploaded in draft area.
|
||||
foreach ($iconfiles as $file) {
|
||||
if (!$file->is_directory()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Copy file to temporary location and the send it for processing icon.
|
||||
if ($iconfile = $file->copy_content_to_temp()) {
|
||||
// There is a new image that has been uploaded.
|
||||
// Process the new image and set the user to make use of it.
|
||||
// NOTE: Uploaded images always take over Gravatar.
|
||||
$newpicture = (int)process_new_icon($context, 'user', 'icon', 0, $iconfile);
|
||||
// Delete temporary file.
|
||||
@unlink($iconfile);
|
||||
// Remove uploaded file.
|
||||
$fs->delete_area_files($context->id, 'user', 'newicon');
|
||||
} else {
|
||||
// Something went wrong while creating temp file.
|
||||
// Remove uploaded file.
|
||||
$fs->delete_area_files($context->id, 'user', 'newicon');
|
||||
return false;
|
||||
// Save newly uploaded file, this will avoid context mismatch for newly created users.
|
||||
if (!isset($usernew->imagefile)) {
|
||||
$usernew->imagefile = 0;
|
||||
}
|
||||
file_save_draft_area_files($usernew->imagefile, $context->id, 'user', 'newicon', 0, $filemanageroptions);
|
||||
if (($iconfiles = $fs->get_area_files($context->id, 'user', 'newicon')) && count($iconfiles) == 2) {
|
||||
// Get file which was uploaded in draft area.
|
||||
foreach ($iconfiles as $file) {
|
||||
if (!$file->is_directory()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Copy file to temporary location and the send it for processing icon.
|
||||
if ($iconfile = $file->copy_content_to_temp()) {
|
||||
// There is a new image that has been uploaded.
|
||||
// Process the new image and set the user to make use of it.
|
||||
// NOTE: Uploaded images always take over Gravatar.
|
||||
$newpicture = (int)process_new_icon($context, 'user', 'icon', 0, $iconfile);
|
||||
// Delete temporary file.
|
||||
@unlink($iconfile);
|
||||
// Remove uploaded file.
|
||||
$fs->delete_area_files($context->id, 'user', 'newicon');
|
||||
} else {
|
||||
// Something went wrong while creating temp file.
|
||||
// Remove uploaded file.
|
||||
$fs->delete_area_files($context->id, 'user', 'newicon');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newpicture != $user->picture) {
|
||||
|
||||
Reference in New Issue
Block a user