fixed problems with not sorting.. sorts descending now with newest on top
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 12 Nov 2000 06:17:51 +0000 (06:17 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 12 Nov 2000 06:17:51 +0000 (06:17 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@845 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mailbox_display.php

index e93a9e0..60b2085 100644 (file)
                   $size[$q] = $hdr->size;
                   $type[$q] = $hdr->type0;
                   $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
+                  $id[$q] = $q + 1;
                }
             } else {
                // if it's not sorted
                      $startMessage = 1;
                }
 
-               $j = $startMessage - 1;;
-               echo $startMessage . " - " . $endMessage . "<br>";
-               for ($q = $startMessage; $q <= $endMessage; $q++) {
+
+               $real_startMessage = $numMessages - $startMessage + 1;
+               $real_endMessage = $numMessages - $startMessage - $show_num;
+               
+               $j = 0;
+               for ($q = $real_startMessage; $q >= $real_endMessage; $q--) {
                   if($mailbox == $sent_folder)
                      $hdr = sqimap_get_small_header ($imapConnection, $q, true);
                   else
                   $size[$j] = $hdr->size;
                   $type[$j] = $hdr->type0;
                   $flags[$j] = sqimap_get_flags ($imapConnection, $q);
+                  $id[$j] = $q;
                   $j++;
                }
             }   
 
             $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);
             $messages[$j]["DATE_STRING"] = getDateString($messages[$j]["TIME_STAMP"]);
-            $messages[$j]["ID"] = $j+1;
+            $messages[$j]["ID"] = $id[$j];
             $messages[$j]["FROM"] = decodeHeader($from[$j]);
             $messages[$j]["FROM-SORT"] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
             $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
          "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
           $mailbox, $sort, $Message, $More);
 
+      if ($sort == 6)
+         $endVar = $show_num;
+      else
+         $endVar = $endMessage + 1;
       
       // loop through and display the info for each message.
       $t = 0; // $t is used for the checkbox number
          echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
          echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp;</CENTER></TD></TR>";
       } elseif ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
-         $i = $startMessage;
+         if ($sort != 6)
+            $i = $startMessage;
+         else
+            $i = 1;
          reset($msort);
          do {
             $key = key($msort);
          } while (isset ($key) && ($k < $i));
          printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, 0, 0);
       } else {
-         $i = $startMessage;
+         if ($sort != 6)
+            $i = $startMessage;
+         else
+            $i = 1;
          reset($msort);
          do {
             $key = key($msort);
             $t++;
             $i++;
             next($msort);
-         } while ($i < ($endMessage+1));
+         } while ($i < $endVar);
       }
       echo "</TABLE>";