summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-04-14 20:35:03 +0200
committerThomas Bruederli <thomas@roundcube.net>2014-04-14 20:35:03 +0200
commitf97fe4ee084cd3fd286625cb9fe4ec9b5c5a9d6d (patch)
treed8e926d8c4542f9d6bd5cceec3da693a5706bf8f /program
parenta12bbbaf41a200e98e437c2082b9dcc68c5a8f46 (diff)
Allow to search in multiple folders with rcube_imap::search_once(); always set folder property in message header struct
Diffstat (limited to 'program')
-rw-r--r--program/lib/Roundcube/rcube_imap.php32
1 files changed, 21 insertions, 11 deletions
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index 5c30327a1..baca052b8 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -1544,20 +1544,27 @@ class rcube_imap extends rcube_storage
*/
public function search_once($folder = null, $str = 'ALL')
{
+ if (!$this->check_connection()) {
+ return new rcube_result_index();
+ }
+
if (!$str) {
$str = 'ALL';
}
- if (!strlen($folder)) {
- $folder = $this->folder;
+ // multi-folder search
+ if (is_array($folder) && count($folder) > 1) {
+ $searcher = new rcube_imap_search($this->options, $this->conn);
+ $index = $searcher->exec($folder, $str, $this->default_charset);
}
-
- if (!$this->check_connection()) {
- return new rcube_result_index();
+ else {
+ $folder = is_array($folder) ? $folder[0] : $folder;
+ if (!strlen($folder)) {
+ $folder = $this->folder;
+ }
+ $index = $this->conn->search($folder, $str, true);
}
- $index = $this->conn->search($folder, $str, true);
-
return $index;
}
@@ -1707,15 +1714,15 @@ class rcube_imap extends rcube_storage
*/
public function get_message_headers($uid, $folder = null, $force = false)
{
- if (!strlen($folder)) {
- $folder = $this->folder;
- }
-
// decode combined UID-folder identifier
if (preg_match('/^\d+-.+/', $uid)) {
list($uid, $folder) = explode('-', $uid, 2);
}
+ if (!strlen($folder)) {
+ $folder = $this->folder;
+ }
+
// get cached headers
if (!$force && $uid && ($mcache = $this->get_mcache_engine())) {
$headers = $mcache->get_message($folder, $uid);
@@ -1726,6 +1733,9 @@ class rcube_imap extends rcube_storage
else {
$headers = $this->conn->fetchHeader(
$folder, $uid, true, true, $this->get_fetch_headers());
+
+ if (is_object($headers))
+ $headers->folder = $folder;
}
return $headers;