Skip to content

Commit

Permalink
MDL-41811 navigation: Fixed navigation issues on pages
Browse files Browse the repository at this point in the history
Few admin pages don't add navigation node and hence they should
not show site admin
  • Loading branch information
Rajesh Taneja committed Oct 21, 2013
1 parent 8141ba8 commit b92adf2
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
$PAGE->set_url($url);
$PAGE->set_context($context);

if ($isfrontpage) {
navigation_node::require_admin_tree();
}

$contextname = $context->get_context_name();
$courseid = $course->id;

Expand Down
4 changes: 3 additions & 1 deletion admin/roles/override.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_pagelayout('admin');

if (!$isfrontpage) {
navigation_node::no_admin_navigation_node();
}
$courseid = $course->id;

$returnurl = new moodle_url('/admin/roles/permissions.php', array('contextid' => $context->id));
Expand Down
2 changes: 1 addition & 1 deletion course/editcategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
// Page "Add new category" (with "Top" as a parent) does not exist in navigation.
// We pretend we are on course management page.
if ($id !== 0) {
navigation_node::override_active_url(new moodle_url('/course/management.php', true));
navigation_node::override_active_url(new moodle_url('/course/management.php'), true);
}

$PAGE->set_context($context);
Expand Down
1 change: 1 addition & 0 deletions course/modedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
}
$PAGE->set_pagetype($pagepath);
$PAGE->set_pagelayout('admin');
navigation_node::no_admin_navigation_node();

$modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
if (file_exists($modmoodleform)) {
Expand Down
1 change: 1 addition & 0 deletions group/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
$PAGE->set_title($strgroups);
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('admin');
navigation_node::require_admin_tree();
echo $OUTPUT->header();

// Add tabs
Expand Down
1 change: 1 addition & 0 deletions lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,7 @@ public function process_url_edit() {
redirect($this->page->url);

} else {
navigation_node::no_admin_navigation_node();
$strheading = get_string('blockconfiga', 'moodle', $block->get_title());
$editpage->set_title($strheading);
$editpage->set_heading($strheading);
Expand Down
14 changes: 14 additions & 0 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class navigation_node implements renderable {
public static $autofindactive = true;
/** @var bool should we load full admin tree or rely on AJAX for performance reasons */
protected static $loadadmintree = false;
/** @var bool no admin navigation node is added for this page */
protected static $noadminnavigationnode = false;
/** @var mixed If set to an int, that section will be included even if it has no activities */
public $includesectionnum = false;

Expand Down Expand Up @@ -263,6 +265,14 @@ public static function require_admin_tree() {
self::$loadadmintree = true;
}

/**
* Uses when page doesn't have admin navigation node and we need to decide if
* site admin should be loaded.
*/
public static function no_admin_navigation_node() {
self::$noadminnavigationnode = true;
}

/**
* Creates a navigation node, ready to add it as a child using add_node
* function. (The created node needs to be added before you can use it.)
Expand Down Expand Up @@ -3479,6 +3489,10 @@ protected function is_admin_tree_needed(navigation_node $frontpagesettings = nul
}

if ($this->page->pagelayout === 'admin' or strpos($this->page->pagetype, 'admin-') === 0) {
// No navigation node is added for this page, case like block editing page.
if (self::$noadminnavigationnode) {
return false;
}
// Greater then course context or user context pages add there own navigation node, so don't load site admin.
if (($this->page->context->contextlevel >= CONTEXT_COURSE) || ($this->page->context->contextlevel === CONTEXT_USER)) {
if (($frontpagesettings && $frontpagesettings->contains_active_node()) ||
Expand Down
1 change: 1 addition & 0 deletions question/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
}
$contexts = new question_edit_contexts($thiscontext);
$PAGE->set_pagelayout('admin');
navigation_node::no_admin_navigation_node();

if (optional_param('addcancel', false, PARAM_BOOL)) {
redirect($returnurl);
Expand Down

0 comments on commit b92adf2

Please sign in to comment.