* @return int The depth to the active(requested) node
*/
protected function load_for_course() {
- global $PAGE, $CFG;
+ global $PAGE, $CFG, $USER;
$keys = array();
$depth = $this->load_course_categories($keys);
$depth += $this->load_course($keys);
}
return $depth;
}
- $depth += $this->load_course_activities($keys);
- $depth += $this->load_course_sections($keys);
+
+ 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_sections($keys);
+ }
return $depth;
}
$keys = array();
parent::load_course($keys, $course);
- 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'));
- }
- $section = $this->cache->{'course'.$course->id.'section0'};
- $this->load_section_activities($course, $section);
- if ($this->depthforward>0) {
- $this->load_course_sections($keys, $course);
+
+ if (isloggedin() && has_capability('moodle/course:view', get_context_instance(CONTEXT_COURSE, $instanceid))) {
+
+ 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'));
+ }
+ $section = $this->cache->{'course'.$course->id.'section0'};
+ $this->load_section_activities($course, $section);
+ if ($this->depthforward>0) {
+ $this->load_course_sections($keys, $course);
+ }
}
}
/**