final fix for thread sort indent before 1.2.6
authorjmunro <jmunro@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 29 Apr 2002 22:23:44 +0000 (22:23 +0000)
committerjmunro <jmunro@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 29 Apr 2002 22:23:44 +0000 (22:23 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2769 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_messages.php

index 12cf11a75a4ed689158af7508800235fc7b61b9b..7185482c7aa6dcc7e4e5d6b8db9e28dadb03d107 100755 (executable)
@@ -171,7 +171,7 @@ function get_parent_level ($imap_stream) {
     } 
     $indent_array = array();
         if (!$thread_new) {
-                $thread_new = array();
+            $thread_new = array();
         }
     /* looping through the parts of one message thread */
     
@@ -190,7 +190,8 @@ function get_parent_level ($imap_stream) {
        to get the indent level
     */
         $level = 0;
-        $spaces = 0;
+        $spaces = array();
+        $spaces_total = 0;
         $indent = 0;
         $fake = FALSE;
         for ($k=1;$k<(count($thread_new[$i]))-1;$k++) {
@@ -200,7 +201,7 @@ function get_parent_level ($imap_stream) {
             }
             if (isset($chars['41'])) {      /* testing for ) */
                 $level = $level - $chars['41'];
-                $spaces = 0;
+                $spaces[$level] = 0;
                 /* if we were faking lets stop, this portion
                    of the thread is over
                 */
@@ -209,9 +210,17 @@ function get_parent_level ($imap_stream) {
                 }
             }
             if (isset($chars['32'])) {      /* testing for space */
-                $spaces = $spaces + $chars['32'];
+                if (!isset($spaces[$level])) {
+                    $spaces[$level] = 0;
+                }
+                $spaces[$level] = $spaces[$level] + $chars['32'];
+            }
+            for ($x=0;$x<=$level;$x++) {
+                if (isset($spaces[$x])) {
+                    $spaces_total = $spaces_total + $spaces[$x];
+                }
             }
-            $indent = $level + $spaces;
+            $indent = $level + $spaces_total;
             /* must have run into a message that broke the thread
                so we are adjusting for that portion
             */
@@ -233,6 +242,7 @@ function get_parent_level ($imap_stream) {
                errors would occur
             */
             $indent_array[$child] = abs($indent);
+            $spaces_total = 0;
         }    
     }
     return $indent_array;
@@ -275,7 +285,9 @@ function get_thread_sort ($imap_stream) {
           $server_sort_array = 'no';
           return $server_sort_array;
        }
-    $thread_temp = preg_split("//", $thread_list, -1, PREG_SPLIT_NO_EMPTY);
+    if (isset($thread_list)) {
+        $thread_temp = preg_split("//", $thread_list, -1, PREG_SPLIT_NO_EMPTY);
+    }
     $char_count = count($thread_temp);
     $counter = 0;
     $thread_new = array();