Browse Source

changed messages to objects

Luke Ehresman 25 years ago
parent
commit
4e1e5d8c63
3 changed files with 45 additions and 32 deletions
  1. 0 1
      functions/imap_mailbox.php
  2. 35 22
      functions/imap_messages.php
  3. 10 9
      functions/mailbox_display.php

+ 0 - 1
functions/imap_mailbox.php

@@ -221,7 +221,6 @@
 	         }
 	         }
 	      }
 	      }
       }
       }
-
 		$boxes = sqimap_mailbox_parse ($merged, $dm);
 		$boxes = sqimap_mailbox_parse ($merged, $dm);
 		
 		
 		/** Now, lets sort for special folders **/
 		/** Now, lets sort for special folders **/

+ 35 - 22
functions/imap_messages.php

@@ -38,34 +38,47 @@
    /******************************************************************************
    /******************************************************************************
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     ******************************************************************************/
     ******************************************************************************/
-   function sqimap_get_small_header ($imap_stream, $id, &$from, &$subject, &$date, $sent) {
+	class small_header {
+		var $from, $subject, $date;
+	}
+	 
+   function sqimap_get_small_header ($imap_stream, $start, $end, $sent) {
       //fputs ($imap_stream, "a001 FETCH $id BODY[HEADER.FIELDS (DATE FROM SUBJECT)]\r\n");
       //fputs ($imap_stream, "a001 FETCH $id BODY[HEADER.FIELDS (DATE FROM SUBJECT)]\r\n");
-      //fputs ($imap_stream, "a001 FETCH $id RFC822.HEADER\r\n");
-      fputs ($imap_stream, "a001 FETCH $id BODY.PEEK[HEADER.FIELDS (Date To From Subject)]\r\n");
+      //fputs ($imap_stream, "a001 FETCH $start:$end RFC822.HEADER\r\n");
+      fputs ($imap_stream, "a001 FETCH $start:$end BODY.PEEK[HEADER.FIELDS (Date To From Subject)]\r\n");
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
 
 
       $subject = _("(no subject)");
       $subject = _("(no subject)");
       $from = _("Unknown Sender");
       $from = _("Unknown Sender");
       for ($i = 0; $i < count($read); $i++) {
       for ($i = 0; $i < count($read); $i++) {
-
-			if ($sent == true) {
-         	if (eregi ("^to:", $read[$i])) {
-            	$from = sqimap_find_displayable_name(substr($read[$i], 3));
-				}	
-			} else { 
-         	if (eregi ("^from:", $read[$i])) {
-            	$from = sqimap_find_displayable_name(substr($read[$i], 5));
-				}	
-			}
-
-         if (eregi ("^date:", $read[$i])) {
-            $date = substr($read[$i], 5);
-         } else if (eregi ("^subject:", $read[$i])) {
-            $subject = htmlspecialchars(eregi_replace ("^subject: ", "", $read[$i]));
-            if (strlen($subject) == 0)
-               $subject = _("(no subject)");
-         }
-      }
+			while (substr($read[$i], 0, 1) != ")") {
+				if ($sent == true) {
+	         	if (eregi ("^to:", $read[$i])) {
+	            	$from = sqimap_find_displayable_name(substr($read[$i], 3));
+					}	
+				} else { 
+	         	if (eregi ("^from:", $read[$i])) {
+	            	$from = sqimap_find_displayable_name(substr($read[$i], 5));
+					}	
+				}
+	
+	         if (eregi ("^date:", $read[$i])) {
+	            $date = substr($read[$i], 5);
+	         } else if (eregi ("^subject:", $read[$i])) {
+	            $subject = htmlspecialchars(eregi_replace ("^subject: ", "", $read[$i]));
+	            if (strlen($subject) == 0)
+	               $subject = _("(no subject)");
+	         }
+				$i++;
+      	}
+			$header = new small_header;
+			$header->from = $from;
+			$header->date = $date;
+			$header->subject = $subject;
+			$ary[$g] = $header;
+			$g++;
+		}
+		return $ary;
    }
    }
 
 
    /******************************************************************************
    /******************************************************************************

+ 10 - 9
functions/mailbox_display.php

@@ -44,15 +44,16 @@
 
 
       if (!$use_cache) {
       if (!$use_cache) {
          if ($numMessages >= 1) {
          if ($numMessages >= 1) {
-            for ($q = 0; $q < $numMessages; $q++) {
-					if ($mailbox == $sent_folder)
-               	sqimap_get_small_header ($imapConnection, $q+1, $f, $s, $d, true);
-					else
-               	sqimap_get_small_header ($imapConnection, $q+1, $f, $s, $d, false);
+				if ($mailbox == $sent_folder)
+              	$ary = sqimap_get_small_header ($imapConnection, 1, $numMessages, true);
+				else
+              	$ary = sqimap_get_small_header ($imapConnection, 1, $numMessages, false);
 						
 						
-               $from[$q] = $f;
-               $date[$q] = $d;
-               $subject[$q] = $s;
+            for ($q = 0; $q < $numMessages; $q++) {
+					$from[$q] = $ary[$q]->from;
+					$date[$q] = $ary[$q]->date;
+					$subject[$q] = $ary[$q]->subject;
+
                $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
                $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
             }
             }
          }
          }
@@ -249,7 +250,7 @@
       // loop through and display the info for each message.
       // loop through and display the info for each message.
       $t = 0; // $t is used for the checkbox number
       $t = 0; // $t is used for the checkbox number
       if ($numMessages == 0) { // if there's no messages in this folder
       if ($numMessages == 0) { // if there's no messages in this folder
-         echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=4><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp</CENTER></TD></TR>";
+         echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=5><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp</CENTER></TD></TR>";
       } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
       } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
          $i = $startMessage - 1;
          $i = $startMessage - 1;
          reset($msort);
          reset($msort);