5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 ** This file is used for reading the msgs array and displaying
9 ** the resulting emails in the right frame.
19 if (!isset($config_php))
20 include("../config/config.php");
21 if (!isset($strings_php))
22 include("../functions/strings.php");
23 if (!isset($page_header_php))
24 include("../functions/page_header.php");
25 if (!isset($imap_php))
26 include("../functions/imap.php");
27 if (!isset($mime_php))
28 include("../functions/mime.php");
29 if (!isset($date_php))
30 include("../functions/date.php");
32 // given an IMAP message id number, this will look it up in the cached and sorted msgs array and
33 // return the index. used for finding the next and previous messages
35 // returns the index of the next valid message from the array
36 function findNextMessage() {
37 global $msort, $currentArrayIndex, $msgs;
38 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
39 if ($currentArrayIndex == $msgs[$key]["ID"]) {
43 return $msgs[$key]["ID"];
49 // returns the index of the previous message from the array
50 function findPreviousMessage() {
51 global $msort, $currentArrayIndex, $msgs;
52 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
53 if ($currentArrayIndex == $msgs[$key]["ID"]) {
57 return $msgs[$key]["ID"];
64 $currentArrayIndex = $passed_id;
66 for ($i=0; $i < count($msgs); $i++) {
67 if ($msgs[$i]["ID"] == $passed_id) {
68 $currentArrayIndex = $i;
74 $currentArrayIndex = -1;
77 for ($i = 0; $i < count($msgs); $i++
) {
78 if ($msgs[$i]["ID"] == $passed_id)
79 $msgs[$i]["FLAG_SEEN"] = true;
82 include("../src/load_prefs.php");
83 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
84 sqimap_mailbox_select($imapConnection, $mailbox);
86 // $message contains all information about the message
87 // including header and body
88 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
90 displayPageHeader($color, $mailbox);
92 /** translate the subject and mailbox into url-able text **/
93 $url_subj = urlencode(trim(stripslashes($message->header
->subject
)));
94 $urlMailbox = urlencode($mailbox);
95 $url_replyto = urlencode($message->header
->replyto
);
97 $url_replytoall = urlencode($message->header
->replyto
);
98 $url_replytoallcc = urlencode(getLineOfAddrs($message->header
->to
) . ", " . getLineOfAddrs($message->header
->cc
));
100 $dateString = getLongDateString($message->header
->date
);
101 $ent_num = findDisplayEntity($message);
103 /** TEXT STRINGS DEFINITIONS **/
104 $echo_more = _("more");
105 $echo_less = _("less");
107 /** FORMAT THE TO STRING **/
110 $to_ary = $message->header
->to
;
111 while ($i < count($to_ary)) {
112 $to_ary[$i] = htmlspecialchars($to_ary[$i]);
115 $to_string = "$to_string<BR>$to_ary[$i]";
117 $to_string = "$to_ary[$i]";
120 if (count($to_ary) > 1) {
121 if ($show_more == false) {
123 $to_string = "$to_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
126 } else if ($i == 1) {
127 $to_string = "$to_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
132 /** FORMAT THE CC STRING **/
135 $cc_ary = $message->header
->cc
;
136 while ($i < count($cc_ary)) {
137 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
139 $cc_string = "$cc_string<BR>$cc_ary[$i]";
141 $cc_string = "$cc_ary[$i]";
144 if (count($cc_ary) > 1) {
145 if ($show_more_cc == false) {
147 $cc_string = "$cc_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
150 } else if ($i == 1) {
151 $cc_string = "$cc_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
156 /** make sure everything will display in HTML format **/
157 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
158 $subject = decodeHeader(htmlspecialchars(stripslashes($message->header
->subject
)));
161 echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=98% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
162 echo " <TR><TD BGCOLOR=\"$color[0]\" WIDTH=100%>";
163 echo " <TABLE WIDTH=100% CELLSPACING=0 BORDER=0 COLS=2 CELLPADDING=3>";
165 echo " <TD ALIGN=LEFT WIDTH=33%>";
167 echo " <A HREF=\"right_main.php?use_mailbox_cache=1&sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
168 echo _("Message List");
169 echo "</A> | ";
170 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">";
172 echo "</A> ";
174 echo " </TD><TD WIDTH=33% ALIGN=CENTER>";
176 if ($currentArrayIndex == -1) {
177 echo "Previous | Next";
179 $prev = findPreviousMessage();
180 $next = findNextMessage();
182 echo "<a href=\"read_body.php?passed_id=$prev&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
184 echo _("Previous") . " | ";
186 echo "<a href=\"read_body.php?passed_id=$next&mailbox=$mailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
191 echo " </TD><TD WIDTH=33% ALIGN=RIGHT>";
193 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox&ent_num=$ent_num\">";
195 echo "</A> | ";
196 echo " <A HREF=\"compose.php?send_to=$url_replyto&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">";
198 echo "</A> | ";
199 echo " <A HREF=\"compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">";
201 echo "</A> ";
207 echo " <TR><TD CELLSPACING=0 WIDTH=100%>";
208 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=3>\n";
211 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
213 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
214 echo " <B>$subject</B>\n";
219 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
221 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
222 echo " <B>$from_name</B>\n";
227 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT>\n";
229 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85%>\n";
230 echo " <B>$dateString</B>\n";
235 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
237 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
238 echo " <B>$to_string</B>\n";
242 if ($message->header
->cc
) {
244 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
246 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=85% VALIGN=TOP>\n";
247 echo " <B>$cc_string</B>\n";
254 echo " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=100%>\n";
255 $body = formatBody($message, $color, $wrap_at);
260 echo " </TD></TR>\n";
261 echo " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>";