$mbox = '';
$sorted = new IMP_Indices();
- $query = $this[$id]->query;
- if (!$query) {
+ if (!($query_list = $this[$id]->query)) {
return $sorted;
}
- /* Prepare the search query. */
- if (!empty($ob)) {
- $query->andSearch(array($ob));
- }
-
/* How do we want to sort results? */
$sortpref = IMP::getSort(null, true);
if ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) {
$sortpref['by'] = $GLOBALS['prefs']->getValue('sortdate');
}
- foreach ($this[$id]->mboxes as $val) {
- $results = $this->imapSearch($val, $query, array('reverse' => $sortpref['dir'], 'sort' => array($sortpref['by'])));
- $sorted->add($val, $results['sort']);
+ foreach ($query_list as $mbox => $query) {
+ if (!empty($ob)) {
+ $query->andSearch(array($ob));
+ }
+ $results = $this->imapSearch($mbox, $query, array('reverse' => $sortpref['dir'], 'sort' => array($sortpref['by'])));
+ $sorted->add($mbox, $results['sort']);
}
return $sorted;
/**
* Adds the current query item to the query object.
*
- * @param Horde_Imap_Client_Search_Query The query object.
+ * @param string $mbox The mailbox to create
+ * the query for.
+ * @param Horde_Imap_Client_Search_Query $queryob The query object.
+ *
+ * @return Horde_Imap_Client_Search_Query The altered query object.
*/
- abstract public function createQuery($queryob);
+ abstract public function createQuery($mbox, $queryob);
/**
* Return search query text representation.
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$queryob->headerText('precedence', 'bulk', $this->_data);
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$date = new DateTime($this->_data->d);
$queryob->dateSearch($date, ($this->_data->t == self::DATE_ON) ? Horde_Imap_Client_Search_Query::DATE_ON : (($this->_data->t == self::DATE_BEFORE) ? Horde_Imap_Client_Search_Query::DATE_BEFORE : Horde_Imap_Client_Search_Query::DATE_SINCE));
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$queryob->flag($this->_data->f, $this->_data->s);
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$queryob->headerText($this->_data->h, $this->_data->t, $this->_data->n);
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$queryob->headerText('list-id', '', $this->_data);
{
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$ob = new Horde_Imap_Client_Search_Query();
$ob->orSearch(array($queryob));
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$and_ob = new Horde_Imap_Client_Search_Query();
$identity = $GLOBALS['injector']->getInstance('IMP_Identity');
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$and_ob = new Horde_Imap_Client_Search_Query();
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$queryob->size($this->_data->s, $this->_data->l);
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
$queryob->text($this->_data->t, $this->_data->b, $this->_data->n);
/**
*/
- public function createQuery($queryob)
+ public function createQuery($mbox, $queryob)
{
/* Limited to day granularity because that is the technical
* limit for IMAP servers without 'WITHIN' extension. */
* 'label' - (string) The query label.
* 'mboxes' - (array) The list of mailboxes to query.
* 'mid' - (string) The query ID with the search mailbox prefix.
- * 'query' - (Horde_Imap_Client_Search_Query) The IMAP query object.
+ * 'query' - (array) The list of IMAP queries that comprise this search.
+ * Keys are mailbox names, values are
+ * Horde_Imap_Client_Search_Query objects.
* 'querytext' - (string) The textual representation of the query.
* </pre>
*
return IMP_Search::MBOX_PREFIX . $this->_id;
case 'query':
- $query = new Horde_Imap_Client_Search_Query();
- foreach ($this->_criteria as $elt) {
- $query = $elt->createQuery($query);
+ $qout = array();
+
+ foreach ($this->_mboxes as $mbox) {
+ $query = new Horde_Imap_Client_Search_Query();
+ foreach ($this->_criteria as $elt) {
+ $query = $elt->createQuery($mbox, $query);
+ }
+ $qout[$mbox] = $query;
}
- return $query;
+
+ return $qout;
case 'querytext':
$text = array(_("Search"));