moodle/admin/timezone.php

60 lines
1.6 KiB
PHP
Raw Normal View History

2003-11-22 09:00:15 +00:00
<?php // $Id$
include("../config.php");
require_login();
if (!isadmin()) {
error("You must be an admin");
}
$strtimezone = get_string("timezone");
$strsavechanges = get_string("savechanges");
$strusers = get_string("users");
$strall = get_string("all");
print_header($strtimezone, $strtimezone, $strtimezone);
print_heading("");
2004-10-04 13:50:37 +00:00
if (isset($zone) and confirm_sesskey()) {
2003-11-22 09:00:15 +00:00
$db->debug = true;
echo "<center>";
execute_sql("UPDATE {$CFG->prefix}user SET timezone = '$zone'");
$db->debug = false;
echo "</center>";
$USER->timezone = $zone;
}
$user = $USER;
if (abs($user->timezone) > 13) {
$user->timezone = 99;
}
$timenow = time();
$timeformat = get_string('strftimedaytime');
2003-11-22 09:00:15 +00:00
for ($tz = -26; $tz <= 26; $tz++) {
$zone = (float)$tz/2.0;
$usertime = $timenow + ($tz * 1800);
if ($tz == 0) {
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT)";
2003-11-22 09:00:15 +00:00
} else if ($tz < 0) {
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT$zone)";
2003-11-22 09:00:15 +00:00
} else {
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT+$zone)";
2003-11-22 09:00:15 +00:00
}
}
2004-10-04 13:50:37 +00:00
echo '<center><form action="timezone.php" method="get">';
2003-11-22 09:00:15 +00:00
echo "$strusers ($strall): ";
choose_from_menu ($timezones, "zone", $user->timezone, get_string("serverlocaltime"), "", "99");
2004-10-04 13:50:37 +00:00
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\">";
2004-09-12 00:21:21 +00:00
echo "<input type=\"submit\" value=\"$strsavechanges\">";
2004-10-04 13:50:37 +00:00
echo "</form></center>";
2003-11-22 09:00:15 +00:00
print_footer();
?>