MDL-31631 navigation: Removed caching of activities and sections arrays in favour of relying on cminfo caching
This commit is contained in:
+36
-41
@@ -1627,55 +1627,50 @@ class global_navigation extends navigation_node {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
if (!$this->cache->cached('course_sections_'.$course->id) || !$this->cache->cached('course_activites_'.$course->id)) {
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
$sections = array_slice(get_all_sections($course->id), 0, $course->numsections+1, true);
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
|
||||
$activities = array();
|
||||
$sections = array_slice(get_all_sections($course->id), 0, $course->numsections+1, true);
|
||||
$activities = array();
|
||||
|
||||
foreach ($sections as $key => $section) {
|
||||
$sections[$key]->hasactivites = false;
|
||||
if (!array_key_exists($section->section, $modinfo->sections)) {
|
||||
foreach ($sections as $key => $section) {
|
||||
$sections[$key]->hasactivites = false;
|
||||
if (!array_key_exists($section->section, $modinfo->sections)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($modinfo->sections[$section->section] as $cmid) {
|
||||
$cm = $modinfo->cms[$cmid];
|
||||
if (!$cm->uservisible) {
|
||||
continue;
|
||||
}
|
||||
foreach ($modinfo->sections[$section->section] as $cmid) {
|
||||
$cm = $modinfo->cms[$cmid];
|
||||
if (!$cm->uservisible) {
|
||||
continue;
|
||||
}
|
||||
$activity = new stdClass;
|
||||
$activity->section = $section->section;
|
||||
$activity->name = $cm->name;
|
||||
$activity->icon = $cm->icon;
|
||||
$activity->iconcomponent = $cm->iconcomponent;
|
||||
$activity->id = $cm->id;
|
||||
$activity->hidden = (!$cm->visible);
|
||||
$activity->modname = $cm->modname;
|
||||
$activity->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
$activity->onclick = $cm->get_on_click();
|
||||
$url = $cm->get_url();
|
||||
if (!$url) {
|
||||
$activity->url = null;
|
||||
$activity->display = false;
|
||||
} else {
|
||||
$activity->url = $cm->get_url()->out();
|
||||
$activity->display = true;
|
||||
if (self::module_extends_navigation($cm->modname)) {
|
||||
$activity->nodetype = navigation_node::NODETYPE_BRANCH;
|
||||
}
|
||||
}
|
||||
$activities[$cmid] = $activity;
|
||||
if ($activity->display) {
|
||||
$sections[$key]->hasactivites = true;
|
||||
$activity = new stdClass;
|
||||
$activity->id = $cm->id;
|
||||
$activity->course = $course->id;
|
||||
$activity->section = $section->section;
|
||||
$activity->name = $cm->name;
|
||||
$activity->icon = $cm->icon;
|
||||
$activity->iconcomponent = $cm->iconcomponent;
|
||||
$activity->hidden = (!$cm->visible);
|
||||
$activity->modname = $cm->modname;
|
||||
$activity->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
$activity->onclick = $cm->get_on_click();
|
||||
$url = $cm->get_url();
|
||||
if (!$url) {
|
||||
$activity->url = null;
|
||||
$activity->display = false;
|
||||
} else {
|
||||
$activity->url = $cm->get_url()->out();
|
||||
$activity->display = true;
|
||||
if (self::module_extends_navigation($cm->modname)) {
|
||||
$activity->nodetype = navigation_node::NODETYPE_BRANCH;
|
||||
}
|
||||
}
|
||||
$activities[$cmid] = $activity;
|
||||
if ($activity->display) {
|
||||
$sections[$key]->hasactivites = true;
|
||||
}
|
||||
}
|
||||
$this->cache->set('course_sections_'.$course->id, $sections);
|
||||
$this->cache->set('course_activites_'.$course->id, $activities);
|
||||
} else {
|
||||
$sections = $this->cache->{'course_sections_'.$course->id};
|
||||
$activities = $this->cache->{'course_activites_'.$course->id};
|
||||
}
|
||||
|
||||
return array($sections, $activities);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user