global $USER, $CONTEXT, $CFG;
- if (!isloggedin() && !isset($USER->capabilities)) {
+ if (empty($userid) && !isloggedin() && !isset($USER->capabilities)) {
load_notloggedin_role();
}
error ('This is an unknown context!');
return false;
}
- if ($CFG->debug > 15) {
+ if ($CFG->debug > 7) {
notify("Found $capability recursively from context $context->id at level $context->aggregatelevel: $permission", 'notifytiny');
}
global $USER, $CFG;
- // make sure it's cleaned when loaded (again)
- if (!empty($USER->capabilities)) {
- unset($USER->capabilities);
- }
if (empty($userid)) {
+ if (empty($USER->id)) { // We have no user to get capabilities for
+ return false;
+ }
+ if (!empty($USER->capabilities)) { // make sure it's cleaned when loaded (again)
+ unset($USER->capabilities);
+ }
$userid = $USER->id;
+ $otheruserid = false;
} else {
$otheruserid = $userid;
}
return false;
}
+ if ($groupid && !record_exists('groups', 'id', $groupid)) {
+ notify('Group does not exist!');
+ return false;
+ }
+
if (!$context = get_context_instance_by_id($contextid)) {
notify('A valid context must be provided');
return false;