Skip to content

Commit

Permalink
fixed a bug where admin can't unassign himself from non admin roles a…
Browse files Browse the repository at this point in the history
…t site context
  • Loading branch information
toyomoyo committed Dec 4, 2006
1 parent fe2f027 commit aea1aa8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions admin/roles/assign.php
Expand Up @@ -158,9 +158,17 @@
} else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {

$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$topleveladmin = ( ($context->id == $sitecontext->id) &&
has_capability('moodle/site:doanything', $sitecontext) );

$topleveladmin = false;

// we only worry about this if the role has doanything capability at site level
if ($adminroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext)) {
foreach ($adminroles as $adminrole) {
if ($adminrole->id == $roleid) {
$topleveladmin = true;
}
}
}

foreach ($frm->removeselect as $removeuser) {
$removeuser = clean_param($removeuser, PARAM_INT);

Expand Down

0 comments on commit aea1aa8

Please sign in to comment.