Aleksander Machniak
2012-12-12 0435f40999564586dd9bd9669696ec04c16f2e32
Add EXISTS mode to count() method - return number of all messages in a folder,
event if skip_deleted is enabled and/or search is active.
2 files modified
14 ■■■■■ changed files
program/lib/Roundcube/rcube_imap.php 12 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_storage.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_imap.php
@@ -571,7 +571,7 @@
     * Get message count for a specific folder
     *
     * @param  string  $folder  Folder name
     * @param  string  $mode    Mode for count [ALL|THREADS|UNSEEN|RECENT]
     * @param  string  $mode    Mode for count [ALL|THREADS|UNSEEN|RECENT|EXISTS]
     * @param  boolean $force   Force reading from server and update cache
     * @param  boolean $status  Enables storing folder status info (max UID/count),
     *                          required for folder_status()
@@ -592,7 +592,7 @@
     * protected method for getting nr of messages
     *
     * @param string  $folder  Folder name
     * @param string  $mode    Mode for count [ALL|THREADS|UNSEEN|RECENT]
     * @param string  $mode    Mode for count [ALL|THREADS|UNSEEN|RECENT|EXISTS]
     * @param boolean $force   Force reading from server and update cache
     * @param boolean $status  Enables storing folder status info (max UID/count),
     *                         required for folder_status()
@@ -613,6 +613,10 @@
                return $this->search_set->count();
            }
        }
        // EXISTS is a special alias for ALL, it allows to get the number
        // of all messages in a folder also when search is active and with
        // any skip_deleted setting
        $a_folder_cache = $this->get_cache('messagecount');
@@ -644,7 +648,7 @@
            $count = $this->conn->countRecent($folder);
        }
        // use SEARCH for message counting
        else if (!empty($this->options['skip_deleted'])) {
        else if ($mode != 'EXISTS' && !empty($this->options['skip_deleted'])) {
            $search_str = "ALL UNDELETED";
            $keys       = array('COUNT');
@@ -683,7 +687,7 @@
            }
            else {
                $count = $this->conn->countMessages($folder);
                if ($status) {
                if ($status && $mode == 'ALL') {
                    $this->set_folder_stats($folder,'cnt', $count);
                    $this->set_folder_stats($folder, 'maxuid', $count ? $this->id2uid($count, $folder) : 0);
                }
program/lib/Roundcube/rcube_storage.php
@@ -354,7 +354,7 @@
     * Get messages count for a specific folder.
     *
     * @param  string  $folder  Folder name
     * @param  string  $mode    Mode for count [ALL|THREADS|UNSEEN|RECENT]
     * @param  string  $mode    Mode for count [ALL|THREADS|UNSEEN|RECENT|EXISTS]
     * @param  boolean $force   Force reading from server and update cache
     * @param  boolean $status  Enables storing folder status info (max UID/count),
     *                          required for folder_status()