This updates the next/previous option. It kinda works, but not fully yet.
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 22 Nov 1999 20:39:47 +0000 (20:39 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 22 Nov 1999 20:39:47 +0000 (20:39 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@16 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mailbox_display.php3
src/left_main.php3
src/right_main.php3

index d04a3e1..83bcca2 100644 (file)
     **
     **/
 
-   function printMessageInfo($imapConnection, $i, $from, $subject, $date) {
-      getMessageHeaders($imapConnection, $i, $from, $subject, $date);
-      getMessageFlags($imapConnection, $i, $flags);
+   function printMessageInfo($imapConnection, $i, $from, $subject, $date, $answered, $seen) {
+//      getMessageHeaders($imapConnection, $i, $from, $subject, $date);
       $dateParts = explode(" ", trim($date));
       $dateString = getDateString($dateParts);  // this will reformat the date string into a good format for us.
       $senderName = getSenderName($from);
       if (strlen(Chop($subject)) == 0)
          $subject = "(no subject)";
 
-      $j = 0;
-      $deleted = false;
-      $seen = false;
-      $answered = false;
-      while ($j < count($flags)) {
-         if ($flags[$j] == "Deleted") {
-            $deleted = true;
-         } else if ($flags[$j] == "Answered") {
-            $answered = true;
-         } else if ($flags[$j] == "Seen") {
-            $seen = true;
+      echo "<TR>\n";
+      if ($seen == false) {
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$i</B></FONT></TD>\n";
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$senderName</B></FONT></TD>\n";
+         echo "   <TD><CENTER><B><FONT FACE=\"Arial,Helvetica\">$dateString</FONT></B></CENTER></TD>\n";
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT></TD>\n";
+      } else {
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\">$i</FONT></TD>\n";
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\">$senderName</FONT></TD>\n";
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><CENTER>$dateString</CENTER></FONT></TD>\n";
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\">$subject</FONT></TD>\n";
+      }
+      echo "</TR>\n";
+   }
+
+   /**
+    ** This function loops through a group of messages in the mailbox and shows them
+    **/
+   function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort) {
+      $i = 1;
+      $j = 1;
+      while ($j <= $numMessages) {
+         getMessageHeaders($imapConnection, $j, $from, $subject, $date);
+         getMessageFlags($imapConnection, $j, $flags);
+
+         echo "$date --";
+         $messages[$i]["DATE"] = getTimeStamp(explode(" ", trim($date)));
+         $messages[$i]["ID"] = $j;
+         $messages[$i]["FROM"] = $from;
+         $messages[$i]["SUBJECT"] = $subject;
+//         echo "$messages[$i][\"DATE\"]<BR>";
+
+         $messages[$i]["FLAG_DELETED"] = false;
+         $messages[$i]["FLAG_ANSWERED"] = false;
+         $messages[$i]["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;
+            $q++;
          }
+
+         if ($messages[$i]["FLAG_DELETED"] == false)
+            $i++;
          $j++;
       }
 
-      if ($deleted == false) {
-         echo "<TR>\n";
-         if ($seen == false) {
-            echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$i</B></FONT></TD>\n";
-            echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$senderName</B></FONT></TD>\n";
-            echo "   <TD><CENTER><B><FONT FACE=\"Arial,Helvetica\">$dateString</FONT></B></CENTER></TD>\n";
-            echo "   <TD><FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT></TD>\n";
-         } else {
-            echo "   <TD><FONT FACE=\"Arial,Helvetica\">$i</FONT></TD>\n";
-            echo "   <TD><FONT FACE=\"Arial,Helvetica\">$senderName</FONT></TD>\n";
-            echo "   <TD><FONT FACE=\"Arial,Helvetica\"><CENTER>$dateString</CENTER></FONT></TD>\n";
-            echo "   <TD><FONT FACE=\"Arial,Helvetica\">$subject</FONT></TD>\n";
-         }
-         echo "</TR>\n";
+      $numMessagesOld = $numMessages;
+      $numMessages = $i;
+
+      if ($sort == 0)
+         $msgs = ary_sort($messages, "DATE", -1);
+      else
+         $msgs = ary_sort($messages, "DATE", 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;
+      }
+
+      $prevGroup = $startMessage - 25;
+
+      echo "Messages:  $numMessages, $numMessagesOld<BR>";
+      echo "Start:     $startMessage to $endMessage<BR>";
+      echo "NextGroup: $nextGroup<BR>";
+      echo "PrevGroup: $prevGroup<BR>";
+
+      if (($nextGroup > -1) && ($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)) {
+         echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$prevGroup&mailbox=$mailbox\" TARGET=\"right\">Previous</A>\n";
       }
+      else if (($nextGroup > -1) && ($prevGroup < 0)) {
+         echo "<A HREF=\"right_main.php3?sort=$sort&startMessage=$nextGroup&mailbox=$mailbox\" TARGET=\"right\">Next</A>\n";
+      }
+
+      /** This is the beginning of the message list table.  It wraps around all messages */
+      echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1>";
+      echo "<TR><TD BGCOLOR=DCDCDC>";
+      echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=FFFFFF>";
+      echo "<TR BGCOLOR=FFFFCC ALIGN=\"center\">";
+      echo "   <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>Num</B></FONT></TD>";
+      echo "   <TD WIDTH=25%><FONT FACE=\"Arial,Helvetica\"><B>From</B></FONT></TD>";
+      echo "   <TD WIDTH=15%><FONT FACE=\"Arial,Helvetica\"><B>Date</B></FONT>";
+      if ($sort == 0)
+         echo "   <A HREF=\"right_main.php3?sort=1&startMessage=1&mailbox=$mailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
+      else
+         echo "   <A HREF=\"right_main.php3?sort=0&startMessage=1&mailbox=$mailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
+      echo "   <TD WIDTH=*><FONT FACE=\"Arial,Helvetica\"><B>Subject</B></FONT></TD>\n";
+      echo "</TR>";
+
+      // loop through and display the info for each message.
+      for ($i = $startMessage;$i <= $endMessage; $i++) {
+         printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"]);
+      }
+
+      echo "</TABLE>\n";
+      echo "</TD></TR></TABLE>"; /** End of message-list table */
    }
 ?>
\ No newline at end of file
index 60232d2..7a2d670 100644 (file)
@@ -85,7 +85,7 @@
          echo "&nbsp;&nbsp;";
       
       $mailboxURL = urlencode($mailbox);
-      echo "<a href=\"right_main.php3?sort=0&startMessage=0&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
+      echo "<a href=\"right_main.php3?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\"><FONT FACE=\"Arial,Helvetica\">";
       echo readShortMailboxName($mailbox, ".");
       echo "</FONT></a><br>\n";
    }
index b647a6b..eb8e378 100644 (file)
 
    // switch to the mailbox, and get the number of messages in it.
    selectMailbox($imapConnection, $mailbox, $numMessages);
+   $numMessages = $numMessages - 1;  // I did this so it's 0 based like the message array
 
    // make a URL safe $mailbox for use in the links
    $urlMailbox = urlencode($mailbox);
-  
-   displayPageHeader($mailbox);
-   $i = 1;
-   while ($i <= $numMessages) {
-      getMessageHeaders($imapConnection, $i, $from, $subject, $date);
-
-      $messages[$i]["DATE"] = getTimeStamp(explode(" ", trim($date)));
-      $messages[$i]["ID"] = $i;
-      $messages[$i]["FROM"] = $from;
-      $messages[$i]["SUBJECT"] = $subject;
-      $i++;
-   }
-
-   if ($sort == 0)
-      $msgs = ary_sort($messages, "DATE", -1);
-   else
-      $msgs = ary_sort($messages, "DATE", 1);
-
-   if ($endMessage > 24) {
-      echo "<A HREF=\"right_main.php3?sort=1&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\"><FONT FACE=\"Arial,Helvetica\">Next</FONT></A>&nbsp&nbsp&nbsp";
-      $endMessage = 24;
-   }
-
-   /** Display "Next, Previous" on top */
-
-   /** This is the beginning of the message list table.  It wraps around all messages */
-   echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1>";
-   echo "<TR><TD BGCOLOR=DCDCDC>";
-   echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=FFFFFF>";
-   echo "<TR BGCOLOR=FFFFCC ALIGN=\"center\">";
-   echo "   <TD WIDTH=5%><FONT FACE=\"Arial,Helvetica\"><B>Num</B></FONT></TD>";
-   echo "   <TD WIDTH=25%><FONT FACE=\"Arial,Helvetica\"><B>From</B></FONT></TD>";
-   echo "   <TD WIDTH=15%><FONT FACE=\"Arial,Helvetica\"><B>Date</B></FONT>";
-   if ($sort == 0)
-      echo "   <A HREF=\"right_main.php3?sort=1&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n";
-   else
-      echo "   <A HREF=\"right_main.php3?sort=0&startMessage=0&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n";
-   echo "   <TD WIDTH=*><FONT FACE=\"Arial,Helvetica\"><B>Subject</B></FONT></TD>\n";
-   echo "</TR>";
 
-   // loop through and display the info for each message.
-   for ($i = $startMessage;$i <= $endMessage; $i++) {
-      printMessageInfo($imapConnection, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE"]);
-   }
+   // Display the header at the top of the page
+   displayPageHeader($mailbox);
 
-   echo "</TABLE>\n";
-   echo "</TD></TR></TABLE>"; /** End of message-list table */
+   // Get the list of messages for this mailbox
+   echo "$numMessages : $startMessage : $sort<BR><BR>";
+   showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort);
 
-   /** Display "Next, Previous" on bottom */
+   // close the connection
    fclose($imapConnection);
 ?>
 </FONT>