Skip to content

Commit

Permalink
MDL-73848 administration: Fix the breadcrumbs and nav highlights
Browse files Browse the repository at this point in the history
Create or update the breadcrumbs in the site administration
pages where it is required.
Highlight the corresponding site adminstration tab.
Highlight the primary nav to Site administration when user
is navigating to any of the site administration pages.

Also changed the boostnavbar so that the nodes in the secondary
navigation are not shown in the breadcrumbs when user is in site
administration page.
  • Loading branch information
sharidas authored and junpataleta committed Mar 25, 2022
1 parent 34ce146 commit aa1c2e2
Show file tree
Hide file tree
Showing 61 changed files with 187 additions and 13 deletions.
1 change: 1 addition & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@
$SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);

$adminroot = admin_get_root();
$PAGE->set_primary_active_tab('siteadminnode');

// Check if there are any new admin settings which have still yet to be set
if (any_new_admin_settings($adminroot)) {
Expand Down
2 changes: 2 additions & 0 deletions admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

$pluginman = core_plugin_manager::instance();

$PAGE->set_primary_active_tab('siteadminnode');

if ($uninstall) {

if (!$confirmed) {
Expand Down
3 changes: 3 additions & 0 deletions admin/roles/allow.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
redirect($baseurl);
}

$PAGE->set_secondary_active_tab('users');
$PAGE->set_primary_active_tab('siteadminnode');

$controller->load_current_settings();

// Display the editing form.
Expand Down
4 changes: 4 additions & 0 deletions admin/roles/define.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
$title = get_string('editingrolex', 'core_role', $rolenames[$roleid]->localname);
}

$PAGE->set_secondary_active_tab('users');
$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->navbar->add($title, $baseurl);

// Decide how to create new role.
if ($action === 'add' and $resettype !== 'none') {
$mform = new core_role_preset_form(null, array('action'=>'add', 'roleid'=>0, 'resettype'=>'0', 'return'=>'manage'));
Expand Down
3 changes: 3 additions & 0 deletions admin/roles/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
$undeletableroles[$CFG->guestroleid] = 1;
$undeletableroles[$CFG->defaultuserroleid] = 1;

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->navbar->add(get_string('defineroles', 'role'), $PAGE->url);

// Process submitted data.
$confirmed = (optional_param('confirm', false, PARAM_BOOL) && data_submitted() && confirm_sesskey());
switch ($action) {
Expand Down
2 changes: 2 additions & 0 deletions admin/searchareas.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
// In action cases, we'll throw this exception below. In non-action cases, we produce a lang string error.
}

$PAGE->set_primary_active_tab('siteadminnode');

// Handle all the actions.
if ($action) {
// If dealing with an areaid, we need to check that the area exists.
Expand Down
3 changes: 3 additions & 0 deletions admin/searchreindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
}
$areaname = $area->get_visible_name();

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('modules');

// Start page output.
$heading = get_string('gradualreindex', 'search', '');
$PAGE->set_title($PAGE->title . ': ' . $heading);
Expand Down
5 changes: 5 additions & 0 deletions admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@

$PAGE->set_title("$SITE->shortname: " . implode(": ",$visiblepathtosection));
$PAGE->set_heading($SITE->fullname);
if ($section === 'frontpagesettings') {
$PAGE->navbar->add(get_string('frontpage', 'admin'),
new moodle_url('/admin/category.php', ['category' => 'frontpage']));
$PAGE->navbar->add(get_string('frontpagesettings', 'admin'), $PAGE->url);
}
echo $OUTPUT->header();

if ($errormsg !== '') {
Expand Down
4 changes: 4 additions & 0 deletions admin/tool/admin_presets/classes/local/action/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ protected function display_header(): void {
$PAGE->navbar->add($title);
}

if ($node = $PAGE->settingsnav->find('tool_admin_presets', \navigation_node::TYPE_SETTING)) {
$node->make_active();
}

echo $OUTPUT->header();
echo $OUTPUT->heading($title);
if ($text) {
Expand Down
1 change: 1 addition & 0 deletions admin/tool/admin_presets/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
$PAGE->set_context($context);
$PAGE->set_primary_active_tab('siteadminnode');

// Executes the required action.
$instance = new $classname();
Expand Down
6 changes: 5 additions & 1 deletion admin/tool/analytics/classes/output/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ public static function set_navbar(string $title, \moodle_url $url, ?\context $co

$PAGE->set_context($context);
$PAGE->set_url($url);
$PAGE->set_secondary_active_tab('siteadminnode');
$PAGE->set_primary_active_tab('siteadminnode');

if ($siteadmin = $PAGE->settingsnav->find('root', \navigation_node::TYPE_SITE_ADMIN)) {
$PAGE->navbar->add($siteadmin->get_content(), $siteadmin->action());
$PAGE->navbar->add($siteadmin->get_content(), $siteadmin->action(),
\breadcrumb_navigation_node::TYPE_SITE_ADMIN, null, 'root');
}

if ($analytics = $PAGE->settingsnav->find('analytics', \navigation_node::TYPE_SETTING)) {
$PAGE->navbar->add($analytics->get_content(), $analytics->action());
}
Expand Down
5 changes: 5 additions & 0 deletions admin/tool/customlang/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
array('pagelayout' => 'report')); // Hack: allows for wide page contents.

$PAGE->requires->js_init_call('M.tool_customlang.init_editor', array(), true);
$PAGE->set_context(context_system::instance());
$PAGE->set_secondary_active_tab('siteadminnode');
$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->navbar->add(get_string('editlangpack', 'tool_customlang'), $PAGE->url);


if (empty($lng)) {
// PARAM_LANG validation failed
Expand Down
6 changes: 6 additions & 0 deletions admin/tool/customlang/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
admin_externalpage_setup('toolcustomlang', '', null,
new moodle_url('/admin/tool/customlang/import.php', ['lng' => $lng]));

$PAGE->set_context(context_system::instance());

$PAGE->set_secondary_active_tab('siteadminnode');
$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->navbar->add(get_string('import', 'tool_customlang'), $PAGE->url);

$output = $PAGE->get_renderer('tool_customlang');

$form = new import(null, ['lng' => $lng]);
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/customlang/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
admin_externalpage_setup('toolcustomlang');
$langs = get_string_manager()->get_list_of_translations();

$PAGE->set_primary_active_tab('siteadminnode');

// pre-output actions
if ($action === 'checkout') {
require_sesskey();
Expand Down
1 change: 1 addition & 0 deletions admin/tool/customlang/lang/en/tool_customlang.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
$string['customlang:view'] = 'View local translation';
$string['export'] = 'Export custom strings';
$string['exportfilter'] = 'Select component(s) to export';
$string['editlangpack'] = 'Edit language pack';
$string['filter'] = 'Filter strings';
$string['filtercomponent'] = 'Show strings of these components';
$string['filtercustomized'] = 'Customised only';
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/dataprivacy/classes/page_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public static function setup(moodle_url $url, $title, $attachtoparentnode = '',
$PAGE->set_pagelayout('admin');
$PAGE->set_title($title);
$PAGE->set_heading($SITE->fullname);
$PAGE->set_secondary_active_tab('users');
$PAGE->set_primary_active_tab('siteadminnode');

// If necessary, override the settings navigation to add this page into the breadcrumb navigation.
if ($attachtoparentnode) {
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/filetypes/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
$PAGE->set_context($context);
$PAGE->set_pagelayout('admin');
$PAGE->set_title($SITE->fullname. ': ' . $title);
$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('server');

// Display the page.
echo $OUTPUT->header();
Expand Down
4 changes: 4 additions & 0 deletions admin/tool/filetypes/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
// Page settings.
$context = context_system::instance();
$PAGE->set_url(new \moodle_url('/admin/tool/filetypes/edit.php', array('oldextension' => $oldextension)));

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('server');

$PAGE->navbar->add($oldextension ? s($oldextension) : $title);
$PAGE->set_context($context);
$PAGE->set_pagelayout('admin');
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/langimport/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
}
get_string_manager()->reset_caches();

$PAGE->set_primary_active_tab('siteadminnode');

echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('langimport', 'tool_langimport'));

Expand Down
4 changes: 4 additions & 0 deletions admin/tool/messageinbound/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

$pageurl = new moodle_url('/admin/tool/messageinbound/index.php');

$PAGE->set_primary_active_tab('siteadminnode');

$PAGE->navbar->add(get_string('message_handlers', 'tool_messageinbound'), $PAGE->url);

if (empty($classname)) {
$renderer = $PAGE->get_renderer('tool_messageinbound');

Expand Down
4 changes: 4 additions & 0 deletions admin/tool/monitor/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
$context = context_system::instance();
$coursename = format_string($SITE->fullname, true, array('context' => $context));
$PAGE->set_context($context);
$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('reports');
} else {
$course = get_course($courseid);
require_login($course);
Expand Down Expand Up @@ -65,6 +67,7 @@

// Mform setup.
if (!empty($ruleid)) {
$PAGE->navbar->add(get_string('editrule', 'tool_monitor'), $PAGE->url);
$rule = \tool_monitor\rule_manager::get_rule($ruleid)->get_mform_set_data();
$rule->minutes = $rule->timewindow / MINSECS;
$subscriptioncount = \tool_monitor\subscription_manager::count_rule_subscriptions($ruleid);
Expand All @@ -75,6 +78,7 @@
return $classname === $rule->eventname || !$classname::is_deprecated();
}, ARRAY_FILTER_USE_KEY);
} else {
$PAGE->navbar->add(get_string('addrule', 'tool_monitor'), $PAGE->url);
$rule = new stdClass();
$subscriptioncount = 0;

Expand Down
5 changes: 4 additions & 1 deletion admin/tool/monitor/managerules.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
$context = context_system::instance();
$coursename = format_string($SITE->fullname, true, array('context' => $context));
$PAGE->set_context($context);
$PAGE->set_primary_active_tab('siteadminnode');
} else {
$course = get_course($courseid);
require_login($course);
Expand All @@ -56,7 +57,6 @@
$PAGE->set_title($coursename);
$PAGE->set_heading($coursename);


if (!empty($action) && $action == 'changestatus') {
require_sesskey();
require_capability('tool/monitor:managetool', context_system::instance());
Expand All @@ -74,6 +74,9 @@
redirect(new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => $courseid)));
}

if ($action === 'delete') {
$PAGE->navbar->add(get_string('deleterule', 'tool_monitor'), $PAGE->url);
}
echo $OUTPUT->header();
$rule = \tool_monitor\rule_manager::get_rule($rule);
switch ($action) {
Expand Down
4 changes: 4 additions & 0 deletions admin/tool/task/scheduledtasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
}
}

$PAGE->navbar->add(get_string('scheduledtasks', 'tool_task'), $PAGE->url);

if ($action == 'edit') {
$PAGE->navbar->add(get_string('edittaskschedule', 'tool_task', $task->get_name()));
}
Expand All @@ -51,6 +53,8 @@
$nexturl = new moodle_url($PAGE->url, ['lastchanged' => $taskname]);
}

$PAGE->set_primary_active_tab('siteadminnode');

$renderer = $PAGE->get_renderer('tool_task');

if ($mform && ($mform->is_cancelled() || !empty($CFG->preventscheduledtaskchanges) || $task->is_overridden())) {
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/usertours/classes/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ protected function setup_admin_externalpage(string $action): void {
* @param string $action The action to perform.
*/
public function execute($action) {
global $PAGE;
$this->setup_admin_externalpage($action);
$PAGE->set_primary_active_tab('siteadminnode');

// Add the main content.
switch($action) {
Expand Down
3 changes: 3 additions & 0 deletions admin/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

$returnurl = new moodle_url('/admin/user.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage, 'page'=>$page));

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->navbar->add(get_string('userlist', 'admin'), $PAGE->url);

// The $user variable is also used outside of these if statements.
$user = null;
if ($confirmuser and confirm_sesskey()) {
Expand Down
3 changes: 3 additions & 0 deletions admin/user/user_bulk_confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
redirect($return);
}

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('users');

echo $OUTPUT->header();

//TODO: add support for large number of users
Expand Down
3 changes: 3 additions & 0 deletions admin/user/user_bulk_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
redirect($return);
}

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('users');

echo $OUTPUT->header();

//TODO: add support for large number of users
Expand Down
3 changes: 3 additions & 0 deletions admin/user/user_bulk_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

$strnever = get_string('never');

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('users');

echo $OUTPUT->header();

$countries = get_string_manager()->get_list_of_countries(true);
Expand Down
3 changes: 3 additions & 0 deletions admin/user/user_bulk_download.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
exit;
}

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('users');

echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('download', 'admin'));
echo $OUTPUT->download_dataformat_selector(get_string('userbulkdownload', 'admin'), 'user_bulk_download.php');
Expand Down
3 changes: 3 additions & 0 deletions admin/user/user_bulk_forcepasswordchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
redirect($return);
}

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('users');

echo $OUTPUT->header();

if ($confirm and confirm_sesskey()) {
Expand Down
3 changes: 3 additions & 0 deletions admin/user/user_bulk_message.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
print_error('messagingdisable', 'error');
}

$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->set_secondary_active_tab('users');

//TODO: add support for large number of users

if ($confirm and !empty($msg) and confirm_sesskey()) {
Expand Down
12 changes: 11 additions & 1 deletion admin/webservice/service.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
$node->display = false;
$newnode->make_active();
}
$PAGE->navbar->add(get_string('externalservice', 'webservice'));
$PAGE->navbar->add(get_string('externalservices', 'webservice'),
new moodle_url('/admin/settings.php', ['section' => 'externalservices']));

$PAGE->set_primary_active_tab('siteadminnode');


//Retrieve few general parameters
$id = required_param('id', PARAM_INT);
Expand Down Expand Up @@ -104,6 +108,12 @@
redirect($returnurl);
}

if ($id == 0) {
$PAGE->navbar->add(get_string('addexternalservice', 'webservice'), $PAGE->url);
} else {
$PAGE->navbar->add(get_string('editexternalservice', 'webservice'), $PAGE->url);
}

//OUTPUT edit/create form
echo $OUTPUT->header();
$mform->display();
Expand Down
3 changes: 3 additions & 0 deletions admin/webservice/service_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
if ($node) {
$node->make_active();
}
$PAGE->set_primary_active_tab('siteadminnode');
$PAGE->navbar->add(get_string('externalservices', 'webservice'),
new moodle_url('/admin/settings.php', ['section' => 'externalservices']));
$PAGE->navbar->add(get_string('functions', 'webservice'),
new moodle_url('/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $serviceid)));

Expand Down
Loading

0 comments on commit aa1c2e2

Please sign in to comment.