Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-38442 navigation: set_expansion_limit now only hides structural n…

…odes
  • Loading branch information...
commit 0f16db943cb61091ab2b7c7016a8987616913d0f 1 parent 7d253e0
@samhemelryk samhemelryk authored
Showing with 23 additions and 11 deletions.
  1. +23 −11 lib/navigationlib.php
View
34 lib/navigationlib.php
@@ -667,12 +667,18 @@ public function set_parent(navigation_node $parent) {
* Hides the node and any children it has.
*
* @since 2.3.5
+ * @param array $typestohide Optional. An array of node types that should be hidden.
+ * If null all nodes will be hidden.
+ * If an array is given then nodes will only be hidden if their type mtatches an element in the array.
+ * e.g. array(navigation_node::TYPE_COURSE) would hide only course nodes.
*/
- public function hide() {
- $this->display = false;
- if ($this->has_children()) {
- foreach ($this->children as $child) {
- $child->hide();
+ public function hide(array $typestohide = null) {
+ if ($typestohide === null || in_array($this->type, $typestohide)) {
+ $this->display = false;
+ if ($this->has_children()) {
+ foreach ($this->children as $child) {
+ $child->hide($typestohide);
+ }
}
}
}
@@ -2745,18 +2751,24 @@ public function clear_cache() {
public function set_expansion_limit($type) {
global $SITE;
$nodes = $this->find_all_of_type($type);
+
+ // We only want to hide specific types of nodes.
+ // Only nodes that represent "structure" in the navigation tree should be hidden.
+ // If we hide all nodes then we risk hiding vital information.
+ $typestohide = array(
+ self::TYPE_CATEGORY,
+ self::TYPE_COURSE,
+ self::TYPE_SECTION,
+ self::TYPE_ACTIVITY
+ );
+
foreach ($nodes as $node) {
// We need to generate the full site node
if ($type == self::TYPE_COURSE && $node->key == $SITE->id) {
continue;
}
foreach ($node->children as $child) {
- // We still want to show course reports and participants containers
- // or there will be navigation missing.
- if ($type == self::TYPE_COURSE && $child->type === self::TYPE_CONTAINER) {
- continue;
- }
- $child->hide();
+ $child->hide($typestohide);
}
}
return true;
Please sign in to comment.
Something went wrong with that request. Please try again.