merged fixed a bug where admin can't unassign himself from non-admin role in site context

This commit is contained in:
toyomoyo 2006-12-04 01:54:24 +00:00
parent a08d5db719
commit 30c82426e3

View File

@ -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);