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:
poltawski
2008-01-26 17:00:03 +00:00
parent 29ee92888b
commit fc4b2decc0
5 changed files with 23 additions and 12 deletions
+4 -6
View File
@@ -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';
}