Add IMP::getViewMode().
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Aug 2009 08:45:38 +0000 (02:45 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Aug 2009 08:46:40 +0000 (02:46 -0600)
imp/lib/IMP.php

index c15924e..3a75cf8 100644 (file)
@@ -90,9 +90,7 @@ class IMP
         }
 
         $GLOBALS['notification'] = Horde_Notification::singleton();
-        $viewmode = isset($_SESSION['imp']['view'])
-            ? $_SESSION['imp']['view']
-            : 'imp';
+        $viewmode = self::getViewMode();
 
         if ($viewmode == 'mimp') {
             $GLOBALS['imp_notify'] = $GLOBALS['notification']->attach('status', null, 'Horde_Notification_Listener_Mobile');
@@ -111,6 +109,18 @@ class IMP
     }
 
     /**
+     * Returns the current view mode for IMP.
+     *
+     * @return string  Either 'dimp', 'imp', or 'mimp'.
+     */
+    static public function getViewMode()
+    {
+        return isset($_SESSION['imp']['view'])
+            ? $_SESSION['imp']['view']
+            : 'imp';
+    }
+
+    /**
      * Returns the plain text label that is displayed for the current mailbox,
      * replacing virtual search mailboxes with an appropriate description and
      * removing namespace and mailbox prefix information from what is shown to
@@ -386,10 +396,7 @@ class IMP
         $args = self::composeLinkArgs($args, $extra);
 
         if (is_null($view)) {
-            /* Default to 'imp' if not currently logged-in. */
-            $view = empty($_SESSION['imp']['view'])
-                ? 'imp'
-                : $_SESSION['imp']['view'];
+            $view = self::getViewMode();
         }
 
         if ($view == 'dimp') {