MDL-13179 - avoid calling get_admin() when unecessary.
It uses a relatively complex query and its not needed except for a minority of users so we may as well avoid it.. merged from MOODLE_19_STABLE
This commit is contained in:
+4
-6
@@ -95,9 +95,8 @@
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);
|
||||
|
||||
/// Can only edit profile if it belongs to user or current user is admin and not editing primary admin
|
||||
|
||||
$mainadmin = get_admin();
|
||||
/// Can only edit profile if it belongs to user or current user is admin and not editing primary admin
|
||||
|
||||
if(empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
@@ -122,11 +121,10 @@
|
||||
$edittype = 'normal';
|
||||
}
|
||||
|
||||
} else if ($user->id != $mainadmin->id) {
|
||||
//no editing of primary admin!
|
||||
if (has_capability('moodle/user:update', $systemcontext)) {
|
||||
} else {
|
||||
if (has_capability('moodle/user:update', $systemcontext) and !is_primary_admin($user->id)){
|
||||
$edittype = 'advanced';
|
||||
} else if (has_capability('moodle/user:editprofile', $personalcontext)) {
|
||||
} else if (has_capability('moodle/user:editprofile', $personalcontext) and !is_primary_admin($user->id)){
|
||||
//teachers, parents, etc.
|
||||
$edittype = 'normal';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user