From 6706818ea22f59fd6bbe6d0559eefad18533efdf Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 15 Nov 2010 23:22:00 +0100 Subject: [PATCH] Add 'mobile' as a possible IMP view, and use that for all mobile webkit browsers. --- imp/lib/Application.php | 5 +++++ imp/lib/Auth.php | 17 ++++++++++++++--- imp/mobile.php | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 2678a04a4..a142a60b5 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -130,6 +130,11 @@ class IMP_Application extends Horde_Registry_Application ($this->initParams['impmode'] != 'mimp')); break; + case 'mobile': + $redirect = (!empty($this->initParams['impmode']) && + ($this->initParams['impmode'] != 'mobile')); + break; + case 'imp': $redirect = (!empty($this->initParams['impmode']) && ($this->initParams['impmode'] != 'imp')); diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index 016a95e8f..eb837308c 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -338,6 +338,10 @@ class IMP_Auth $page = 'mailbox-mimp.php'; break; + case 'mobile': + $page = 'mobile.php'; + break; + default: $init_url = ($GLOBALS['session']->get('imp', 'protocol') == 'pop') ? 'INBOX' @@ -467,9 +471,16 @@ class IMP_Auth if (empty($conf['user']['force_view'])) { if (empty($conf['user']['select_view']) || !$session->get('imp', 'select_view')) { - $view = $browser->isMobile() - ? 'mimp' - : ($prefs->getValue('dynamic_view') ? 'dimp' : 'imp'); + // THIS IS A HACK. DO PROPER SMARTPHONE DETECTION. + if ($browser->isMobile()) { + if ($browser->getBrowser() == 'webkit') { + $view = 'mobile'; + } else { + $view = 'mimp'; + } + } else { + $view = $prefs->getValue('dynamic_view') ? 'dimp' : 'imp'; + } } else { $setcookie = true; $view = $session->get('imp', 'select_view'); diff --git a/imp/mobile.php b/imp/mobile.php index 31123c783..2cad3be02 100644 --- a/imp/mobile.php +++ b/imp/mobile.php @@ -14,7 +14,7 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('imp', array('impmode' => 'imp')); +Horde_Registry::appInit('imp', array('impmode' => 'mobile')); $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mobile')); new Horde_View_Helper_Text($view); -- 2.11.0