1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-24 18:04:43 +02:00

MDL-61402 Core: Add a cancel button to edit profile page

This commit is contained in:
M Kassaei 2018-02-08 11:14:37 +00:00
parent d1b4ca921e
commit 7ce538be0f
5 changed files with 43 additions and 22 deletions

@ -176,18 +176,20 @@ $userform = new user_edit_form(new moodle_url($PAGE->url, array('returnto' => $r
$emailchanged = false;
if ($usernew = $userform->get_data()) {
// Deciding where to send the user back in most cases.
if ($returnto === 'profile') {
if ($course->id != SITEID) {
$returnurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
} else {
$returnurl = new moodle_url('/user/profile.php', array('id' => $user->id));
}
// Deciding where to send the user back in most cases.
if ($returnto === 'profile') {
if ($course->id != SITEID) {
$returnurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
} else {
$returnurl = new moodle_url('/user/preferences.php', array('userid' => $user->id));
$returnurl = new moodle_url('/user/profile.php', array('id' => $user->id));
}
} else {
$returnurl = new moodle_url('/user/preferences.php', array('userid' => $user->id));
}
if ($userform->is_cancelled()) {
redirect($returnurl);
} else if ($usernew = $userform->get_data()) {
$emailchangedhtml = '';

@ -104,7 +104,7 @@ class user_edit_form extends moodleform {
// Next the customisable profile fields.
profile_definition($mform, $userid);
$this->add_action_buttons(false, get_string('updatemyprofile'));
$this->add_action_buttons(true, get_string('updatemyprofile'));
$this->set_data($user);
}

@ -154,7 +154,21 @@ $userform = new user_editadvanced_form(new moodle_url($PAGE->url, array('returnt
'filemanageroptions' => $filemanageroptions,
'user' => $user));
if ($usernew = $userform->get_data()) {
// Deciding where to send the user back in most cases.
if ($returnto === 'profile') {
if ($course->id != SITEID) {
$returnurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
} else {
$returnurl = new moodle_url('/user/profile.php', array('id' => $user->id));
}
} else {
$returnurl = new moodle_url('/user/preferences.php', array('userid' => $user->id));
}
if ($userform->is_cancelled()) {
redirect($returnurl);
} else if ($usernew = $userform->get_data()) {
$usercreated = false;
if (empty($usernew->auth)) {
@ -292,15 +306,6 @@ if ($usernew = $userform->get_data()) {
// Somebody double clicked when editing admin user during install.
redirect("$CFG->wwwroot/$CFG->admin/");
} else {
if ($returnto === 'profile') {
if ($course->id != SITEID) {
$returnurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
} else {
$returnurl = new moodle_url('/user/profile.php', array('id' => $user->id));
}
} else {
$returnurl = new moodle_url('/user/preferences.php', array('userid' => $user->id));
}
redirect($returnurl);
}
} else {

@ -154,7 +154,7 @@ class user_editadvanced_form extends moodleform {
$btnstring = get_string('updatemyprofile');
}
$this->add_action_buttons(false, $btnstring);
$this->add_action_buttons(true, $btnstring);
$this->set_data($user);
}

@ -35,6 +35,13 @@ Feature: Both first name and surname are always available for every user
# End UI test covering "I open my profile in edit mode"
When I set the field "First name" to " "
And I set the field "Surname" to " "
And I click on "Cancel" "button"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
Then I should see "Foo"
And I should see "Bar"
When I set the field "First name" to " "
And I set the field "Surname" to " "
And I click on "Update profile" "button"
Then I should see "Missing given name"
And I should see "Missing surname"
@ -49,6 +56,13 @@ Feature: Both first name and surname are always available for every user
And I click on "Edit profile" "link" in the "region-main" "region"
When I set the field "First name" to " "
And I set the field "Surname" to " "
And I click on "Cancel" "button"
And I follow "Foo Bar"
And I click on "Edit profile" "link" in the "region-main" "region"
Then I should see "Foo"
And I should see "Bar"
When I set the field "First name" to " "
And I set the field "Surname" to " "
And I click on "Update profile" "button"
Then I should see "Missing given name"
And I should see "Missing surname"