PHP Class Horde_Imap_Client_Search_Query, horde

Allows translation between abstracted search criteria and a generated IMAP search criteria string suitable for sending to a remote IMAP server.
Author: Michael Slusarz ([email protected])
Inheritance: implements Serializable
显示文件 Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_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]).
$_search array The list of search params.

Public Methods

Method Description
__toString ( ) String representation: The IMAP search string.
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.
build ( Horde_Imap_Client_Base $exts = [] ) : array Builds an IMAP4rev1 compliant search string.
charset ( string $charset, boolean $convert = true ) Sets the charset of the search text.
dateSearch ( mixed $date, string $range, boolean $header = true, boolean $not = false, array $opts = [] ) Search for messages within a date range.
flag ( string $name, boolean $set = true, array $opts = [] ) Search for a flag/keywords.
flagSearch ( ) : boolean Determines if flags are a part of the search.
headerText ( string $header, string $text, boolean $not = false, array $opts = [] ) Search for text in the header of a message.
ids ( Horde_Imap_Client_Ids $ids, boolean $not = false, array $opts = [] ) Search for messages within a given UID range. Only one message range can be specified per query.
intervalSearch ( integer $interval, string $range, boolean $not = false, array $opts = [] ) 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.
modseq ( integer $value, string $name = null, string $type = null, boolean $not = false, array $opts = [] ) Search for messages modified since a specific moment. The IMAP server must support the CONDSTORE extension (RFC 7162) for this query to be used.
newMsgs ( boolean $newmsgs = true, array $opts = [] ) 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.
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.
previousSearch ( boolean $not = false, array $opts = [] ) Use the results from the previous SEARCH command. The IMAP server must support the SEARCHRES extension (RFC 5182) for this query to be used.
serialize ( ) : string Serialization.
size ( integer $size, boolean $larger = false, boolean $not = false, array $opts = [] ) Search for messages smaller/larger than a certain size.
text ( string $text, string $bodyonly = true, boolean $not = false, array $opts = [] ) Search for text in either the entire message, or just the body.
unserialize ( string $data ) Unserialization.

Protected Methods

Method Description
_addFuzzy ( boolean $add, array &$temp ) Adds fuzzy modifier to search keys.
_buildAndOr ( string $type, array $data, &$charset, &$exts_used, &$cmds ) : boolean Builds the AND/OR query.

Method Details

__toString() public method

String representation: The IMAP search string.
public __toString ( )

_addFuzzy() protected method

Adds fuzzy modifier to search keys.
protected _addFuzzy ( boolean $add, array &$temp )
$add boolean Add the fuzzy modifier?
$temp array Temporary build data.

_buildAndOr() protected method

Builds the AND/OR query.
protected _buildAndOr ( string $type, array $data, &$charset, &$exts_used, &$cmds ) : boolean
$type string 'AND' or 'OR'.
$data array Query data.
return boolean True if query might return results.

andSearch() public method

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.
public andSearch ( mixed $queries )
$queries mixed A query, or an array of queries, to AND with the current query.

build() public method

Builds an IMAP4rev1 compliant search string.
public build ( Horde_Imap_Client_Base $exts = [] ) : array
$exts Horde_Imap_Client_Base 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.
return 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.

charset() public method

Sets the charset of the search text.
public charset ( string $charset, boolean $convert = true )
$charset string The charset to use for the search.
$convert boolean Convert existing text values?

dateSearch() public method

Search for messages within a date range.
public dateSearch ( mixed $date, string $range, boolean $header = true, boolean $not = false, array $opts = [] )
$date mixed DateTime or Horde_Date object.
$range string Either: - Horde_Imap_Client_Search_Query::DATE_BEFORE - Horde_Imap_Client_Search_Query::DATE_ON - Horde_Imap_Client_Search_Query::DATE_SINCE
$header boolean If true, search using the date in the message headers. If false, search using the internal IMAP date (usually arrival time).
$not boolean If true, do a 'NOT' search of the range.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

flag() public method

Search for a flag/keywords.
public flag ( string $name, boolean $set = true, array $opts = [] )
$name string The flag or keyword name.
$set boolean If true, search for messages that have the flag set. If false, search for messages that do not have the flag set.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

flagSearch() public method

Determines if flags are a part of the search.
public flagSearch ( ) : boolean
return boolean True if search query involves flags.

headerText() public method

Search for text in the header of a message.
public headerText ( string $header, string $text, boolean $not = false, array $opts = [] )
$header string The header field.
$text string The search text.
$not boolean If true, do a 'NOT' search of $text.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

ids() public method

Search for messages within a given UID range. Only one message range can be specified per query.
public ids ( Horde_Imap_Client_Ids $ids, boolean $not = false, array $opts = [] )
$ids Horde_Imap_Client_Ids The list of UIDs to search.
$not boolean If true, do a 'NOT' search of the UIDs.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

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.

modseq() public method

Search for messages modified since a specific moment. The IMAP server must support the CONDSTORE extension (RFC 7162) for this query to be used.
public modseq ( integer $value, string $name = null, string $type = null, boolean $not = false, array $opts = [] )
$value integer The mod-sequence value.
$name string The entry-name string.
$type string Either 'shared', 'priv', or 'all'. Defaults to 'all'
$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.

newMsgs() public method

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.
public newMsgs ( boolean $newmsgs = true, array $opts = [] )
$newmsgs boolean If true, searches for new messages. Else, search for old messages.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

orSearch() public method

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.
public orSearch ( mixed $queries )
$queries mixed A query, or an array of queries, to OR with the current query.

previousSearch() public method

Use the results from the previous SEARCH command. The IMAP server must support the SEARCHRES extension (RFC 5182) for this query to be used.
public previousSearch ( boolean $not = false, array $opts = [] )
$not boolean If true, don't match the previous query.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

serialize() public method

Serialization.
public serialize ( ) : string
return string Serialized data.

size() public method

Search for messages smaller/larger than a certain size.
public size ( integer $size, boolean $larger = false, boolean $not = false, array $opts = [] )
$size integer The size (in bytes).
$larger boolean Search for messages larger than $size?
$not boolean If true, do a 'NOT' search of $text.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

text() public method

Search for text in either the entire message, or just the body.
public text ( string $text, string $bodyonly = true, boolean $not = false, array $opts = [] )
$text string The search text.
$bodyonly string If true, only search in the body of the message. If false, also search in the headers.
$not boolean If true, do a 'NOT' search of $text.
$opts array Additional options: - fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server MUST support RFC 6203.

unserialize() public method

Unserialization.
public unserialize ( string $data )
$data string Serialized data.

Property Details

$_charset protected_oe property

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]).
protected string $_charset
return string