Commit 8aa074c4 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Adding 'success' messages for admin/users/edit.php (Bug #1314416)

Now should get succes messages for:
- saving Site account settings
- adding user to institution
- updating user institution settings
- removing user from institution

Change-Id: Ifc7de7950442e0e0be29a03c7bf2ba570e3e2d58
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent c679c3b2
......@@ -519,7 +519,7 @@ function edituser_site_submit(Pieform $form, $values) {
}
}
db_commit();
$SESSION->add_ok_msg(get_string('usersitesettingschanged', 'admin'));
redirect('/admin/users/edit.php?id='.$user->id);
}
......@@ -739,7 +739,7 @@ function edituser_institution_submit(Pieform $form, $values) {
}
$userinstitutions = $user->get('institutions');
global $USER;
global $USER, $SESSION;
foreach ($userinstitutions as $i) {
if ($USER->can_edit_institution($i->institution)) {
if (isset($values[$i->institution.'_submit'])) {
......@@ -762,13 +762,17 @@ function edituser_institution_submit(Pieform $form, $values) {
}
handle_event('updateuser', $user->id);
db_commit();
$SESSION->add_ok_msg(get_string('userinstitutionupdated', 'admin', $i->displayname));
break;
} else if (isset($values[$i->institution.'_remove'])) {
}
else if (isset($values[$i->institution.'_remove'])) {
if ($user->id == $USER->id) {
$USER->leave_institution($i->institution);
} else {
}
else {
$user->leave_institution($i->institution);
}
$SESSION->add_ok_msg(get_string('userinstitutionremoved', 'admin', $i->displayname));
// Institutional admins can no longer access this page
// if they remove the user from the institution, so
// send them back to user search.
......@@ -792,6 +796,8 @@ function edituser_institution_submit(Pieform $form, $values) {
else {
$user->join_institution($values['addinstitution']);
}
$userinstitutions = $user->get('institutions');
$SESSION->add_ok_msg(get_string('userinstitutionjoined', 'admin', $userinstitutions[$values['addinstitution']]->displayname));
}
redirect('/admin/users/edit.php?id='.$user->id);
......
......@@ -768,7 +768,11 @@ $string['usereditwarning'] = 'NOTE: Saving the account changes will cause the us
$string['suspenduserdescription'] = 'A suspended user is unable to log in until the account is unsuspended.';
$string['deleteusernote'] = 'Please note that this operation <strong>cannot be undone</strong>.';
$string['youcannotadministerthisuser'] = 'You cannot administer this user.';
$string['userinstitutionjoined'] = 'User added to institution "%s".';
$string['userinstitutionremoved'] = 'User removed from institution "%s".';
$string['userinstitutionupdated'] = 'User settings for institution "%s" updated.';
$string['usernamechangenotallowed'] = 'The chosen authentication method does not allow changes to the username.';
$string['usersitesettingschanged'] = 'Site account settings updated.';
$string['passwordchangenotallowed'] = 'The chosen authentication method does not allow changes to the password.';
$string['thisuserdeleted'] = 'This user has been deleted.';
$string['disableemail'] = 'Disable email';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment