Permalink
Browse files

MDL-39127 navigation: fixed loading of categories for navbar

Conflicts:

	lib/navigationlib.php
  • Loading branch information...
1 parent 1e803a3 commit d203a50c02606b2cbc54046b6487bf0dbc8f368f Sam Hemelryk committed with damyon Apr 15, 2013
Showing with 18 additions and 7 deletions.
  1. +18 −7 lib/navigationlib.php
View
25 lib/navigationlib.php
@@ -3106,15 +3106,26 @@ public function get_items() {
*/
private function get_course_categories() {
$categories = array();
- $id = $this->page->course->category;
- while ($id) {
- $category = get_course_category($id);
- $url = new moodle_url('/course/category.php', array('id' => $id));
- $name = format_string($category->name, true, context_coursecat::instance($category->id));
- $categories[] = navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $id);
+ foreach ($this->page->categories as $category) {
+ $url = new moodle_url('/course/category.php', array('id' => $category->id));
+ $name = format_string($category->name, true, array('context' => context_coursecat::instance($category->id)));
+ $categories[] = navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $category->id);
$id = $category->parent;
}
- $categories[] = $this->page->navigation->get('courses');
+ if (is_enrolled(context_course::instance($this->page->course->id))) {
+ $courses = $this->page->navigation->get('mycourses');
+ } else {
+ $courses = $this->page->navigation->get('courses');
+ }
+ if (!$courses) {
+ // Courses node may not be present.
+ $courses = navigation_node::create(
+ get_string('courses'),
+ new moodle_url('/course/index.php'),
+ self::TYPE_CONTAINER
+ );
+ }
+ $categories[] = $courses;
return $categories;
}

0 comments on commit d203a50

Please sign in to comment.