Auto-detect client language and timezone if desired by config/prefs
| | |
| | | CHANGELOG RoundCube Webmail |
| | | --------------------------- |
| | | |
| | | 2008/09/03 (thomasb) |
| | | ---------- |
| | | - Allow to auto-detect client language if none set (#1484434) |
| | | - Auto-detect the client timezone (user configurable) |
| | | |
| | | 2008/09/03 (alec) |
| | | ---------- |
| | | - Add RFC2231 header value continuations support for attachment |
| | |
| | | // please provide a string of exactly 24 chars. |
| | | $rcmail_config['des_key'] = 'rcmail-!24ByteDESkey*Str'; |
| | | |
| | | // the default locale setting |
| | | $rcmail_config['language'] = 'en_US'; |
| | | // the default locale setting (leave empty for auto-detection) |
| | | // RFC1766 formatted language name like en_US, de_DE, de_CH, fr_FR, pt_BR |
| | | $rcmail_config['language'] = null; |
| | | |
| | | // use this format for short date display |
| | | $rcmail_config['date_short'] = 'D H:i'; |
| | |
| | | $rcmail_config['pagesize'] = 40; |
| | | |
| | | // use this timezone to display date/time |
| | | $rcmail_config['timezone'] = intval(date('O'))/100 - date('I'); |
| | | $rcmail_config['timezone'] = 'auto'; |
| | | |
| | | // is daylight saving On? |
| | | $rcmail_config['dst_active'] = (bool)date('I'); |
| | |
| | | echo $input_locale->show($RCI->getprop('language')); |
| | | |
| | | ?> |
| | | <div>The default locale setting. This also defines the language of the login screen.</div> |
| | | <div>The default locale setting. This also defines the language of the login screen.<br/>Leave it empty to auto-detect the user agent language.</div> |
| | | <p class="hint">Enter a <a href="http://www.faqs.org/rfcs/rfc1766">RFC1766</a> formatted language name. Examples: en_US, de_DE, de_CH, fr_FR, pt_BR</p> |
| | | </dd> |
| | | |
| | |
| | | return ''; |
| | | |
| | | // get user's timezone |
| | | 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); |
| | |
| | | | 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 $ |
| | | |
| | | */ |
| | | |
| | |
| | | $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'); |
| | |
| | | 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'); |
| | |
| | | $_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(); |
| | | $this->imap->clear_cache('mailboxes'); |
| | |
| | | */ |
| | | 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']) { |
| | |
| | | $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(); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 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() |
| | |
| | | $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)) { |
| | |
| | | } |
| | | |
| | | $out = $input_action->show(); |
| | | $out .= $input_tzone->show(); |
| | | $out .= $table->show(); |
| | | |
| | | // surround html output with a form tag |
| | |
| | | case 'login': |
| | | var input_user = rcube_find_object('rcmloginuser'); |
| | | var input_pass = rcube_find_object('rcmloginpwd'); |
| | | var input_tz = rcube_find_object('rcmlogintz'); |
| | | |
| | | if (input_user) |
| | | input_user.onkeyup = function(e){ return rcmail.login_user_keyup(e); }; |
| | | if (input_user && input_user.value=='') |
| | |
| | | else if (input_pass) |
| | | input_pass.focus(); |
| | | |
| | | // detect client timezone |
| | | if (input_tz) |
| | | input_tz.value = new Date().getTimezoneOffset() / -60; |
| | | |
| | | this.enable_command('login', true); |
| | | break; |
| | | |
| | |
| | | $labels['edititem'] = 'Edit item'; |
| | | |
| | | $labels['setdefault'] = 'Set default'; |
| | | $labels['autodetect'] = 'Auto'; |
| | | $labels['language'] = 'Language'; |
| | | $labels['timezone'] = 'Time zone'; |
| | | $labels['pagesize'] = 'Rows per page'; |
| | |
| | | $select_lang->add(array_values($a_lang), array_keys($a_lang)); |
| | | |
| | | $table->add('title', html::label($field_id, Q(rcube_label('language')))); |
| | | $table->add(null, $select_lang->show($_SESSION['language'])); |
| | | $table->add(null, $select_lang->show($config['language'])); |
| | | } |
| | | |
| | | |
| | | // show page size selection |
| | | if (!isset($no_override['timezone'])) { |
| | | $field_id = 'rcmfd_timezone'; |
| | | $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id)); |
| | | $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 'onchange' => "document.getElementById('rcmfd_dst').disabled=this.selectedIndex==0")); |
| | | $select_timezone->add(rcube_label('autodetect'), 'auto'); |
| | | $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11'); |
| | | $select_timezone->add('(GMT -10:00) Hawaii', '-10'); |
| | | $select_timezone->add('(GMT -9:30) Marquesas Islands', '-9.5'); |
| | |
| | | // daylight savings |
| | | if (!isset($no_override['dst_active'])) { |
| | | $field_id = 'rcmfd_dst'; |
| | | $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1)); |
| | | $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1, 'disabled' => ($config['timezone'] == 'auto'))); |
| | | |
| | | $table->add('title', html::label($field_id, Q(rcube_label('dstactive')))); |
| | | $table->add(null, $input_dst->show($config['dst_active'])); |
| | |
| | | */ |
| | | |
| | | $a_user_prefs = array( |
| | | 'timezone' => isset($_POST['_timezone']) ? floatval($_POST['_timezone']) : $CONFIG['timezone'], |
| | | 'timezone' => isset($_POST['_timezone']) ? (is_numeric($_POST['_timezone']) ? floatval($_POST['_timezone']) : get_input_value('_timezone', RCUBE_INPUT_POST)) : $CONFIG['timezone'], |
| | | 'dst_active' => isset($_POST['_dst_active']) ? TRUE : FALSE, |
| | | 'pagesize' => is_numeric($_POST['_pagesize']) ? max(2, intval($_POST['_pagesize'])) : $CONFIG['pagesize'], |
| | | 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE, |