From 058edbafc8a4e078a83f89037fcfbcad863f8744 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 3 Nov 2016 10:40:38 +0800 Subject: [PATCH] MDL-56711 theme_boost: Highlight sections at activity level When looking at an activity, the current section for the course should be active in the flat navigation. --- lib/navigationlib.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 73913f2f21a..b2cd8948be0 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -3638,6 +3638,24 @@ class flat_navigation_node extends navigation_node { return $this->type == navigation_node::TYPE_SECTION; } + /** + * In flat navigation - sections are active if we are looking at activities in the section. + * @return boolean + */ + public function isactive() { + global $PAGE; + + if ($this->is_section()) { + $active = $PAGE->navigation->find_active_node(); + while ($active = $active->parent) { + if ($active->key == $this->key && $active->type == $this->type) { + return true; + } + } + } + return $this->isactive; + } + /** * Getter for "showdivider" * @return boolean