summaryrefslogtreecommitdiff
path: root/program/lib
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-04-07 16:24:37 +0200
committerThomas Bruederli <thomas@roundcube.net>2014-04-07 16:24:37 +0200
commite8cb51669a325a3d5b60fcc37b99d494809bf837 (patch)
treebe0a7cb9f9de8c158d1a53502598055e9202b5cd /program/lib
parente7a3ae9a765cef4b2a851ed49a718629e6e8d186 (diff)
More fixes for multi-folder search (#1485234)
Diffstat (limited to 'program/lib')
-rw-r--r--program/lib/Roundcube/rcube_imap.php15
-rw-r--r--program/lib/Roundcube/rcube_imap_search.php3
-rw-r--r--program/lib/Roundcube/rcube_message.php5
-rw-r--r--program/lib/Roundcube/rcube_result_multifolder.php5
4 files changed, 20 insertions, 8 deletions
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index f60be620c..a708e1d92 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -1480,10 +1480,6 @@ class rcube_imap extends rcube_storage
$str = 'ALL';
}
- if (empty($folder)) {
- $folder = $this->folder;
- }
-
// multi-folder search
if (is_array($folder) && count($folder) > 1 && $str != 'ALL') {
new rcube_result_index; // trigger autoloader and make these classes available for threaded context
@@ -1506,6 +1502,9 @@ class rcube_imap extends rcube_storage
}
else {
$folder = is_array($folder) ? $folder[0] : $folder;
+ if (!strlen($folder)) {
+ $folder = $this->folder;
+ }
$results = $this->search_index($folder, $str, $charset, $sort_field);
}
@@ -1664,8 +1663,12 @@ class rcube_imap extends rcube_storage
public function refresh_search()
{
if (!empty($this->search_string)) {
- // FIXME: make this work with saved multi-folder searches
- $this->search('', $this->search_string, $this->search_charset, $this->search_sort_field);
+ $this->search(
+ is_object($this->search_set) ? $this->search_set->get_parameters('MAILBOX') : '',
+ $this->search_string,
+ $this->search_charset,
+ $this->search_sort_field
+ );
}
return $this->get_search_set();
diff --git a/program/lib/Roundcube/rcube_imap_search.php b/program/lib/Roundcube/rcube_imap_search.php
index c88198140..926a75d76 100644
--- a/program/lib/Roundcube/rcube_imap_search.php
+++ b/program/lib/Roundcube/rcube_imap_search.php
@@ -65,6 +65,8 @@ class rcube_imap_search
{
$pthreads = defined('PTHREADS_INHERIT_ALL');
+ $results = new rcube_result_multifolder($folders);
+
// start a search job for every folder to search in
foreach ($folders as $folder) {
$job = new rcube_imap_search_job($folder, $str, $charset, $sort_field, $threading);
@@ -82,7 +84,6 @@ class rcube_imap_search
$this->shutdown();
// gather results
- $results = new rcube_result_multifolder;
foreach ($this->jobs as $job) {
$results->add($job->get_result());
}
diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php
index f24ec3ed8..ad94005ac 100644
--- a/program/lib/Roundcube/rcube_message.php
+++ b/program/lib/Roundcube/rcube_message.php
@@ -74,6 +74,11 @@ class rcube_message
*/
function __construct($uid, $folder = null)
{
+ // decode combined UID-folder identifier
+ if (preg_match('/^\d+-[^,]+$/', $uid)) {
+ list($uid, $folder) = explode('-', $uid);
+ }
+
$this->uid = $uid;
$this->app = rcube::get_instance();
$this->storage = $this->app->get_storage();
diff --git a/program/lib/Roundcube/rcube_result_multifolder.php b/program/lib/Roundcube/rcube_result_multifolder.php
index 188fb26f2..ac0889526 100644
--- a/program/lib/Roundcube/rcube_result_multifolder.php
+++ b/program/lib/Roundcube/rcube_result_multifolder.php
@@ -32,6 +32,7 @@ class rcube_result_multifolder
protected $meta = array();
protected $index = array();
+ protected $folders = array();
protected $sorting;
protected $order = 'ASC';
@@ -39,8 +40,9 @@ class rcube_result_multifolder
/**
* Object constructor.
*/
- public function __construct()
+ public function __construct($folders = array())
{
+ $this->folders = $folders;
$this->meta = array('count' => 0);
}
@@ -228,6 +230,7 @@ class rcube_result_multifolder
$params = array(
'SORT' => $this->sorting,
'ORDER' => $this->order,
+ 'MAILBOX' => $this->folders,
);
if ($param !== null) {