]> git.mjollnir.org Git - moodle.git/commitdiff
isguest() compatible with roles
authorskodak <skodak>
Sat, 26 Aug 2006 18:42:56 +0000 (18:42 +0000)
committerskodak <skodak>
Sat, 26 Aug 2006 18:42:56 +0000 (18:42 +0000)
lib/moodlelib.php

index 2e8808900efc683be760fc7d67f279491855ed91..82455867c0537304aa687c22b48bfce33fe7a185 100644 (file)
@@ -2262,7 +2262,18 @@ function isstudent($courseid, $userid=0) {
  * @return bool
  */
 function isguest($userid=0) {
-    global $USER;
+    global $USER, $CFG;
+
+    if (!empty($CFG->rolesactive)) {
+
+        $context = get_context_instance(CONTEXT_SYSTEM, SITEID);  
+
+        if (!$userid) {
+            return has_capability('moodle/legacy:guest', $context);
+        } else {
+            return has_capability('moodle/legacy:guest', $context, $userid);
+        }
+    }
 
     if (!$userid) {
         if (empty($USER->username)) {