| | |
| | | protected $meta = array(); |
| | | protected $index = array(); |
| | | protected $folders = array(); |
| | | protected $sdata = array(); |
| | | protected $order = 'ASC'; |
| | | protected $sorting; |
| | | |
| | |
| | | public function revert() |
| | | { |
| | | $this->order = $this->order == 'ASC' ? 'DESC' : 'ASC'; |
| | | $this->index = array(); |
| | | $this->index = array_reverse($this->index); |
| | | |
| | | // revert order in all sub-sets |
| | | foreach ($this->sets as $set) { |
| | | if ($this->order != $set->get_parameters('ORDER')) { |
| | | $set->revert(); |
| | | } |
| | | |
| | | $folder = $set->get_parameters('MAILBOX'); |
| | | $index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $set->get()); |
| | | |
| | | $this->index = array_merge($this->index, $index); |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * Slices data set. |
| | | * |
| | | * @param $offset Offset (as for PHP's array_slice()) |
| | | * @param $length Number of elements (as for PHP's array_slice()) |
| | | * |
| | | * @param int $offset Offset (as for PHP's array_slice()) |
| | | * @param int $length Number of elements (as for PHP's array_slice()) |
| | | */ |
| | | public function slice($offset, $length) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Return all messages in the result. |
| | | * Return all messages in the result in compressed form |
| | | * |
| | | * @return array List of message IDs |
| | | * @return string List of message IDs in compressed form |
| | | */ |
| | | public function get_compressed() |
| | | { |
| | |
| | | * 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 |
| | | * |
| | | * @return false|object rcube_result_* instance of false if none found |
| | | */ |
| | | public function get_set($folder) |
| | | { |
| | |
| | | |
| | | public function __sleep() |
| | | { |
| | | return array('sets','folders','sorting','order'); |
| | | $this->sdata = array('incomplete' => array(), 'error' => array()); |
| | | |
| | | foreach ($this->sets as $set) { |
| | | if ($set->incomplete) { |
| | | $this->sdata['incomplete'][] = $set->get_parameters('MAILBOX'); |
| | | } |
| | | else if ($set->is_error()) { |
| | | $this->sdata['error'][] = $set->get_parameters('MAILBOX'); |
| | | } |
| | | } |
| | | |
| | | return array('sdata', 'index', 'folders', 'sorting', 'order'); |
| | | } |
| | | |
| | | public function __wakeup() |
| | | { |
| | | // restore index from saved result sets |
| | | $this->meta = array('count' => 0); |
| | | $this->meta = array('count' => count($this->index)); |
| | | $this->incomplete = count($this->sdata['incomplete']) > 0; |
| | | |
| | | foreach ($this->sets as $result) { |
| | | if ($result->count()) { |
| | | $this->append_result($result); |
| | | // restore result sets from saved index |
| | | $data = array(); |
| | | foreach ($this->index as $item) { |
| | | list($uid, $folder) = explode('-', $item, 2); |
| | | $data[$folder] .= ' ' . $uid; |
| | | } |
| | | else if ($result->incomplete) { |
| | | $this->incomplete = true; |
| | | |
| | | foreach ($this->folders as $folder) { |
| | | if (in_array($folder, $this->sdata['error'])) { |
| | | $data_str = null; |
| | | } |
| | | else { |
| | | $data_str = '* SORT' . $data[$folder]; |
| | | } |
| | | |
| | | $set = new rcube_result_index($folder, $data_str, strtoupper($this->order)); |
| | | |
| | | if (in_array($folder, $this->sdata['incomplete'])) { |
| | | $set->incomplete = true; |
| | | } |
| | | |
| | | $this->sets[] = $set; |
| | | } |
| | | } |
| | | } |