If $CFG->forcetimezone is not empty, don't allow users to change the timezone from

their profiles, and instead show a disabled menu with the forced timezone selected.

Also, fixed a get_string (reading from wrong lang file).
This commit is contained in:
defacer
2005-04-09 09:36:47 +00:00
parent 7b9e355e43
commit 02a5309439
2 changed files with 16 additions and 5 deletions
+7 -2
View File
@@ -234,7 +234,7 @@ if (isadmin()) {
</tr>
-->
<tr>
<th><?php print_string('timezone', 'calendar')?>:</th>
<th><?php print_string('timezone')?>:</th>
<td>
<?php
$records = get_records_sql('SELECT id, name FROM '.$CFG->prefix.'timezone GROUP BY name');
@@ -260,7 +260,12 @@ if (isadmin()) {
$presets[sprintf("%.1f", $i)] = $tzstring;
}
}
choose_from_menu($presets, 'timezone', $user->timezone, get_string('serverlocaltime'), '', '99');
if(!empty($CFG->forcetimezone)) {
choose_from_menu($presets, 'timezone', $CFG->forcetimezone, get_string('serverlocaltime'), '', '99', false, true);
}
else {
choose_from_menu($presets, 'timezone', $user->timezone, get_string('serverlocaltime'), '', '99');
}
?>
</td>
</tr>
+9 -3
View File
@@ -99,9 +99,15 @@
$usernew->htmleditor = clean_param($usernew->htmleditor, PARAM_INT);
$usernew->emailstop = clean_param($usernew->emailstop, PARAM_INT);
// Some replaces to prevent SQL injections
$usernew->timezone = str_replace(';', '', $usernew->timezone);
$usernew->timezone = str_replace('\'', '', $usernew->timezone);
if(!empty($CFG->forcetimezone) && isset($usernew->timezone)) {
// Don't allow changing this in any way if a timezone is forced
unset($usernew->timezone);
}
else {
// Some replaces to prevent SQL injections
$usernew->timezone = str_replace(';', '', $usernew->timezone);
$usernew->timezone = str_replace('\'', '', $usernew->timezone);
}
foreach ($usernew as $key => $data) {
$usernew->$key = addslashes(clean_text(stripslashes(trim($usernew->$key)), FORMAT_MOODLE));