Reduce duplicated code

pull/171/merge
Thomas Bruederli 10 years ago
parent 31aa080609
commit 6f9bb11bb1

@ -57,19 +57,27 @@ class rcube_result_multifolder
{ {
$this->sets[] = $result; $this->sets[] = $result;
if ($count = $result->count()) { if ($result->count()) {
$this->meta['count'] += $count; $this->append_result($result);
// 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) { else if ($result->incomplete) {
$this->incomplete = true; $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);
}
/** /**
* Store a global index of (sorted) message UIDs * Store a global index of (sorted) message UIDs
*/ */
@ -312,13 +320,8 @@ class rcube_result_multifolder
$this->meta = array('count' => 0); $this->meta = array('count' => 0);
foreach ($this->sets as $result) { foreach ($this->sets as $result) {
if ($count = $result->count()) { if ($result->count()) {
$this->meta['count'] += $count; $this->append_result($result);
// 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) { else if ($result->incomplete) {
$this->incomplete = true; $this->incomplete = true;

Loading…
Cancel
Save