| | |
| | | * |
| | | * @param mixed Message UIDs as array or as comma-separated string |
| | | * @param string Flag to set: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT |
| | | * @param string Folder name |
| | | * @return boolean True on success, False on failure |
| | | */ |
| | | function set_flag($uids, $flag) |
| | | function set_flag($uids, $flag, $mbox_name=NULL) |
| | | { |
| | | $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; |
| | | |
| | | $flag = strtoupper($flag); |
| | | if (!is_array($uids)) |
| | | $uids = explode(',',$uids); |
| | | |
| | | if ($flag=='UNDELETED') |
| | | $result = iil_C_Undelete($this->conn, $this->mailbox, join(',', $uids)); |
| | | $result = iil_C_Undelete($this->conn, $mailbox, join(',', $uids)); |
| | | else if ($flag=='UNSEEN') |
| | | $result = iil_C_Unseen($this->conn, $this->mailbox, join(',', $uids)); |
| | | $result = iil_C_Unseen($this->conn, $mailbox, join(',', $uids)); |
| | | else if ($flag=='UNFLAGGED') |
| | | $result = iil_C_UnFlag($this->conn, $this->mailbox, join(',', $uids), 'FLAGGED'); |
| | | $result = iil_C_UnFlag($this->conn, $mailbox, join(',', $uids), 'FLAGGED'); |
| | | else |
| | | $result = iil_C_Flag($this->conn, $this->mailbox, join(',', $uids), $flag); |
| | | $result = iil_C_Flag($this->conn, $mailbox, join(',', $uids), $flag); |
| | | |
| | | // reload message headers if cached |
| | | $cache_key = $this->mailbox.'.msg'; |
| | | $cache_key = $mailbox.'.msg'; |
| | | if ($this->caching_enabled) |
| | | { |
| | | foreach ($uids as $uid) |
| | |
| | | |
| | | // clear message count cache |
| | | if ($result && $flag=='SEEN') |
| | | $this->_set_messagecount($this->mailbox, 'UNSEEN', $count*(-1)); |
| | | $this->_set_messagecount($mailbox, 'UNSEEN', $count*(-1)); |
| | | else if ($result && $flag=='UNSEEN') |
| | | $this->_set_messagecount($this->mailbox, 'UNSEEN', $count); |
| | | $this->_set_messagecount($mailbox, 'UNSEEN', $count); |
| | | else if ($result && $flag=='DELETED') |
| | | $this->_set_messagecount($this->mailbox, 'ALL', $count*(-1)); |
| | | $this->_set_messagecount($mailbox, 'ALL', $count*(-1)); |
| | | |
| | | return $result; |
| | | } |
| | |
| | | // but only when flag_for_deletion is set to false |
| | | if (!rcmail::get_instance()->config->get('flag_for_deletion', false)) |
| | | { |
| | | $this->_expunge($from_mbox, FALSE); |
| | | $this->_expunge($from_mbox, FALSE, $a_uids); |
| | | $this->_clear_messagecount($from_mbox); |
| | | $this->_clear_messagecount($to_mbox); |
| | | } |
| | |
| | | // really deleted from the mailbox |
| | | if ($deleted) |
| | | { |
| | | $this->_expunge($mailbox, FALSE); |
| | | $this->_expunge($mailbox, FALSE, $a_uids); |
| | | $this->_clear_messagecount($mailbox); |
| | | unset($this->uid_id_map[$mailbox]); |
| | | } |
| | |
| | | * Send IMAP expunge command and clear cache |
| | | * |
| | | * @see rcube_imap::expunge() |
| | | * @param string Mailbox name |
| | | * @param boolean False if cache should not be cleared |
| | | * @param string List of UIDs to remove, separated by comma |
| | | * @return boolean True on success |
| | | * @access private |
| | | */ |
| | | function _expunge($mailbox, $clear_cache=TRUE) |
| | | function _expunge($mailbox, $clear_cache=TRUE, $uids=NULL) |
| | | { |
| | | $result = iil_C_Expunge($this->conn, $mailbox); |
| | | if ($uids && $this->get_capability('UIDPLUS')) |
| | | $a_uids = is_array($uids) ? join(',', $uids) : $uids; |
| | | else |
| | | $a_uids = NULL; |
| | | |
| | | $result = iil_C_Expunge($this->conn, $mailbox, $a_uids); |
| | | |
| | | if ($result>=0 && $clear_cache) |
| | | { |
| | |
| | | if (($p = array_search(strtolower($folder), $this->default_folders_lc)) !== false && !$a_defaults[$p]) |
| | | $a_defaults[$p] = $folder; |
| | | else |
| | | $folders[$folder] = rc_strtolower(rcube_charset_convert($folder, 'UTF-7')); |
| | | $folders[$folder] = rc_strtolower(rcube_charset_convert($folder, 'UTF7-IMAP')); |
| | | } |
| | | |
| | | // sort folders and place defaults on the top |