[Svn] r4180 - in trunk/roundcubemail/program: include steps/mail

trac at roundcube.net trac at roundcube.net
Thu Nov 4 15:03:26 CET 2010


Author: alec
Date: 2010-11-04 09:03:26 -0500 (Thu, 04 Nov 2010)
New Revision: 4180

Modified:
   trunk/roundcubemail/program/include/rcube_imap.php
   trunk/roundcubemail/program/steps/mail/pagenav.inc
Log:
- Add possibility to force mailbox selection. There're situations where we're invoking
  STATUS (for all messages count) and SELECT later for other operations. If we
  call SELECT first, the STATUS will be not needed.


Modified: trunk/roundcubemail/program/include/rcube_imap.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_imap.php	2010-11-04 13:48:17 UTC (rev 4179)
+++ trunk/roundcubemail/program/include/rcube_imap.php	2010-11-04 14:03:26 UTC (rev 4180)
@@ -113,7 +113,7 @@
         $this->conn = new rcube_imap_generic();
     }
 
-    
+
     /**
      * Connect to an IMAP server
      *
@@ -182,7 +182,7 @@
         return false;
     }
 
-    
+
     /**
      * Close IMAP connection
      * Usually done on script shutdown
@@ -195,7 +195,7 @@
         $this->write_cache();
     }
 
-    
+
     /**
      * Close IMAP connection and re-connect
      * This is used to avoid some strange socket errors when talking to Courier IMAP
@@ -233,8 +233,8 @@
     {
         return ($this->conn) ? $this->conn->error : '';
     }
-    
 
+
     /**
      * Set options to be used in rcube_imap_generic::connect()
      *
@@ -245,7 +245,7 @@
         $this->options = array_merge($this->options, (array)$opt);
     }
 
-    
+
     /**
      * Set a root folder for the IMAP connection.
      *
@@ -267,7 +267,7 @@
             $this->get_hierarchy_delimiter();
     }
 
-    
+
     /**
      * Set default message charset
      *
@@ -281,7 +281,7 @@
         $this->default_charset = $cs;
     }
 
-    
+
     /**
      * This list of folders will be listed above all other folders
      *
@@ -299,7 +299,7 @@
         }
     }
 
-    
+
     /**
      * Set internal mailbox reference.
      *
@@ -321,8 +321,28 @@
         $this->_clear_messagecount($mailbox);
     }
 
-    
+
     /**
+     * Forces selection of a mailbox
+     *
+     * @param  string $mailbox Mailbox/Folder name
+     * @access public
+     */
+    function select_mailbox($mailbox)
+    {
+        $mailbox = $this->mod_mailbox($mailbox);
+
+        $selected = $this->conn->select($mailbox);
+
+        if ($selected && $this->mailbox != $mailbox) {
+            // clear messagecount cache for this mailbox
+            $this->_clear_messagecount($mailbox);
+            $this->mailbox = $mailbox;
+        }
+    }
+
+
+    /**
      * Set internal list page
      *
      * @param  number $page Page number to list
@@ -333,7 +353,7 @@
         $this->list_page = (int)$page;
     }
 
-    
+
     /**
      * Set internal page size
      *
@@ -345,7 +365,7 @@
         $this->page_size = (int)$size;
     }
 
-    
+
     /**
      * Save a set of message ids for future message listing methods
      *
@@ -372,7 +392,7 @@
         $this->search_sorted     = $sorted;
     }
 
-    
+
     /**
      * Return the saved search set as hash array
      * @return array Search set
@@ -388,7 +408,7 @@
 	    );
     }
 
-    
+
     /**
      * Returns the currently used mailbox name
      *
@@ -400,7 +420,7 @@
         return $this->conn->connected() ? $this->mod_mailbox($this->mailbox, 'out') : '';
     }
 
-    
+
     /**
      * Returns the IMAP server's capability
      *
@@ -413,7 +433,7 @@
         return $this->conn->getCapability(strtoupper($cap));
     }
 
-    
+
     /**
      * Sets threading flag to the best supported THREAD algorithm
      *
@@ -437,7 +457,7 @@
         return $this->threading;
     }
 
-    
+
     /**
      * Checks the PERMANENTFLAGS capability of the current mailbox
      * and returns true if the given flag is supported by the IMAP server
@@ -453,7 +473,7 @@
         return (in_array_nocase($imap_flag, $this->conn->data['PERMANENTFLAGS']));
     }
 
-    
+
     /**
      * Returns the delimiter that is used by the IMAP server for folder separation
      *
@@ -471,7 +491,7 @@
         return $this->delimiter;
     }
 
-    
+
     /**
      * Get message count for a specific mailbox
      *
@@ -489,7 +509,7 @@
         return $this->_messagecount($mailbox, $mode, $force, $status);
     }
 
-    
+
     /**
      * Private method for getting nr of messages
      *

Modified: trunk/roundcubemail/program/steps/mail/pagenav.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/pagenav.inc	2010-11-04 13:48:17 UTC (rev 4179)
+++ trunk/roundcubemail/program/steps/mail/pagenav.inc	2010-11-04 14:03:26 UTC (rev 4180)
@@ -20,8 +20,14 @@
 */
 
 $uid = get_input_value('_uid', RCUBE_INPUT_GET);
-$cnt  = $IMAP->messagecount(NULL, 'ALL'); // Only messages, no threads here
 
+// Select mailbox first, for better performance
+$mbox_name = $IMAP->get_mailbox_name();
+$IMAP->select_mailbox($mbox_name);
+
+// Get messages count (only messages, no threads here)
+$cnt  = $IMAP->messagecount(NULL, 'ALL');
+
 if ($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] != 'DESC'
     && empty($_REQUEST['_search']) && !$CONFIG['skip_deleted'] && !$IMAP->threading
 ) {

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



More information about the Svn mailing list