/** * Mark messages as deleted and expunge mailbox * * @param mixed $uids Message UIDs as array or comma-separated string, or '*' * @param string $mbox_name Source mailbox * @return boolean True on success, False on error */ function delete_message($uids, $mbox_name = '') { $mailbox = strlen($mbox_name) ? $this->mod_mailbox($mbox_name) : $this->mailbox; list($uids, $all_mode) = $this->_parse_uids($uids, $mailbox); // exit if no message uids are specified if (empty($uids)) { return false; } $deleted = $this->conn->delete($mailbox, $uids); if ($deleted) { // send expunge command in order to have the deleted message // really deleted from the mailbox $this->_expunge($mailbox, false, $uids); $this->_clear_messagecount($mailbox); unset($this->uid_id_map[$mailbox]); // unset threads internal cache unset($this->icache['threads']); // remove message ids from search set if ($this->search_set && $mailbox == $this->mailbox) { // threads are too complicated to just remove messages from set if ($this->search_threads || $all_mode) { $this->refresh_search(); } else { $uids = explode(',', $uids); foreach ($uids as $uid) { $a_mids[] = $this->_uid2id($uid, $mailbox); } $this->search_set = array_diff($this->search_set, $a_mids); } } // remove deleted messages from cache $cache_key = $mailbox . '.msg'; if ($all_mode || ($start_index = $this->get_message_cache_index_min($cache_key, $uids))) { // clear cache from the lowest index on $this->clear_message_cache($cache_key, $all_mode ? 1 : $start_index); } } return $deleted; }
/** * Mark messages as deleted and expunge mailbox * * @param mixed $uids Message UIDs as array or comma-separated string, or '*' * @param string $mailbox Source mailbox * * @return boolean True on success, False on error */ function delete_message($uids, $mailbox = '') { if (!strlen($mailbox)) { $mailbox = $this->mailbox; } list($uids, $all_mode) = $this->_parse_uids($uids, $mailbox); // exit if no message uids are specified if (empty($uids)) { return false; } $deleted = $this->conn->delete($mailbox, $uids); if ($deleted) { // send expunge command in order to have the deleted message // really deleted from the mailbox $this->_expunge($mailbox, false, $uids); $this->_clear_messagecount($mailbox); unset($this->uid_id_map[$mailbox]); // unset threads internal cache unset($this->icache['threads']); // remove message ids from search set if ($this->search_set && $mailbox == $this->mailbox) { // threads are too complicated to just remove messages from set if ($this->search_threads || $all_mode) { $this->refresh_search(); } else { $a_uids = explode(',', $uids); foreach ($a_uids as $uid) { $a_mids[] = $this->uid2id($uid, $mailbox); } $this->search_set = array_diff($this->search_set, $a_mids); unset($a_uids); unset($a_mids); } } // remove cached messages $this->clear_message_cache($mailbox, $all_mode ? null : explode(',', $uids)); } return $deleted; }