Take the thread type user setting in account
authoralex-brainstorm <alex-brainstorm@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 11 Nov 2003 00:35:06 +0000 (00:35 +0000)
committeralex-brainstorm <alex-brainstorm@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 11 Nov 2003 00:35:06 +0000 (00:35 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6140 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_asearch.php

index b986dbc861ae4059c9a3b843e4bc7eba46ffe8d7..a742296b41966e62c1d27f3ce72c88930cd3f174 100644 (file)
@@ -605,13 +605,14 @@ function sqimap_asearch_get_sub_mailboxes($cur_mailbox, $mboxes_array)
  * @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)
 {
-       global $allow_server_sort, $sort, $allow_thread_sort, $thread_sort_messages;
+       global $allow_server_sort, $sort, $allow_thread_sort, $thread_sort_messages, $sort_by_ref;
        global $data_dir, $username;
 
        $search_charset = sqimap_asearch_get_charset();
@@ -636,7 +637,10 @@ function sqimap_asearch($imapConnection, $mailbox_array, $biop_array, $unop_arra
                                        sqimap_mailbox_select($imapConnection, $cur_mailbox);
                                        $thread_sort_messages = $allow_thread_sort && getPref($data_dir, $username, 'thread_' . $cur_mailbox);
                                        if ($thread_sort_messages) {
-                                               $thread_algorithm = 'REFERENCES';
+                                               if ($sort_by_ref == 1)
+                                                       $thread_algorithm = 'REFERENCES';
+                                               else
+                                                       $thread_algorithm = 'ORDEREDSUBJECT';
                                                $found_msgs = sqimap_run_thread($imapConnection, $search_string, $search_charset, $thread_algorithm);
                                        }
                                        else