]> git.mjollnir.org Git - moodle.git/commitdiff
datalib: get_my_courses() now returns invisible courses if visible to $USER
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:21:35 +0000 (07:21 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:21:35 +0000 (07:21 +0000)
So admins can see the appropriate user listing in the profile page.

In fact, probably _all_ the visibility checks should be done by callers.
Hmmm...

lib/datalib.php

index 9f2873848fde95173f5583d596b6faa8dd8d06dd..f568caf6e41f58f3a8d7b6bcd1a48255a401a79e 100644 (file)
@@ -765,7 +765,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL
     for ($n=0; $n<$cc; $n++) {
 
         //
-        // Check whether the user can _actually_ see them
+        // Check whether $USER (not $userid) can _actually_ see them
         // Easy if $CFG->allowvisiblecoursesinhiddencategories
         // is set, and we don't have to care about categories.
         // Lots of work otherwise... (all in mem though!)
@@ -775,7 +775,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL
             if ($courses[$n]->visible == true) {
                 $cansee = true;
             } elseif (has_capability('moodle/course:viewhiddencourses',
-                                     $courses[$n]->context, $userid)) {
+                                     $courses[$n]->context, $USER->id)) {
                 $cansee = true;
             }
         } else {
@@ -803,7 +803,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL
             }
 
             //
-            // Perhaps it's actually visible to this user
+            // Perhaps it's actually visible to $USER
             // check moodle/category:visibility
             // 
             // The name isn't obvious, but the description says
@@ -812,7 +812,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL
             if ($viscat === false) {
                 $catctx = $cats[ $courses[$n]->category ]->context;
                 if (has_capability('moodle/category:visibility',
-                                   $catctx, $userid)) {
+                                   $catctx, $USER->id)) {
                     $vcatpaths[$courses[$n]->categorypath] = true;
                     $viscat = true;
                 }
@@ -825,7 +825,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL
                 if ($courses[$n]->visible == true) {
                     $cansee = true;
                 } elseif (has_capability('moodle/course:viewhiddencourses',
-                                        $courses[$n]->context, $userid)) {
+                                        $courses[$n]->context, $USER->id)) {
                     $cansee = true;
                 }
             }