intervalSearch() public method

Search for messages within a given interval. Only one interval of each type can be specified per search query. If the IMAP server supports the WITHIN extension (RFC 5032), it will be used. Otherwise, the search query will be dynamically created using IMAP4rev1 search terms.
public intervalSearch ( integer $interval, string $range, boolean $not = false, array $opts = [] )
$interval integer Seconds from the present.
$range string Either: - Horde_Imap_Client_Search_Query::INTERVAL_OLDER - Horde_Imap_Client_Search_Query::INTERVAL_YOUNGER
$not boolean If true, do a 'NOT' search.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.
示例#1
0
 /**
  * Tidy up old messages in the confirmation folder.
  *
  * @return bool Whether tidying occurred successfully.
  */
 public function tidy_old_messages()
 {
     // Grab the new IMAP client.
     if (!$this->get_imap_client()) {
         return false;
     }
     // Open the mailbox.
     mtrace("Searching for messages older than 24 hours in the '" . $this->get_confirmation_folder() . "' folder.");
     $this->client->openMailbox($this->get_confirmation_folder());
     $mailbox = $this->get_mailbox();
     // Build the search.
     $search = new \Horde_Imap_Client_Search_Query();
     // Delete messages older than 24 hours old.
     $search->intervalSearch(DAYSECS, \Horde_Imap_Client_Search_Query::INTERVAL_OLDER);
     $results = $this->client->search($mailbox, $search);
     // Build the base query.
     $query = new \Horde_Imap_Client_Fetch_Query();
     $query->envelope();
     // Retrieve the messages and mark them for removal.
     $messages = $this->client->fetch($mailbox, $query, array('ids' => $results['match']));
     mtrace("Found " . $messages->count() . " messages for removal.");
     foreach ($messages as $message) {
         $this->add_flag_to_message($message->getUid(), self::MESSAGE_DELETED);
     }
     mtrace("Finished removing messages.");
     $this->close_connection();
     return true;
 }
示例#2
0
 /**
  * @dataProvider intervalSearchQueryProvider
  */
 public function testIntervalSearchQuery($range, $not, $fuzzy, $expected)
 {
     $ob = new Horde_Imap_Client_Search_Query();
     $ob->intervalSearch(30, $range, $not, array('fuzzy' => $fuzzy));
     $this->assertEquals($expected, $fuzzy ? $this->_fuzzy($ob, array('WITHIN')) : strval($ob));
 }
示例#3
0
 public function getFromId()
 {
     $query = new Horde_Imap_Client_Search_Query();
     // 604800 = 60 seconds * 60 minutes * 24 hours * 7 days (1 week)
     $query->intervalSearch(604800, Horde_Imap_Client_Search_Query::INTERVAL_YOUNGER);
     $results = $this->imap_imp->search('INBOX', $query, array());
 }