[Svn] r4186 - trunk/roundcubemail/program/include

trac at roundcube.net trac at roundcube.net
Fri Nov 5 13:19:13 CET 2010


Author: alec
Date: 2010-11-05 07:19:12 -0500 (Fri, 05 Nov 2010)
New Revision: 4186

Modified:
   trunk/roundcubemail/program/include/rcube_imap.php
Log:
- Fix mailbox status checking when skip_deleted and threading are enabled


Modified: trunk/roundcubemail/program/include/rcube_imap.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_imap.php	2010-11-05 11:53:36 UTC (rev 4185)
+++ trunk/roundcubemail/program/include/rcube_imap.php	2010-11-05 12:19:12 UTC (rev 4186)
@@ -547,10 +547,12 @@
             $a_mailbox_cache[$mailbox] = array();
 
         if ($mode == 'THREADS') {
-            $count = $this->_threadcount($mailbox, $msg_count);
+            $res   = $this->_threadcount($mailbox, $msg_count);
+            $count = $res['count'];
+
             if ($status) {
-                $this->set_folder_stats($mailbox, 'cnt', $msg_count);
-                $this->set_folder_stats($mailbox, 'maxuid', $msg_count ? $this->_id2uid($msg_count, $mailbox) : 0);
+                $this->set_folder_stats($mailbox, 'cnt', $res['msgcount']);
+                $this->set_folder_stats($mailbox, 'maxuid', $res['maxuid'] ? $this->_id2uid($res['maxuid'], $mailbox) : 0);
             }
         }
         // RECENT count is fetched a bit different
@@ -618,25 +620,33 @@
      * Private method for getting nr of threads
      *
      * @param string $mailbox   Folder name
-     * @param int    $msg_count Number of messages in the folder
+     *
+     * @returns array Array containing items: 'count' - threads count,
+     *                'msgcount' = messages count, 'maxuid' = max. UID in the set
      * @access  private
-     * @see     rcube_imap::messagecount()
      */
-    private function _threadcount($mailbox, &$msg_count)
+    private function _threadcount($mailbox)
     {
+        $result = array();
+
         if (!empty($this->icache['threads'])) {
-            $msg_count = count($this->icache['threads']['depth']);
-            return count($this->icache['threads']['tree']);
+            $result = array(
+                'count'    => count($this->icache['threads']['tree']),
+                'msgcount' => count($this->icache['threads']['depth']),
+                'maxuid'   => max(array_keys($this->icache['threads']['depth'])),
+            );
         }
-
-        if (is_array($result = $this->_fetch_threads($mailbox))) {
-            $thread_tree = array_shift($result);
-            $msg_count = count($result[0]);
+        else if (is_array($result = $this->_fetch_threads($mailbox))) {
+//        list ($thread_tree, $msg_depth, $has_children) = $result;
+//        $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children);
+            $result = array(
+                'count'    => count($result[0]),
+                'msgcount' => count($result[1]),
+                'maxuid'   => max(array_keys($result[1])),
+            );
         }
 
-//        list ($thread_tree, $msg_depth, $has_children) = $result;
-//        $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children);
-        return count($thread_tree);
+        return $result;
     }
 
 

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list