*
* @param string $mailbox The mailbox to create. Either in UTF7-IMAP or
* UTF-8.
+ * @param array $opts Additional options:
+ * <pre>
+ * '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.
+ * </pre>
*
* @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.
* '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,
* 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);
* 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);
}
/**
* 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])) {
* 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
* 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);
}
/**
$select_opts[] = 'RECURSIVEMATCH';
}
+ if (!empty($options['special_use'])) {
+ $select_opts[] = 'SPECIAL-USE';
+ }
+
if (!empty($select_opts)) {
$cmd[] = $select_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
*/
- 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);
}
<api>alpha</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add Horde_Imap_Client_Base::validSearchCharset().
+ <notes>* 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]).