Horde_Imap_Client_Socket::_getMetadata PHP Method

_getMetadata() protected method

protected _getMetadata ( Horde_Imap_Client_Mailbox $mailbox, $entries, $options )
$mailbox Horde_Imap_Client_Mailbox
    protected function _getMetadata(Horde_Imap_Client_Mailbox $mailbox, $entries, $options)
    {
        $pipeline = $this->_pipeline();
        $pipeline->data['metadata'] = array();
        if ($this->_capability('METADATA') || strlen($mailbox) && $this->_capability('METADATA-SERVER')) {
            $cmd_options = new Horde_Imap_Client_Data_Format_List();
            if (!empty($options['maxsize'])) {
                $cmd_options->add(array('MAXSIZE', new Horde_Imap_Client_Data_Format_Number($options['maxsize'])));
            }
            if (!empty($options['depth'])) {
                $cmd_options->add(array('DEPTH', new Horde_Imap_Client_Data_Format_Number($options['depth'])));
            }
            $queries = new Horde_Imap_Client_Data_Format_List();
            foreach ($entries as $md_entry) {
                $queries->add(new Horde_Imap_Client_Data_Format_Astring($md_entry));
            }
            $cmd = $this->_command('GETMETADATA')->add($this->_getMboxFormatOb($mailbox));
            if (count($cmd_options)) {
                $cmd->add($cmd_options);
            }
            $cmd->add($queries);
            $pipeline->add($cmd);
        } else {
            if (!$this->_capability('ANNOTATEMORE') && !$this->_capability('ANNOTATEMORE2')) {
                throw new Horde_Imap_Client_Exception_NoSupportExtension('METADATA');
            }
            $queries = array();
            foreach ($entries as $md_entry) {
                list($entry, $type) = $this->_getAnnotateMoreEntry($md_entry);
                if (!isset($queries[$type])) {
                    $queries[$type] = new Horde_Imap_Client_Data_Format_List();
                }
                $queries[$type]->add(new Horde_Imap_Client_Data_Format_String($entry));
            }
            foreach ($queries as $key => $val) {
                // TODO: Honor maxsize and depth options.
                $pipeline->add($this->_command('GETANNOTATION')->add(array($this->_getMboxFormatOb($mailbox), $val, new Horde_Imap_Client_Data_Format_String($key))));
            }
        }
        return $this->_sendCmd($pipeline)->data['metadata'];
    }