|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // searches for admin settings 00004 00005 require_once('../config.php'); 00006 require_once($CFG->libdir.'/adminlib.php'); 00007 00008 $query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string 00009 00010 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); 00011 00012 admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page 00013 00014 $adminroot = admin_get_root(); // need all settings here 00015 $adminroot->search = $query; // So we can reference it in search boxes later in this invocation 00016 $statusmsg = ''; 00017 $errormsg = ''; 00018 $focus = ''; 00019 00020 // now we'll deal with the case that the admin has submitted the form with changed settings 00021 if ($data = data_submitted() and confirm_sesskey()) { 00022 if (admin_write_settings($data)) { 00023 $statusmsg = get_string('changessaved'); 00024 } 00025 $adminroot = admin_get_root(true); //reload tree 00026 00027 if (!empty($adminroot->errors)) { 00028 $errormsg = get_string('errorwithsettings', 'admin'); 00029 $firsterror = reset($adminroot->errors); 00030 $focus = $firsterror->id; 00031 } 00032 } 00033 00034 // and finally, if we get here, then there are matching settings and we have to print a form 00035 // to modify them 00036 echo $OUTPUT->header($focus); 00037 00038 if ($errormsg !== '') { 00039 echo $OUTPUT->notification($errormsg); 00040 00041 } else if ($statusmsg !== '') { 00042 echo $OUTPUT->notification($statusmsg, 'notifysuccess'); 00043 } 00044 00045 $resultshtml = admin_search_settings_html($query); // case insensitive search only 00046 00047 echo '<form action="search.php" method="post" id="adminsettings">'; 00048 echo '<div>'; 00049 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; 00050 echo '<input type="hidden" name="query" value="'.s($query).'" />'; 00051 echo '</div>'; 00052 echo '<fieldset>'; 00053 echo '<div class="clearer"><!-- --></div>'; 00054 if ($resultshtml != '') { 00055 echo $resultshtml; 00056 } else { 00057 echo get_string('noresults','admin'); 00058 } 00059 echo '</fieldset>'; 00060 echo '</form>'; 00061 00062 echo $OUTPUT->footer(); 00063 00064