Skip to content
Browse files

MDL-34250 navigation: Always look for correct parent context.

  • Loading branch information...
1 parent d71c486 commit 111938abd98bc5a04436437d9c1d8d5f6f1ecb11 @stronk7 stronk7 committed Aug 28, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/navigationlib.php
View
8 lib/navigationlib.php
@@ -1131,7 +1131,13 @@ public function initialise() {
$addedcategories[$category->id] = $categoryparent->add($category->name, $url, self::TYPE_CATEGORY, $category->name, $category->id);
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;
} else {
$addedcategories[$category->id]->hidden = true;

0 comments on commit 111938a

Please sign in to comment.
Something went wrong with that request. Please try again.