navigation MDL-14632 Fixed bug whereby if someone called PAGE->set_course() on a page outside of a course and then a user browsed to it they would be shown the course content in the navigation

This commit is contained in:
samhemelryk 2009-09-11 08:26:36 +00:00
parent f3153c9123
commit d755d8c3bd

View File

@ -881,7 +881,7 @@ class global_navigation extends navigation_node {
* @return int The depth to the active(requested) node * @return int The depth to the active(requested) node
*/ */
protected function load_for_course() { protected function load_for_course() {
global $PAGE, $CFG; global $PAGE, $CFG, $USER;
$keys = array(); $keys = array();
$depth = $this->load_course_categories($keys); $depth = $this->load_course_categories($keys);
$depth += $this->load_course($keys); $depth += $this->load_course($keys);
@ -892,8 +892,11 @@ class global_navigation extends navigation_node {
} }
return $depth; return $depth;
} }
if (isloggedin() && has_capability('moodle/course:view', get_context_instance(CONTEXT_COURSE, $PAGE->course->id))) {
$depth += $this->load_course_activities($keys); $depth += $this->load_course_activities($keys);
$depth += $this->load_course_sections($keys); $depth += $this->load_course_sections($keys);
}
return $depth; return $depth;
} }
@ -1595,6 +1598,9 @@ class limited_global_navigation extends global_navigation {
$keys = array(); $keys = array();
parent::load_course($keys, $course); parent::load_course($keys, $course);
if (isloggedin() && has_capability('moodle/course:view', get_context_instance(CONTEXT_COURSE, $instanceid))) {
if (!$this->cache->cached('course'.$course->id.'section0')) { if (!$this->cache->cached('course'.$course->id.'section0')) {
$this->cache->{'course'.$course->id.'section0'} = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0')); $this->cache->{'course'.$course->id.'section0'} = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0'));
} }
@ -1604,6 +1610,7 @@ class limited_global_navigation extends global_navigation {
$this->load_course_sections($keys, $course); $this->load_course_sections($keys, $course);
} }
} }
}
/** /**
* Use the instance id to load a specific course section * Use the instance id to load a specific course section
* *