IMP_Mailbox_List::getMailboxArray PHP Method

getMailboxArray() public method

Build the array of message information.
public getMailboxArray ( array $msgnum ) : array
$msgnum array An array of index numbers.
return array An array with the following keys:
  - overview: (array) The overview information. Contains the following:
    - envelope: (Horde_Imap_Client_Data_Envelope) Envelope information
                returned from the IMAP server.
    - flags: (array) The list of IMAP flags returned from the server.
    - headers: (array) Horde_Mime_Headers objects containing header
               data for non-envelope headers.
    - idx: (integer) Array index of this message.
    - mailbox: (string) The mailbox containing the message.
    - size: (integer) The size of the message in bytes.
    - uid: (string) The unique ID of the message.
  - uids: (IMP_Indices) An indices object.
    public function getMailboxArray($msgnum)
    {
        $this->_buildMailbox();
        $overview = $to_process = $uids = array();
        /* Build the list of mailboxes and messages. */
        foreach ($msgnum as $i) {
            /* Make sure that the index is actually in the slice of messages
               we're looking at. If we're hiding deleted messages, for
               example, there may be gaps here. */
            if (isset($this->_sorted[$i - 1])) {
                $to_process[strval($this->_getMbox($i - 1))][$i] = $this->_sorted[$i - 1];
            }
        }
        $fetch_query = new Horde_Imap_Client_Fetch_Query();
        $fetch_query->envelope();
        $fetch_query->flags();
        $fetch_query->size();
        $fetch_query->uid();
        $fetch_query->headers('imp', array_merge(self::$headersUsed, IMP_Contents_Message::$headersUsed), array('cache' => true, 'peek' => true));
        /* Retrieve information from each mailbox. */
        foreach ($to_process as $mbox => $ids) {
            try {
                $imp_imap = IMP_Mailbox::get($mbox)->imp_imap;
                if ($imp_imap->config->atc_structure) {
                    $query = clone $fetch_query;
                    $query->structure();
                } else {
                    $query = $fetch_query;
                }
                $fetch_res = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($ids)));
                $mbox_ids = array();
                foreach ($ids as $k => $v) {
                    if (!isset($fetch_res[$v])) {
                        continue;
                    }
                    $f = $fetch_res[$v];
                    $uid = $f->getUid();
                    $v = array('envelope' => $f->getEnvelope(), 'flags' => $f->getFlags(), 'headers' => $f->getHeaders('imp', Horde_Imap_Client_Data_Fetch::HEADER_PARSE), 'idx' => $k, 'mailbox' => $mbox, 'size' => $f->getSize(), 'structure' => $f->getStructure(), 'uid' => $uid);
                    $overview[] = $v;
                    $mbox_ids[] = $uid;
                }
                $uids[$mbox] = $mbox_ids;
            } catch (IMP_Imap_Exception $e) {
            }
        }
        return array('overview' => $overview, 'uids' => new IMP_Indices($uids));
    }