From: Michael M Slusarz Date: Thu, 26 Nov 2009 01:12:40 +0000 (-0700) Subject: Store the thread algorithm used in the session. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8b0b22d2366cc81146e18ef89d5ea4820e691020;p=horde.git Store the thread algorithm used in the session. Explicitly state REFERENCES as the desired first choice thread algorithm --- diff --git a/imp/config/servers.php.dist b/imp/config/servers.php.dist index d16900df4..5f461b513 100644 --- a/imp/config/servers.php.dist +++ b/imp/config/servers.php.dist @@ -194,6 +194,11 @@ * (i.e. it is selected per default). Otherwise the first entry * in the list is selected. * + * thread: (string) Set the preferred thread sort algorithm. This algorithm + * must be supported by the remote server. By default, IMP attempts + * to use REFERENCES sorting and, if this is not available, it will + * fall back to ORDEREDSUBJECT sorting done on the local server. + * * * $Id$ */ diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index d3dd584be..6f33859be 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -81,6 +81,14 @@ class IMP_Auth throw new Horde_Auth_Exception($e->getMessage()); } + /* Set the IMAP threading algorithm. */ + $ptr = $GLOBALS['imp_imap']->loadServerConfig($credentials['server']); + if (strcasecmp($ptr['protocol'], 'imap') == 0) { + $_SESSION['imp']['imap']['thread'] = in_array(isset($ptr['thread']) ? strtoupper($ptr['thread']) : 'REFERENCES', $GLOBALS['imp_imap']->ob()->queryCapability('THREAD')) + ? 'REFERENCES' + : 'ORDEREDSUBJECT'; + } + return false; } diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index 93e37893b..1d43bf265 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -667,22 +667,9 @@ class IMP_Mailbox { if (is_null($this->_threadob)) { try { - $this->_threadob = $GLOBALS['imp_imap']->ob()->thread($this->_mailbox); - $ref_errcode = null; + $this->_threadob = $GLOBALS['imp_imap']->ob()->thread($this->_mailbox, array('criteria' => $_SESSION['imp']['imap']['thread'])); } catch (Horde_Imap_Client_Exception $e) { - $error = $e; - $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'); - } - } elseif (!is_null($ref_errcode)) { - $GLOBALS['notification']->push($error, 'horde.error'); + $GLOBALS['notification']->push($e, 'horde.error'); return new Horde_Imap_Client_Thread(array(), 'uid'); } }