Changeset 5879c09 in github
- Timestamp:
- Jan 4, 2012 7:47:50 AM (18 months ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
- Children:
- e2c9ab4
- Parents:
- 7645a0a
- Files:
-
- 6 edited
-
CHANGELOG (modified) (1 diff)
-
config/main.inc.php.dist (modified) (1 diff)
-
program/include/main.inc (modified) (5 diffs)
-
program/include/rcube_config.php (modified) (4 diffs)
-
program/steps/settings/func.inc (modified) (1 diff)
-
program/steps/settings/save_prefs.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r08ffd939 r5879c09 2 2 =========================== 3 3 4 - Use proper timezones from PHP's internal timezonedb (#1485592) 4 5 - Add separate pagesize setting for mail messages and contacts (#1488269) 5 6 - Fix handling of INBOX's subfolders in special folders config (#1488279) -
config/main.inc.php.dist
r08ffd939 r5879c09 662 662 663 663 // use this timezone to display date/time 664 // valid timezone identifers are listed here: php.net/manual/en/timezones.php 665 // 'auto' will use the browser's timezone settings 664 666 $rcmail_config['timezone'] = 'auto'; 665 666 // is daylight saving On? Default: (bool)date('I');667 $rcmail_config['dst_active'] = null;668 667 669 668 // prefer displaying HTML messages -
program/include/main.inc
r672dc41 r5879c09 1063 1063 return ''; 1064 1064 1065 if ($convert) { 1066 // get user's timezone offset 1067 $tz = $RCMAIL->config->get_timezone(); 1068 1069 // convert time to user's timezone 1070 $timestamp = $ts - date('Z', $ts) + ($tz * 3600); 1071 1072 // get current timestamp in user's timezone 1073 $now = time(); // local time 1074 $now -= (int)date('Z'); // make GMT time 1075 $now += ($tz * 3600); // user's time 1076 } 1077 else { 1078 $now = time(); 1079 $timestamp = $ts; 1080 } 1065 $date = new DateTime; 1066 $date->setTimestamp($ts); 1067 1068 // convert to the right timezone 1069 $stz = date_default_timezone_get(); 1070 $tz = new DateTimeZone($convert ? $RCMAIL->config->get('timezone') : 'GMT'); 1071 date_default_timezone_set($tz->getName()); 1072 $date->setTimezone($tz); 1073 1074 $timestamp = $date->getTimestamp(); 1081 1075 1082 1076 // define date format depending on current time … … 1099 1093 if (preg_match('/%[a-z]+/i', $format)) { 1100 1094 $format = strftime($format, $timestamp); 1095 date_default_timezone_set($stz); 1101 1096 return $today ? (rcube_label('today') . ' ' . $format) : $format; 1102 1097 } … … 1114 1109 // weekday (short) 1115 1110 else if ($format[$i]=='D') 1116 $out .= rcube_label(strtolower( date('D', $timestamp)));1111 $out .= rcube_label(strtolower($date->format('D'))); 1117 1112 // weekday long 1118 1113 else if ($format[$i]=='l') 1119 $out .= rcube_label(strtolower( date('l', $timestamp)));1114 $out .= rcube_label(strtolower($date->format('l'))); 1120 1115 // month name (short) 1121 1116 else if ($format[$i]=='M') 1122 $out .= rcube_label(strtolower( date('M', $timestamp)));1117 $out .= rcube_label(strtolower($date->format('M'))); 1123 1118 // month name (long) 1124 1119 else if ($format[$i]=='F') 1125 $out .= rcube_label('long'.strtolower( date('M', $timestamp)));1120 $out .= rcube_label('long'.strtolower($date->format('M'))); 1126 1121 else if ($format[$i]=='x') 1127 1122 $out .= strftime('%x %X', $timestamp); 1128 1123 else 1129 $out .= date($format[$i], $timestamp);1124 $out .= $date->format($format[$i]); 1130 1125 } 1131 1126 … … 1141 1136 } 1142 1137 1138 date_default_timezone_set($stz); 1143 1139 return $out; 1144 1140 } … … 1879 1875 function rcmail_user_date() 1880 1876 { 1881 global $RCMAIL , $CONFIG;1877 global $RCMAIL; 1882 1878 1883 1879 // get user's timezone 1884 $tz = $RCMAIL->config->get_timezone(); 1885 1886 $date = time() + $tz * 60 * 60; 1887 $date = gmdate('r', $date); 1888 $tz = sprintf('%+05d', intval($tz) * 100 + ($tz - intval($tz)) * 60); 1889 $date = preg_replace('/[+-][0-9]{4}$/', $tz, $date); 1890 1891 return $date; 1880 $tz = new DateTimeZone($RCMAIL->config->get('timezone')); 1881 1882 $date = new DateTime('now', $tz); 1883 return $date->format('r'); 1892 1884 } 1893 1885 -
program/include/rcube_config.php
r0829b76 r5879c09 94 94 // set timezone auto settings values 95 95 if ($this->prop['timezone'] == 'auto') { 96 $this->prop['dst_active'] = intval(date('I')); 97 $this->prop['_timezone_value'] = date('Z') / 3600 - $this->prop['dst_active']; 98 } 99 else if ($this->prop['dst_active'] === null) { 100 $this->prop['dst_active'] = intval(date('I')); 101 } 96 $this->prop['_timezone_value'] = $this->client_timezone(); 97 } 98 else if (is_numeric($this->prop['timezone'])) { 99 $this->prop['timezone'] = timezone_name_from_abbr("", $this->prop['timezone'] * 3600, 0); 100 } 101 102 // remove deprecated properties 103 unset($this->prop['dst_active']); 102 104 103 105 // export config data … … 223 225 // override timezone settings with client values 224 226 if ($this->prop['timezone'] == 'auto') { 225 $this->prop['_timezone_value'] = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : $this->prop['_timezone_value']; 226 $this->prop['dst_active'] = $this->userprefs['dst_active'] = isset($_SESSION['dst_active']) ? $_SESSION['dst_active'] : $this->prop['dst_active']; 227 $this->prop['_timezone_value'] = isset($_SESSION['timezone']) ? $this->client_timezone() : $this->prop['_timezone_value']; 227 228 } 228 229 else if (isset($this->prop['_timezone_value'])) … … 245 246 * 246 247 * @return float Timezone offset (in hours) 248 * @deprecated 247 249 */ 248 250 public function get_timezone() 249 251 { 250 return floatval($this->get('timezone')) + intval($this->get('dst_active')); 252 if ($this->get('timezone')) { 253 $tz = new DateTimeZone($this->get('timezone')); 254 return $tz->getOffset(new DateTime('now')) / 3600; 255 } 256 257 return 0; 251 258 } 252 259 … … 350 357 } 351 358 359 360 /** 361 * Internal getter for client's (browser) timezone identifier 362 */ 363 private function client_timezone() 364 { 365 return isset($_SESSION['timezone']) ? timezone_name_from_abbr("", $_SESSION['timezone'] * 3600, 0) : date_default_timezone_get(); 366 } 367 352 368 } -
program/steps/settings/func.inc
ra61ccea r5879c09 178 178 if (!isset($no_override['timezone'])) { 179 179 $field_id = 'rcmfd_timezone'; 180 $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 181 'onchange' => "$('#rcmfd_dst').attr('disabled', this.selectedIndex==0)")); 180 $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id)); 182 181 $select_timezone->add(rcube_label('autodetect'), 'auto'); 183 $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11'); 184 $select_timezone->add('(GMT -10:00) Hawaii', '-10'); 185 $select_timezone->add('(GMT -9:30) Marquesas Islands', '-9.5'); 186 $select_timezone->add('(GMT -9:00) Alaska', '-9'); 187 $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8'); 188 $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7'); 189 $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6'); 190 $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5'); 191 $select_timezone->add('(GMT -4:30) Caracas', '-4.5'); 192 $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), La Paz', '-4'); 193 $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5'); 194 $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3'); 195 $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2'); 196 $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1'); 197 $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0'); 198 $select_timezone->add('(GMT +1:00) Central European Time', '1'); 199 $select_timezone->add('(GMT +2:00) EET: Tallinn, Helsinki, Kaliningrad, South Africa', '2'); 200 $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3'); 201 $select_timezone->add('(GMT +3:30) Tehran', '3.5'); 202 $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4'); 203 $select_timezone->add('(GMT +4:30) Kabul', '4.5'); 204 $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5'); 205 $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5'); 206 $select_timezone->add('(GMT +5:45) Kathmandu', '5.75'); 207 $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6'); 208 $select_timezone->add('(GMT +6:30) Cocos Islands, Myanmar', '6.5'); 209 $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7'); 210 $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8'); 211 $select_timezone->add('(GMT +8:45) Caiguna, Eucla, Border Village', '8.75'); 212 $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9'); 213 $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5'); 214 $select_timezone->add('(GMT +10:00) EAST/AEST: Sydney, Guam, Vladivostok', '10'); 215 $select_timezone->add('(GMT +10:30) New South Wales', '10.5'); 216 $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11'); 217 $select_timezone->add('(GMT +11:30) Norfolk Island', '11.5'); 218 $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12'); 219 $select_timezone->add('(GMT +12:45) Chatham Islands', '12.75'); 220 $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13'); 221 $select_timezone->add('(GMT +14:00) Kiribati', '14'); 182 183 $now = new DateTime(); 184 foreach (DateTimeZone::listIdentifiers() as $i => $tzs) { 185 $tz = new DateTimeZone($tzs); 186 $date = new DateTime('2012-12-21', $tz); 187 $offset = $date->format('Z') + 45000; 188 $sortkey = sprintf('%06d.%s', $offset, $tzs); 189 $zones[$sortkey] = array($tzs, $date->format('P')); 190 } 191 192 ksort($zones); 193 foreach ($zones as $zone) { 194 list($tzs, $offset) = $zone; 195 $select_timezone->add('(GMT ' . $offset . ') ' . strtr($tzs, '_', ' '), $tzs); 196 } 197 198 if (is_numeric($config['timezone'])) 199 timezone_name_from_abbr("", $config['timezone'] * 3600, 0); 222 200 223 201 $blocks['main']['options']['timezone'] = array( 224 202 'title' => html::label($field_id, Q(rcube_label('timezone'))), 225 203 'content' => $select_timezone->show((string)$config['timezone']), 226 );227 }228 229 // daylight savings230 if (!isset($no_override['dst_active'])) {231 $field_id = 'rcmfd_dst';232 $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1, 'disabled' => ($config['timezone'] === 'auto')));233 234 $blocks['main']['options']['dstactive'] = array(235 'title' => html::label($field_id, Q(rcube_label('dstactive'))),236 'content' => $input_dst->show($config['dst_active']),237 204 ); 238 205 } -
program/steps/settings/save_prefs.inc
r08ffd939 r5879c09 30 30 $a_user_prefs = array( 31 31 'language' => isset($_POST['_language']) ? get_input_value('_language', RCUBE_INPUT_POST) : $CONFIG['language'], 32 'timezone' => isset($_POST['_timezone']) ? (is_numeric($_POST['_timezone']) ? floatval($_POST['_timezone']) : get_input_value('_timezone', RCUBE_INPUT_POST)) : $CONFIG['timezone'], 33 'dst_active' => isset($_POST['_dst_active']) ? TRUE : FALSE, 32 'timezone' => isset($_POST['_timezone']) ? get_input_value('_timezone', RCUBE_INPUT_POST) : $CONFIG['timezone'], 34 33 'date_format' => isset($_POST['_date_format']) ? get_input_value('_date_format', RCUBE_INPUT_POST) : $CONFIG['date_format'], 35 34 'time_format' => isset($_POST['_time_format']) ? get_input_value('_time_format', RCUBE_INPUT_POST) : ($CONFIG['time_format'] ? $CONFIG['time_format'] : 'H:i'),
Note: See TracChangeset
for help on using the changeset viewer.
