Search moodle.org's
Developer Documentation

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
  • /admin/ -> timezone.php (source)

    Differences Between: [Versions 310 and 34] [Versions 310 and 35] [Versions 310 and 36] [Versions 310 and 37] [Versions 34 and 310] [Versions 35 and 310] [Versions 36 and 310] [Versions 37 and 310]

       1  <?php
       2  
       3      require_once('../config.php');
       4  
       5      $zone = optional_param('zone', '', PARAM_RAW);
       6  
       7      if (!is_numeric($zone)) {
       8           //not a path, but it looks like it anyway
       9           $zone = clean_param($zone, PARAM_PATH);
      10      }
      11  
      12      $PAGE->set_url('/admin/timezone.php');
      13      $PAGE->set_context(context_system::instance());
      14  
      15      require_admin();
      16  
      17      $strtimezone = get_string("timezone");
      18      $strsavechanges = get_string("savechanges");
      19      $strusers = get_string("users");
      20      $strall = get_string("all");
      21  
      22      $PAGE->set_title($strtimezone);
      23      $PAGE->set_heading($strtimezone);
      24      $PAGE->navbar->add($strtimezone);
      25      echo $OUTPUT->header();
      26  
      27      echo $OUTPUT->heading("");
      28  
      29      if (data_submitted() and !empty($zone) and confirm_sesskey()) {
      30          echo "<center>";
      31          $DB->execute("UPDATE {user} SET timezone = ?", array($zone));
      32          echo "</center>";
      33  
      34          $USER->timezone = $zone;
      35          $current = $zone;
      36          echo $OUTPUT->notification('Timezone of all users changed', 'notifysuccess');
      37      } else {
      38          $current = 99;
      39      }
      40  
      41      require_once($CFG->dirroot.'/calendar/lib.php');
      42      $timezones = core_date::get_list_of_timezones(null, true);
      43  
      44      echo '<center><form action="timezone.php" method="post">';
      45      echo html_writer::label($strusers . ' (' . $strall . '): ', 'menuzone');
      46      echo html_writer::select($timezones, "zone", $current);
      47      echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
      48      echo '<input type="submit" value="'.s($strsavechanges).'" />';
      49      echo "</form></center>";
      50  
      51      echo $OUTPUT->footer();
      52  
      53