Add 'mobile' as a possible IMP view, and use that for all mobile webkit browsers.
authorJan Schneider <jan@horde.org>
Mon, 15 Nov 2010 22:22:00 +0000 (23:22 +0100)
committerJan Schneider <jan@horde.org>
Mon, 15 Nov 2010 22:22:14 +0000 (23:22 +0100)
imp/lib/Application.php
imp/lib/Auth.php
imp/mobile.php

index 2678a04..a142a60 100644 (file)
@@ -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'));
index 016a95e..eb83730 100644 (file)
@@ -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');
index 31123c7..2cad3be 100644 (file)
@@ -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);