-
Bug
-
Resolution: Not a bug
-
Minor
-
None
-
4.1.15
-
MOODLE_401_STABLE
The function get() set a default value for the parameter alwaysreturnhidden of false.
Further on in the logic of it checking if it should return something or throw an error it's checking for the not value of this to do something.
} else if (!$alwaysreturnhidden && !$coursecat->is_uservisible($user)) { |
// Course category is found but user can not access it. |
if ($strictness == MUST_EXIST) |
{ throw new moodle_exception('cannotviewcategory'); } |
$coursecat = null; |
}
|
So if if alwaysreturnvisible is false it will then check if the coursecat is visible to the user, which if it isn't will throw the exception. If you have a single category set to hidden then the full course cat check will fail, even if you have passed a single course category to check.
This happened to the guest user who was trying to view a single course category using the lambda2 theme when there were other hidden course categories. I'm not able to replicate with the core themes, however.
The call in the Lambda theme was a direct call and using the default values for the function:
$coursecat = core_course_category::get($catid);
|
I suspect that the test logic should be:
else if ($alwaysreturnhidden && !$coursecat->is_uservisible($user)) { |
as it should be checking if you have specified to return hidden courses and, if so, then checking if you can see them. This certainly worked on the site but I've not checked to see what else could be impacted by this.