summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-11-04 14:03:26 +0000
committeralecpl <alec@alec.pl>2010-11-04 14:03:26 +0000
commit30b30226e6569f13e444cdcb513cd2bfc24318d7 (patch)
tree7944cd0e39dd36c880c6fe684c42779d89ad7d6c
parent29b39739df3393f138dbdd98591e1331af0393ad (diff)
- 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.
-rw-r--r--program/include/rcube_imap.php58
-rw-r--r--program/steps/mail/pagenav.inc8
2 files changed, 46 insertions, 20 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 3d04937fc..17ba91c03 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -113,7 +113,7 @@ class rcube_imap
$this->conn = new rcube_imap_generic();
}
-
+
/**
* Connect to an IMAP server
*
@@ -182,7 +182,7 @@ class rcube_imap
return false;
}
-
+
/**
* Close IMAP connection
* Usually done on script shutdown
@@ -195,7 +195,7 @@ class rcube_imap
$this->write_cache();
}
-
+
/**
* Close IMAP connection and re-connect
* This is used to avoid some strange socket errors when talking to Courier IMAP
@@ -233,7 +233,7 @@ class rcube_imap
{
return ($this->conn) ? $this->conn->error : '';
}
-
+
/**
* Set options to be used in rcube_imap_generic::connect()
@@ -245,7 +245,7 @@ class rcube_imap
$this->options = array_merge($this->options, (array)$opt);
}
-
+
/**
* Set a root folder for the IMAP connection.
*
@@ -267,7 +267,7 @@ class rcube_imap
$this->get_hierarchy_delimiter();
}
-
+
/**
* Set default message charset
*
@@ -281,7 +281,7 @@ class rcube_imap
$this->default_charset = $cs;
}
-
+
/**
* This list of folders will be listed above all other folders
*
@@ -299,7 +299,7 @@ class rcube_imap
}
}
-
+
/**
* Set internal mailbox reference.
*
@@ -321,7 +321,27 @@ class rcube_imap
$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
*
@@ -333,7 +353,7 @@ class rcube_imap
$this->list_page = (int)$page;
}
-
+
/**
* Set internal page size
*
@@ -345,7 +365,7 @@ class rcube_imap
$this->page_size = (int)$size;
}
-
+
/**
* Save a set of message ids for future message listing methods
*
@@ -372,7 +392,7 @@ class rcube_imap
$this->search_sorted = $sorted;
}
-
+
/**
* Return the saved search set as hash array
* @return array Search set
@@ -388,7 +408,7 @@ class rcube_imap
);
}
-
+
/**
* Returns the currently used mailbox name
*
@@ -400,7 +420,7 @@ class rcube_imap
return $this->conn->connected() ? $this->mod_mailbox($this->mailbox, 'out') : '';
}
-
+
/**
* Returns the IMAP server's capability
*
@@ -413,7 +433,7 @@ class rcube_imap
return $this->conn->getCapability(strtoupper($cap));
}
-
+
/**
* Sets threading flag to the best supported THREAD algorithm
*
@@ -437,7 +457,7 @@ class rcube_imap
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 @@ class rcube_imap
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 @@ class rcube_imap
return $this->delimiter;
}
-
+
/**
* Get message count for a specific mailbox
*
@@ -489,7 +509,7 @@ class rcube_imap
return $this->_messagecount($mailbox, $mode, $force, $status);
}
-
+
/**
* Private method for getting nr of messages
*
diff --git a/program/steps/mail/pagenav.inc b/program/steps/mail/pagenav.inc
index b62520fab..e295114e1 100644
--- a/program/steps/mail/pagenav.inc
+++ b/program/steps/mail/pagenav.inc
@@ -20,7 +20,13 @@
*/
$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