Merge branch 'MDL-26505_19' of git://github.com/timhunt/moodle into MOODLE_19_STABLE
[moodle.git] / admin / upgradesettings.php
blob2f23407626596a6e4819a31a7e2bd63677bf09d8
1 <?php // $Id$
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);
30 unset($newsettings);
32 $focus = '';
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/");
38 } else {
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
49 // to modify them
50 admin_externalpage_print_header($focus);
52 print_box(get_string('upgradesettingsintro','admin'), 'generalbox');
54 echo '<form action="upgradesettings.php" method="post" id="adminsettings">';
55 echo '<div>';
56 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
57 echo '<input type="hidden" name="return" value="'.$return.'" />';
58 echo '<fieldset>';
59 echo '<div class="clearer"><!-- --></div>';
60 echo $newsettingshtml;
61 echo '</fieldset>';
62 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
63 echo '</div>';
64 echo '</form>';
66 if (!empty($CFG->adminusehtmleditor)) {
67 use_html_editor();
70 print_footer();