Redmond theme
[squirrelmail.git] / functions / imap_asearch.php
index a742296b41966e62c1d27f3ce72c88930cd3f174..8ebbdc1733e1d088f58ccce5732fcca9686891f5 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * imap_search.php
  *
- * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * IMAP asearch routines
@@ -112,8 +112,7 @@ function sqimap_asearch_error_box($response, $query, $message, $link = '')
 {
        global $imap_error_titles;
 
-       //if (!array_key_exists($response, $imap_error_titles)) //php 4.0.6 compatibility
-       if (!in_array($response, array_keys($imap_error_titles)))
+       if (!array_key_exists($response, $imap_error_titles))
                $title = _("ERROR : Unknown imap response.");
        else
                $title = $imap_error_titles[$response];
@@ -329,21 +328,19 @@ function sqimap_array_merge_unique(&$to, $from)
  */
 function sqimap_run_search($imapConnection, $search_string, $search_charset)
 {
-       global $uid_support;
-
        /* 6.4.4 try OPTIONAL [CHARSET] specification first */
        if ($search_charset != '')
                $query = 'SEARCH CHARSET "' . strtoupper($search_charset) . '" ALL ' . $search_string;
        else
                $query = 'SEARCH ALL ' . $search_string;
        s_debug_dump('C:', $query);
-       $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, $uid_support);
+       $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, TRUE);
 
        /* 6.4.4 try US-ASCII charset if we tried an OPTIONAL [CHARSET] and received a tagged NO response (SHOULD be [BADCHARSET]) */
        if (($search_charset != '')  && (strtoupper($response) == 'NO')) {
                $query = 'SEARCH CHARSET US-ASCII ALL ' . $search_string;
                s_debug_dump('C:', $query);
-               $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, $uid_support);
+               $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, TRUE);
        }
        if (strtoupper($response) != 'OK') {
                sqimap_asearch_error_box($response, $query, $message);
@@ -379,13 +376,11 @@ function sqimap_run_search($imapConnection, $search_string, $search_charset)
  */
 function sqimap_run_sort($imapConnection, $search_string, $search_charset, $sort_criteria)
 {
-       global $uid_support;
-
        if ($search_charset == '')
                $search_charset = 'US-ASCII';
        $query = 'SORT (' . $sort_criteria . ') "' . strtoupper($search_charset) . '" ALL ' . $search_string;
        s_debug_dump('C:', $query);
-       $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, $uid_support);
+       $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, TRUE);
        s_debug_dump('S:', $response);
 
        /* 6.4 try US-ASCII charset if we received a tagged NO response (SHOULD be [BADCHARSET]) */
@@ -393,7 +388,7 @@ function sqimap_run_sort($imapConnection, $search_string, $search_charset, $sort
                s_debug_dump('S:', $readin);
                $query = 'SORT (' . $sort_criteria . ') US-ASCII ALL ' . $search_string;
                s_debug_dump('C:', $query);
-               $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, $uid_support);
+               $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, TRUE);
                s_debug_dump('S:', $response);
        }
 
@@ -430,8 +425,8 @@ function sqimap_run_sort($imapConnection, $search_string, $search_charset, $sort
  * @param string $search_charset mandatory charset
  * @param string $thread_algorithm the threading algorithm "ORDEREDSUBJECT" or "REFERENCES"
  * @return array an IDs or UIDs array of matching messages or an empty array
- * @global array $thread_new will be used by thread view in mailbox_display
- * @global array $server_sort_array will be used by thread view in mailbox_display
+ * @global array thread_new will be used by thread view in mailbox_display
+ * @global array server_sort_array will be used by thread view in mailbox_display
  */
 function sqimap_run_thread($imapConnection, $search_string, $search_charset, $thread_algorithm)
 {
@@ -447,13 +442,11 @@ function sqimap_run_thread($imapConnection, $search_string, $search_charset, $th
 
        $server_sort_array = array();
 
-       global $uid_support;
-
        if ($search_charset == '')
                $search_charset = 'US-ASCII';
        $query = 'THREAD ' . $thread_algorithm . ' "' . strtoupper($search_charset) . '" ALL ' . $search_string;
        s_debug_dump('C:', $query);
-       $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, $uid_support);
+       $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, TRUE);
        s_debug_dump('S:', $response);
 
        /* 6.4 try US-ASCII charset if we received a tagged NO response (SHOULD be [BADCHARSET]) */
@@ -461,7 +454,7 @@ function sqimap_run_thread($imapConnection, $search_string, $search_charset, $th
                s_debug_dump('S:', $readin);
                $query = 'THREAD ' . $thread_algorithm . ' US-ASCII ALL ' . $search_string;
                s_debug_dump('C:', $query);
-               $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, $uid_support);
+               $readin = sqimap_run_command($imapConnection, $query, false, $response, $message, TRUE);
                s_debug_dump('S:', $response);
        }
 
@@ -556,8 +549,8 @@ function sqimap_asearch_get_charset()
  * - reverse order by using REVERSE
  * @param string $mailbox mailbox name to sort
  * @param integer $sort_by sm sort criteria index
- * @global bool $internal_date_sort sort by arrival date instead of message date
- * @global string $sent_folder sent folder name
+ * @global bool internal_date_sort sort by arrival date instead of message date
+ * @global string sent_folder sent folder name
  * @return string imap sort criteria
  */
 function sqimap_asearch_get_sort_criteria($mailbox, $sort_by)
@@ -601,13 +594,13 @@ function sqimap_asearch_get_sub_mailboxes($cur_mailbox, $mboxes_array)
  * @param array $exclude_array
  * @param array $sub_array
  * @param array $mboxes_array selectable unformatted mailboxes names
- * @global bool $allow_server_sort comes from config.php
- * @global integer $sort sm internal sort order
- * @global bool $allow_thread_sort comes from config.php
- * @global bool $thread_sort_messages does it really need to global?
- * @global integer $sort_by_ref thread by references
- * @global string $data_dir
- * @global string $username
+ * @global bool allow_server_sort comes from config.php
+ * @global integer sort sm internal sort order
+ * @global bool allow_thread_sort comes from config.php
+ * @global bool thread_sort_messages does it really need to global?
+ * @global integer sort_by_ref thread by references
+ * @global string data_dir
+ * @global string username
  * @return array $mbox_msgs array(mailbox => array(UIDs))
  */
 function sqimap_asearch($imapConnection, $mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array, $mboxes_array)