2009-11-01 10:57:00 +00:00
|
|
|
<?php
|
2006-10-02 05:52:39 +00:00
|
|
|
|
|
|
|
// searches for admin settings
|
|
|
|
|
|
|
|
require_once('../config.php');
|
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
|
2017-09-22 13:18:24 +02:00
|
|
|
redirect_if_major_upgrade_required();
|
|
|
|
|
2008-05-30 21:36:57 +00:00
|
|
|
$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string
|
|
|
|
|
2016-10-31 13:39:34 +08:00
|
|
|
$context = context_system::instance();
|
|
|
|
$PAGE->set_context($context);
|
2022-03-30 10:33:11 +08:00
|
|
|
|
|
|
|
// If we are performing a search we need to display the secondary navigation with links as opposed to just anchors.
|
|
|
|
// NOTE: hassecondarynavigation will be overridden in classic.
|
|
|
|
$PAGE->set_secondary_navigation(true, !$query);
|
2012-01-04 14:04:57 +08:00
|
|
|
|
2017-09-22 13:18:24 +02:00
|
|
|
$hassiteconfig = has_capability('moodle/site:config', $context);
|
|
|
|
|
|
|
|
if ($hassiteconfig && moodle_needs_upgrading()) {
|
|
|
|
redirect(new moodle_url('/admin/index.php'));
|
|
|
|
}
|
|
|
|
|
2017-09-22 13:16:57 +08:00
|
|
|
// If site registration needs updating, redirect.
|
|
|
|
\core\hub\registration::registration_reminder('/admin/search.php');
|
|
|
|
|
2012-01-04 14:04:57 +08:00
|
|
|
admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page
|
2021-08-03 16:29:41 +08:00
|
|
|
$PAGE->set_heading(get_string('administrationsite')); // Has to be after setup since it has its' own heading set_heading.
|
|
|
|
|
2009-01-20 23:53:34 +00:00
|
|
|
$adminroot = admin_get_root(); // need all settings here
|
2007-12-19 17:35:20 +00:00
|
|
|
$adminroot->search = $query; // So we can reference it in search boxes later in this invocation
|
2006-10-23 12:05:33 +00:00
|
|
|
$statusmsg = '';
|
2007-12-19 17:35:20 +00:00
|
|
|
$errormsg = '';
|
|
|
|
$focus = '';
|
2006-10-23 12:05:33 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
// now we'll deal with the case that the admin has submitted the form with changed settings
|
2016-10-31 22:49:39 +08:00
|
|
|
if ($data = data_submitted() and confirm_sesskey() and isset($data->action) and $data->action == 'save-settings') {
|
2016-10-31 13:39:34 +08:00
|
|
|
require_capability('moodle/site:config', $context);
|
2017-12-06 09:07:25 +08:00
|
|
|
$count = admin_write_settings($data);
|
2007-12-19 17:35:20 +00:00
|
|
|
if (!empty($adminroot->errors)) {
|
|
|
|
$errormsg = get_string('errorwithsettings', 'admin');
|
|
|
|
$firsterror = reset($adminroot->errors);
|
|
|
|
$focus = $firsterror->id;
|
2016-03-17 21:17:35 +11:00
|
|
|
} else {
|
2017-12-06 09:07:25 +08:00
|
|
|
// No errors. Did we change any setting? If so, then redirect with success.
|
|
|
|
if ($count) {
|
|
|
|
redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
|
|
|
|
}
|
2016-03-17 21:17:35 +11:00
|
|
|
redirect($PAGE->url);
|
2006-10-02 05:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-27 16:04:01 +08:00
|
|
|
$PAGE->set_primary_active_tab('siteadminnode');
|
2021-06-01 17:16:55 +02:00
|
|
|
|
2006-10-02 05:52:39 +00:00
|
|
|
// and finally, if we get here, then there are matching settings and we have to print a form
|
|
|
|
// to modify them
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header($focus);
|
2006-10-02 05:52:39 +00:00
|
|
|
|
2017-06-23 11:25:58 +08:00
|
|
|
// Display a warning if site is not registered.
|
|
|
|
if (empty($query)) {
|
|
|
|
$adminrenderer = $PAGE->get_renderer('core', 'admin');
|
|
|
|
echo $adminrenderer->warn_if_not_registered();
|
|
|
|
}
|
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if ($errormsg !== '') {
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->notification($errormsg);
|
2007-12-19 17:35:20 +00:00
|
|
|
|
|
|
|
} else if ($statusmsg !== '') {
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
|
2006-10-23 12:05:33 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 13:39:34 +08:00
|
|
|
$showsettingslinks = true;
|
2016-10-06 14:10:14 +08:00
|
|
|
|
2021-08-03 16:29:41 +08:00
|
|
|
if ($query && $hassiteconfig) {
|
2016-10-31 13:39:34 +08:00
|
|
|
echo '<hr>';
|
2021-08-03 16:29:41 +08:00
|
|
|
echo admin_search_settings_html($query);
|
|
|
|
$showsettingslinks = false;
|
2016-10-31 13:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($showsettingslinks) {
|
2016-10-06 14:10:14 +08:00
|
|
|
$node = $PAGE->settingsnav->find('root', navigation_node::TYPE_SITE_ADMIN);
|
|
|
|
if ($node) {
|
2022-03-02 19:29:47 +08:00
|
|
|
$secondarynavigation = false;
|
|
|
|
if ($PAGE->has_secondary_navigation()) {
|
2022-02-18 15:55:31 +11:00
|
|
|
$moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, true);
|
2022-03-02 19:29:47 +08:00
|
|
|
$secondarynavigation = $moremenu->export_for_template($OUTPUT);
|
|
|
|
}
|
2021-06-01 17:16:55 +02:00
|
|
|
echo $OUTPUT->render_from_template('core/settings_link_page',
|
|
|
|
['node' => $node, 'secondarynavigation' => $secondarynavigation]);
|
2016-10-06 14:10:14 +08:00
|
|
|
}
|
|
|
|
}
|
2006-10-02 05:52:39 +00:00
|
|
|
|
2009-08-06 14:12:46 +00:00
|
|
|
echo $OUTPUT->footer();
|