[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/admin/ -> upgradesettings.php (source)

   1  <?php // $Id: upgradesettings.php,v 1.21.2.3 2008/07/04 23:54:22 skodak Exp $
   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  
   6  require_once ('../config.php');
   7  require_once($CFG->libdir.'/adminlib.php');
   8  
   9  $return = optional_param('return', '', PARAM_ALPHA);
  10  
  11  /// no guest autologin
  12  require_login(0, false);
  13  
  14  $adminroot =& admin_get_root(); // need all settings
  15  admin_externalpage_setup('upgradesettings'); // now hidden page
  16  
  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
  21  }
  22  
  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);
  28  }
  29  $newsettingshtml = implode($newsettings);
  30  unset($newsettings);
  31  
  32  $focus = '';
  33  
  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");
  40      }
  41  }
  42  
  43  if (!empty($adminroot->errors)) {
  44      $firsterror = reset($adminroot->errors);
  45      $focus = $firsterror->id;
  46  }
  47  
  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);
  51  
  52  print_box(get_string('upgradesettingsintro','admin'), 'generalbox');
  53  
  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>';
  65  
  66  if (!empty($CFG->adminusehtmleditor)) {
  67      use_html_editor();
  68  }
  69  
  70  print_footer();
  71  
  72  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7