/** * Send IMAP expunge command and clear cache * * @param string $mailbox Mailbox name * @param boolean $clear_cache False if cache should not be cleared * @param mixed $uids Message UIDs as array or comma-separated string, or '*' * @return boolean True on success * @access private * @see rcube_imap::expunge() */ private function _expunge($mailbox, $clear_cache = true, $uids = NULL) { if ($uids && $this->get_capability('UIDPLUS')) { $a_uids = is_array($uids) ? join(',', $uids) : $uids; } else { $a_uids = NULL; } // force mailbox selection and check if mailbox is writeable // to prevent a situation when CLOSE is executed on closed // or EXPUNGE on read-only mailbox $result = $this->conn->select($mailbox); if (!$result) { return false; } if (!$this->conn->data['READ-WRITE']) { $this->conn->setError(rcube_imap_generic::ERROR_READONLY, "Mailbox is read-only"); return false; } // CLOSE(+SELECT) should be faster than EXPUNGE if (empty($a_uids) || $a_uids == '1:*') { $result = $this->conn->close(); } else { $result = $this->conn->expunge($mailbox, $a_uids); } if ($result && $clear_cache) { $this->clear_message_cache($mailbox . '.msg'); $this->_clear_messagecount($mailbox); } return $result; }
/** * Send IMAP expunge command and clear cache * * @param mixed $uids Message UIDs as array or comma-separated string, or '*' * @param string $folder Folder name * @param boolean $clear_cache False if cache should not be cleared * * @return boolean True on success, False on failure */ public function expunge_message($uids, $folder = null, $clear_cache = true) { if ($uids && $this->get_capability('UIDPLUS')) { list($uids, $all_mode) = $this->parse_uids($uids); } else { $uids = null; } if (!strlen($folder)) { $folder = $this->folder; } if (!$this->check_connection()) { return false; } // force folder selection and check if folder is writeable // to prevent a situation when CLOSE is executed on closed // or EXPUNGE on read-only folder $result = $this->conn->select($folder); if (!$result) { return false; } if (!$this->conn->data['READ-WRITE']) { $this->conn->setError(rcube_imap_generic::ERROR_READONLY, "Folder is read-only"); return false; } // CLOSE(+SELECT) should be faster than EXPUNGE if (empty($uids) || $all_mode) { $result = $this->conn->close(); } else { $result = $this->conn->expunge($folder, $uids); } if ($result && $clear_cache) { $this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids)); $this->clear_messagecount($folder); } return $result; }