Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/upgradesettings.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // detects settings that were added during an upgrade, displays a screen for the admin to
00004 // modify them, and then processes modifications
00005 
00006 require_once('../config.php');
00007 require_once($CFG->libdir.'/adminlib.php');
00008 
00009 $return = optional_param('return', '', PARAM_ALPHA);
00010 
00012 require_login(0, false);
00013 
00014 admin_externalpage_setup('upgradesettings'); // now hidden page
00015 $PAGE->set_pagelayout('maintenance'); // do not print any blocks or other rubbish, we want to force saving
00016 $PAGE->blocks->show_only_fake_blocks();
00017 $adminroot = admin_get_root(); // need all settings
00018 
00019 // now we'll deal with the case that the admin has submitted the form with new settings
00020 if ($data = data_submitted() and confirm_sesskey()) {
00021     $count = admin_write_settings($data);
00022     $adminroot = admin_get_root(true); //reload tree
00023 }
00024 
00025 $newsettings = admin_output_new_settings_by_page($adminroot);
00026 if (isset($newsettings['frontpagesettings'])) {
00027     $frontpage = $newsettings['frontpagesettings'];
00028     unset($newsettings['frontpagesettings']);
00029     array_unshift($newsettings, $frontpage);
00030 }
00031 $newsettingshtml = implode($newsettings);
00032 unset($newsettings);
00033 
00034 $focus = '';
00035 
00036 if (empty($adminroot->errors) and $newsettingshtml === '') {
00037     // there must be either redirect without message or continue button or else upgrade would be sometimes broken
00038     if ($return == 'site') {
00039         redirect("$CFG->wwwroot/");
00040     } else {
00041         redirect("$CFG->wwwroot/$CFG->admin/index.php");
00042     }
00043 }
00044 
00045 if (!empty($adminroot->errors)) {
00046     $firsterror = reset($adminroot->errors);
00047     $focus = $firsterror->id;
00048 }
00049 
00050 // and finally, if we get here, then there are new settings and we have to print a form
00051 // to modify them
00052 echo $OUTPUT->header($focus);
00053 
00054 if (!empty($SITE->fullname) and !empty($SITE->shortname)) {
00055     echo $OUTPUT->box(get_string('upgradesettingsintro','admin'), 'generalbox');
00056 }
00057 
00058 echo '<form action="upgradesettings.php" method="post" id="adminsettings">';
00059 echo '<div>';
00060 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
00061 echo '<input type="hidden" name="return" value="'.$return.'" />';
00062 echo '<fieldset>';
00063 echo '<div class="clearer"><!-- --></div>';
00064 echo $newsettingshtml;
00065 echo '</fieldset>';
00066 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
00067 echo '</div>';
00068 echo '</form>';
00069 
00070 echo $OUTPUT->footer();
00071 
00072 
 All Data Structures Namespaces Files Functions Variables Enumerations