\Horde_Imap_Client_Search_Query

Abstraction of the IMAP4rev1 search criteria (see RFC 3501 [6.4.4]).

Allows translation between abstracted search criteria and a generated IMAP search criteria string suitable for sending to a remote IMAP server.

Summary

Methods
Properties
Constants
__toString()
charset()
build()
flag()
flagSearch()
newMsgs()
headerText()
text()
size()
ids()
dateSearch()
dateTimeSearch()
intervalSearch()
andSearch()
orSearch()
modseq()
previousSearch()
serialize()
unserialize()
No public properties found
VERSION
DATE_BEFORE
DATE_ON
DATE_SINCE
INTERVAL_OLDER
INTERVAL_YOUNGER
_buildAndOr()
_addFuzzy()
$_charset
$_search
N/A
No private methods found
No private properties found
N/A

Constants

VERSION

VERSION

Serialized version.

DATE_BEFORE

DATE_BEFORE

Constants for dateSearch()

DATE_ON

DATE_ON

DATE_SINCE

DATE_SINCE

INTERVAL_OLDER

INTERVAL_OLDER

Constants for intervalSearch()

INTERVAL_YOUNGER

INTERVAL_YOUNGER

Properties

$_charset

$_charset : string

The charset of the search strings. All text strings must be in this charset. By default, this is 'US-ASCII' (see RFC 3501 [6.4.4]).

Type

string

$_search

$_search : array

The list of search params.

Type

array

Methods

__toString()

__toString() 

String representation: The IMAP search string.

charset()

charset(string  $charset, boolean  $convert = true) 

Sets the charset of the search text.

Parameters

string $charset

The charset to use for the search.

boolean $convert

Convert existing text values?

Throws

\Horde_Imap_Client_Exception_SearchCharset

build()

build(\Horde_Imap_Client_Base  $exts = array()) : array

Builds an IMAP4rev1 compliant search string.

Parameters

\Horde_Imap_Client_Base $exts

The server object this query will be run on (@since 2.24.0), a Horde_Imap_Client_Data_Capability object (@since 2.24.0), or the list of extensions present on the server (@deprecated). If null, all extensions are assumed to be available.

Throws

\Horde_Imap_Client_Data_Format_Exception
\Horde_Imap_Client_Exception_NoSupportExtension

Returns

array —

An array with these elements:

  • charset: (string) The charset of the search string. If null, no text strings appear in query.
  • exts: (array) The list of IMAP extensions used to create the string.
  • query: (Horde_Imap_Client_Data_Format_List) The IMAP search command.

flag()

flag(string  $name, boolean  $set = true, array  $opts = array()) 

Search for a flag/keywords.

Parameters

string $name

The flag or keyword name.

boolean $set

If true, search for messages that have the flag set. If false, search for messages that do not have the flag set.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

flagSearch()

flagSearch() : boolean

Determines if flags are a part of the search.

Returns

boolean —

True if search query involves flags.

newMsgs()

newMsgs(boolean  $newmsgs = true, array  $opts = array()) 

Search for either new messages (messages that have the '\Recent' flag but not the '\Seen' flag) or old messages (messages that do not have the '\Recent' flag). If new messages are searched, this will clear any '\Recent' or '\Unseen' flag searches. If old messages are searched, this will clear any '\Recent' flag search.

Parameters

boolean $newmsgs

If true, searches for new messages. Else, search for old messages.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

headerText()

headerText(string  $header, string  $text, boolean  $not = false, array  $opts = array()) 

Search for text in the header of a message.

Parameters

string $header

The header field.

string $text

The search text.

boolean $not

If true, do a 'NOT' search of $text.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

text()

text(string  $text, string  $bodyonly = true, boolean  $not = false, array  $opts = array()) 

Search for text in either the entire message, or just the body.

Parameters

string $text

The search text.

string $bodyonly

If true, only search in the body of the message. If false, also search in the headers.

boolean $not

If true, do a 'NOT' search of $text.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

size()

size(integer  $size, boolean  $larger = false, boolean  $not = false, array  $opts = array()) 

Search for messages smaller/larger than a certain size.

Parameters

integer $size

The size (in bytes).

boolean $larger

Search for messages larger than $size?

boolean $not

If true, do a 'NOT' search of $text.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

ids()

ids(\Horde_Imap_Client_Ids  $ids, boolean  $not = false, array  $opts = array()) 

Search for messages within a given UID range. Only one message range can be specified per query.

Parameters

\Horde_Imap_Client_Ids $ids

The list of UIDs to search.

boolean $not

If true, do a 'NOT' search of the UIDs.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

dateSearch()

dateSearch(mixed  $date, string  $range, boolean  $header = true, boolean  $not = false, array  $opts = array()) 

Search for messages within a date range.

Parameters

mixed $date

DateTime or Horde_Date object.

string $range

Either:

  • Horde_Imap_Client_Search_Query::DATE_BEFORE
  • Horde_Imap_Client_Search_Query::DATE_ON
  • Horde_Imap_Client_Search_Query::DATE_SINCE
boolean $header

If true, search using the date in the message headers. If false, search using the internal IMAP date (usually arrival time).

boolean $not

If true, do a 'NOT' search of the range.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

dateTimeSearch()

dateTimeSearch(mixed  $date, string  $range, boolean  $header = true, boolean  $not = false, array  $opts = array()) 

Search for messages within a date and time range.

Parameters

mixed $date

DateTime or Horde_Date object.

string $range

Either:

  • Horde_Imap_Client_Search_Query::DATE_BEFORE
  • Horde_Imap_Client_Search_Query::DATE_ON
  • Horde_Imap_Client_Search_Query::DATE_SINCE
boolean $header

If true, search using the date in the message headers. If false, search using the internal IMAP date (usually arrival time).

boolean $not

If true, do a 'NOT' search of the range.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

intervalSearch()

intervalSearch(integer  $interval, string  $range, boolean  $not = false, array  $opts = array()) 

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.

Parameters

integer $interval

Seconds from the present.

string $range

Either:

  • Horde_Imap_Client_Search_Query::INTERVAL_OLDER
  • Horde_Imap_Client_Search_Query::INTERVAL_YOUNGER
boolean $not

If true, do a 'NOT' search.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

andSearch()

andSearch(mixed  $queries) 

AND queries - the contents of this query will be AND'ed (in its entirety) with the contents of EACH of the queries passed in. All AND'd queries must share the same charset as this query.

Parameters

mixed $queries

A query, or an array of queries, to AND with the current query.

orSearch()

orSearch(mixed  $queries) 

OR a query - the contents of this query will be OR'ed (in its entirety) with the contents of EACH of the queries passed in. All OR'd queries must share the same charset as this query. All contents of any single query will be AND'ed together.

Parameters

mixed $queries

A query, or an array of queries, to OR with the current query.

modseq()

modseq(integer  $value, string  $name = null, string  $type = null, boolean  $not = false, array  $opts = array()) 

Search for messages modified since a specific moment. The IMAP server must support the CONDSTORE extension (RFC 7162) for this query to be used.

Parameters

integer $value

The mod-sequence value.

string $name

The entry-name string.

string $type

Either 'shared', 'priv', or 'all'. Defaults to 'all'

boolean $not

If true, do a 'NOT' search.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

previousSearch()

previousSearch(boolean  $not = false, array  $opts = array()) 

Use the results from the previous SEARCH command. The IMAP server must support the SEARCHRES extension (RFC 5182) for this query to be used.

Parameters

boolean $not

If true, don't match the previous query.

array $opts

Additional options:

  • fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

serialize()

serialize() : string

Serialization.

Returns

string —

Serialized data.

unserialize()

unserialize(string  $data) 

Unserialization.

Parameters

string $data

Serialized data.

Throws

\Exception

_buildAndOr()

_buildAndOr(string  $type, array  $data,   $charset,   $exts_used,   $cmds) : boolean

Builds the AND/OR query.

Parameters

string $type

'AND' or 'OR'.

array $data

Query data.

$charset
$exts_used
$cmds

Returns

boolean —

True if query might return results.

_addFuzzy()

_addFuzzy(boolean  $add, array  $temp) 

Adds fuzzy modifier to search keys.

Parameters

boolean $add

Add the fuzzy modifier?

array $temp

Temporary build data.

Throws

\Horde_Imap_Client_Exception_NoSupport_Extension