Bug #7296: Convert old IMP 4 sortby pref values
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 2 Jun 2009 19:30:33 +0000 (13:30 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 2 Jun 2009 19:30:33 +0000 (13:30 -0600)
imp/lib/IMP.php

index 40ff187..94a97d8 100644 (file)
@@ -1106,8 +1106,18 @@ class IMP
         $sortpref = @unserialize($GLOBALS['prefs']->getValue('sortpref'));
         $entry = (isset($sortpref[$prefmbox])) ? $sortpref[$prefmbox] : array();
 
+        if (!isset($entry['b'])) {
+            $sortby = $GLOBALS['prefs']->getValue('sortby');
+            /* IMP 4 upgrade: check for old, non-existent sort values.
+             * See Bug #7296. */
+            if ($sortby > 10) {
+                $sortby = Horde_Imap_Client::SORT_ARRIVAL;
+                $GLOBALS['prefs']->setValue($sortby);
+            }
+        }
+
         $ob = array(
-            'by' => isset($entry['b']) ? $entry['b'] : $GLOBALS['prefs']->getValue('sortby'),
+            'by' => isset($entry['b']) ? $entry['b'] : $sortby,
             'dir' => isset($entry['d']) ? $entry['d'] : $GLOBALS['prefs']->getValue('sortdir'),
             'limit' => false
         );