From 0b044e0b3da4090435cef5a53a3d1880552e573b Mon Sep 17 00:00:00 2001 From: Guillaume Viguier Date: Wed, 17 Feb 2010 11:27:26 -0500 Subject: [PATCH] Management of timezones at user level (see CT#599) --- main/inc/lib/main_api.lib.php | 12 ++++++++---- main/install/migrate-db-1.8.6.2-1.8.7-pre.sql | 6 +++--- main/mySpace/myStudents.php | 5 +++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 9350c70361..fb1f47a9bf 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -4510,10 +4510,14 @@ function api_get_local_time($time, $format=null, $to_timezone=null, $from_timezo if ($timezone_value !== null) { $to_timezone = $timezone_value; } - // Third, get the timezone based on user preference, if it exists - $timezone_user = UserManager::get_extra_user_data_by_field($_user['user_id'],'timezone'); - if ($timezone_user['timezone'] != null) { - $to_timezone = $timezone_user['timezone']; + // If allowed by the administrator + $use_users_timezone = api_get_setting('use_users_timezone', 'timezones'); + if ($use_users_timezone == 'true') { + // Get the timezone based on user preference, if it exists + $timezone_user = UserManager::get_extra_user_data_by_field($_user['user_id'],'timezone'); + if ($timezone_user['timezone'] != null) { + $to_timezone = $timezone_user['timezone']; + } } } // Determine the format diff --git a/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql b/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql index 853bba43dc..c0d421ec07 100755 --- a/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql +++ b/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql @@ -27,9 +27,9 @@ ALTER TABLE block ADD UNIQUE(path); INSERT INTO user_field(field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES(1, 'dashboard', 'Dashboard', 0, 0); INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'dashboard', 'checkbox', 'Platform', 'true', 'ShowTabsTitle','ShowTabsComment',NULL,'TabsDashboard', 1); -INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('users_can_change_timezone', 'timezones', 'radio', 'Timezones', 'true', 'AllowUsersTimezoneTitle','AllowUsersTimezoneComment',NULL,'Timezones', 1); -INSERT INTO settings_options (variable, value, display_text) VALUES ('users_can_change_timezone', 'true', 'Yes'); -INSERT INTO settings_options (variable, value, display_text) VALUES ('users_can_change_timezone', 'false', 'No'); +INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('use_users_timezone', 'timezones', 'radio', 'Timezones', 'true', 'UseUsersTimezoneTitle','UseUsersTimezoneComment',NULL,'Timezones', 1); +INSERT INTO settings_options (variable, value, display_text) VALUES ('use_users_timezone', 'true', 'Yes'); +INSERT INTO settings_options (variable, value, display_text) VALUES ('use_users_timezone', 'false', 'No'); INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('timezone_value', 'timezones', 'select', 'Timezones', 'UTC', 'TimezoneValueTitle','TimezoneValueComment',NULL,'Timezones', 1); ALTER TABLE user_field CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00'; diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index dba3c23f4e..98c4288433 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -419,10 +419,11 @@ if (!empty ($_GET['student'])) {