/functions/imap_asearch.php

Description

imap_search.php

IMAP asearch routines

Subfolder search idea from Patch #806075 by Thomas Pohl xraven at users.sourceforge.net. Thanks Thomas!

Variables
bool $imap_asearch_debug_dump (line 28)

Set to TRUE to dump the IMAP dialogue

array $imap_asearch_months (line 76)

IMAP SEARCH month names encoding

array $imap_asearch_opcodes (line 33)

IMAP SEARCH keys

Functions
asearch_nz (line 133)

This is a convenient way to avoid spreading if (isset(... all over the code

  • return: if $var is unset, otherwise $var
mixed asearch_nz ( &$var, [mixed $def = ''], mixed $var)
  • mixed $var: any variable (reference)
  • mixed $def: default value to return if unset (default is zls (''), pass 0 or array() when appropriate)
  • &$var
asearch_unhtmlentities (line 146)

This should give the same results as PHP 4 >= 4.3.0's html_entity_decode(),

except it doesn't handle hex constructs

  • return: decoded string
string asearch_unhtmlentities (string $string)
  • string $string: string to unhtmlentity()
sqimap_array_merge_unique (line 285)

Another way to do array_values(array_unique(array_merge($to, $from)));

  • return: uniquely merged array
array sqimap_array_merge_unique ( &$to, array $from, array $to)
  • array $to: to array (reference)
  • array $from: from array
  • &$to
sqimap_asearch (line 408)

Create the search query strings for all given criteria and merge results for every mailbox

  • return: array(mailbox => array(UIDs))
array sqimap_asearch (resource $imapConnection,  &$mailbox_array,  &$biop_array,  &$unop_array,  &$where_array,  &$what_array,  &$exclude_array,  &$sub_array,  &$mboxes_array, array $mailbox_array, array $biop_array, array $unop_array, array $where_array, array $what_array, array $exclude_array, array $sub_array, array $mboxes_array)
  • resource $imapConnection
  • array $mailbox_array: (reference)
  • array $biop_array: (reference)
  • array $unop_array: (reference)
  • array $where_array: (reference)
  • array $what_array: (reference)
  • array $exclude_array: (reference)
  • array $sub_array: (reference)
  • array $mboxes_array: selectable unformatted mailboxes names (reference)
  • &$mailbox_array
  • &$biop_array
  • &$unop_array
  • &$where_array
  • &$what_array
  • &$exclude_array
  • &$sub_array
  • &$mboxes_array
sqimap_asearch_build_criteria (line 226)

Build one criteria sequence

string sqimap_asearch_build_criteria (string $opcode, string $what, string $charset)
  • string $opcode: search opcode
  • string $what: opcode argument
  • string $charset: search charset
sqimap_asearch_encode_string (line 168)

Encode a string to quoted or literal as defined in rfc 3501

  • 4.3 String: A quoted string is a sequence of zero or more 7-bit characters, excluding CR and LF, with double quote (<">) characters at each end.
  • 9. Formal Syntax: quoted-specials = DQUOTE / "\"

  • return: encoded string
string sqimap_asearch_encode_string (string $what, string $charset)
  • string $what: string to encode
  • string $charset: search charset used
sqimap_asearch_error_box (line 102)

Function to display an error related to an IMAP query.

We need to do our own error management since we may receive NO responses on purpose (even BAD with SORT or THREAD) so we call sqimap_error_box() if the function exists (sm >= 1.5) or use our own embedded code

  • global: array $color: imap_error_titles
void sqimap_asearch_error_box (string $response, string $query, string $message, [string $link = ''])
  • string $response: the imap server response code
  • string $query: the failed query
  • string $message: an optional error message
  • string $link: an optional link to try again
sqimap_asearch_get_charset (line 344)
  • return: the user defined charset if $allow_charset_search is TRUE else zls ('')
  • global: bool $allow_charset_search: allow_charset_search user setting
  • global: array $languages: languages sm languages array
  • global: string $squirrelmail_language: squirrelmail_language user language setting
string sqimap_asearch_get_charset ()
sqimap_asearch_get_sort_criteria (line 364)

Convert SquirrelMail internal sort to IMAP sort taking care of:

  • user defined date sorting (ARRIVAL vs DATE)
  • if the searched mailbox is the sent folder then TO is being used instead of FROM
  • reverse order by using REVERSE

  • return: imap sort criteria
  • global: bool $internal_date_sort: internal_date_sort sort by arrival date instead of message date
  • global: string $sent_folder: sent_folder sent folder name
string sqimap_asearch_get_sort_criteria (string $mailbox, integer $sort_by)
  • string $mailbox: mailbox name to sort
  • integer $sort_by: sm sort criteria index
sqimap_asearch_get_sub_mailboxes (line 384)
  • return: sub mailboxes unformatted names
array sqimap_asearch_get_sub_mailboxes (string $cur_mailbox,  &$mboxes_array, array $boxes_unformatted)
  • string $cur_mailbox: unformatted mailbox name
  • array $boxes_unformatted: selectable mailbox unformatted names array (reference)
  • &$mboxes_array
sqimap_asearch_parse_date (line 188)

Parses a user date string into an rfc 3501 date string

Handles space, slash, backslash, dot and comma as separators (and dash of course ;=)

  • return: a preg_match-style array:
    • [0] = fully formatted rfc 3501 date string (<day number>-<US month TLA>-<4 digit year>)
    • [1] = day
    • [2] = month
    • [3] = year
  • global: array $imap_asearch_months: imap_asearch_months
array sqimap_asearch_parse_date (string $what)
  • string $what: user date
sqimap_run_search (line 306)

Run the IMAP SEARCH command as defined in rfc 3501

array sqimap_run_search (resource $imapConnection, string $search_string, string $search_charset)
  • resource $imapConnection: the current imap stream
  • string $search_string: the full search expression eg "ALL RECENT"
  • string $search_charset: charset to use or zls ('')

Documentation generated on Fri, 18 Apr 2014 04:18:06 +0200 by phpDocumentor 1.4.3