diff --git a/airtime_mvc/application/common/Timezone.php b/airtime_mvc/application/common/Timezone.php index 7da82f6f9..5e12338e2 100644 --- a/airtime_mvc/application/common/Timezone.php +++ b/airtime_mvc/application/common/Timezone.php @@ -18,7 +18,7 @@ class Application_Common_Timezone 'UTC' => DateTimeZone::UTC ); - $tzlist = array(); + $tzlist = array(NULL => "Use station default"); foreach ($regions as $name => $mask) { $ids = DateTimeZone::listIdentifiers($mask); diff --git a/airtime_mvc/application/forms/EditUser.php b/airtime_mvc/application/forms/EditUser.php index d9486113f..cbb2ec22f 100644 --- a/airtime_mvc/application/forms/EditUser.php +++ b/airtime_mvc/application/forms/EditUser.php @@ -121,11 +121,14 @@ class Application_Form_EditUser extends Zend_Form $locale->setValue(Application_Model_Preference::GetUserLocale($currentUserId)); $locale->setDecorators(array('ViewHelper')); $this->addElement($locale); - + + $stationTz = Application_Model_Preference::GetTimezone($currentUserId); + $userTz = Application_Model_Preference::GetUserTimezone($currentUserId); + $timezone = new Zend_Form_Element_Select("cu_timezone"); $timezone->setLabel(_("Interface Timezone:")); $timezone->setMultiOptions(Application_Common_Timezone::getTimezones()); - $timezone->setValue(Application_Model_Preference::GetUserTimezone($currentUserId)); + $timezone->setValue($userTz == $stationTz ? null : $userTz); $timezone->setDecorators(array('ViewHelper')); $this->addElement($timezone); diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index c6e6fff49..30d9a9e9e 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -477,10 +477,6 @@ class Application_Model_Preference public static function SetUserTimezone($timezone = null) { - // When a new user is created they will get the default timezone - // setting which the admin sets on preferences page - if (is_null($timezone)) - $timezone = self::GetDefaultTimezone(); self::setValue("user_timezone", $timezone, true); } @@ -520,10 +516,10 @@ class Application_Model_Preference public static function GetUserLocale() { $locale = self::getValue("user_locale", true); - if (!$locale) { + // empty() checks for null and empty strings - more robust than !val + if (empty($locale)) { return self::GetDefaultLocale(); - } - else { + } else { return $locale; } } diff --git a/airtime_mvc/build/sql/defaultdata.sql b/airtime_mvc/build/sql/defaultdata.sql index bed25b869..4c2ca0af7 100644 --- a/airtime_mvc/build/sql/defaultdata.sql +++ b/airtime_mvc/build/sql/defaultdata.sql @@ -353,7 +353,9 @@ INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('zh_CN', '简体中文' -- added in 2.5.2 INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'UTC'); -INSERT INTO cc_pref (subjid, keystr, valstr) VALUES (1, 'user_timezone', 'UTC'); +-- We don't want to set the user timezone by default - it should instead use the station timezone +-- until the user changes it manually. +-- INSERT INTO cc_pref (subjid, keystr, valstr) VALUES (1, 'user_timezone', 'UTC'); INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0');