Request #9203: Change cached imp view on dynamic_view pref change
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Aug 2010 21:51:55 +0000 (15:51 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Aug 2010 21:51:55 +0000 (15:51 -0600)
imp/lib/Auth.php
imp/lib/Prefs/Ui.php

index e7646f8..6e54b95 100644 (file)
@@ -465,22 +465,18 @@ class IMP_Auth
         if (empty($conf['user']['force_view'])) {
             if (empty($conf['user']['select_view']) ||
                 empty($sess['cache']['select_view'])) {
-                $sess['view'] = $GLOBALS['browser']->isMobile()
+                $view = $GLOBALS['browser']->isMobile()
                     ? 'mimp'
                     : ($GLOBALS['prefs']->getValue('dynamic_view') ? 'dimp' : 'imp');
             } else {
                 $setcookie = true;
-                $sess['view'] = $sess['cache']['select_view'];
+                $view = $sess['cache']['select_view'];
             }
         } else {
-            $sess['view'] = $conf['user']['force_view'];
+            $view = $conf['user']['force_view'];
         }
 
-        /* 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');
-        }
+        self::setViewMode($view);
 
         if ($setcookie) {
             setcookie('default_imp_view', $sess['view'], time() + 30 * 86400, $conf['cookie']['path'], $conf['cookie']['domain']);
@@ -509,4 +505,20 @@ class IMP_Auth
         self::_logMessage('login', 'NOTICE');
     }
 
+    /**
+     * Sets the current view mode.
+     *
+     * @return string  Either 'dimp', 'imp', or 'mimp'.
+     */
+    static public function setViewMode($view)
+    {
+        /* Enforce minimum browser standards for DIMP. */
+        if (($view == 'dimp') && !Horde::ajaxAvailable()) {
+            $view = 'imp';
+            $GLOBALS['notification']->push(_("Your browser is too old to display the dynamic mode. Using traditional mode instead."), 'horde.warning');
+        }
+
+        $_SESSION['imp']['view'] = $view;
+    }
+
 }
index d177d3b..db12f5c 100644 (file)
@@ -131,6 +131,12 @@ class IMP_Prefs_Ui
             }
             break;
 
+        case 'dimp':
+            if (!empty($conf['user']['force_view'])) {
+                $ui->suppress[] = 'dynamic_view';
+            }
+            break;
+
         case 'display':
             /* Set the timezone on this page so the 'time_format' output uses
              * the configured time zone's time, not the system's time zone. */
@@ -533,6 +539,14 @@ class IMP_Prefs_Ui
             }
             break;
 
+        case 'dimp':
+            if ($prefs->isDirty('dynamic_view')) {
+                $_SESSION['imp']['view'] = $prefs->getValue('dynamic_view')
+                    ? 'dimp'
+                    : ($GLOBALS['browser']->isMobile() ? 'mimp' : 'imp');
+            }
+            break;
+
         case 'display':
             if ($prefs->isDirty('tree_view')) {
                 $GLOBALS['registry']->getApiInstance('imp', 'application')->mailboxesChanged();