Skip to content

Commit

Permalink
MDL-34250 navigation: Always look for correct parent context.
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Aug 28, 2012
1 parent d71c486 commit 111938a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/navigationlib.php
Expand Up @@ -1131,7 +1131,13 @@ public function initialise() {
$addedcategories[$category->id] = $categoryparent->add($category->name, $url, self::TYPE_CATEGORY, $category->name, $category->id); $addedcategories[$category->id] = $categoryparent->add($category->name, $url, self::TYPE_CATEGORY, $category->name, $category->id);


if (!$category->visible) { if (!$category->visible) {
if (!has_capability('moodle/category:viewhiddencategories', context_coursecat::instance($category->parent))) { // Let's decide the context where viewhidden cap checks will happen.
if ($category->parent == '0') {
$contexttocheck = context_system::instance();
} else {
$contexttocheck = context_coursecat::instance($category->parent);
}
if (!has_capability('moodle/category:viewhiddencategories', $contexttocheck)) {
$addedcategories[$category->id]->display = false; $addedcategories[$category->id]->display = false;
} else { } else {
$addedcategories[$category->id]->hidden = true; $addedcategories[$category->id]->hidden = true;
Expand Down

0 comments on commit 111938a

Please sign in to comment.