| | |
| | | * Get message count for a specific mailbox |
| | | * |
| | | * @param string Mailbox/folder name |
| | | * @param string Mode for count [ALL|UNSEEN|RECENT] |
| | | * @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 |
| | |
| | | if (!is_array($a_mailbox_cache[$mailbox])) |
| | | $a_mailbox_cache[$mailbox] = array(); |
| | | |
| | | if ($mode == 'THREADS') |
| | | $count = $this->_threadcount($mailbox); |
| | | |
| | | if ($mode == 'THREADS') { |
| | | $count = $this->_threadcount($mailbox, $msg_count); |
| | | $_SESSION['maxuid'][$mailbox] = $msg_count ? $this->_id2uid($msg_count) : 0; |
| | | } |
| | | // RECENT count is fetched a bit different |
| | | else if ($mode == 'RECENT') |
| | | else if ($mode == 'RECENT') { |
| | | $count = iil_C_CheckForRecent($this->conn, $mailbox); |
| | | |
| | | } |
| | | // use SEARCH for message counting |
| | | else if ($this->skip_deleted) |
| | | { |
| | | else if ($this->skip_deleted) { |
| | | $search_str = "ALL UNDELETED"; |
| | | |
| | | // get message count and store in cache |
| | |
| | | |
| | | // get message count using SEARCH |
| | | // not very performant but more precise (using UNDELETED) |
| | | // disable THREADS for this request |
| | | $threads = $this->threading; |
| | | $this->threading = false; |
| | | $index = $this->_search_index($mailbox, $search_str); |
| | | $this->threading = $threads; |
| | | |
| | | $count = is_array($index) ? count($index) : 0; |
| | | |
| | | if ($mode == 'ALL') |
| | |
| | | * @access private |
| | | * @see rcube_imap::messagecount() |
| | | */ |
| | | private function _threadcount($mailbox) |
| | | private function _threadcount($mailbox, &$msg_count) |
| | | { |
| | | if (!empty($this->icache['threads'])) |
| | | return count($this->icache['threads']['tree']); |
| | | |
| | | list ($thread_tree, $msg_depth, $has_children) = $this->_fetch_threads($mailbox); |
| | | |
| | | $msg_count = count($msg_depth); |
| | | |
| | | // $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children); |
| | | return count($thread_tree); |