Skip to content

Commit

Permalink
back porting changes for MDL-8820, users with moodle/user:editprofile…
Browse files Browse the repository at this point in the history
… assigned at user context should be able to edit them
  • Loading branch information
toyomoyo committed Mar 16, 2007
1 parent b068552 commit 5c5cb3e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}

if ($USER->id <> $user->id) { // Current user editing someone else's profile
if (has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) { // Current user can update user profiles
if (has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID)) || has_capability('moodle/user:editprofile', get_context_instance(CONTEXT_USER, $user->id))) { // Current user can update user profiles
if ($mainadmin = get_admin()) {
if ($user->id == $mainadmin->id) { // Can't edit primary admin
print_error('adminprimarynoedit');
Expand Down Expand Up @@ -81,7 +81,7 @@
if ($dummyuser->username == 'changeme') { // check for add user
require_capability('moodle/user:create', $context);
} else {
if ($USER->id <> $usernew->id and !has_capability('moodle/user:update', $context)) { // check for edit
if ($USER->id <> $usernew->id and !has_capability('moodle/user:update', $context) and !has_capability('moodle/user:editprofile', get_context_instance(CONTEXT_USER, $usernew->id))) { // check for edit
print_error('onlyeditown');
}
}
Expand Down Expand Up @@ -258,7 +258,7 @@

add_to_log($course->id, "user", "update", "view.php?id=$user->id&course=$course->id", "");

if ($user->id == $USER->id) {
if ($user->id == $USER->id || !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) { // non admin redirect
// Copy data into $USER session variable
$usernew = (array)$usernew;
foreach ($usernew as $variable => $value) {
Expand Down

0 comments on commit 5c5cb3e

Please sign in to comment.