From 15a9cd31950714c2cadd6cb6dfe92c178aa71abc Mon Sep 17 00:00:00 2001 From: lkehresman Date: Fri, 28 Apr 2000 14:42:11 +0000 Subject: [PATCH] changed messages to objects git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@472 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_mailbox.php | 1 - functions/imap_messages.php | 57 +++++++++++++++++++++-------------- functions/mailbox_display.php | 19 ++++++------ 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 436f4d41..62302f1c 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -221,7 +221,6 @@ } } } - $boxes = sqimap_mailbox_parse ($merged, $dm); /** Now, lets sort for special folders **/ diff --git a/functions/imap_messages.php b/functions/imap_messages.php index 95985009..612ef5fc 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -38,34 +38,47 @@ /****************************************************************************** ** 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 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); $subject = _("(no subject)"); $from = _("Unknown Sender"); 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; } /****************************************************************************** diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 3280c2ab..ab348b92 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -44,15 +44,16 @@ if (!$use_cache) { 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); } } @@ -249,7 +250,7 @@ // loop through and display the info for each message. $t = 0; // $t is used for the checkbox number if ($numMessages == 0) { // if there's no messages in this folder - echo "

". _("THIS FOLDER IS EMPTY") ."
 
"; + echo "

". _("THIS FOLDER IS EMPTY") ."
 
"; } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different. $i = $startMessage - 1; reset($msort); -- 2.25.1