mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-69342 core_user: fixed user picture updating
When editing a user and checking the 'Delete picture' checkbox to delete the old picture and uploading a new one at a time, the new one didn't appear in the user profile. This happened due to the 'if/else' statement in the 'core_user::update_picture()' method which allowed either to delete the old picture or to upload a new one. The fix removes the 'else' part of the 'if/else' statement to force checking for a new uploaded picture no matter if a user checked the 'Delete picture' checkbox or not.
This commit is contained in:
parent
e2ef786003
commit
141216f94c
1 changed files with 27 additions and 25 deletions
|
@ -601,9 +601,12 @@ 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.
|
||||
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.
|
||||
|
@ -629,7 +632,6 @@ class core_user {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($newpicture != $user->picture) {
|
||||
$DB->set_field('user', 'picture', $newpicture, array('id' => $user->id));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue