MDL-29519 move plagiarism cron to after event queue
[moodle.git] / admin / search.php
blob55d93c070af89431753fd331544ec9e07322b4f4
1 <?php
3 // searches for admin settings
5 require_once('../config.php');
6 require_once($CFG->libdir.'/adminlib.php');
8 $query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string
10 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
11 $PAGE->set_course($SITE);
13 $adminroot = admin_get_root(); // need all settings here
14 $adminroot->search = $query; // So we can reference it in search boxes later in this invocation
15 $statusmsg = '';
16 $errormsg = '';
17 $focus = '';
19 admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page
21 // now we'll deal with the case that the admin has submitted the form with changed settings
22 if ($data = data_submitted() and confirm_sesskey()) {
23 if (admin_write_settings($data)) {
24 $statusmsg = get_string('changessaved');
26 $adminroot = admin_get_root(true); //reload tree
28 if (!empty($adminroot->errors)) {
29 $errormsg = get_string('errorwithsettings', 'admin');
30 $firsterror = reset($adminroot->errors);
31 $focus = $firsterror->id;
35 // and finally, if we get here, then there are matching settings and we have to print a form
36 // to modify them
37 echo $OUTPUT->header($focus);
39 if ($errormsg !== '') {
40 echo $OUTPUT->notification($errormsg);
42 } else if ($statusmsg !== '') {
43 echo $OUTPUT->notification($statusmsg, 'notifysuccess');
46 $resultshtml = admin_search_settings_html($query); // case insensitive search only
48 echo '<form action="search.php" method="post" id="adminsettings">';
49 echo '<div>';
50 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
51 echo '<input type="hidden" name="query" value="'.s($query).'" />';
52 echo '</div>';
53 echo '<fieldset>';
54 echo '<div class="clearer"><!-- --></div>';
55 if ($resultshtml != '') {
56 echo $resultshtml;
57 } else {
58 echo get_string('noresults','admin');
60 echo '</fieldset>';
61 echo '</form>';
63 echo $OUTPUT->footer();