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!)
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 {
}
//
- // 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
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;
}
if ($courses[$n]->visible == true) {
$cansee = true;
} elseif (has_capability('moodle/course:viewhiddencourses',
- $courses[$n]->context, $userid)) {
+ $courses[$n]->context, $USER->id)) {
$cansee = true;
}
}