From: Martin Dougiamas Date: Tue, 27 Oct 2009 09:31:46 +0000 (+0000) Subject: accesslib - Remove some notices when user is not logged in X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7fde45a7e6b414deba4c0f67744bcf57d323598b;p=moodle.git accesslib - Remove some notices when user is not logged in --- diff --git a/lib/accesslib.php b/lib/accesslib.php index 7133845edf..d12cbfa961 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -510,7 +510,7 @@ function has_capability($capability, $context, $userid=NULL, $doanything=true) { } $USER->access = $ACCESSLIB_PRIVATE->accessdatabyuser[$userid]; - } else if ($USER->id == $userid && !isset($USER->access)) { + } else if (isset($USER->id) && ($USER->id == $userid) && !isset($USER->access)) { // caps not loaded yet - better to load them to keep BC with 1.8 // not-logged-in user or $USER object set up manually first time here load_all_capabilities(); @@ -549,7 +549,7 @@ function has_capability($capability, $context, $userid=NULL, $doanything=true) { // divulge how many times we are called //// error_log("has_capability: id:{$context->id} path:{$context->path} userid:$userid cap:$capability"); - if ($USER->id == $userid) { // we must accept strings and integers in $userid + if (isset($USER->id) && ($USER->id == $userid)) { // we must accept strings and integers in $userid // // For the logged in user, we have $USER->access // which will have all RAs and caps preloaded for