Skip to content

Commit

Permalink
navigation MDL-24214 Hidden categories are now dealt with correctly b…
Browse files Browse the repository at this point in the history
…y the navigation
  • Loading branch information
Sam Hemelryk committed Sep 15, 2010
1 parent bf413f6 commit 1433768
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1265,14 +1265,21 @@ protected function load_all_categories($categoryid=null) {
* @param navigation_node $parent
*/
protected function add_category($cat, navigation_node $parent) {
$category = $parent->get($cat['category']->id, navigation_node::TYPE_CATEGORY);
if (!$category) {
$categorynode = $parent->get($cat['category']->id, navigation_node::TYPE_CATEGORY);
if (!$categorynode) {
$category = $cat['category'];
$url = new moodle_url('/course/category.php', array('id'=>$category->id));
$category = $parent->add($category->name, null, self::TYPE_CATEGORY, $category->name, $category->id);
$categorynode = $parent->add($category->name, null, self::TYPE_CATEGORY, $category->name, $category->id);
if (empty($category->visible)) {
if (has_capability('moodle/category:viewhiddencategories', get_system_context())) {
$categorynode->hidden = true;
} else {
$categorynode->display = false;
}
}
}
foreach ($cat['children'] as $child) {
$this->add_category($child, $category);
$this->add_category($child, $categorynode);
}
}

Expand Down

0 comments on commit 1433768

Please sign in to comment.