Skip to content

Commit

Permalink
navigation MDL-25291 Added a session variable so that admin tree is s…
Browse files Browse the repository at this point in the history
…kipped if it is found to be empty.
  • Loading branch information
Sam Hemelryk committed Jan 27, 2011
1 parent 8cdc85a commit 7e90d3a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/navigationlib.php
Expand Up @@ -2537,7 +2537,7 @@ public function __construct(moodle_page &$page) {
*
*/
public function initialise() {
global $DB;
global $DB, $SESSION;

if (during_initial_install()) {
return false;
Expand Down Expand Up @@ -2581,7 +2581,13 @@ public function initialise() {
}

$settings = $this->load_user_settings($this->page->course->id);
$admin = $this->load_administration_settings();

if (isloggedin() && !isguestuser() && (!property_exists($SESSION, 'load_navigation_admin') || $SESSION->load_navigation_admin)) {
$admin = $this->load_administration_settings();
$SESSION->load_navigation_admin = ($admin->has_children());
} else {
$admin = false;
}

if ($context->contextlevel == CONTEXT_SYSTEM && $admin) {
$admin->force_open();
Expand All @@ -2598,8 +2604,6 @@ public function initialise() {
$this->add(get_string('returntooriginaluser', 'moodle', fullname($realuser, true)), $url, self::TYPE_SETTING, null, null, new pix_icon('t/left', ''));
}

// Make sure the first child doesnt have proceed with hr set to true

foreach ($this->children as $key=>$node) {
if ($node->nodetype != self::NODETYPE_BRANCH || $node->children->count()===0) {
$node->remove();
Expand Down

0 comments on commit 7e90d3a

Please sign in to comment.