Index: lib/datalib.php
===================================================================
--- lib/datalib.php	(revision 8644)
+++ lib/datalib.php	(working copy)
@@ -807,7 +807,7 @@
  */
 function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NULL, $doanything=false,$limit=0) {
 
-    global $CFG,$USER;
+    global $CFG,$USER, $ACCESS;
 
     // Guest's do not have any courses
     $sitecontext = get_context_instance(CONTEXT_SYSTEM);
@@ -925,7 +925,10 @@
     if ($userid === $USER->id && isset($USER->access)) {
         $accessinfo = $USER->access;
     } else {
-        $accessinfo = get_user_access_sitewide($userid);
+        if (!isset($ACCESS[$userid])) {
+            load_user_accessdata($userid);
+        }
+        $accessinfo = $ACCESS[$userid];
     }