Improve thread sort display on servers that don't support REFERENCES sort
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Aug 2009 07:03:17 +0000 (01:03 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Aug 2009 07:03:17 +0000 (01:03 -0600)
imp/lib/Mailbox.php

index 4e28901..357c910 100644 (file)
@@ -663,8 +663,18 @@ class IMP_Mailbox
         if (is_null($this->_threadob)) {
             try {
                 $this->_threadob = $GLOBALS['imp_imap']->ob->thread($this->_mailbox);
+                $ref_errcode = null;
             } catch (Horde_Imap_Client_Exception $e) {
-                return new Horde_Imap_Client_Thread();
+                $ref_errcode = $e->getCode();
+            }
+
+            if ($ref_errcode == Horde_Imap_Client_Exception::NOSUPPORTIMAPEXT) {
+                try {
+                    $this->_threadob = $GLOBALS['imp_imap']->ob->thread($this->_mailbox, array('criteria' => Horde_Imap_Client::THREAD_ORDEREDSUBJECT));
+                } catch (Horde_Imap_Client_Exception $e) {
+                    $GLOBALS['notification']->push(_("Server does not support thread sorting."), 'horde.error');
+                    return new Horde_Imap_Client_Thread(array(), 'uid');
+                }
             }
         }