summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-04-23 13:36:44 +0200
committerThomas Bruederli <thomas@roundcube.net>2014-04-23 13:36:44 +0200
commit6f9bb11bb1b695439a99b9969b6c46a7379c0534 (patch)
tree70df9e5b614f469cf116d26ae5a3eebb2a1694e5 /program
parent31aa080609f6ea8a561182eb5b3da46733bef313 (diff)
Reduce duplicated code
Diffstat (limited to 'program')
-rw-r--r--program/lib/Roundcube/rcube_result_multifolder.php31
1 files changed, 17 insertions, 14 deletions
diff --git a/program/lib/Roundcube/rcube_result_multifolder.php b/program/lib/Roundcube/rcube_result_multifolder.php
index e5abead51..4bbd2188d 100644
--- a/program/lib/Roundcube/rcube_result_multifolder.php
+++ b/program/lib/Roundcube/rcube_result_multifolder.php
@@ -57,13 +57,8 @@ class rcube_result_multifolder
{
$this->sets[] = $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);
+ if ($result->count()) {
+ $this->append_result($result);
}
else if ($result->incomplete) {
$this->incomplete = true;
@@ -71,6 +66,19 @@ class rcube_result_multifolder
}
/**
+ * Append message UIDs from the given result to our index
+ */
+ protected function append_result($result)
+ {
+ $this->meta['count'] += $result->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);
+ }
+
+ /**
* Store a global index of (sorted) message UIDs
*/
public function set_message_index($headers, $sort_field, $sort_order)
@@ -312,13 +320,8 @@ class rcube_result_multifolder
$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);
+ if ($result->count()) {
+ $this->append_result($result);
}
else if ($result->incomplete) {
$this->incomplete = true;