diff --git a/lang/en/moodle.php b/lang/en/moodle.php index a998a5efd8a..9cbbe57f529 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1263,6 +1263,7 @@ Cheers from the \'{$a->sitename}\' administrator, {$a->signoff}'; $string['newpicture'] = 'New picture'; $string['newpicture_help'] = 'To add a new picture, browse and select an image (in JPG or PNG format) then click "Update profile". The image will be cropped to a square and resized to 100x100 pixels.'; +$string['newpictureusernotsetup'] = 'A profile picture can only be added once all required profile information has been saved.'; $string['newsectionname'] = 'New name for section {$a}'; $string['newsitem'] = 'news item'; $string['newsitems'] = 'news items'; diff --git a/user/edit_form.php b/user/edit_form.php index 5bf35a9d9e4..bb614acaf2b 100644 --- a/user/edit_form.php +++ b/user/edit_form.php @@ -45,6 +45,7 @@ class user_edit_form extends moodleform { $mform = $this->_form; $editoroptions = null; $filemanageroptions = null; + $usernotfullysetup = user_not_fully_set_up($USER); if (!is_array($this->_customdata)) { throw new coding_exception('invalid custom data for user_edit_form'); @@ -76,12 +77,30 @@ class user_edit_form extends moodleform { useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $user); // Extra settigs. - if (!empty($CFG->disableuserimages)) { + if (!empty($CFG->disableuserimages) || $usernotfullysetup) { $mform->removeElement('deletepicture'); $mform->removeElement('imagefile'); $mform->removeElement('imagealt'); } + // If the user isn't fully set up, let them know that they will be able to change + // their profile picture once their profile is complete. + if ($usernotfullysetup) { + $userpicturewarning = $mform->createElement('warning', 'userpicturewarning', 'notifymessage', get_string('newpictureusernotsetup')); + $enabledusernamefields = useredit_get_enabled_name_fields(); + if ($mform->elementExists('moodle_additional_names')) { + $mform->insertElementBefore($userpicturewarning, 'moodle_additional_names'); + } else if ($mform->elementExists('moodle_interests')) { + $mform->insertElementBefore($userpicturewarning, 'moodle_interests'); + } else { + $mform->insertElementBefore($userpicturewarning, 'moodle_optional'); + } + + // This is expected to exist when the form is submitted. + $imagefile = $mform->createElement('hidden', 'imagefile'); + $mform->insertElementBefore($imagefile, 'userpicturewarning'); + } + // Next the customisable profile fields. profile_definition($mform, $userid);