source: moodle/trunk/fuentes/admin/search.php @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 3 years ago

Ported code to xenial

File size: 1.8 KB
Line 
1<?php
2
3// searches for admin settings
4
5require_once('../config.php');
6require_once($CFG->libdir.'/adminlib.php');
7
8$query = trim(optional_param('query', '', PARAM_NOTAGS));  // Search string
9
10$PAGE->set_context(context_system::instance());
11
12admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page
13
14$adminroot = admin_get_root(); // need all settings here
15$adminroot->search = $query; // So we can reference it in search boxes later in this invocation
16$statusmsg = '';
17$errormsg  = '';
18$focus = '';
19
20// now we'll deal with the case that the admin has submitted the form with changed settings
21if ($data = data_submitted() and confirm_sesskey()) {
22    if (admin_write_settings($data)) {
23        $statusmsg = get_string('changessaved');
24    }
25    $adminroot = admin_get_root(true); //reload tree
26
27    if (!empty($adminroot->errors)) {
28        $errormsg = get_string('errorwithsettings', 'admin');
29        $firsterror = reset($adminroot->errors);
30        $focus = $firsterror->id;
31    }
32}
33
34// and finally, if we get here, then there are matching settings and we have to print a form
35// to modify them
36echo $OUTPUT->header($focus);
37
38if ($errormsg !== '') {
39    echo $OUTPUT->notification($errormsg);
40
41} else if ($statusmsg !== '') {
42    echo $OUTPUT->notification($statusmsg, 'notifysuccess');
43}
44
45$resultshtml = admin_search_settings_html($query); // case insensitive search only
46
47echo '<form action="search.php" method="post" id="adminsettings">';
48echo '<div>';
49echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
50echo '<input type="hidden" name="query" value="'.s($query).'" />';
51echo '</div>';
52echo '<fieldset>';
53echo '<div class="clearer"><!-- --></div>';
54if ($resultshtml != '') {
55    echo $resultshtml;
56} else {
57    echo get_string('noresults','admin');
58}
59echo '</fieldset>';
60echo '</form>';
61
62echo $OUTPUT->footer();
63
64
Note: See TracBrowser for help on using the repository browser.