/** * 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; }
/** * Gets connection (and current folder) data: UIDVALIDITY, EXISTS, RECENT, * PERMANENTFLAGS, UIDNEXT, UNSEEN * * @param string $folder Folder name * * @return array Data */ public function folder_data($folder) { if (!strlen($folder)) { $folder = $this->folder !== null ? $this->folder : 'INBOX'; } if ($this->conn->selected != $folder) { if (!$this->check_connection()) { return array(); } if ($this->conn->select($folder)) { $this->folder = $folder; } else { return null; } } $data = $this->conn->data; // add (E)SEARCH result for ALL UNDELETED query if (!empty($this->icache['undeleted_idx']) && $this->icache['undeleted_idx']->get_parameters('MAILBOX') == $folder ) { $data['UNDELETED'] = $this->icache['undeleted_idx']; } return $data; }
/** * Gets connection (and current mailbox) data: UIDVALIDITY, EXISTS, RECENT, * PERMANENTFLAGS, UIDNEXT, UNSEEN * * @param string $mailbox Folder name * * @return array Data */ function mailbox_data($mailbox) { if (!strlen($mailbox)) { $mailbox = $this->mailbox !== null ? $this->mailbox : 'INBOX'; } if ($this->conn->selected != $mailbox) { if ($this->conn->select($mailbox)) { $this->mailbox = $mailbox; } else { return null; } } $data = $this->conn->data; // add (E)SEARCH result for ALL UNDELETED query if (!empty($this->icache['undeleted_idx']) && $this->icache['undeleted_idx'][0] == $mailbox) { $data['ALL_UNDELETED'] = $this->icache['undeleted_idx'][1]; $data['COUNT_UNDELETED'] = $this->icache['undeleted_idx'][2]; } return $data; }