3 // detects settings that were added during an upgrade, displays a screen for the admin to
4 // modify them, and then processes modifications
6 require_once('../config.php');
7 require_once($CFG->libdir
.'/adminlib.php');
9 $return = optional_param('return', '', PARAM_ALPHA
);
11 /// no guest autologin
12 require_login(0, false);
14 $adminroot =& admin_get_root(); // need all settings
15 admin_externalpage_setup('upgradesettings'); // now hidden page
17 // now we'll deal with the case that the admin has submitted the form with new settings
18 if ($data = data_submitted() and confirm_sesskey()) {
19 $count = admin_write_settings($data);
20 $adminroot =& admin_get_root(true); //reload tree
23 $newsettings = admin_output_new_settings_by_page($adminroot);
24 if (isset($newsettings['frontpagesettings'])) {
25 $frontpage = $newsettings['frontpagesettings'];
26 unset($newsettings['frontpagesettings']);
27 array_unshift($newsettings, $frontpage);
29 $newsettingshtml = implode($newsettings);
34 if (empty($adminroot->errors
) and $newsettingshtml === '') {
35 // there must be either redirect without message or continue button or else upgrade would be sometimes broken
36 if ($return == 'site') {
37 redirect("$CFG->wwwroot/");
39 redirect("$CFG->wwwroot/$CFG->admin/index.php");
43 if (!empty($adminroot->errors
)) {
44 $firsterror = reset($adminroot->errors
);
45 $focus = $firsterror->id
;
48 // and finally, if we get here, then there are new settings and we have to print a form
50 admin_externalpage_print_header($focus);
52 print_box(get_string('upgradesettingsintro','admin'), 'generalbox');
54 echo '<form action="upgradesettings.php" method="post" id="adminsettings">';
56 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
57 echo '<input type="hidden" name="return" value="'.$return.'" />';
59 echo '<div class="clearer"><!-- --></div>';
60 echo $newsettingshtml;
62 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
66 if (!empty($CFG->adminusehtmleditor
)) {