MDL-74026 admin: consistently show search element on admin pages.

This commit is contained in:
Paul Holden
2022-04-01 18:41:16 +01:00
parent b5f51883f0
commit b7417f2adf
5 changed files with 74 additions and 13 deletions
+9 -1
View File
@@ -8804,10 +8804,11 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
$adminroot = admin_get_root(false, false); // settings not required for external pages
$extpage = $adminroot->locate($section, true);
$hassiteconfig = has_capability('moodle/site:config', context_system::instance());
if (empty($extpage) or !($extpage instanceof admin_externalpage)) {
// The requested section isn't in the admin tree
// It could be because the user has inadequate capapbilities or because the section doesn't exist
if (!has_capability('moodle/site:config', context_system::instance())) {
if (!$hassiteconfig) {
// The requested section could depend on a different capability
// but most likely the user has inadequate capabilities
print_error('accessdenied', 'admin');
@@ -8878,6 +8879,13 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
$PAGE->set_title("$SITE->shortname: " . implode(": ", $visiblepathtosection));
$PAGE->set_heading($SITE->fullname);
if ($hassiteconfig) {
$PAGE->add_header_action($OUTPUT->render_from_template('core_admin/header_search_input', [
'action' => new moodle_url('/admin/search.php'),
'query' => $PAGE->url->get_param('query'),
]));
}
// prevent caching in nav block
$PAGE->navigation->clear_cache();
}