From: toyomoyo Date: Mon, 4 Dec 2006 01:54:24 +0000 (+0000) Subject: merged fixed a bug where admin can't unassign himself from non-admin role in site... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=30c82426e3ffa64b4cc12b33fce825830d54cb4d;p=moodle.git merged fixed a bug where admin can't unassign himself from non-admin role in site context --- diff --git a/admin/roles/assign.php b/admin/roles/assign.php index 48db187816..a8419543a6 100755 --- a/admin/roles/assign.php +++ b/admin/roles/assign.php @@ -155,9 +155,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);