From 6f9bb11bb1b695439a99b9969b6c46a7379c0534 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli <thomas@roundcube.net> Date: Wed, 23 Apr 2014 07:36:44 -0400 Subject: [PATCH] Reduce duplicated code --- program/lib/Roundcube/rcube_result_multifolder.php | 31 +++++++++++++++++-------------- 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 e5abead..4bbd218 100644 --- a/program/lib/Roundcube/rcube_result_multifolder.php +++ b/program/lib/Roundcube/rcube_result_multifolder.php @@ -57,17 +57,25 @@ { $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; } + } + + /** + * 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); } /** @@ -312,13 +320,8 @@ $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; -- Gitblit v1.9.1