summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube_result_multifolder.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-04-23 13:21:51 +0200
committerThomas Bruederli <thomas@roundcube.net>2014-04-23 13:21:51 +0200
commit31aa080609f6ea8a561182eb5b3da46733bef313 (patch)
tree24ef1d723fdfaaf9ccc3a709fa2df7b3b4183bd4 /program/lib/Roundcube/rcube_result_multifolder.php
parent3b55b2f92b435630f56e63f5796471abacaaf425 (diff)
Further refine cross-folder searching:
- Store incomplete search results in session and re-send search requests to the server if returned before complete (this should avoid hitting request timeouts). - Display full folder path on mouseover in message list - Remove pthreads implementation stuff as this wasn't really working
Diffstat (limited to 'program/lib/Roundcube/rcube_result_multifolder.php')
-rw-r--r--program/lib/Roundcube/rcube_result_multifolder.php52
1 files changed, 51 insertions, 1 deletions
diff --git a/program/lib/Roundcube/rcube_result_multifolder.php b/program/lib/Roundcube/rcube_result_multifolder.php
index b5473b841..e5abead51 100644
--- a/program/lib/Roundcube/rcube_result_multifolder.php
+++ b/program/lib/Roundcube/rcube_result_multifolder.php
@@ -28,6 +28,7 @@ class rcube_result_multifolder
{
public $multi = true;
public $sets = array();
+ public $incomplete = false;
public $folder;
protected $meta = array();
@@ -54,8 +55,9 @@ class rcube_result_multifolder
*/
public function add($result)
{
+ $this->sets[] = $result;
+
if ($count = $result->count()) {
- $this->sets[] = $result;
$this->meta['count'] += $count;
// append UIDs to global index
@@ -63,6 +65,9 @@ class rcube_result_multifolder
$index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $result->get());
$this->index = array_merge($this->index, $index);
}
+ else if ($result->incomplete) {
+ $this->incomplete = true;
+ }
}
/**
@@ -266,6 +271,22 @@ class rcube_result_multifolder
return $params;
}
+ /**
+ * Returns the stored result object for a particular folder
+ *
+ * @param string $folder Folder name
+ * @return false|obejct rcube_result_* instance of false if none found
+ */
+ public function get_set($folder)
+ {
+ foreach ($this->sets as $set) {
+ if ($set->get_parameters('MAILBOX') == $folder) {
+ return $set;
+ }
+ }
+
+ return false;
+ }
/**
* Returns length of internal data representation
@@ -276,4 +297,33 @@ class rcube_result_multifolder
{
return $this->count();
}
+
+
+ /* Serialize magic methods */
+
+ public function __sleep()
+ {
+ return array('sets','folders','sorting','order');
+ }
+
+ public function __wakeup()
+ {
+ // restore index from saved result sets
+ $this->meta = array('count' => 0);
+
+ foreach ($this->sets as $result) {
+ if ($count = $result->count()) {
+ $this->meta['count'] += $count;
+
+ // append UIDs to global index
+ $folder = $result->get_parameters('MAILBOX');
+ $index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $result->get());
+ $this->index = array_merge($this->index, $index);
+ }
+ else if ($result->incomplete) {
+ $this->incomplete = true;
+ }
+ }
+ }
+
}