From: Michael M Slusarz Date: Fri, 20 Aug 2010 21:43:12 +0000 (-0600) Subject: Add support for special-use mailboxes (draft-ietf-morg-list-specialuse-02) X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a88ee4ed970f2de8d3fce4280ff97d4de9b8a39f;p=horde.git Add support for special-use mailboxes (draft-ietf-morg-list-specialuse-02) --- diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php index 682c6d42a..1403c774b 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php @@ -695,22 +695,33 @@ abstract class Horde_Imap_Client_Base * * @param string $mailbox The mailbox to create. Either in UTF7-IMAP or * UTF-8. + * @param array $opts Additional options: + *
+     * 'special_use' - (array) An array of special-use flags to mark the
+     *                 mailbox with.  The server must support broadcast the
+     *                 CREATE-SPECIAL-USE capability string.
+     * 
* * @throws Horde_Imap_Client_Exception */ - public function createMailbox($mailbox) + public function createMailbox($mailbox, array $opts = array()) { - $this->_createMailbox(Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($mailbox)); + if (!$this->queryCapability('CREATE-SPECIAL-USE')) { + unset($opts['special_use']); + } + + $this->_createMailbox(Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($mailbox), $opts); } /** * Create a mailbox. * * @param string $mailbox The mailbox to create (UTF7-IMAP). + * @param array $opts Additional options. See self::createMailbox(). * * @throws Horde_Imap_Client_Exception */ - abstract protected function _createMailbox($mailbox); + abstract protected function _createMailbox($mailbox, $opts); /** * Delete a mailbox. @@ -859,6 +870,14 @@ abstract class Horde_Imap_Client_Base * 'remote' - (boolean) Tell server to return mailboxes that reside on * another server. Requires the LIST-EXTENDED extension. * DEFAULT: false + * 'special_use' - (boolean) Tell server to return special-use attribute + * information (\Drafts, \Flagged, \Junk, \Sent, \Trash, + * \All, \Archive)). Server must support the SPECIAL-USE + * return option for this setting to have any effect. + * Server MAY return this attribute without this option. + * Aidditionaly, server SHOULD return this information if + * this option is given, but it is not guaranteed. + * DEFAULT: false * 'status' - (integer) Tell server to return status information. The * value is a bitmask that may contain the following: * Horde_Imap_Client::STATUS_MESSAGES, diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php index 27aff24ab..462e29525 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php @@ -340,11 +340,17 @@ class Horde_Imap_Client_Cclient extends Horde_Imap_Client_Base * Create a mailbox. * * @param string $mailbox The mailbox to create (UTF7-IMAP). + * @param array $opts Additional options. See self::createMailbox(). * * @throws Horde_Imap_Client_Exception */ - protected function _createMailbox($mailbox) + protected function _createMailbox($mailbox, $opts) { + if (isset($opts['special_use'])) { + $this->_getSocket()->createMailbox($mailbox, $opts); + return; + } + $this->login(); $old_error = error_reporting(0); diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php index 569c7c897..8e33ca19c 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php @@ -125,10 +125,11 @@ class Horde_Imap_Client_Cclient_Pop3 extends Horde_Imap_Client_Cclient * Create a mailbox. * * @param string $mailbox The mailbox to create (UTF7-IMAP). + * @param array $opts Additional options. See self::createMailbox(). * * @throws Horde_Imap_Client_Exception */ - protected function _createMailbox($mailbox) + protected function _createMailbox($mailbox, $opts) { throw new Horde_Imap_Client_Exception('Creating mailboxes not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED); } diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Mock.php b/framework/Imap_Client/lib/Horde/Imap/Client/Mock.php index 1ef526286..c87980ab0 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Mock.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Mock.php @@ -297,11 +297,13 @@ class Horde_Imap_Client_Mock extends Horde_Imap_Client_Base /** * Create a mailbox. * - * @param string $mailbox The mailbox to create (UTF7-IMAP). + * @param string $mailbox The mailbox to create (UTF7-IMAP). + * @param array $opts Additional options. See self::createMailbox(). + * * * @throws Horde_Imap_Client_Exception */ - protected function _createMailbox($mailbox) + protected function _createMailbox($mailbox, $opts) { $mailbox = $this->_parseFolder($mailbox); if (isset(self::$storage[$mailbox])) { diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php index ca7fbacf9..03fc67a7c 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php @@ -40,8 +40,9 @@ * RFC 5530 - IMAP Response Codes * RFC 5819 - LIST-STATUS * - * draft-ietf-morg-sortdisplay-02 SORT=DISPLAY - * draft-ietf-morg-inthread-00 THREAD=REFS + * draft-ietf-morg-list-specialuse-02 CREATE-SPECIAL-USE + * draft-ietf-morg-sortdisplay-02 SORT=DISPLAY + * draft-ietf-morg-inthread-00 THREAD=REFS * * [NO RFC] - XIMAPPROXY * + Requires imapproxy v1.2.7-rc1 or later @@ -905,18 +906,31 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base * Create a mailbox. * * @param string $mailbox The mailbox to create (UTF7-IMAP). + * @param array $opts Additional options. See self::createMailbox(). * * @throws Horde_Imap_Client_Exception */ - protected function _createMailbox($mailbox) + protected function _createMailbox($mailbox, $opts) { $this->login(); - // CREATE returns no untagged information (RFC 3501 [6.3.3]) - $this->_sendLine(array( + $cmd = array( 'CREATE', array('t' => Horde_Imap_Client::DATA_MAILBOX, 'v' => $mailbox) - )); + ); + + if (isset($opts['special_use'])) { + $cmd[] = 'USE'; + + $flags = array(); + foreach ($opts['special_use'] as $val) { + $flags[] = array('t' => Horde_Imap_Client::DATA_ATOM, 'v' => $val); + } + $cmd[] = $flags; + } + + // CREATE returns no untagged information (RFC 3501 [6.3.3]) + $this->_sendLine($cmd); } /** @@ -1083,6 +1097,10 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base $select_opts[] = 'RECURSIVEMATCH'; } + if (!empty($options['special_use'])) { + $select_opts[] = 'SPECIAL-USE'; + } + if (!empty($select_opts)) { $cmd[] = $select_opts; } diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php index 178f789e3..6a9535e4d 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php @@ -453,10 +453,11 @@ class Horde_Imap_Client_Socket_Pop3 extends Horde_Imap_Client_Base * Create a mailbox. * * @param string $mailbox The mailbox to create (UTF7-IMAP). + * @param array $opts Additional options. See self::createMailbox(). * * @throws Horde_Imap_Client_Exception */ - protected function _createMailbox($mailbox) + protected function _createMailbox($mailbox, $opts) { throw new Horde_Imap_Client_Exception('Creating mailboxes not supported on POP3 servers.', Horde_Imap_Client_Exception::POP3_NOTSUPPORTED); } diff --git a/framework/Imap_Client/package.xml b/framework/Imap_Client/package.xml index d30f63f7e..98c04247a 100644 --- a/framework/Imap_Client/package.xml +++ b/framework/Imap_Client/package.xml @@ -31,7 +31,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> alpha LGPL - * Add Horde_Imap_Client_Base::validSearchCharset(). + * Add support for special-use mailboxes (draft-ietf-morg-list-specialuse-02). + * Add Horde_Imap_Client_Base::validSearchCharset(). * Add Horde_Imap_Client_Base::fetchFromSectionString(). * Add support for RFC 4469 (CATENATE). * Correctly output 8-bit strings (RFC 3501 [4.3]).