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 admin_externalpage_setup('upgradesettings'); // now hidden page
15 $PAGE->set_pagelayout('maintenance'); // do not print any blocks or other rubbish, we want to force saving
16 $PAGE->blocks
->show_only_fake_blocks();
17 $adminroot = admin_get_root(); // need all settings
19 // now we'll deal with the case that the admin has submitted the form with new settings
20 if ($data = data_submitted() and confirm_sesskey()) {
21 $count = admin_write_settings($data);
22 $adminroot = admin_get_root(true); //reload tree
25 $newsettings = admin_output_new_settings_by_page($adminroot);
26 if (isset($newsettings['frontpagesettings'])) {
27 $frontpage = $newsettings['frontpagesettings'];
28 unset($newsettings['frontpagesettings']);
29 array_unshift($newsettings, $frontpage);
31 $newsettingshtml = implode($newsettings);
36 if (empty($adminroot->errors
) and $newsettingshtml === '') {
37 // there must be either redirect without message or continue button or else upgrade would be sometimes broken
38 if ($return == 'site') {
39 redirect("$CFG->wwwroot/");
41 redirect("$CFG->wwwroot/$CFG->admin/index.php");
45 if (!empty($adminroot->errors
)) {
46 $firsterror = reset($adminroot->errors
);
47 $focus = $firsterror->id
;
50 // and finally, if we get here, then there are new settings and we have to print a form
52 echo $OUTPUT->header($focus);
54 if (!empty($SITE->fullname
) and !empty($SITE->shortname
)) {
55 echo $OUTPUT->box(get_string('upgradesettingsintro','admin'), 'generalbox');
58 echo '<form action="upgradesettings.php" method="post" id="adminsettings">';
60 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
61 echo '<input type="hidden" name="return" value="'.$return.'" />';
63 echo '<div class="clearer"><!-- --></div>';
64 echo $newsettingshtml;
66 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
70 echo $OUTPUT->footer();