Horde_Imap_Client_Socket::_sendCmd PHP Method

_sendCmd() protected method

Sends command(s) to the IMAP server. A connection to the server must have already been made.
protected _sendCmd ( mixed $cmd ) : Horde_Imap_Client_Interaction_Pipeline
$cmd mixed Either a Command object or a Pipeline object.
return Horde_Imap_Client_Interaction_Pipeline A pipeline object.
    protected function _sendCmd($cmd)
    {
        $pipeline = $cmd instanceof Horde_Imap_Client_Interaction_Command ? $this->_pipeline($cmd) : $cmd;
        if (!empty($this->_cmdQueue)) {
            /* Add commands in reverse order. */
            foreach (array_reverse($this->_cmdQueue) as $val) {
                $pipeline->add($val, true);
            }
            $this->_cmdQueue = array();
        }
        $cmd_list = array();
        foreach ($pipeline as $val) {
            if ($val->continuation) {
                $this->_sendCmdChunk($pipeline, $cmd_list);
                $this->_sendCmdChunk($pipeline, array($val));
                $cmd_list = array();
            } else {
                $cmd_list[] = $val;
            }
        }
        $this->_sendCmdChunk($pipeline, $cmd_list);
        /* If any FLAGS responses contain MODSEQs but not UIDs, don't
         * cache any data and immediately close the mailbox. */
        foreach ($pipeline->data['modseqs_nouid'] as $val) {
            if (!$pipeline->fetch[$val]->getUid()) {
                $this->_debug->info('Server provided FLAGS MODSEQ without providing UID.');
                $this->close();
                return $pipeline;
            }
        }
        /* Update HIGHESTMODSEQ value. */
        if (!empty($pipeline->data['modseqs'])) {
            $modseq = max($pipeline->data['modseqs']);
            $this->_mailboxOb()->setStatus(Horde_Imap_Client::STATUS_HIGHESTMODSEQ, $modseq);
            /* CONDSTORE has not yet updated flag information, so don't update
             * modseq yet. */
            if ($this->_capability()->isEnabled('QRESYNC')) {
                $this->_updateModSeq($modseq);
            }
        }
        /* Update cache items. */
        $this->_updateCache($pipeline->fetch);
        return $pipeline;
    }