| | |
| | | /** |
| | | * Get message count for a specific mailbox |
| | | * |
| | | * @param string Mailbox/folder name |
| | | * @param string Mode for count [ALL|THREADS|UNSEEN|RECENT] |
| | | * @param boolean Force reading from server and update cache |
| | | * @return int Number of messages |
| | | * @access public |
| | | * @param string Mailbox/folder name |
| | | * @param string Mode for count [ALL|THREADS|UNSEEN|RECENT] |
| | | * @param boolean Force reading from server and update cache |
| | | * @param boolean Enables MAXUIDs checking |
| | | * @return int Number of messages |
| | | * @access public |
| | | */ |
| | | function messagecount($mbox_name='', $mode='ALL', $force=false) |
| | | function messagecount($mbox_name='', $mode='ALL', $force=false, $maxuid=true) |
| | | { |
| | | $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; |
| | | return $this->_messagecount($mailbox, $mode, $force); |
| | | return $this->_messagecount($mailbox, $mode, $force, $maxuid); |
| | | } |
| | | |
| | | |
| | |
| | | * @access private |
| | | * @see rcube_imap::messagecount() |
| | | */ |
| | | private function _messagecount($mailbox='', $mode='ALL', $force=false) |
| | | private function _messagecount($mailbox='', $mode='ALL', $force=false, $maxuid=true) |
| | | { |
| | | $mode = strtoupper($mode); |
| | | |
| | |
| | | |
| | | if ($mode == 'THREADS') { |
| | | $count = $this->_threadcount($mailbox, $msg_count); |
| | | $_SESSION['maxuid'][$mailbox] = $msg_count ? $this->_id2uid($msg_count) : 0; |
| | | if ($maxuid) |
| | | $_SESSION['maxuid'][$mailbox] = $msg_count ? $this->_id2uid($msg_count, $mailbox) : 0; |
| | | } |
| | | // RECENT count is fetched a bit different |
| | | else if ($mode == 'RECENT') { |
| | |
| | | |
| | | $count = is_array($index) ? count($index) : 0; |
| | | |
| | | if ($mode == 'ALL') |
| | | $_SESSION['maxuid'][$mailbox] = $index ? $this->_id2uid(max($index)) : 0; |
| | | if ($mode == 'ALL' && $maxuid) |
| | | $_SESSION['maxuid'][$mailbox] = $index ? $this->_id2uid(max($index), $mailbox) : 0; |
| | | } |
| | | else { |
| | | if ($mode == 'UNSEEN') |
| | | $count = $this->conn->countUnseen($mailbox); |
| | | else { |
| | | $count = $this->conn->countMessages($mailbox); |
| | | $_SESSION['maxuid'][$mailbox] = $count ? $this->_id2uid($count) : 0; |
| | | if ($maxuid) |
| | | $_SESSION['maxuid'][$mailbox] = $count ? $this->_id2uid($count, $mailbox) : 0; |
| | | } |
| | | } |
| | | |
| | |
| | | function get_headers($id, $mbox_name=NULL, $is_uid=true, $bodystr=false) |
| | | { |
| | | $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox; |
| | | $uid = $is_uid ? $id : $this->_id2uid($id); |
| | | $uid = $is_uid ? $id : $this->_id2uid($id, $mailbox); |
| | | |
| | | // get cached headers |
| | | if ($uid && ($headers = &$this->get_cached_message($mailbox.'.msg', $uid))) |
| | |
| | | return true; |
| | | } |
| | | else { |
| | | $a_folders = $this->conn->listMailboxes($this->mod_mailbox(''), $mbox_mbox); |
| | | $a_folders = $this->conn->listMailboxes($this->mod_mailbox(''), $mbox_name); |
| | | |
| | | if (is_array($a_folders) && in_array($this->mod_mailbox($mbox_name), $a_folders)) |
| | | return true; |