Horde_Imap_Client_Socket::_close PHP Method

_close() protected method

protected _close ( $options )
    protected function _close($options)
    {
        if (empty($options['expunge'])) {
            if ($this->_capability('UNSELECT')) {
                // RFC 3691 defines 'UNSELECT' for precisely this purpose
                $this->_sendCmd($this->_command('UNSELECT'));
            } else {
                /* RFC 3501 [6.4.2]: to close a mailbox without expunge,
                 * select a non-existent mailbox. */
                try {
                    $this->_sendCmd($this->_command('EXAMINE')->add($this->_getMboxFormatOb("nonexist")));
                    /* Not pipelining, since the odds that this CLOSE is even
                     * needed is tiny; and it returns BAD, which should be
                     * avoided, if possible. */
                    $this->_sendCmd($this->_command('CLOSE'));
                } catch (Horde_Imap_Client_Exception_ServerResponse $e) {
                    // Ignore error; it is expected.
                }
            }
        } else {
            // If caching, we need to know the UIDs being deleted, so call
            // expunge() before calling close().
            if ($this->_initCache(true)) {
                $this->expunge($this->_selected);
            }
            // CLOSE returns no untagged information (RFC 3501 [6.4.2])
            $this->_sendCmd($this->_command('CLOSE'));
        }
    }