public function listMailboxes($pattern,
                                  $mode = Horde_Imap_Client::MBOX_ALL,
                                  array $options = array())
    {
        $this->login();

        $pattern = is_array($pattern)
            ? array_unique($pattern)
            : array($pattern);

        /* Prepare patterns. */
        $plist = array();
        foreach ($pattern as $val) {
            if ($val instanceof Horde_Imap_Client_Mailbox) {
                $val = $val->list_escape;
            }
            $plist[] = Horde_Imap_Client_Mailbox::get(preg_replace(
                array("/\*{2,}/", "/\%{2,}/"),
                array('*', '%'),
                Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($val)
            ), true);
        }

        if (isset($options['special_use']) &&
            !$this->_capability('SPECIAL-USE')) {
            unset($options['special_use']);
        }

        $ret = $this->_listMailboxes($plist, $mode, $options);

        if (!empty($options['status']) &&
            !$this->_capability('LIST-STATUS')) {
            foreach ($this->status(array_keys($ret), $options['status']) as $key => $val) {
                $ret[$key]['status'] = $val;
            }
        }

        if (empty($options['sort'])) {
            return $ret;
        }

        $list_ob = new Horde_Imap_Client_Mailbox_List(empty($options['flat']) ? array_keys($ret) : $ret);
        $sorted = $list_ob->sort(array(
            'delimiter' => empty($options['sort_delimiter']) ? '.' : $options['sort_delimiter']
        ));

        if (!empty($options['flat'])) {
            return $sorted;
        }

        $out = array();
        foreach ($sorted as $val) {
            $out[$val] = $ret[$val];
        }

        return $out;
    }
public function listMailboxes($pattern,
                                  $mode = Horde_Imap_Client::MBOX_ALL,
                                  array $options = array())
    {
        $this->login();

        $pattern = is_array($pattern)
            ? array_unique($pattern)
            : array($pattern);

        /* Prepare patterns. */
        $plist = array();
        foreach ($pattern as $val) {
            if ($val instanceof Horde_Imap_Client_Mailbox) {
                $val = $val->list_escape;
            }
            $plist[] = Horde_Imap_Client_Mailbox::get(preg_replace(
                array("/\*{2,}/", "/\%{2,}/"),
                array('*', '%'),
                Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap($val)
            ), true);
        }

        if (isset($options['special_use']) &&
            !$this->_capability('SPECIAL-USE')) {
            unset($options['special_use']);
        }

        $ret = $this->_listMailboxes($plist, $mode, $options);

        if (!empty($options['status']) &&
            !$this->_capability('LIST-STATUS')) {
            foreach ($this->status(array_keys($ret), $options['status']) as $key => $val) {
                $ret[$key]['status'] = $val;
            }
        }

        if (empty($options['sort'])) {
            return $ret;
        }

        $list_ob = new Horde_Imap_Client_Mailbox_List(empty($options['flat']) ? array_keys($ret) : $ret);
        $sorted = $list_ob->sort(array(
            'delimiter' => empty($options['sort_delimiter']) ? '.' : $options['sort_delimiter']
        ));

        if (!empty($options['flat'])) {
            return $sorted;
        }

        $out = array();
        foreach ($sorted as $val) {
            $out[$val] = $ret[$val];
        }

        return $out;
    }
public function listMailboxes ( $ pattern , $ mode = Horde_Imap_Client :: MBOX_ALL , array $ options = array ( ) ) { $ this -> login ( ) ; $ pattern = is_array ( $ pattern ) ? array_unique ( $ pattern ) : array ( $ pattern ) ; /* Prepare patterns. */ $ plist = array ( ) ; foreach ( $ pattern as $ val ) { if ( $ val instanceof Horde_Imap_Client_Mailbox ) { $ val = $ val -> list_escape ; } $ plist [ ] = Horde_Imap_Client_Mailbox :: get ( preg_replace ( array ( "/\*{2,}/" , "/\%{2,}/" ) , array ( '*' , '%' ) , Horde_Imap_Client_Utf7imap :: Utf8ToUtf7Imap ( $ val ) ) , true ) ; } if ( isset ( $ options [ 'special_use' ] ) && ! $ this -> _capability ( 'SPECIAL-USE' ) ) { unset ( $ options [ 'special_use' ] ) ; } $ ret = $ this -> _listMailboxes ( $ plist , $ mode , $ options ) ; if ( ! empty ( $ options [ 'status' ] ) && ! $ this -> _capability ( 'LIST-STATUS' ) ) { foreach ( $ this -> status ( array_keys ( $ ret ) , $ options [ 'status' ] ) as $ key => $ val ) { $ ret [ $ key ] [ 'status' ] = $ val ; } } if ( empty ( $ options [ 'sort' ] ) ) { return $ ret ; } $ list_ob = new Horde_Imap_Client_Mailbox_List ( empty ( $ options [ 'flat' ] ) ? array_keys ( $ ret ) : $ ret ) ; $ sorted = $ list_ob -> sort ( array ( 'delimiter' => empty ( $ options [ 'sort_delimiter' ] ) ? '.' : $ options [ 'sort_delimiter' ] ) ) ; if ( ! empty ( $ options [ 'flat' ] ) ) { return $ sorted ; } $ out = array ( ) ; foreach ( $ sorted as $ val ) { $ out [ $ val ] = $ ret [ $ val ] ; } return $ out ; }
Obtain a list of mailboxes matching a pattern.

@param mixed $pattern   The mailbox search pattern(s) (see RFC 3501
[6.3.8] for the format). A UTF-8 string or an
array of strings. If a Horde_Imap_Client_Mailbox
object is given, it is escaped (i.e. wildcard
patterns are converted to return the miminal
number of matches possible).
@param integer $mode    Which mailboxes to return.  Either:
- Horde_Imap_Client::MBOX_SUBSCRIBED
Return subscribed mailboxes.
- Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS
Return subscribed mailboxes that exist on the server.
- Horde_Imap_Client::MBOX_UNSUBSCRIBED
Return unsubscribed mailboxes.
- Horde_Imap_Client::MBOX_ALL
Return all mailboxes regardless of subscription status.
- Horde_Imap_Client::MBOX_ALL_SUBSCRIBED (@since 2.23.0)
Return all mailboxes regardless of subscription status, and ensure
the '\subscribed' attribute is set if mailbox is subscribed
(implies 'attributes' option is true).
@param array $options   Additional options:
<pre>
- attributes: (boolean) If true, return attribute information under
the 'attributes' key.
DEFAULT: Do not return this information.
- children: (boolean) Tell server to return children attribute
information (\HasChildren, \HasNoChildren). Requires the
LIST-EXTENDED extension to guarantee this information is
returned. Server MAY return this attribute without this
option, or if the CHILDREN extension is available, but it
is not guaranteed.
DEFAULT: false
- flat: (boolean) If true, return a flat list of mailbox names only.
Overrides the 'attributes' option.
DEFAULT: Do not return flat list.
- recursivematch: (boolean) Force the server to return information
about parent mailboxes that don't match other
selection options, but have some sub-mailboxes that
do. Information about children is returned in the
CHILDINFO extended data item ('extended'). Requires
the LIST-EXTENDED extension.
DEFAULT: false
- 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 (see Horde_Imap_Client SPECIALUSE_*
constants). Server must support the SPECIAL-USE return
option for this setting to have any effect.
DEFAULT: false
- status: (integer) Tell server to return status information. The
value is a bitmask that may contain any of:
- Horde_Imap_Client::STATUS_MESSAGES
- Horde_Imap_Client::STATUS_RECENT
- Horde_Imap_Client::STATUS_UIDNEXT
- Horde_Imap_Client::STATUS_UIDVALIDITY
- Horde_Imap_Client::STATUS_UNSEEN
- Horde_Imap_Client::STATUS_HIGHESTMODSEQ
DEFAULT: 0
- sort: (boolean) If true, return a sorted list of mailboxes?
DEFAULT: Do not sort the list.
- sort_delimiter: (string) If 'sort' is true, this is the delimiter
used to sort the mailboxes.
DEFAULT: '.'
</pre>

@return array  If 'flat' option is true, the array values are a list
of Horde_Imap_Client_Mailbox objects. Otherwise, the
keys are UTF-8 mailbox names and the values are arrays
with these keys:
- attributes: (array) List of lower-cased attributes [only if
'attributes' option is true].
- delimiter: (string) The delimiter for the mailbox.
- extended: (TODO) TODO [only if 'recursivematch' option is true and
LIST-EXTENDED extension is supported on the server].
- mailbox: (Horde_Imap_Client_Mailbox) The mailbox object.
- status: (array) See status() [only if 'status' option is true].

@throws Horde_Imap_Client_Exception
Obtain a list of mailboxes matching a pattern .