2009-11-01 10:57:00 +00:00
|
|
|
<?php
|
2006-10-02 05:52:39 +00:00
|
|
|
|
|
|
|
// searches for admin settings
|
|
|
|
|
|
|
|
require_once('../config.php');
|
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
|
2008-05-30 21:36:57 +00:00
|
|
|
$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string
|
|
|
|
|
2009-05-06 08:55:53 +00:00
|
|
|
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
2009-06-12 11:53:35 +00:00
|
|
|
$PAGE->set_course($SITE);
|
|
|
|
|
2009-01-20 23:53:34 +00:00
|
|
|
$adminroot = admin_get_root(); // need all settings here
|
2007-12-19 17:35:20 +00:00
|
|
|
$adminroot->search = $query; // So we can reference it in search boxes later in this invocation
|
2006-10-23 12:05:33 +00:00
|
|
|
$statusmsg = '';
|
2007-12-19 17:35:20 +00:00
|
|
|
$errormsg = '';
|
|
|
|
$focus = '';
|
2006-10-23 12:05:33 +00:00
|
|
|
|
2009-05-06 08:55:53 +00:00
|
|
|
admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page
|
2006-10-23 12:05:33 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
// now we'll deal with the case that the admin has submitted the form with changed settings
|
2008-06-09 16:53:30 +00:00
|
|
|
if ($data = data_submitted() and confirm_sesskey()) {
|
2007-12-19 17:35:20 +00:00
|
|
|
if (admin_write_settings($data)) {
|
|
|
|
$statusmsg = get_string('changessaved');
|
|
|
|
}
|
2009-01-20 23:53:34 +00:00
|
|
|
$adminroot = admin_get_root(true); //reload tree
|
2006-10-02 05:52:39 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if (!empty($adminroot->errors)) {
|
|
|
|
$errormsg = get_string('errorwithsettings', 'admin');
|
|
|
|
$firsterror = reset($adminroot->errors);
|
|
|
|
$focus = $firsterror->id;
|
2006-10-02 05:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// and finally, if we get here, then there are matching settings and we have to print a form
|
|
|
|
// to modify them
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header($focus);
|
2006-10-02 05:52:39 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if ($errormsg !== '') {
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->notification($errormsg);
|
2007-12-19 17:35:20 +00:00
|
|
|
|
|
|
|
} else if ($statusmsg !== '') {
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
|
2006-10-23 12:05:33 +00:00
|
|
|
}
|
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
$resultshtml = admin_search_settings_html($query); // case insensitive search only
|
2006-10-02 05:52:39 +00:00
|
|
|
|
2007-01-04 21:32:36 +00:00
|
|
|
echo '<form action="search.php" method="post" id="adminsettings">';
|
2007-03-23 01:17:43 +00:00
|
|
|
echo '<div>';
|
2007-12-19 17:35:20 +00:00
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
|
|
|
echo '<input type="hidden" name="query" value="'.s($query).'" />';
|
2007-03-23 01:17:43 +00:00
|
|
|
echo '</div>';
|
2006-10-02 05:52:39 +00:00
|
|
|
echo '<fieldset>';
|
|
|
|
echo '<div class="clearer"><!-- --></div>';
|
|
|
|
if ($resultshtml != '') {
|
|
|
|
echo $resultshtml;
|
|
|
|
} else {
|
|
|
|
echo get_string('noresults','admin');
|
|
|
|
}
|
2006-11-30 08:42:11 +00:00
|
|
|
echo '</fieldset>';
|
2006-10-02 05:52:39 +00:00
|
|
|
echo '</form>';
|
|
|
|
|
2009-08-06 14:12:46 +00:00
|
|
|
echo $OUTPUT->footer();
|
2006-10-02 05:52:39 +00:00
|
|
|
|
2009-11-01 10:57:00 +00:00
|
|
|
|