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

Last change on this file was 1331, checked in by jrpelegrina, 4 years ago

Updated to moodle 3.0.3

File size: 1.9 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
26    if (!empty($adminroot->errors)) {
27        $errormsg = get_string('errorwithsettings', 'admin');
28        $firsterror = reset($adminroot->errors);
29        $focus = $firsterror->id;
30    }
31}
32
33// and finally, if we get here, then there are matching settings and we have to print a form
34// to modify them
35echo $OUTPUT->header($focus);
36
37if ($errormsg !== '') {
38    echo $OUTPUT->notification($errormsg);
39
40} else if ($statusmsg !== '') {
41    echo $OUTPUT->notification($statusmsg, 'notifysuccess');
42}
43
44$resultshtml = admin_search_settings_html($query); // case insensitive search only
45
46echo '<form action="' . $PAGE->url->out(true) . '" method="post" id="adminsettings">';
47echo '<div>';
48echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
49// HACK to prevent browsers from automatically inserting the user's password into the wrong fields.
50echo prevent_form_autofill_password();
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.