diff options
author | thomascube <thomas@roundcube.net> | 2008-09-03 16:03:19 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2008-09-03 16:03:19 +0000 |
commit | c8ae2497b7e4c7393210ed186acd672a0040389f (patch) | |
tree | b21442a9fff2d15cee5809db3d532d8ef378da37 /program/include | |
parent | 7003206d64c83534f29d1eb9dfc53edf993baf5b (diff) |
Auto-detect client language and timezone if desired by config/prefs
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/main.inc | 10 | ||||
-rw-r--r-- | program/include/rcmail.php | 19 | ||||
-rw-r--r-- | program/include/rcube_config.php | 4 | ||||
-rw-r--r-- | program/include/rcube_shared.inc | 56 | ||||
-rwxr-xr-x | program/include/rcube_template.php | 2 |
5 files changed, 25 insertions, 66 deletions
diff --git a/program/include/main.inc b/program/include/main.inc index 83ed8c02e..469d8441c 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -706,9 +706,13 @@ function format_date($date, $format=NULL) return ''; // get user's timezone - $tz = $CONFIG['timezone']; - if ($CONFIG['dst_active']) - $tz++; + if ($CONFIG['timezone'] == 'auto') + $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : intval(date('O'))/100; + else { + $tz = $CONFIG['timezone']; + if ($CONFIG['dst_active']) + $tz++; + } // convert time to user's timezone $timestamp = $ts - date('Z', $ts) + ($tz * 3600); diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 348a91675..243b6f835 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -15,7 +15,7 @@ | Author: Thomas Bruederli <roundcube@gmail.com> | +-----------------------------------------------------------------------+ - $Id: rcube_browser.php 328 2006-08-30 17:41:21Z thomasb $ + $Id: rcmail.php 328 2006-08-30 17:41:21Z thomasb $ */ @@ -167,7 +167,7 @@ class rcmail $this->config->merge((array)$this->user->get_prefs()); } - $_SESSION['language'] = $this->user->language = $this->language_prop($this->config->get('language')); + $_SESSION['language'] = $this->user->language = $this->language_prop($this->config->get('language', $_SESSION['language'])); // set localization setlocale(LC_ALL, $_SESSION['language'] . '.utf8'); @@ -183,7 +183,13 @@ class rcmail private function language_prop($lang) { static $rcube_languages, $rcube_language_aliases; - + + // user HTTP_ACCEPT_LANGUAGE if no language is specified + if (empty($lang) || $lang == 'auto') { + $accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + $lang = str_replace('-', '_', $accept_langs[0]); + } + if (empty($rcube_languages)) { @include(INSTALL_PATH . 'program/localization/index.inc'); } @@ -471,6 +477,9 @@ class rcmail $_SESSION['imap_ssl'] = $imap_ssl; $_SESSION['password'] = $this->encrypt_passwd($pass); $_SESSION['login_time'] = mktime(); + + if ($_REQUEST['_timezone'] != '_default_') + $_SESSION['timezone'] = floatval($_REQUEST['_timezone']); // force reloading complete list of subscribed mailboxes $this->set_imap_prop(); @@ -641,7 +650,7 @@ class rcmail */ public function load_language($lang = null) { - $lang = $lang ? $this->language_prop($lang) : $_SESSION['language']; + $lang = $this->language_prop(($lang ? $lang : $_SESSION['language'])); // load localized texts if (empty($this->texts) || $lang != $_SESSION['language']) { @@ -748,7 +757,7 @@ class rcmail $this->user->save_prefs(array('message_sort_col' => $_SESSION['sort_col'], 'message_sort_order' => $_SESSION['sort_order'])); } - $_SESSION = array('language' => $USER->language, 'auth_time' => time(), 'temp' => true); + $_SESSION = array('language' => $this->user->language, 'auth_time' => time(), 'temp' => true); setcookie('sessauth', '-del-', time() - 60); $this->user->reset(); } diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php index 43f735ba9..98e688d02 100644 --- a/program/include/rcube_config.php +++ b/program/include/rcube_config.php @@ -84,9 +84,9 @@ class rcube_config ini_set('log_errors', 1); if ($this->prop['log_driver'] == 'syslog') { - ini_set('error_log', 'syslog'); + ini_set('error_log', 'syslog'); } else { - ini_set('error_log', $this->prop['log_dir'].'/errors'); + ini_set('error_log', $this->prop['log_dir'].'/errors'); } } if ($this->prop['debug_level'] & 4) { diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc index d82b1fef0..0dd661ec5 100644 --- a/program/include/rcube_shared.inc +++ b/program/include/rcube_shared.inc @@ -28,62 +28,6 @@ /** - * Provide details about the client's browser - * - * @return array Key-value pairs of browser properties - */ -function rcube_browser() -{ - $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; - - $bw['ver'] = 0; - $bw['win'] = stristr($HTTP_USER_AGENT, 'win'); - $bw['mac'] = stristr($HTTP_USER_AGENT, 'mac'); - $bw['linux'] = stristr($HTTP_USER_AGENT, 'linux'); - $bw['unix'] = stristr($HTTP_USER_AGENT, 'unix'); - - $bw['ns4'] = stristr($HTTP_USER_AGENT, 'mozilla/4') && !stristr($HTTP_USER_AGENT, 'msie'); - $bw['ns'] = ($bw['ns4'] || stristr($HTTP_USER_AGENT, 'netscape')); - $bw['ie'] = stristr($HTTP_USER_AGENT, 'msie'); - $bw['mz'] = stristr($HTTP_USER_AGENT, 'mozilla/5'); - $bw['opera'] = stristr($HTTP_USER_AGENT, 'opera'); - $bw['safari'] = stristr($HTTP_USER_AGENT, 'safari'); - - if($bw['ns']) - { - $test = eregi("mozilla\/([0-9\.]+)", $HTTP_USER_AGENT, $regs); - $bw['ver'] = $test ? (float)$regs[1] : 0; - } - if($bw['mz']) - { - $test = ereg("rv:([0-9\.]+)", $HTTP_USER_AGENT, $regs); - $bw['ver'] = $test ? (float)$regs[1] : 0; - } - if($bw['ie']) - { - $test = eregi("msie ([0-9\.]+)", $HTTP_USER_AGENT, $regs); - $bw['ver'] = $test ? (float)$regs[1] : 0; - } - if($bw['opera']) - { - $test = eregi("opera ([0-9\.]+)", $HTTP_USER_AGENT, $regs); - $bw['ver'] = $test ? (float)$regs[1] : 0; - } - - if(eregi(" ([a-z]{2})-([a-z]{2})", $HTTP_USER_AGENT, $regs)) - $bw['lang'] = $regs[1]; - else - $bw['lang'] = 'en'; - - $bw['dom'] = ($bw['mz'] || $bw['safari'] || ($bw['ie'] && $bw['ver']>=5) || ($bw['opera'] && $bw['ver']>=7)); - $bw['pngalpha'] = $bw['mz'] || $bw['safari'] || ($bw['ie'] && $bw['ver']>=5.5) || - ($bw['ie'] && $bw['ver']>=5 && $bw['mac']) || ($bw['opera'] && $bw['ver']>=7) ? TRUE : FALSE; - - return $bw; -} - - -/** * Send HTTP headers to prevent caching this page */ function send_nocacheing_headers() diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php index db2275ed4..847ea0df5 100755 --- a/program/include/rcube_template.php +++ b/program/include/rcube_template.php @@ -922,6 +922,7 @@ class rcube_template extends rcube_html_page $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'size' => 30) + $attrib); $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'size' => 30) + $attrib); $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login')); + $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_')); $input_host = null; if (is_array($default_host)) { @@ -960,6 +961,7 @@ class rcube_template extends rcube_html_page } $out = $input_action->show(); + $out .= $input_tzone->show(); $out .= $table->show(); // surround html output with a form tag |