Permalink
Browse files

Merge branch 'wip-MDL-28184-m21' of git://github.com/samhemelryk/mood…

…le into MOODLE_21_STABLE
  • Loading branch information...
2 parents 719368f + f3e47fc commit aa3097da6365e7aad797d085f08958bcb61eff70 @skodak skodak committed Jul 18, 2011
Showing with 16 additions and 5 deletions.
  1. +16 −5 lib/navigationlib.php
View
@@ -1159,13 +1159,17 @@ public function initialise() {
// Load the course associated with the page into the navigation
$coursenode = $this->load_course($course);
+ // If the course wasn't added then don't try going any further.
+ if (!$coursenode) {
+ $canviewcourseprofile = false;
+ break;
+ }
+
// If the user is not enrolled then we only want to show the
// course node and not populate it.
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
if (!can_access_course($coursecontext)) {
- if ($coursenode) {
- $coursenode->make_active();
- }
+ $coursenode->make_active();
$canviewcourseprofile = false;
break;
}
@@ -1222,6 +1226,13 @@ public function initialise() {
}
// Load the course associated with the user into the navigation
$coursenode = $this->load_course($course);
+
+ // If the course wasn't added then don't try going any further.
+ if (!$coursenode) {
+ $canviewcourseprofile = false;
+ break;
+ }
+
// If the user is not enrolled then we only want to show the
// course node and not populate it.
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
@@ -2170,14 +2181,14 @@ public function add_course(stdClass $course, $forcegeneric = false, $ismycourse
* @param stdClass $course
* @return bool
*/
- public function add_course_essentials(navigation_node $coursenode, stdClass $course) {
+ public function add_course_essentials($coursenode, stdClass $course) {
global $CFG;
if ($course->id == SITEID) {
return $this->add_front_page_course_essentials($coursenode, $course);
}
- if ($coursenode == false || $coursenode->get('participants', navigation_node::TYPE_CONTAINER)) {
+ if ($coursenode == false || !($coursenode instanceof navigation_node) || $coursenode->get('participants', navigation_node::TYPE_CONTAINER)) {
return true;
}

0 comments on commit aa3097d

Please sign in to comment.