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.
Copyright 2008-2012 Horde LLC (http://www.horde.org/)
See the enclosed file COPYING for license information (LGPL). If you
did not receive this file, see http://www.horde.org/licenses/lgpl21.
Methods summary
public
|
#
__toString( )
String representation: The IMAP search string.
String representation: The IMAP search string.
|
public
|
#
charset( string $charset, callable $callback = null )
Sets the charset of the search text.
Sets the charset of the search text.
Parameters
- $charset
- The charset to use for the search.
- $callback
- <p>A callback function to run on all text
values when the charset changes. It must
accept three parameters: the text, the old
charset (will be null if no charset was
previously given), and the new charset. It
should return the converted text value.</p>
|
public
array
|
#
build( array $exts = array() )
Builds an IMAP4rev1 compliant search string.
Builds an IMAP4rev1 compliant search string.
Parameters
- $exts
- <p>The list of extensions supported by the server.
This determines whether certain criteria can be
used, and determines whether workarounds are used
for other criteria. In the format returned by
Horde_Imap_Client_Base::capability(). If this value
is null, all extensions are assumed to be
available.</p>
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.
- imap4: (boolean) True if the search uses IMAP4 criteria (as opposed
to IMAP2 search criteria).
- query: (array) The IMAP search string.
Throws
|
public
|
#
flag( string $name, boolean $set = true, array $opts = array() )
Search for a flag/keywords.
Search for a flag/keywords.
Parameters
- $name
- The flag or keyword name.
- $set
- <p>If true, search for messages that have the flag
set. If false, search for messages that do not
have the flag set.</p>
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
boolean
|
#
flagSearch( )
Determines if flags are a part of the search.
Determines if flags are a part of the search.
Returns
boolean True if search query involves flags.
|
public
|
#
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.
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
- $newmsgs
- <p>If true, searches for new messages. Else,
search for old messages.</p>
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
|
#
text( string $text, string $bodyonly = true, boolean $not = false, array $opts = array() )
Search for text in either the entire message, or just the body.
Search for text in either the entire message, or just the body.
Parameters
- $text
- The search text.
- $bodyonly
- <p>If true, only search in the body of the
message. If false, also search in the headers.</p>
- $not
- If true, do a 'NOT' search of $text.
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
|
#
size( integer $size, boolean $larger = false, boolean $not = false, array $opts = array() )
Search for messages smaller/larger than a certain size.
Search for messages smaller/larger than a certain size.
Parameters
- $size
- The size (in bytes).
- $larger
- Search for messages larger than $size?
- $not
- If true, do a 'NOT' search of $text.
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
|
#
ids( Horde_Imap_Client_Ids $ids, boolean $not = false, array $opts = array() )
Search for messages within a given ID sequence range. Only one message
range can be specified per query.
Search for messages within a given ID sequence range. Only one message
range can be specified per query.
Parameters
- $ids
- The list of IDs to search.
- $not
- <p>If true, do a 'NOT' search of the
IDs.</p>
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
|
#
dateSearch( mixed $date, string $range, boolean $header = true, boolean $not = false, array $opts = array() )
Search for messages within a date range.
Search for messages within a date range.
Parameters
- $date
- DateTime or Horde_Date object.
- $range
- <p>Either:
- Horde_Imap_Client_Search_Query::DATE_BEFORE
- Horde_Imap_Client_Search_Query::DATE_ON
- Horde_Imap_Client_Search_Query::DATE_SINCE</p>
- $header
- <p>If true, search using the date in the message
headers. If false, search using the internal
IMAP date (usually arrival time).</p>
- $not
- If true, do a 'NOT' search of the range.
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
|
#
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.
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
- $interval
- Seconds from the present.
- $range
- <p>Either:
- Horde_Imap_Client_Search_Query::INTERVAL_OLDER
- Horde_Imap_Client_Search_Query::INTERVAL_YOUNGER</p>
- $not
- If true, do a 'NOT' search.
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
|
#
andSearch( array $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.
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
- $queries
- <p>An array of queries to AND with this one. Each
query is a Horde_Imap_Client_Search_Query
object.</p>
|
public
|
#
orSearch( array $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.
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
- $queries
- <p>An array of queries to OR with this one. Each
query is a Horde_Imap_Client_Search_Query
object.</p>
|
public
|
#
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 4551) for this query to be
used.
Search for messages modified since a specific moment. The IMAP server
must support the CONDSTORE extension (RFC 4551) for this query to be
used.
Parameters
- $value
- The mod-sequence value.
- $name
- The entry-name string.
- $type
- <p>Either 'shared', 'priv', or 'all'. Defaults to
'all'</p>
- $not
- If true, do a 'NOT' search.
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
|
#
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.
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
- $not
- If true, don't match the previous query.
- $opts
- <p>Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203.</p>
|
public
string
|
#
serialize( )
Serialization.
Returns
string Serialized data.
Implementation of
Serializable::serialize()
|
public
|
#
unserialize( string $data )
Unserialization.
Parameters
Throws
Exception
Implementation of
Serializable::unserialize()
|