From 2d61ecac5bcd544a6ea4e9c0cc1200f6e6b2d283 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 6 Aug 2010 11:33:02 -0600 Subject: [PATCH] Add Horde::ajaxAvailable() --- framework/Core/lib/Horde.php | 14 ++++++++++++++ imp/lib/Auth.php | 6 +----- kronolith/lib/Kronolith.php | 6 +----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 4c521c0ea..d65f35e6a 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -2025,4 +2025,18 @@ HTML; self::$_metaTags = array(); } + /** + * Is an AJAX view supported/available on the current browser? + * + * return boolean True if the AJAX view can be displayed. + */ + static public function ajaxAvailable() + { + global $browser; + + return $browser->hasFeature('xmlhttpreq') && + (!$browser->isBrowser('msie') || $browser->getMajor() >= 7) && + (!$browser->hasFeature('issafari') || $browser->getMajor() >= 2); + } + } diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index c1a9ce5c1..f68070874 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -467,11 +467,7 @@ class IMP_Auth /* Enforce minimum browser standards for DIMP. * No IE < 7; Safari < 3 */ - if (($sess['view'] == 'dimp') && - (($GLOBALS['browser']->isBrowser('msie') && - ($GLOBALS['browser']->getMajor() < 7)) || - ($GLOBALS['browser']->hasFeature('issafari') && - ($GLOBALS['browser']->getMajor() < 2)))) { + 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'); } diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index a5c3fc902..6f9a45d2d 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -2921,11 +2921,7 @@ class Kronolith public static function showAjaxView() { return $GLOBALS['prefs']->getValue('dynamic_view') && - $GLOBALS['browser']->hasFeature('xmlhttpreq') && - (!$GLOBALS['browser']->isBrowser('msie') || - $GLOBALS['browser']->getMajor() >= 7) && - (!$GLOBALS['browser']->hasFeature('issafari') || - $GLOBALS['browser']->getMajor() >= 2); + Horde::ajaxAvailable(); } /** -- 2.11.0