diff --git a/calendar/inc/class.calendar_timezones.inc.php b/calendar/inc/class.calendar_timezones.inc.php
index 84d112a655..39e0282d5d 100644
--- a/calendar/inc/class.calendar_timezones.inc.php
+++ b/calendar/inc/class.calendar_timezones.inc.php
@@ -170,6 +170,8 @@ class calendar_timezones
{
$msg = self::import_sqlite($updated);
if ($updated) error_log($msg); // log that timezones have been updated
+ $msg = self::import_tz_aliases($updated);
+ if ($updated) error_log($msg); // log that timezone aliases have been updated
}
catch (Exception $e)
{
@@ -182,7 +184,7 @@ class calendar_timezones
/**
* Import timezones from sqlite file
*
- * @param boolean $updated=null on return true if update was neccessary, false if tz's were already up to date
+ * @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date
* @param string $file='calendar/setup/timezones.sqlite' filename relative to EGW_SERVER_ROOT
* @param boolean $check_version=true true: check version and only act, if it's different
* @return string message about update
@@ -217,12 +219,12 @@ class calendar_timezones
throw new egw_exception_wrong_parameter(__METHOD__."('$file') only schema version 1 supported!");
}
$tz_version = $pdo->query('SELECT version FROM tz_version')->fetchColumn();
- $tz_db_version = $GLOBALS['egw']->db->query("SELECT config_value FROM egw_config WHERE config_name='tz_version' AND config_app='phpgwapi'",__LINE__,__FILE__)->fetchColumn();
- //echo "
tz_version($path)=$tz_version, tz_db_version=$tz_db_version
\n";
- if ($tz_version === $tz_db_version)
+ $config = config::read('phpgwapi');
+ //echo "tz_version($path)=$tz_version, tz_db_version=$config[tz_version]
\n";
+ if ($tz_version === $config['tz_version'])
{
$updated = false;
- return lang('Nothing to update, version is already %1.',$tz_db_version); // we already have the right
+ return lang('Nothing to update, version is already %1.',$config['tz_version']); // we already have the right
}
$tz2id = array();
foreach($pdo->query('SELECT * FROM tz_data ORDER BY alias') as $data)
@@ -249,16 +251,59 @@ class calendar_timezones
// only query last insert id, if not already in database (gives warning for PostgreSQL)
if (!$tz2id[$data['tzid']]) $tz2id[$data['tzid']] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
}
- $GLOBALS['egw']->db->insert('egw_config',array('config_value' => $tz_version),array(
- 'config_name' => 'tz_version',
- 'config_app' => 'phpgwapi',
- ),__LINE__,__FILE__,'phpgwapi');
+ config::save_value('tz_version', $tz_version, 'phpgwapi');
//_debug_array($tz2id);
$updated = true;
return lang('Timezones updated to version %1 (%2 records updated).',$tz_version,count($tz2id));
}
+ /**
+ * Import timezone aliases
+ *
+ * @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date
+ * @param string $file='calendar/setup/tz_aliases.inc.php' filename relative to EGW_SERVER_ROOT
+ * @param boolean $check_mtime=true true: check version and only act, if it's different
+ * @return string message about update
+ * @throws egw_exception_wrong_parameter if $file is not readable or wrong format/version
+ */
+ public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php',$check_mtime=true)
+ {
+ $path = EGW_SERVER_ROOT.'/'.$file;
+
+ if (!file_exists($path) || !is_readable($path))
+ {
+ throw new egw_exception_wrong_parameter(__METHOD__."('$file') not found or readable!");
+ }
+ $config = config::read('phpgwapi');
+ $tz_aliases_mtime = date('Y-m-d H:i:s', filemtime($path));
+ if ($tz_aliases_mtime === $config['tz_aliases_mtime'])
+ {
+ $updated = false;
+ return lang('Nothing to update, version is already %1.',$tz_aliases_mtime);
+ }
+ include($path); // sets $tz_aliases
+
+ $updated = 0;
+ foreach($tz_aliases as $alias => $tzid)
+ {
+ if (self::tz2id($tzid, 'alias') !== $alias) // not in DB or different
+ {
+ $GLOBALS['egw']->db->insert('egw_cal_timezones',array(
+ 'tz_alias' => $alias,
+ ),array(
+ 'tz_tzid' => $tzid,
+ ),__LINE__,__FILE__,'calendar');
+ ++$updated;
+ }
+ }
+ config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi');
+
+ //_debug_array($tz2id);
+ $updated = true;
+ return lang('Timezones aliases updated to version %1 (%2 records updated).', $tz_aliases_mtime, $updated);
+ }
+
/**
* Admin >> Update timezones
*
@@ -269,7 +314,10 @@ class calendar_timezones
{
throw new egw_exception_no_permission_admin();
}
- $GLOBALS['egw']->framework->render(''.self::import_sqlite()."
\n",lang('Update timezones'),true);
+ $GLOBALS['egw']->framework->render(
+ ''.self::import_sqlite()."
\n".
+ ''.self::import_tz_aliases()."
\n",
+ lang('Update timezones'),true);
}
}
/*
diff --git a/calendar/setup/default_records.inc.php b/calendar/setup/default_records.inc.php
index aba5bae909..e52256676c 100644
--- a/calendar/setup/default_records.inc.php
+++ b/calendar/setup/default_records.inc.php
@@ -27,6 +27,7 @@ foreach(array(
try
{
calendar_timezones::import_sqlite();
+ calendar_timezones::import_tz_aliases();
}
// catch broken sqlite extension exception and output message, as user can't do anything about it
// all other exceptions are fatal, to get user to fix them!
diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php
index 74290b96e6..12944c77e6 100644
--- a/calendar/setup/tables_update.inc.php
+++ b/calendar/setup/tables_update.inc.php
@@ -1882,119 +1882,8 @@ function calendar_upgrade1_7_004()
*/
function calendar_upgrade1_7_005()
{
- foreach(array(
- 'AUS Central Standard Time' => 'Australia/Darwin',
- 'AUS Eastern Standard Time' => 'Australia/Sydney',
- 'Afghanistan Standard Time' => 'Asia/Kabul',
- 'Alaskan Standard Time' => 'America/Anchorage',
- 'Arab Standard Time' => 'Asia/Riyadh',
- 'Arabian Standard Time' => 'Asia/Dubai',
- 'Arabic Standard Time' => 'Asia/Baghdad',
- 'Argentina Standard Time' => 'America/Argentina/Buenos_Aires', // was 'America/Buenos_Aires',
- 'Armenian Standard Time' => 'Asia/Yerevan',
- 'Atlantic Standard Time' => 'America/Halifax',
- 'Azerbaijan Standard Time' => 'Asia/Baku',
- 'Azores Standard Time' => 'Atlantic/Azores',
- 'Canada Central Standard Time' => 'America/Regina',
- 'Cape Verde Standard Time' => 'Atlantic/Cape_Verde',
- 'Caucasus Standard Time' => 'Asia/Yerevan',
- 'Cen. Australia Standard Time' => 'Australia/Adelaide',
- 'Central America Standard Time' => 'America/Guatemala',
- 'Central Asia Standard Time' => 'Asia/Dhaka',
- 'Central Brazilian Standard Time' => 'America/Manaus',
- 'Central Europe Standard Time' => 'Europe/Budapest',
- 'Central European Standard Time' => 'Europe/Warsaw',
- 'Central Pacific Standard Time' => 'Pacific/Guadalcanal',
- 'Central Standard Time' => 'America/Chicago',
- 'Central Standard Time (Mexico)' => 'America/Mexico_City',
- 'China Standard Time' => 'Asia/Shanghai',
- 'Dateline Standard Time' => 'Etc/GMT+12',
- 'E. Africa Standard Time' => 'Africa/Nairobi',
- 'E. Australia Standard Time' => 'Australia/Brisbane',
- 'E. Europe Standard Time' => 'Europe/Minsk',
- 'E. South America Standard Time' => 'America/Sao_Paulo',
- 'Eastern Standard Time' => 'America/New_York',
- 'Egypt Standard Time' => 'Africa/Cairo',
- 'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg',
- 'FLE Standard Time' => 'Europe/Kiev',
- 'Fiji Standard Time' => 'Pacific/Fiji',
- 'GMT Standard Time' => 'Europe/London',
- 'GTB Standard Time' => 'Europe/Istanbul',
- 'Georgian Standard Time' => 'Etc/GMT-3',
- 'Greenland Standard Time' => 'America/Godthab',
- 'Greenwich Standard Time' => 'Atlantic/Reykjavik', // was 'Africa/Reykjavik',
- 'Hawaiian Standard Time' => 'Pacific/Honolulu',
- 'India Standard Time' => 'Asia/Calcutta',
- 'Iran Standard Time' => 'Asia/Tehran',
- 'Israel Standard Time' => 'Asia/Jerusalem',
- 'Jordan Standard Time' => 'Asia/Amman',
- 'Korea Standard Time' => 'Asia/Seoul',
- 'Mauritius Standard Time' => 'Indian/Mauritius',
- 'Mexico Standard Time' => 'America/Mexico_City',
- 'Mexico Standard Time 2' => 'America/Chihuahua',
- 'Mid-Atlantic Standard Time' => 'Atlantic/South_Georgia',
- 'Middle East Standard Time' => 'Asia/Beirut',
- 'Montevideo Standard Time' => 'America/Montevideo',
- 'Morocco Standard Time' => 'Africa/Casablanca',
- 'Mountain Standard Time' => 'America/Denver',
- 'Mountain Standard Time (Mexico)' => 'America/Chihuahua',
- 'Myanmar Standard Time' => 'Asia/Rangoon',
- 'N. Central Asia Standard Time' => 'Asia/Novosibirsk',
- 'Namibia Standard Time' => 'Africa/Windhoek',
- 'Nepal Standard Time' => 'Asia/Katmandu',
- 'New Zealand Standard Time' => 'Pacific/Auckland',
- 'Newfoundland Standard Time' => 'America/St_Johns',
- 'North Asia East Standard Time' => 'Asia/Irkutsk',
- 'North Asia Standard Time' => 'Asia/Krasnoyarsk',
- 'Pacific SA Standard Time' => 'America/Santiago',
- 'Pacific Standard Time' => 'America/Los_Angeles',
- 'Pacific Standard Time (Mexico)' => 'America/Tijuana',
- 'Pakistan Standard Time' => 'Asia/Karachi',
- 'Romance Standard Time' => 'Europe/Paris',
- 'Russian Standard Time' => 'Europe/Moscow',
- 'SA Eastern Standard Time' => 'Etc/GMT+3',
- 'SA Pacific Standard Time' => 'America/Bogota',
- 'SA Western Standard Time' => 'America/La_Paz',
- 'SE Asia Standard Time' => 'Asia/Bangkok',
- 'Samoa Standard Time' => 'Pacific/Apia',
- 'Singapore Standard Time' => 'Asia/Singapore',
- 'South Africa Standard Time' => 'Africa/Johannesburg',
- 'Sri Lanka Standard Time' => 'Asia/Colombo',
- 'Taipei Standard Time' => 'Asia/Taipei',
- 'Tasmania Standard Time' => 'Australia/Hobart',
- 'Tokyo Standard Time' => 'Asia/Tokyo',
- 'Tonga Standard Time' => 'Pacific/Tongatapu',
- 'US Eastern Standard Time' => 'Etc/GMT+5',
- 'US Mountain Standard Time' => 'America/Phoenix',
- 'Venezuela Standard Time' => 'America/Caracas',
- 'Vladivostok Standard Time' => 'Asia/Vladivostok',
- 'W. Australia Standard Time' => 'Australia/Perth',
- 'W. Central Africa Standard Time' => 'Africa/Lagos',
- 'W. Europe Standard Time' => 'Europe/Berlin',
- 'West Asia Standard Time' => 'Asia/Tashkent',
- 'West Pacific Standard Time' => 'Pacific/Port_Moresby',
- 'Yakutsk Standard Time' => 'Asia/Yakutsk',
- ) as $win_tz => $tzid)
- {
- if (!(calendar_timezones::tz2id($win_tz))) // not already defined
- {
- if (!($id = calendar_timezones::tz2id($tzid)))
- {
- error_log(__METHOD__."() Windows timezone: '$win_tz': TZID='$tzid' is NOT defined!");
- }
- else
- {
- $GLOBALS['egw']->db->insert('egw_cal_timezones',array(
- 'tz_alias' => $id,
- 'tz_latitude' => null,
- 'tz_longitude' => null,
- 'tz_component' => null,
- ),array(
- 'tz_tzid' => $win_tz,
- ),__LINE__,__FILE__,'calendar');
- }
- }
- }
+ calendar_timezones::import_tz_aliases();
+
return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.006';
}
diff --git a/calendar/setup/tz_aliases.inc.php b/calendar/setup/tz_aliases.inc.php
new file mode 100644
index 0000000000..9be7b71b0e
--- /dev/null
+++ b/calendar/setup/tz_aliases.inc.php
@@ -0,0 +1,103 @@
+ 'Australia/Darwin',
+ 'AUS Eastern Standard Time' => 'Australia/Sydney',
+ 'Afghanistan Standard Time' => 'Asia/Kabul',
+ 'Alaskan Standard Time' => 'America/Anchorage',
+ 'Arab Standard Time' => 'Asia/Riyadh',
+ 'Arabian Standard Time' => 'Asia/Dubai',
+ 'Arabic Standard Time' => 'Asia/Baghdad',
+ 'Argentina Standard Time' => 'America/Argentina/Buenos_Aires', // was 'America/Buenos_Aires',
+ 'Armenian Standard Time' => 'Asia/Yerevan',
+ 'Atlantic Standard Time' => 'America/Halifax',
+ 'Azerbaijan Standard Time' => 'Asia/Baku',
+ 'Azores Standard Time' => 'Atlantic/Azores',
+ 'Canada Central Standard Time' => 'America/Regina',
+ 'Cape Verde Standard Time' => 'Atlantic/Cape_Verde',
+ 'Caucasus Standard Time' => 'Asia/Yerevan',
+ 'Cen. Australia Standard Time' => 'Australia/Adelaide',
+ 'Central America Standard Time' => 'America/Guatemala',
+ 'Central Asia Standard Time' => 'Asia/Dhaka',
+ 'Central Brazilian Standard Time' => 'America/Manaus',
+ 'Central Europe Standard Time' => 'Europe/Budapest',
+ 'Central European Standard Time' => 'Europe/Warsaw',
+ 'Central Pacific Standard Time' => 'Pacific/Guadalcanal',
+ 'Central Standard Time' => 'America/Chicago',
+ 'Central Standard Time (Mexico)' => 'America/Mexico_City',
+ 'China Standard Time' => 'Asia/Shanghai',
+ 'Dateline Standard Time' => 'Etc/GMT+12',
+ 'E. Africa Standard Time' => 'Africa/Nairobi',
+ 'E. Australia Standard Time' => 'Australia/Brisbane',
+ 'E. Europe Standard Time' => 'Europe/Minsk',
+ 'E. South America Standard Time' => 'America/Sao_Paulo',
+ 'Eastern Standard Time' => 'America/New_York',
+ 'Egypt Standard Time' => 'Africa/Cairo',
+ 'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg',
+ 'FLE Standard Time' => 'Europe/Kiev',
+ 'Fiji Standard Time' => 'Pacific/Fiji',
+ 'GMT Standard Time' => 'Europe/London',
+ 'GTB Standard Time' => 'Europe/Istanbul',
+ 'Georgian Standard Time' => 'Etc/GMT-3',
+ 'Greenland Standard Time' => 'America/Godthab',
+ 'Greenwich Standard Time' => 'Atlantic/Reykjavik', // was 'Africa/Reykjavik',
+ 'Hawaiian Standard Time' => 'Pacific/Honolulu',
+ 'India Standard Time' => 'Asia/Calcutta',
+ 'Iran Standard Time' => 'Asia/Tehran',
+ 'Israel Standard Time' => 'Asia/Jerusalem',
+ 'Jordan Standard Time' => 'Asia/Amman',
+ 'Korea Standard Time' => 'Asia/Seoul',
+ 'Mauritius Standard Time' => 'Indian/Mauritius',
+ 'Mexico Standard Time' => 'America/Mexico_City',
+ 'Mexico Standard Time 2' => 'America/Chihuahua',
+ 'Mid-Atlantic Standard Time' => 'Atlantic/South_Georgia',
+ 'Middle East Standard Time' => 'Asia/Beirut',
+ 'Montevideo Standard Time' => 'America/Montevideo',
+ 'Morocco Standard Time' => 'Africa/Casablanca',
+ 'Mountain Standard Time' => 'America/Denver',
+ 'Mountain Standard Time (Mexico)' => 'America/Chihuahua',
+ 'Myanmar Standard Time' => 'Asia/Rangoon',
+ 'N. Central Asia Standard Time' => 'Asia/Novosibirsk',
+ 'Namibia Standard Time' => 'Africa/Windhoek',
+ 'Nepal Standard Time' => 'Asia/Katmandu',
+ 'New Zealand Standard Time' => 'Pacific/Auckland',
+ 'Newfoundland Standard Time' => 'America/St_Johns',
+ 'North Asia East Standard Time' => 'Asia/Irkutsk',
+ 'North Asia Standard Time' => 'Asia/Krasnoyarsk',
+ 'Pacific SA Standard Time' => 'America/Santiago',
+ 'Pacific Standard Time' => 'America/Los_Angeles',
+ 'Pacific Standard Time (Mexico)' => 'America/Tijuana',
+ 'Pakistan Standard Time' => 'Asia/Karachi',
+ 'Romance Standard Time' => 'Europe/Paris',
+ 'Russian Standard Time' => 'Europe/Moscow',
+ 'SA Eastern Standard Time' => 'Etc/GMT+3',
+ 'SA Pacific Standard Time' => 'America/Bogota',
+ 'SA Western Standard Time' => 'America/La_Paz',
+ 'SE Asia Standard Time' => 'Asia/Bangkok',
+ 'Samoa Standard Time' => 'Pacific/Apia',
+ 'Singapore Standard Time' => 'Asia/Singapore',
+ 'South Africa Standard Time' => 'Africa/Johannesburg',
+ 'Sri Lanka Standard Time' => 'Asia/Colombo',
+ 'Taipei Standard Time' => 'Asia/Taipei',
+ 'Tasmania Standard Time' => 'Australia/Hobart',
+ 'Tokyo Standard Time' => 'Asia/Tokyo',
+ 'Tonga Standard Time' => 'Pacific/Tongatapu',
+ 'US Eastern Standard Time' => 'Etc/GMT+5',
+ 'US Mountain Standard Time' => 'America/Phoenix',
+ 'Venezuela Standard Time' => 'America/Caracas',
+ 'Vladivostok Standard Time' => 'Asia/Vladivostok',
+ 'W. Australia Standard Time' => 'Australia/Perth',
+ 'W. Central Africa Standard Time' => 'Africa/Lagos',
+ 'W. Europe Standard Time' => 'Europe/Berlin',
+ 'West Asia Standard Time' => 'Asia/Tashkent',
+ 'West Pacific Standard Time' => 'Pacific/Port_Moresby',
+ 'Yakutsk Standard Time' => 'Asia/Yakutsk',
+);
\ No newline at end of file