| | |
| | | <?php |
| | | |
| | | /* |
| | | /** |
| | | +-----------------------------------------------------------------------+ |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2011, The Roundcube Dev Team | |
| | |
| | | */ |
| | | class rcube_result_index |
| | | { |
| | | public $incomplete = false; |
| | | |
| | | protected $raw_data; |
| | | protected $mailbox; |
| | | protected $meta = array(); |
| | | protected $meta = array(); |
| | | protected $params = array(); |
| | | protected $order = 'ASC'; |
| | | protected $order = 'ASC'; |
| | | |
| | | const SEPARATOR_ELEMENT = ' '; |
| | | |
| | |
| | | /** |
| | | * Object constructor. |
| | | */ |
| | | public function __construct($mailbox = null, $data = null) |
| | | public function __construct($mailbox = null, $data = null, $order = null) |
| | | { |
| | | $this->mailbox = $mailbox; |
| | | $this->order = $order == 'DESC' ? 'DESC' : 'ASC'; |
| | | $this->init($data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Initializes object with SORT command response |
| | |
| | | $this->raw_data = $data; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Checks the result from IMAP command |
| | | * |
| | |
| | | */ |
| | | public function is_error() |
| | | { |
| | | return $this->raw_data === null ? true : false; |
| | | return $this->raw_data === null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Checks if the result is empty |
| | |
| | | */ |
| | | public function is_empty() |
| | | { |
| | | return empty($this->raw_data) ? true : false; |
| | | return empty($this->raw_data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns number of elements in the result |
| | |
| | | return $this->meta['count']; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns number of elements in the result. |
| | | * Alias for count() for compatibility with rcube_result_thread |
| | |
| | | { |
| | | return $this->count(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns maximal message identifier in the result |
| | |
| | | return $this->meta['max']; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns minimal message identifier in the result |
| | | * |
| | |
| | | return $this->meta['min']; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Slices data set. |
| | | * |
| | | * @param $offset Offset (as for PHP's array_slice()) |
| | | * @param $length Number of elements (as for PHP's array_slice()) |
| | | * |
| | | */ |
| | | public function slice($offset, $length) |
| | | { |
| | |
| | | $this->meta['count'] = count($data); |
| | | $this->raw_data = implode(self::SEPARATOR_ELEMENT, $data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Filters data set. Removes elements not listed in $ids list. |
| | |
| | | $this->raw_data = implode(self::SEPARATOR_ELEMENT, $data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Reverts order of elements in the result |
| | | */ |
| | |
| | | return; |
| | | } |
| | | |
| | | // @TODO: maybe do this in chunks |
| | | $data = $this->get(); |
| | | $data = array_reverse($data); |
| | | $this->raw_data = implode(self::SEPARATOR_ELEMENT, $data); |
| | | |
| | | $this->meta['pos'] = array(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Check if the given message ID exists in the object |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return all messages in the result. |
| | | * |
| | |
| | | return explode(self::SEPARATOR_ELEMENT, $this->raw_data); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return all messages in the result. |
| | | * |
| | |
| | | |
| | | return rcube_imap_generic::compressMessageSet($this->get()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return result element at specified index |
| | |
| | | return $data[$index]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns response parameters, e.g. ESEARCH's MIN/MAX/COUNT/ALL/MODSEQ |
| | | * or internal data e.g. MAILBOX, ORDER |
| | |
| | | |
| | | return $params; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns length of internal data representation |