Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / admin / search.php
blob4fcde9546a3d90c7da2d531bf2d046ac063ffe4c
1 <?php // $Id$
3 // searches for admin settings
5 require_once('../config.php');
6 require_once($CFG->libdir.'/adminlib.php');
8 $query = trim(stripslashes(optional_param('query', '', PARAM_NOTAGS))); // Search string
10 $adminroot =& admin_get_root(); // need all settings here
11 $adminroot->search = $query; // So we can reference it in search boxes later in this invocation
12 $statusmsg = '';
13 $errormsg = '';
14 $focus = '';
16 admin_externalpage_setup('search'); // now hidden page
18 // now we'll deal with the case that the admin has submitted the form with changed settings
19 if ($data = data_submitted() and confirm_sesskey()) {
20 if (admin_write_settings($data)) {
21 $statusmsg = get_string('changessaved');
23 $adminroot =& admin_get_root(true); //reload tree
25 if (!empty($adminroot->errors)) {
26 $errormsg = get_string('errorwithsettings', 'admin');
27 $firsterror = reset($adminroot->errors);
28 $focus = $firsterror->id;
32 // and finally, if we get here, then there are matching settings and we have to print a form
33 // to modify them
34 admin_externalpage_print_header($focus);
36 if ($errormsg !== '') {
37 notify ($errormsg);
39 } else if ($statusmsg !== '') {
40 notify ($statusmsg, 'notifysuccess');
43 $resultshtml = admin_search_settings_html($query); // case insensitive search only
45 echo '<form action="search.php" method="post" id="adminsettings">';
46 echo '<div>';
47 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
48 echo '<input type="hidden" name="query" value="'.s($query).'" />';
49 echo '</div>';
50 echo '<fieldset>';
51 echo '<div class="clearer"><!-- --></div>';
52 if ($resultshtml != '') {
53 echo $resultshtml;
54 } else {
55 echo get_string('noresults','admin');
57 echo '</fieldset>';
58 echo '</form>';
60 print_footer();