moodle/admin/search.php

63 lines
1.8 KiB
PHP
Raw Normal View History

<?php
// searches for admin settings
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
2008-05-30 21:36:57 +00:00
$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string
$PAGE->set_context(context_system::instance());
admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page
2009-01-20 23:53:34 +00:00
$adminroot = admin_get_root(); // need all settings here
$adminroot->search = $query; // So we can reference it in search boxes later in this invocation
$statusmsg = '';
$errormsg = '';
$focus = '';
// now we'll deal with the case that the admin has submitted the form with changed settings
2008-06-09 16:53:30 +00:00
if ($data = data_submitted() and confirm_sesskey()) {
if (admin_write_settings($data)) {
redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}
if (!empty($adminroot->errors)) {
$errormsg = get_string('errorwithsettings', 'admin');
$firsterror = reset($adminroot->errors);
$focus = $firsterror->id;
} else {
redirect($PAGE->url);
}
}
// and finally, if we get here, then there are matching settings and we have to print a form
// to modify them
echo $OUTPUT->header($focus);
echo $OUTPUT->heading(get_string('administrationsite'));
if ($errormsg !== '') {
echo $OUTPUT->notification($errormsg);
} else if ($statusmsg !== '') {
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
}
require_once("admin_settings_search_form.php");
$form = new admin_settings_search_form();
$form->display();
echo '<hr>';
if ($query) {
echo admin_search_settings_html($query);
} else {
$node = $PAGE->settingsnav->find('root', navigation_node::TYPE_SITE_ADMIN);
if ($node) {
echo $OUTPUT->render_from_template('core/settings_link_page', ['node' => $node]);
}
}
echo $OUTPUT->footer();