Permalink
Browse files

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

…le into MOODLE_20_STABLE
  • Loading branch information...
2 parents 393d636 + 49d85b7 commit 4f76e7ddf714f6ae5729a6e21c94a6ebe478821f @skodak skodak committed Jul 18, 2011
Showing with 16 additions and 5 deletions.
  1. +16 −5 lib/navigationlib.php
View
@@ -1040,13 +1040,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;
}
@@ -1099,6 +1103,13 @@ public function initialise() {
if ($course->id != SITEID) {
// 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);
@@ -1994,14 +2005,14 @@ public function add_course(stdClass $course, $forcegeneric = false) {
* @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 4f76e7d

Please sign in to comment.