1<?php 2 3// detects settings that were added during an upgrade, displays a screen for the admin to 4// modify them, and then processes modifications 5 6require_once('../config.php'); 7require_once($CFG->libdir.'/adminlib.php'); 8 9$return = optional_param('return', '', PARAM_ALPHA); 10 11/// no guest autologin 12require_login(0, false); 13if (isguestuser()) { 14 // Login as real user! 15 $SESSION->wantsurl = (string)new moodle_url('/admin/upgradesettings.php', array('return'=>$return)); 16 redirect(get_login_url()); 17} 18 19admin_externalpage_setup('upgradesettings'); // now hidden page 20$PAGE->set_pagelayout('maintenance'); // do not print any blocks or other rubbish, we want to force saving 21$PAGE->blocks->show_only_fake_blocks(); 22$adminroot = admin_get_root(); // need all settings 23 24// now we'll deal with the case that the admin has submitted the form with new settings 25if ($data = data_submitted() and confirm_sesskey()) { 26 $count = admin_write_settings($data); 27} 28 29$newsettings = admin_output_new_settings_by_page($adminroot); 30if (isset($newsettings['frontpagesettings'])) { 31 $frontpage = $newsettings['frontpagesettings']; 32 unset($newsettings['frontpagesettings']); 33 array_unshift($newsettings, $frontpage); 34} 35$newsettingshtml = implode($newsettings); 36unset($newsettings); 37 38$focus = ''; 39 40if (empty($adminroot->errors) and $newsettingshtml === '') { 41 // there must be either redirect without message or continue button or else upgrade would be sometimes broken 42 if ($return == 'site') { 43 redirect("$CFG->wwwroot/"); 44 } else { 45 redirect("$CFG->wwwroot/$CFG->admin/index.php"); 46 } 47} 48 49if (!empty($adminroot->errors)) { 50 $firsterror = reset($adminroot->errors); 51 $focus = $firsterror->id; 52} 53 54// and finally, if we get here, then there are new settings and we have to print a form 55// to modify them 56echo $OUTPUT->header($focus); 57 58if (!empty($SITE->fullname) and !empty($SITE->shortname)) { 59 echo $OUTPUT->box(get_string('upgradesettingsintro','admin'), 'generalbox'); 60} 61 62echo '<form action="upgradesettings.php" method="post" id="adminsettings">'; 63echo '<div>'; 64echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; 65echo '<input type="hidden" name="return" value="'.$return.'" />'; 66echo '<fieldset>'; 67echo '<div class="clearer"><!-- --></div>'; 68echo $newsettingshtml; 69echo '</fieldset>'; 70echo '<div class="form-buttons"><input class="form-submit btn btn-primary" type="submit" value="'.get_string('savechanges','admin').'" /></div>'; 71echo '</div>'; 72echo '</form>'; 73 74echo $OUTPUT->footer(); 75 76 77