From 30c82426e3ffa64b4cc12b33fce825830d54cb4d Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Mon, 4 Dec 2006 01:54:24 +0000 Subject: [PATCH] merged fixed a bug where admin can't unassign himself from non-admin role in site context --- admin/roles/assign.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/admin/roles/assign.php b/admin/roles/assign.php index 48db1878166..a8419543a6b 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);