Permalink
Browse files

get_my_courses() - added optimisation for guest login

- was causing very slow page generation
  • Loading branch information...
1 parent b5f523a commit dcf93f810795d4bbd27d4fffa306c79c1c2cb0d6 martinlanghoff committed May 6, 2007
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/datalib.php
View
@@ -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 @@ function get_my_courses($userid, $sort=NULL, $fields=NULL, $doanything=false,$li
$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

0 comments on commit dcf93f8

Please sign in to comment.