2009-11-01 10:57:00 +00:00
|
|
|
<?php
|
2006-08-28 06:02:00 +00:00
|
|
|
|
2006-09-20 21:00:45 +00:00
|
|
|
// detects settings that were added during an upgrade, displays a screen for the admin to
|
2006-08-28 06:02:00 +00:00
|
|
|
// modify them, and then processes modifications
|
|
|
|
|
|
|
|
require_once('../config.php');
|
2006-09-02 13:14:57 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
2006-08-28 06:02:00 +00:00
|
|
|
|
2007-10-02 21:38:53 +00:00
|
|
|
$return = optional_param('return', '', PARAM_ALPHA);
|
|
|
|
|
2007-12-22 18:17:15 +00:00
|
|
|
/// no guest autologin
|
|
|
|
require_login(0, false);
|
|
|
|
|
2007-04-30 17:08:34 +00:00
|
|
|
admin_externalpage_setup('upgradesettings'); // now hidden page
|
2010-04-14 02:26:26 +00:00
|
|
|
$adminroot = admin_get_root(); // need all settings
|
2006-08-28 06:02:00 +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 new settings
|
2008-06-09 16:53:30 +00:00
|
|
|
if ($data = data_submitted() and confirm_sesskey()) {
|
2007-12-19 17:35:20 +00:00
|
|
|
$count = admin_write_settings($data);
|
2009-01-20 23:53:34 +00:00
|
|
|
$adminroot = admin_get_root(true); //reload tree
|
2007-12-19 17:35:20 +00:00
|
|
|
}
|
2006-09-02 13:14:57 +00:00
|
|
|
|
2008-07-04 23:53:13 +00:00
|
|
|
$newsettings = admin_output_new_settings_by_page($adminroot);
|
|
|
|
if (isset($newsettings['frontpagesettings'])) {
|
|
|
|
$frontpage = $newsettings['frontpagesettings'];
|
|
|
|
unset($newsettings['frontpagesettings']);
|
|
|
|
array_unshift($newsettings, $frontpage);
|
|
|
|
}
|
|
|
|
$newsettingshtml = implode($newsettings);
|
|
|
|
unset($newsettings);
|
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
$focus = '';
|
2006-08-28 06:02:00 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if (empty($adminroot->errors) and $newsettingshtml === '') {
|
|
|
|
// there must be either redirect without message or continue button or else upgrade would be sometimes broken
|
2007-10-02 21:38:53 +00:00
|
|
|
if ($return == 'site') {
|
|
|
|
redirect("$CFG->wwwroot/");
|
|
|
|
} else {
|
|
|
|
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
|
|
|
}
|
2006-08-28 06:02:00 +00:00
|
|
|
}
|
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if (!empty($adminroot->errors)) {
|
|
|
|
$firsterror = reset($adminroot->errors);
|
|
|
|
$focus = $firsterror->id;
|
2006-08-28 06:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// and finally, if we get here, then there are new settings and we have to print a form
|
|
|
|
// to modify them
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header($focus);
|
2006-08-28 06:02:00 +00:00
|
|
|
|
2009-02-01 17:45:32 +00:00
|
|
|
if (!empty($SITE->fullname) and !empty($SITE->shortname)) {
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box(get_string('upgradesettingsintro','admin'), 'generalbox');
|
2009-02-01 17:45:32 +00:00
|
|
|
}
|
2006-09-26 20:51:28 +00:00
|
|
|
|
2007-01-04 21:32:36 +00:00
|
|
|
echo '<form action="upgradesettings.php" method="post" id="adminsettings">';
|
2007-12-19 17:35:20 +00:00
|
|
|
echo '<div>';
|
2007-10-02 21:38:53 +00:00
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
|
|
|
echo '<input type="hidden" name="return" value="'.$return.'" />';
|
2006-09-27 07:49:34 +00:00
|
|
|
echo '<fieldset>';
|
|
|
|
echo '<div class="clearer"><!-- --></div>';
|
2006-09-04 21:38:23 +00:00
|
|
|
echo $newsettingshtml;
|
2006-12-11 11:29:19 +00:00
|
|
|
echo '</fieldset>';
|
2007-12-19 17:35:20 +00:00
|
|
|
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
|
|
|
|
echo '</div>';
|
2006-08-28 06:02:00 +00:00
|
|
|
echo '</form>';
|
|
|
|
|
2009-08-06 14:12:46 +00:00
|
|
|
echo $OUTPUT->footer();
|
2006-09-04 21:38:23 +00:00
|
|
|
|
2009-11-01 10:57:00 +00:00
|
|
|
|