From 19c0155646f0ccddf91d0f33e237b035d401f075 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 6 Aug 2010 12:02:58 -0600 Subject: [PATCH] Request #9159: Automatically determine view --- imp/config/conf.xml | 9 +++++---- imp/config/prefs.php.dist | 9 ++++++++- imp/docs/CHANGES | 2 ++ imp/lib/Application.php | 17 +++++++---------- imp/lib/Auth.php | 31 ++++++++++++++++++++----------- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/imp/config/conf.xml b/imp/config/conf.xml index 2e8413272..00b247523 100644 --- a/imp/config/conf.xml +++ b/imp/config/conf.xml @@ -25,13 +25,14 @@ will be a 'Message Source' link in the parts list of every message, allowing the user to view the entire raw message, or to download it and save it to disk.">true - true + false - imp + + imp dimp mimp diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 6f4f328b5..25a6f2b9c 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -1713,7 +1713,14 @@ $prefGroups['dimp'] = array( 'column' => _("Other Options"), 'label' => _("Dynamic View Options"), 'desc' => _("Configure options for the dynamic view."), - 'members' => array('dimp_login_view') + 'members' => array('dynamic_view', 'dimp_login_view') +); + +// Show dynamic view? +$_prefs['dynamic_view'] = array( + 'value' => 1, + 'type' => 'checkbox', + 'desc' => _("Show the dynamic view by default, if the browser supports it?") ); // Login preferences (dimp) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 532f17626..93d4fd0df 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,8 @@ v5.0-git -------- +[mms] Automatically determine view based on browser and 'dynamic_view' + preference (Request #9159). [mms] Add preference to define default font family/size for the HTML compose editor. [mms] Honor nav_expanded preference (DIMP). diff --git a/imp/lib/Application.php b/imp/lib/Application.php index a09c7eb3e..64b52cc37 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -235,18 +235,18 @@ class IMP_Application extends Horde_Registry_Application } /* Show selection of alternate views. */ - if (empty($GLOBALS['conf']['user']['select_view'])) { - $view_cookie = empty($conf['user']['force_view']) - ? 'imp' - : $conf['user']['force_view']; - } else { - $views = array(); + $js_code = array( + 'ImpLogin.server_key_error=' . Horde_Serialize::serialize(_("Please choose a mail server."), Horde_Serialize::JSON) + ); + if (!empty($GLOBALS['conf']['user']['select_view'])) { if (!($view_cookie = Horde_Util::getFormData('imp_select_view'))) { $view_cookie = isset($_COOKIE['default_imp_view']) ? $_COOKIE['default_imp_view'] : ($GLOBALS['browser']->isMobile() ? 'mimp' : 'imp'); } + $js_code[] = 'ImpLogin.dimp_sel=' . intval($view_cookie == 'dimp'); + $params['imp_select_view'] = array( 'label' => _("Mode"), 'type' => 'select', @@ -269,10 +269,7 @@ class IMP_Application extends Horde_Registry_Application } return array( - 'js_code' => array( - 'ImpLogin.dimp_sel=' . intval($view_cookie == 'dimp'), - 'ImpLogin.server_key_error=' . Horde_Serialize::serialize(_("Please choose a mail server."), Horde_Serialize::JSON) - ), + 'js_code' => $js_code, 'js_files' => array( array('login.js', 'imp') ), diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index f68070874..1838a4292 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -460,24 +460,33 @@ class IMP_Auth $editor = $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('Ckeditor', array('no_notify' => true)); $sess['rteavail'] = $editor->supportedByBrowser(); - /* Set view in session/cookie. */ - $sess['view'] = empty($conf['user']['select_view']) - ? (empty($conf['user']['force_view']) ? 'imp' : $conf['user']['force_view']) - : (empty($sess['cache']['select_view']) ? 'imp' : $sess['cache']['select_view']); + /* Determine view. */ + $setcookie = false; + if (empty($conf['user']['force_view'])) { + if (empty($conf['user']['select_view']) || + empty($sess['cache']['select_view'])) { + $sess['view'] = $GLOBALS['browser']->isMobile() + ? 'mimp' + : ($GLOBALS['prefs']->getValue('dynamic_view') ? 'dimp' : 'imp'); + } else { + $setcookie = true; + $sess['view'] = $sess['cache']['select_view']; + } + } else { + $sess['view'] = $conf['user']['force_view']; + } - /* Enforce minimum browser standards for DIMP. - * No IE < 7; Safari < 3 */ + /* Enforce minimum browser standards for DIMP. */ if (($sess['view'] == 'dimp') && !Horde::ajaxAvailable()) { $sess['view'] = 'imp'; $GLOBALS['notification']->push(_("Your browser is too old to display the dynamic mode. Using traditional mode instead."), 'horde.warning'); } - setcookie('default_imp_view', $sess['view'], time() + 30 * 86400, - $conf['cookie']['path'], - $conf['cookie']['domain']); + if ($setcookie) { + setcookie('default_imp_view', $sess['view'], time() + 30 * 86400, $conf['cookie']['path'], $conf['cookie']['domain']); + } - /* Suppress menus in options screen and indicate that notifications - * should use the ajax mode. */ + /* Indicate that notifications should use AJAX mode. */ if ($sess['view'] == 'dimp') { $_SESSION['horde_notification']['override'] = array( IMP_BASE . '/lib/Notification/Listener/AjaxStatus.php', -- 2.11.0