]> git.mjollnir.org Git - moodle.git/commitdiff
get_my_courses() - added optimisation for guest login
authormartinlanghoff <martinlanghoff>
Sun, 6 May 2007 05:28:39 +0000 (05:28 +0000)
committermartinlanghoff <martinlanghoff>
Sun, 6 May 2007 05:28:39 +0000 (05:28 +0000)
- was causing very slow page generation

lib/datalib.php

index 65dce50b3c9afa7f1d8b9fff58108e8db994e140..7472d84bda37242fc791e76b06cdd9adbe0f26cb 100644 (file)
@@ -717,6 +717,11 @@ function get_my_courses($userid, $sort=NULL, $fields=NULL, $doanything=false,$li
     
     // Check root permissions
     $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); 
+    
+    // Guest's do not have any courses
+    if (has_capability('moodle/legacy:guest',$sitecontext,$userid,true)) {
+        return(array());
+    }
 
     // we can optimise some things for true admins
     $candoanything = false;
@@ -778,7 +783,8 @@ ORDER BY $sort");
                     $mycourses[$course->id] = $course;
                     continue;
                 }
-
+                
+                
                 // users with moodle/course:view are considered course participants
                 // the course needs to be visible, or user must have moodle/course:viewhiddencourses 
                 // capability set to view hidden courses