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