| | |
| | | |
| | | public function run() |
| | | { |
| | | #trigger_error("Start search $this->folder", E_USER_NOTICE); |
| | | // trigger_error("Start search $this->folder", E_USER_NOTICE); |
| | | $this->result = $this->search_index(); |
| | | #trigger_error("End search $this->folder: " . $this->result->count(), E_USER_NOTICE); |
| | | // trigger_error("End search $this->folder: " . $this->result->count(), E_USER_NOTICE); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | protected function search_index() |
| | | { |
| | | $pthreads = defined('PTHREADS_INHERIT_ALL'); |
| | | $criteria = $this->search; |
| | | $charset = $this->charset; |
| | | |
| | |
| | | rcube_imap::convert_criteria($criteria, $charset), true, 'US-ASCII'); |
| | | } |
| | | |
| | | // close IMAP connection again |
| | | if ($pthreads) |
| | | $imap->closeConnection(); |
| | | |
| | | return $threads; |
| | | } |
| | | |
| | |
| | | $messages = $imap->sort($this->folder, $this->sort_field, |
| | | rcube_imap::convert_criteria($criteria, $charset), true, 'US-ASCII'); |
| | | } |
| | | |
| | | if (!$messages->is_error()) { |
| | | return $messages; |
| | | } |
| | | } |
| | | |
| | | if (!$messages || !$messages->is_error()) { |
| | | $messages = $imap->search($this->folder, |
| | | ($charset && $charset != 'US-ASCII' ? "CHARSET $charset " : '') . $criteria, true); |
| | | |
| | |
| | | $messages = $imap->search($this->folder, |
| | | rcube_imap::convert_criteria($criteria, $charset), true); |
| | | } |
| | | } |
| | | |
| | | // close IMAP connection again |
| | | if ($pthreads) |
| | | $imap->closeConnection(); |
| | | |
| | | return $messages; |
| | | } |
| | |
| | | */ |
| | | public function __construct($id, $options) |
| | | { |
| | | $options['ident']['command'] = 'search-'.$id; |
| | | |
| | | $this->id = $id; |
| | | $this->options = $options; |
| | | } |
| | |
| | | # $conn->setDebug(true, function($conn, $message){ trigger_error($message, E_USER_NOTICE); }); |
| | | |
| | | if ($this->options['user'] && $this->options['password']) { |
| | | // TODO: do this synchronized to avoid warnings like "Only one Id allowed in non-authenticated state" |
| | | $conn->connect($this->options['host'], $this->options['user'], $this->options['password'], $this->options); |
| | | } |
| | | |
| | | if ($conn->error) |
| | | trigger_error($this->conn->error, E_USER_WARNING); |
| | | trigger_error($conn->error, E_USER_WARNING); |
| | | |
| | | #$this->conn = $conn; |
| | | return $conn; |