]> git.mjollnir.org Git - moodle.git/commitdiff
merged fixed a bug where admin can't unassign himself from non-admin role in site...
authortoyomoyo <toyomoyo>
Mon, 4 Dec 2006 01:54:24 +0000 (01:54 +0000)
committertoyomoyo <toyomoyo>
Mon, 4 Dec 2006 01:54:24 +0000 (01:54 +0000)
admin/roles/assign.php

index 48db187816628285c5de2e2d4f770e955fb93a7a..a8419543a6bac9830c6d8fd36b10b0161fccfd8a 100755 (executable)
         } 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);