Next/Previous are working a bit better
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 23 Nov 1999 00:43:10 +0000 (00:43 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 23 Nov 1999 00:43:10 +0000 (00:43 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@18 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/date.php3
functions/mailbox_display.php3
src/right_main.php3

index 83aae61..9e07dc7 100644 (file)
@@ -4,8 +4,8 @@
     **
     **  Takes a date and parses it into a usable format.  The form that a
     **  date SHOULD arrive in is:
-    **        Tue, 29 Jun 1999 09:52:11 -0500 (EDT)
-    **  (as specified in RFC 822)
+    **        <Tue,> 29 Jun 1999 09:52:11 -0500 (EDT)
+    **  (as specified in RFC 822) -- "Tue" is optional
     **
     **/
 
    }
 
    function getTimeStamp($dateParts) {
-//      if (eregi("mon|tue|wed|thu|fri|sat|sun", $dateParts[0], $tmp)) {
+      if (eregi("mon|tue|wed|thu|fri|sat|sun", $dateParts[0], $tmp)) {
          $d[0] = getHour($dateParts[4]);
          $d[1] = getMinute($dateParts[4]);
          $d[2] = getSecond($dateParts[4]);
          $d[4] = getDayOfMonth($dateParts[1]);
          $d[5] = getYear($dateParts[3]);
          return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
-//      }
-//      $d[0] = getHour($dateParts[3]);
-//      $d[1] = getMinute($dateParts[3]);
-//      $d[2] = getSecond($dateParts[3]);
-//      $d[3] = getMonthNum($dateParts[1]);
-//      $d[4] = getDayOfMonth($dateParts[0]);
-//      $d[5] = getYear($dateParts[2]);
-//      return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
+      }
+      $d[0] = getHour($dateParts[3]);
+      $d[1] = getMinute($dateParts[3]);
+      $d[2] = getSecond($dateParts[3]);
+      $d[3] = getMonthNum($dateParts[1]);
+      $d[4] = getDayOfMonth($dateParts[0]);
+      $d[5] = getYear($dateParts[2]);
+      return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
    }
 ?>
index 2666e3a..ef78d7b 100644 (file)
     ** This function loops through a group of messages in the mailbox and shows them
     **/
    function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) {
-      $i = 0;
       $j = 1;
       while ($j <= $numMessages) {
+         $q = 0;
          getMessageHeaders($imapConnection, $j, $from, $subject, $date);
          getMessageFlags($imapConnection, $j, $flags);
 
-         $messages[$i]["TIME_STAMP"] = getTimeStamp(explode(" ", trim($date)));
-         $messages[$i]["DATE_STRING"] = getDateString(explode(" ", trim($date)));
-         $messages[$i]["ID"] = $j;
-         $messages[$i]["FROM"] = $from;
-         $messages[$i]["SUBJECT"] = $subject;
-
-         $messages[$i]["FLAG_DELETED"] = false;
-         $messages[$i]["FLAG_ANSWERED"] = false;
-         $messages[$i]["FLAG_SEEN"] = false;
+         $messages[$j]["TIME_STAMP"] = getTimeStamp(explode(" ", trim($date)));
+         $messages[$j]["DATE_STRING"] = getDateString(explode(" ", trim($date)));
+         $messages[$j]["ID"] = $j;
+         $messages[$j]["FROM"] = $from;
+         $messages[$j]["SUBJECT"] = $subject;
+         $messages[$j]["FLAG_DELETED"] = false;
+         $messages[$j]["FLAG_ANSWERED"] = false;
+         $messages[$j]["FLAG_SEEN"] = false;
 
-         $q = 0;
          while ($q < count($flags)) {
-            if ($flags[$q] == "Deleted")
-               $messages[$i]["FLAG_DELETED"] = true;
-            else if ($flags[$q] == "Answered")
-               $messages[$i]["FLAG_ANSWERED"] = true;
-            else if ($flags[$q] == "Seen")
-               $messages[$i]["FLAG_SEEN"] = true;
+            if ($flags[$q] == "Deleted") {
+               $messages[$j]["FLAG_DELETED"] = true;
+            }
+            else if ($flags[$q] == "Answered") {
+               $messages[$j]["FLAG_ANSWERED"] = true;
+            }
+            else if ($flags[$q] == "Seen") {
+               $messages[$j]["FLAG_SEEN"] = true;
+            }
             $q++;
          }
 
-         if ($messages[$i]["FLAG_DELETED"] == false)
-            $i++;
+         $j++;
+      }
+
+      /** Find and remove the ones that are deleted */
+      $i = 1;
+      $j = 1;
+      while ($j <= $numMessages) {
+         if ($messages[$j]["FLAG_DELETED"] == true) {
+            $j++;
+            continue;
+         }
+         $msgs[$i]["TIME_STAMP"]    = $messages[$j]["TIME_STAMP"];
+         $msgs[$i]["DATE_STRING"]   = $messages[$j]["DATE_STRING"];
+         $msgs[$i]["ID"]            = $messages[$j]["ID"];
+         $msgs[$i]["FROM"]          = $messages[$j]["FROM"];
+         $msgs[$i]["SUBJECT"]       = $messages[$j]["SUBJECT"];
+         $msgs[$i]["FLAG_DELETED"]  = $messages[$j]["FLAG_DELETED"];
+         $msgs[$i]["FLAG_ANSWERED"] = $messages[$j]["FLAG_ANSWERED"];
+         $msgs[$i]["FLAG_SEEN"]     = $messages[$j]["FLAG_SEEN"];
+         $i++;
          $j++;
       }
 
       $numMessagesOld = $numMessages;
-      $numMessages = $i;
+      $numMessages = $i - 1;
 
       if ($sort == 0)
-         $msgs = ary_sort($messages, "TIME_STAMP", -1);
+         $msgs = ary_sort($msgs, "TIME_STAMP", -1);
       else
-         $msgs = ary_sort($messages, "TIME_STAMP", 1);
+         $msgs = ary_sort($msgs, "TIME_STAMP", 1);
 
       if ($startMessage + 24 < $numMessages) {
-         $nextGroup = $startMessage + 24 + 1; // +1 to go to beginning of next group
          $endMessage = $startMessage + 24;
       } else {
-         $nextGroup = -1;
          $endMessage = $numMessages;
       }
 
+      $nextGroup = $startMessage + 25;
       $prevGroup = $startMessage - 25;
 
-      echo "Messages:  $numMessages, $numMessagesOld<BR>";
+      echo "Messages:  $numMessages, $numMessagesOld -- ";
       echo "Start:     $startMessage to $endMessage<BR>";
-      echo "NextGroup: $nextGroup<BR>";
+      echo "NextGroup: $nextGroup -- ";
       echo "PrevGroup: $prevGroup<BR>";
 
-      if (($nextGroup > -1) && ($prevGroup > 0)) {
+      if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
          echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\">Next</A>\n";
          echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$prevGroup&mailbox=$mailbox\" TARGET=\"right\">Previous</A>\n";
       }
-      else if (($nextGroup == -1) && ($prevGroup >= 0)) {
+      else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
          echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$prevGroup&mailbox=$mailbox\" TARGET=\"right\">Previous</A>\n";
       }
-      else if (($nextGroup > -1) && ($prevGroup < 0)) {
+      else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
          echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\">Next</A>\n";
       }
 
index ab5cd7d..7e16f0b 100644 (file)
@@ -83,7 +83,6 @@
    displayPageHeader($mailbox);
 
    // Get the list of messages for this mailbox
-   echo "$numMessages : $startMessage : $sort<BR><BR>";
    showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort);
 
    // close the connection