Templates for reading a message
[squirrelmail.git] / src / read_body.php
CommitLineData
59177427 1<?php
134e4174 2
35586184 3/**
4 * read_body.php
5 *
35586184 6 * This file is used for reading the msgs array and displaying
7 * the resulting emails in the right frame.
8 *
47ccfad4 9 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
30967a1e 11 * @version $Id$
8f6f9ba5 12 * @package squirrelmail
a07cd1a4 13 */
35586184 14
30967a1e 15/**
202bcbcc 16 * Include the SquirrelMail initialization file.
30967a1e 17 */
202bcbcc 18require('../include/init.php');
86725763 19
20/* SquirrelMail required files. */
202bcbcc 21
22
86725763 23require_once(SM_PATH . 'functions/imap.php');
202bcbcc 24require_once(SM_PATH . 'functions/imap_asearch.php'); // => move to mailbox_display
86725763 25require_once(SM_PATH . 'functions/mime.php');
26require_once(SM_PATH . 'functions/date.php');
27require_once(SM_PATH . 'functions/url_parser.php');
6d021521 28require_once(SM_PATH . 'functions/identity.php');
202bcbcc 29require_once(SM_PATH . 'functions/mailbox_display.php');
30require_once(SM_PATH . 'functions/forms.php');
31require_once(SM_PATH . 'functions/attachment_common.php');
38c944cc 32
a07cd1a4 33/**
1fca12b5 34 * Given an IMAP message id number, this will look it up in the cached
1e150c97 35 * and sorted msgs array and return the index of the next message
1fca12b5 36 *
1e150c97 37 * @param int $passed_id The current message UID
1fca12b5 38 * @return the index of the next valid message from the array
39 */
e0e30169 40function findNextMessage($uidset,$passed_id='backwards') {
324ac3c5 41 if (!is_array($uidset)) {
42 return -1;
43 }
e0e30169 44 if ($passed_id=='backwards' || !is_array($uidset)) { // check for backwards compattibilty gpg plugin
45 $passed_id = $uidset;
e0e30169 46 }
91c27aee 47 $result = sqm_array_get_value_by_offset($uidset,$passed_id,1);
48 if ($result === false) {
49 return -1;
50 } else {
51 return $result;
10f0ce72 52 }
a07cd1a4 53}
54
1e150c97 55/**
56 * Given an IMAP message id number, this will look it up in the cached
57 * and sorted msgs array and return the index of the previous message
58 *
59 * @param int $passed_id The current message UID
60 * @return the index of the next valid message from the array
61 */
e0e30169 62
63function findPreviousMessage($uidset, $passed_id) {
324ac3c5 64 if (!is_array($uidset)) {
65 return -1;
e0e30169 66 }
91c27aee 67 $result = sqm_array_get_value_by_offset($uidset,$passed_id,-1);
68 if ($result === false) {
69 return -1;
70 } else {
71 return $result;
a07cd1a4 72 }
a07cd1a4 73}
10f0ce72 74
a07cd1a4 75/**
1fca12b5 76 * Displays a link to a page where the message is displayed more
77 * "printer friendly".
1e150c97 78 * @param string $mailbox Name of current mailbox
4669e892 79 * @param int $passed_id
1fca12b5 80 */
1e150c97 81function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) {
4c8986b4 82 global $javascript_on, $show_html_default;
a07cd1a4 83
e2da1d80 84 /* hackydiehack */
85 if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) {
86 $view_unsafe_images = false;
87 } else {
88 $view_unsafe_images = true;
89 }
164584f0 90 $params = '?passed_ent_id=' . urlencode($passed_ent_id) .
c2324b26 91 '&mailbox=' . urlencode($mailbox) .
4c8986b4 92 '&passed_id=' . urlencode($passed_id) .
93 '&view_unsafe_images='. (bool) $view_unsafe_images .
94 '&show_html_default=' . $show_html_default;
10f0ce72 95
a07cd1a4 96 $print_text = _("View Printable Version");
10f0ce72 97
c615b1da 98 $result = '';
a07cd1a4 99 /* Output the link. */
100 if ($javascript_on) {
2c92ea9d 101 $result = '<script type="text/javascript">' . "\n" .
9f42bfc8 102 '<!--' . "\n" .
103 " function printFormat() {\n" .
104 ' window.open("../src/printer_friendly_main.php' .
105 $params . '","Print","width=800,height=600");' . "\n".
106 " }\n" .
107 "// -->\n" .
108 "</script>\n" .
109 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
a07cd1a4 110 } else {
c2324b26 111 $result = '<a target="_blank" href="../src/printer_friendly_bottom.php' .
9f42bfc8 112 "$params\">$print_text</a>\n";
a07cd1a4 113 }
d9c1dccc 114 return $result;
a07cd1a4 115}
116
7277191e 117function view_as_html_link($mailbox, $passed_id, $passed_ent_id, $message) {
118 global $base_uri, $show_html_default;
119
120 $has_html = false;
121 if ($message->header->type0 == 'message' && $message->header->type1 == 'rfc822') {
122 $type0 = $message->rfc822_header->content_type->type0;
123 $type1 = $message->rfc822_header->content_type->type1;
124 } else {
125 $type0 = $message->header->type0;
126 $type1 = $message->header->type1;
127 }
128 if($type0 == 'multipart' &&
129 ($type1 == 'alternative' || $type1 == 'mixed' || $type1 == 'related')) {
130 if ($message->findDisplayEntity(array(), array('text/html'), true)) {
131 $has_html = true;
132 }
133 }
134 /*
135 * Normal single part message so check its type.
136 */
137 else {
138 if($type0 == 'text' && $type1 == 'html') {
139 $has_html = true;
140 }
141 }
142 if($has_html == true) {
202bcbcc 143 $vars = array('passed_ent_id', 'show_more', 'show_more_cc', 'override_type0', 'override_type1', 'startMessage','where', 'what');
7277191e 144
145 $new_link = $base_uri . 'src/read_body.php?passed_id=' . urlencode($passed_id) .
146 '&amp;passed_ent_id=' . urlencode($passed_ent_id) .
147 '&amp;mailbox=' . urlencode($mailbox);
148 foreach($vars as $var) {
149 if(sqgetGlobalVar($var, $temp)) {
150 $new_link .= '&amp;' . $var . '=' . urlencode($temp);
151 }
152 }
153
154 if($show_html_default == 1) {
155 $new_link .= '&amp;show_html_default=0';
156 $link = _("View as plain text");
157 } else {
158 $new_link .= '&amp;show_html_default=1';
159 $link = _("View as HTML");
160 }
161 return '&nbsp;|&nbsp<a href="' . $new_link . '">' . $link . '</a>';
162 }
163 return '';
164}
165
4669e892 166function ServerMDNSupport($aFlags) {
167 /* escaping $ doesn't work -> \x36 */
c075fcfe 168 return ( in_array('$mdnsent',$aFlags,true) ||
169 in_array('\\*',$aFlags,true) ) ;
57257333 170}
171
fc224f68 172function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
8d8da447 173 global $username, $attachment_dir, $popuser, $username, $color,
ce68b76b 174 $version, $squirrelmail_language, $default_charset,
175 $languages, $useSendmail, $domain, $sent_folder;
57257333 176
e95c04ec 177 sqgetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER);
0b97a708 178
38bca81c 179 $header = $message->rfc822_header;
57257333 180
fc224f68 181 $rfc822_header = new Rfc822Header();
d9c1dccc 182 $content_type = new ContentType('multipart/report');
fc224f68 183 $content_type->properties['report-type']='disposition-notification';
d9c1dccc 184
fc224f68 185 set_my_charset();
186 if ($default_charset) {
d9c1dccc 187 $content_type->properties['charset']=$default_charset;
fc224f68 188 }
189 $rfc822_header->content_type = $content_type;
190 $rfc822_header->to[] = $header->dnt;
a20855e4 191 $rfc822_header->subject = _("Read:") . ' ' . encodeHeader($header->subject);
fc224f68 192
27a1d10a 193 // Patch #793504 Return Receipt Failing with <@> from Tim Craig (burny_md)
194 // This merely comes from compose.php and only happens when there is no
195 // email_addr specified in user's identity (which is the startup config)
196 if (ereg("^([^@%/]+)[@%/](.+)$", $username, $usernamedata)) {
197 $popuser = $usernamedata[1];
198 $domain = $usernamedata[2];
199 unset($usernamedata);
200 } else {
201 $popuser = $username;
202 }
fc224f68 203
204 $reply_to = '';
6d021521 205 $ident = get_identities();
206 if(!isset($identity)) $identity = 0;
207 $full_name = $ident[$identity]['full_name'];
208 $from_mail = $ident[$identity]['email_address'];
209 $from_addr = '"'.$full_name.'" <'.$from_mail.'>';
210 $reply_to = $ident[$identity]['reply_to'];
211
27a1d10a 212 if (!$from_mail) {
213 $from_mail = "$popuser@$domain";
214 $from_addr = $from_mail;
fc224f68 215 }
216 $rfc822_header->from = $rfc822_header->parseAddress($from_addr,true);
217 if ($reply_to) {
218 $rfc822_header->reply_to = $rfc822_header->parseAddress($reply_to,true);
219 }
d9c1dccc 220
57257333 221 // part 1 (RFC2298)
57257333 222 $senton = getLongDateString( $header->date );
223 $to_array = $header->to;
224 $to = '';
225 foreach ($to_array as $line) {
af568a82 226 $to .= ' '.$line->getAddress();
57257333 227 }
57257333 228 $now = getLongDateString( time() );
78db1583 229 set_my_charset();
46bb8da8 230 $body = _("Your message") . "\r\n\r\n" .
48027e89 231 "\t" . _("To") . ': ' . decodeHeader($to,false,false) . "\r\n" .
232 "\t" . _("Subject") . ': ' . decodeHeader($header->subject,false,false) . "\r\n" .
233 "\t" . _("Sent") . ': ' . $senton . "\r\n" .
46bb8da8 234 "\r\n" .
235 sprintf( _("Was displayed on %s"), $now );
f69feefe 236
fc224f68 237 $special_encoding = '';
4669e892 238 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
f4bb5d22 239 function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode')) {
240 $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode', $body);
d9c1dccc 241 if (strtolower($default_charset) == 'iso-2022-jp') {
242 if (mb_detect_encoding($body) == 'ASCII') {
243 $special_encoding = '8bit';
244 } else {
245 $body = mb_convert_encoding($body, 'JIS');
246 $special_encoding = '7bit';
247 }
248 }
21461ca4 249 } elseif (sq_is8bit($body)) {
250 $special_encoding = '8bit';
6fbd125b 251 }
fc224f68 252 $part1 = new Message();
253 $part1->setBody($body);
254 $mime_header = new MessageHeader;
255 $mime_header->type0 = 'text';
256 $mime_header->type1 = 'plain';
257 if ($special_encoding) {
258 $mime_header->encoding = $special_encoding;
d9c1dccc 259 } else {
fc224f68 260 $mime_header->encoding = 'us-ascii';
261 }
262 if ($default_charset) {
263 $mime_header->parameters['charset'] = $default_charset;
264 }
265 $part1->mime_header = $mime_header;
266
57257333 267 // part2 (RFC2298)
d9c1dccc 268 $original_recipient = $to;
57257333 269 $original_message_id = $header->message_id;
270
fc224f68 271 $report = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
57257333 272 if ($original_recipient != '') {
fc224f68 273 $report .= "Original-Recipient : $original_recipient\r\n";
57257333 274 }
275 $final_recipient = $sender;
fc224f68 276 $report .= "Final-Recipient: rfc822; $final_recipient\r\n" .
57257333 277 "Original-Message-ID : $original_message_id\r\n" .
278 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
279
fc224f68 280 $part2 = new Message();
281 $part2->setBody($report);
282 $mime_header = new MessageHeader;
283 $mime_header->type0 = 'message';
284 $mime_header->type1 = 'disposition-notification';
285 $mime_header->encoding = 'us-ascii';
286 $part2->mime_header = $mime_header;
287
288 $composeMessage = new Message();
289 $composeMessage->rfc822_header = $rfc822_header;
290 $composeMessage->addEntity($part1);
291 $composeMessage->addEntity($part2);
292
293
d9c1dccc 294 if ($useSendmail) {
295 require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
f3dc9c62 296 global $sendmail_path, $sendmail_args;
297 // Check for outdated configuration
298 if (!isset($sendmail_args)) {
299 if ($sendmail_path=='/var/qmail/bin/qmail-inject') {
300 $sendmail_args = '';
301 } else {
302 $sendmail_args = '-i -t';
303 }
304 }
305 $deliver = new Deliver_SendMail(array('sendmail_args'=>$sendmail_args));
d9c1dccc 306 $stream = $deliver->initStream($composeMessage,$sendmail_path);
fc224f68 307 } else {
d9c1dccc 308 require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php');
309 $deliver = new Deliver_SMTP();
ce68b76b 310 global $smtpServerAddress, $smtpPort, $pop_before_smtp;
d9c1dccc 311 $authPop = (isset($pop_before_smtp) && $pop_before_smtp) ? true : false;
9bd3b1e6 312 get_smtp_user($user, $pass);
d9c1dccc 313 $stream = $deliver->initStream($composeMessage,$domain,0,
70ce2218 314 $smtpServerAddress, $smtpPort, $user, $pass, $authPop);
d9c1dccc 315 }
316 $success = false;
fc224f68 317 if ($stream) {
d9c1dccc 318 $length = $deliver->mail($composeMessage, $stream);
319 $success = $deliver->finalizeStream($stream);
fc224f68 320 }
d9c1dccc 321 if (!$success) {
a15f9d93 322 $msg = $deliver->dlv_msg;
323 if (! empty($deliver->dlv_server_msg)) {
324 $msg.= '<br />' .
0cc4fb0d 325 _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
a15f9d93 326 nl2br(htmlspecialchars($deliver->dlv_server_msg));
327 }
fc224f68 328 plain_error_message($msg, $color);
329 } else {
330 unset ($deliver);
d9c1dccc 331 if (sqimap_mailbox_exists ($imapConnection, $sent_folder)) {
81de00c0 332 $sid = sqimap_append ($imapConnection, $sent_folder, $length);
d9c1dccc 333 require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
334 $imap_deliver = new Deliver_IMAP();
335 $imap_deliver->mail($composeMessage, $imapConnection);
81de00c0 336 sqimap_append_done ($imapConnection, $sent_folder);
d9c1dccc 337 unset ($imap_deliver);
338 }
339 }
340 return $success;
57257333 341}
342
6201339c 343function ToggleMDNflag ($set ,$imapConnection, $mailbox, $passed_id) {
d9c1dccc 344 $sg = $set?'+':'-';
345 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
4669e892 346 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
6201339c 347 $readmessage, TRUE);
57257333 348}
349
4d0cd98b 350function formatRecipientString($recipients, $item ) {
d9c1dccc 351 global $show_more_cc, $show_more, $show_more_bcc,
352 $PHP_SELF;
4d0cd98b 353
d9c1dccc 354 $string = '';
38c944cc 355 if ((is_array($recipients)) && (isset($recipients[0]))) {
d9c1dccc 356 $show = false;
38c944cc 357
358 if ($item == 'to') {
d9c1dccc 359 if ($show_more) {
360 $show = true;
361 $url = set_url_var($PHP_SELF, 'show_more',0);
362 } else {
363 $url = set_url_var($PHP_SELF, 'show_more',1);
364 }
365 } else if ($item == 'cc') {
366 if ($show_more_cc) {
367 $show = true;
368 $url = set_url_var($PHP_SELF, 'show_more_cc',0);
369 } else {
370 $url = set_url_var($PHP_SELF, 'show_more_cc',1);
371 }
372 } else if ($item == 'bcc') {
373 if ($show_more_bcc) {
374 $show = true;
375 $url = set_url_var($PHP_SELF, 'show_more_bcc',0);
376 } else {
377 $url = set_url_var($PHP_SELF, 'show_more_bcc',1);
378 }
379 }
380
381 $cnt = count($recipients);
382 foreach($recipients as $r) {
a91189d6 383 $add = decodeHeader($r->getAddress(true));
d9c1dccc 384 if ($string) {
3c621ba1 385 $string .= '<br />' . $add;
d9c1dccc 386 } else {
387 $string = $add;
388 if ($cnt > 1) {
3c621ba1 389 $string .= '&nbsp;(<a href="'.$url;
d9c1dccc 390 if ($show) {
3c621ba1 391 $string .= '">'._("less").'</a>)';
d9c1dccc 392 } else {
3c621ba1 393 $string .= '">'._("more").'</a>)';
d9c1dccc 394 break;
395 }
396 }
397 }
1fca12b5 398 }
4d0cd98b 399 }
c615b1da 400 return $string;
401}
402
e0e30169 403function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message,
af568a82 404 $color, $FirstTimeSee) {
ce68b76b 405 global $default_use_mdn, $default_use_priority,
77836429 406 $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on,
134e4174 407 $squirrelmail_language;
38bca81c 408
134e4174 409 $mailbox = $aMailbox['NAME'];
e0e30169 410
d9c1dccc 411 $header = $message->rfc822_header;
412 $env = array();
bdb9ce72 413 $env[_("Subject")] = str_replace("&nbsp;"," ",decodeHeader($header->subject));
7893c8a5 414
d9c1dccc 415 $from_name = $header->getAddr_s('from');
d6b6d221 416 if (!$from_name)
d9c1dccc 417 $from_name = $header->getAddr_s('sender');
d6b6d221 418 if (!$from_name)
419 $env[_("From")] = _("Unknown sender");
420 else
421 $env[_("From")] = decodeHeader($from_name);
d9c1dccc 422 $env[_("Date")] = getLongDateString($header->date);
423 $env[_("To")] = formatRecipientString($header->to, "to");
424 $env[_("Cc")] = formatRecipientString($header->cc, "cc");
425 $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
426 if ($default_use_priority) {
0e8006dc 427 $env[_("Priority")] = htmlspecialchars(getPriorityStr($header->priority));
d9c1dccc 428 }
429 if ($show_xmailer_default) {
a91189d6 430 $env[_("Mailer")] = decodeHeader($header->xmailer);
d9c1dccc 431 }
432 if ($default_use_mdn) {
433 if ($mdn_user_support) {
434 if ($header->dnt) {
435 if ($message->is_mdnsent) {
509ce88e 436 $env[_("Read receipt")] = _("sent");
d9c1dccc 437 } else {
4669e892 438 $env[_("Read receipt")] = _("requested");
439 if (!(handleAsSent($mailbox) ||
d9c1dccc 440 $message->is_deleted ||
441 $passed_ent_id)) {
bfb55134 442 $mdn_url = $PHP_SELF;
443 $mdn_url = set_url_var($PHP_SELF, 'mailbox', urlencode($mailbox));
444 $mdn_url = set_url_var($PHP_SELF, 'passed_id', $passed_id);
445 $mdn_url = set_url_var($PHP_SELF, 'passed_ent_id', $passed_ent_id);
446 $mdn_url = set_url_var($PHP_SELF, 'sendreceipt', 1);
d9c1dccc 447 if ($FirstTimeSee && $javascript_on) {
2c92ea9d 448 $script = '<script type="text/javascript">' . "\n";
d9c1dccc 449 $script .= '<!--'. "\n";
450 $script .= 'if(window.confirm("' .
451 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
452 '")) { '."\n" .
453 ' sendMDN()'.
454 '}' . "\n";
455 $script .= '// -->'. "\n";
456 $script .= '</script>'. "\n";
457 echo $script;
458 }
459 $env[_("Read receipt")] .= '&nbsp;<a href="' . $mdn_url . '">[' .
460 _("Send read receipt now") . ']</a>';
461 }
462 }
463 }
464 }
465 }
c615b1da 466
3c621ba1 467 $s = '<table width="100%" cellpadding="0" cellspacing="2" border="0"';
468 $s .= ' align="center" bgcolor="'.$color[0].'">';
d9c1dccc 469 foreach ($env as $key => $val) {
470 if ($val) {
3c621ba1 471 $s .= '<tr>';
472 $s .= html_tag('td', '<b>' . $key . ':&nbsp;&nbsp;</b>', 'right', '', 'valign="top" width="20%"') . "\n";
473 $s .= html_tag('td', $val, 'left', '', 'valign="top" width="80%"') . "\n";
474 $s .= '</tr>';
d9c1dccc 475 }
476 }
3c621ba1 477 echo '<table bgcolor="'.$color[9].'" width="100%" cellpadding="1"'.
478 ' cellspacing="0" border="0" align="center">'."\n";
479 echo '<tr><td height="5" colspan="2" bgcolor="'.
480 $color[4].'"></td></tr><tr><td align="center">'."\n";
d9c1dccc 481 echo $s;
00ac2f42 482 do_hook('read_body_header');
d9c1dccc 483 formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
3c621ba1 484 echo '</table>';
485 echo '</td></tr><tr><td height="5" colspan="2" bgcolor="'.$color[4].'"></td></tr>'."\n";
486 echo '</table>';
d9c1dccc 487}
c615b1da 488
1e150c97 489/**
4669e892 490 * Format message toolbar
491 *
1e150c97 492 * @param string $mailbox Name of current mailbox
493 * @param int $passed_id UID of current message
494 * @param int $passed_ent_id Id of entity within message
495 * @param object $message Current message object
496 * @param object $mbx_response
497 */
324ac3c5 498function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removedVar, $nav_on_top = TRUE) {
a94c1db1 499 global $base_uri, $draft_folder, $where, $what, $color, $sort,
4669e892 500 $startMessage, $PHP_SELF, $save_as_draft,
1e150c97 501 $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox,
24bb7e49 502 $username, $delete_prev_next_display, $show_copy_buttons,
91c27aee 503 $compose_new_win, $javascript_on, $compose_width, $compose_height;
c615b1da 504
e0e30169 505 //FIXME cleanup argument list, use $aMailbox where possible
506 $mailbox = $aMailbox['NAME'];
507
d9c1dccc 508 $topbar_delimiter = '&nbsp;|&nbsp;';
1e150c97 509 $double_delimiter = '&nbsp;&nbsp;&nbsp;&nbsp;';
d9c1dccc 510 $urlMailbox = urlencode($mailbox);
c615b1da 511
1e150c97 512 $msgs_url = $base_uri . 'src/';
2ffa3f57 513
1e150c97 514 // BEGIN NAV ROW - PREV/NEXT, DEL PREV/NEXT, LINKS TO INDEX, etc.
45c1ed84 515 $nav_row = '<tr><td align="left" colspan="2" style="border: 1px solid '.$color[9].';"><small>';
e55c441a 516
1e150c97 517 // Create Prev & Next links
518 // Handle nested entities first (i.e. Mime Attach parts)
519 if (isset($passed_ent_id) && $passed_ent_id) {
520 // code for navigating through attached message/rfc822 messages
d9c1dccc 521 $url = set_url_var($PHP_SELF, 'passed_ent_id',0);
70bdc740 522 $entities = array();
523 $entity_count = array();
524 $c = 0;
f2f03410 525
70bdc740 526 foreach($message->parent->entities as $ent) {
9f42bfc8 527 if ($ent->type0 == 'message' && $ent->type1 == 'rfc822') {
528 $c++;
529 $entity_count[$c] = $ent->entity_id;
530 $entities[$ent->entity_id] = $c;
531 }
70bdc740 532 }
1e150c97 533
70bdc740 534 $prev_link = _("Previous");
91c27aee 535 if(isset($entities[$passed_ent_id]) && $entities[$passed_ent_id] > 1) {
70bdc740 536 $prev_ent_id = $entity_count[$entities[$passed_ent_id] - 1];
537 $prev_link = '<a href="'
538 . set_url_var($PHP_SELF, 'passed_ent_id', $prev_ent_id)
539 . '">' . $prev_link . '</a>';
540 }
1e150c97 541
542 $next_link = _("Next");
91c27aee 543 if(isset($entities[$passed_ent_id]) && $entities[$passed_ent_id] < $c) {
70bdc740 544 $next_ent_id = $entity_count[$entities[$passed_ent_id] + 1];
545 $next_link = '<a href="'
546 . set_url_var($PHP_SELF, 'passed_ent_id', $next_ent_id)
547 . '">' . $next_link . '</a>';
548 }
1e150c97 549
d9c1dccc 550 $par_ent_id = $message->parent->entity_id;
1e150c97 551 $up_link = '';
d9c1dccc 552 if ($par_ent_id) {
553 $par_ent_id = substr($par_ent_id,0,-2);
1e150c97 554 if ( $par_ent_id != 0 ) {
555 $up_link = $topbar_delimiter;
556 $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id);
557 $up_link .= '<a href="'.$url.'">'._("Up").'</a>';
558 }
559 }
560
561 $nav_row .= $prev_link . $up_link . $topbar_delimiter . $next_link;
abafb676 562 $nav_row .= $double_delimiter . '[<a href="'.$url.'">'._("View Message").'</a>]';
1e150c97 563
564 // Prev/Next links for regular messages
324ac3c5 565 } else if ( true ) { //!(isset($where) && isset($what)) ) {
324ac3c5 566 $prev = findPreviousMessage($aMailbox['UIDSET'][$what], $passed_id);
567 $next = findNextMessage($aMailbox['UIDSET'][$what],$passed_id);
1e150c97 568
569 $prev_link = _("Previous");
570 if ($prev >= 0) {
571 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
572 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
324ac3c5 573 "&amp;where=$where&amp;what=$what" .
1e150c97 574 '&amp;startMessage='.$startMessage.'&amp;show_more=0';
575 $prev_link = '<a href="'.$uri.'">'.$prev_link.'</a>';
d9c1dccc 576 }
1e150c97 577
578 $next_link = _("Next");
579 if ($next >= 0) {
580 $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
581 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
324ac3c5 582 "&amp;where=$where&amp;what=$what" .
1e150c97 583 '&amp;startMessage='.$startMessage.'&amp;show_more=0';
584 $next_link = '<a href="'.$uri.'">'.$next_link.'</a>';
585 }
586
1e150c97 587 // Only bother with Delete & Prev and Delete & Next IF
6201339c 588 // top display is enabled.
4669e892 589 if ( $delete_prev_next_display == 1 &&
324ac3c5 590 in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) {
407e7032 591 $del_prev_link = _("Delete &amp; Prev");
1e150c97 592 if ($prev >= 0) {
593 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
594 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
595 '&amp;startMessage='.$startMessage.'&amp;show_more=0'.
324ac3c5 596 "&amp;where=$where&amp;what=$what" .
1e150c97 597 '&amp;delete_id='.$passed_id;
4669e892 598 $del_prev_link = '<a href="'.$uri.'">'.$del_prev_link.'</a>';
1e150c97 599 }
600
407e7032 601 $del_next_link = _("Delete &amp; Next");
1e150c97 602 if ($next >= 0) {
603 $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
604 '&amp;mailbox='.$urlMailbox.'&amp;sort='.$sort.
605 '&amp;startMessage='.$startMessage.'&amp;show_more=0'.
324ac3c5 606 "&amp;where=$where&amp;what=$what" .
1e150c97 607 '&amp;delete_id='.$passed_id;
45c1ed84 608 $del_next_link = '<a href="'.$uri.'">'.$del_next_link.'</a>';
1e150c97 609 }
1e150c97 610 }
45c1ed84 611
abafb676 612 $nav_row .= '['.$prev_link.$topbar_delimiter.$next_link.']';
613 if ( isset($del_prev_link) && isset($del_next_link) )
614 $nav_row .= $double_delimiter.'['.$del_prev_link.$topbar_delimiter.$del_next_link.']';
1e150c97 615 }
616
617 // Start with Search Results or Message List link.
324ac3c5 618 $msgs_url .= "$where?where=read_body.php&amp;what=$what&amp;mailbox=" . $urlMailbox.
619 "&amp;startMessage=$startMessage";
620 if ($where == 'search.php') {
1e150c97 621 $msgs_str = _("Search Results");
622 } else {
1e150c97 623 $msgs_str = _("Message List");
624 }
625 $nav_row .= $double_delimiter .
abafb676 626 '[<a href="' . $msgs_url . '">' . $msgs_str . '</a>]';
1e150c97 627
628 $nav_row .= '</small></td></tr>';
629
630
631 // BEGIN MENU ROW - DELETE/REPLY/FORWARD/MOVE/etc.
ad2ee09d 632 $menu_row = '<tr bgcolor="'.$color[0].'"><td><small>';
98a9cc03 633 $comp_uri = $base_uri.'src/compose.php' .
634 '?passed_id=' . $passed_id .
635 '&amp;mailbox=' . $urlMailbox .
636 '&amp;startMessage=' . $startMessage .
637 (isset($passed_ent_id) ? '&amp;passed_ent_id='.$passed_ent_id : '');
4669e892 638
639 // Start form for reply/reply all/forward..
1a531551 640 $target = '';
641 $on_click='';
ee66175d 642 $method='method="post" ';
6190378c 643 $onsubmit='';
1a531551 644 if ($compose_new_win == '1') {
91c27aee 645 if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
646 $compose_width = '640';
647 }
648 if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
649 $compose_height = '550';
650 }
1a531551 651 if ( $javascript_on ) {
91c27aee 652 $on_click=' onclick="comp_in_new_form(\''.$comp_uri.'\', this, this.form,'. $compose_width .',' . $compose_height .')"';
1a531551 653 $comp_uri = 'javascript:void(0)';
ee66175d 654 $method='method="get" ';
6190378c 655 $onsubmit = 'onsubmit="return false" ';
1a531551 656 } else {
657 $target = 'target="_blank"';
1a531551 658 }
659 }
660
6190378c 661 $menu_row .= "\n".'<form name="composeForm" action="'.$comp_uri.'" '
662 . $method.$target.$onsubmit.' style="display: inline">'."\n";
98a9cc03 663
1e150c97 664 // If Draft folder - create Resume link
665 if (($mailbox == $draft_folder) && ($save_as_draft)) {
1a531551 666 $new_button = 'smaction_draft';
1e150c97 667 $comp_alt_string = _("Resume Draft");
668 } else if (handleAsSent($mailbox)) {
669 // If in Sent folder, edit as new
1a531551 670 $new_button = 'smaction_edit_new';
1e150c97 671 $comp_alt_string = _("Edit Message as New");
672 }
1e150c97 673 // Show Alt URI for Draft/Sent
98a9cc03 674 if (isset($comp_alt_string))
e1728a7a 675 $menu_row .= getButton('submit', $new_button, $comp_alt_string, $on_click) . "\n";
1e150c97 676
e1728a7a 677 $menu_row .= getButton('submit', 'smaction_reply', _("Reply"), $on_click) . "\n";
678 $menu_row .= getButton('submit', 'smaction_reply_all', _("Reply All"), $on_click) ."\n";
679 $menu_row .= getButton('submit', 'smaction_forward', _("Forward"), $on_click);
98a9cc03 680 if ($enable_forward_as_attachment)
ff0969a0 681 $menu_row .= '<input type="checkbox" name="smaction_attache" />' . _("As Attachment") .'&nbsp;&nbsp;'."\n";
1e150c97 682
51eb014b 683 $menu_row .= '</form>&nbsp;';
c615b1da 684
324ac3c5 685 if ( in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) {
686 // Form for deletion. Form is handled by the originating display in $where. This is right_main.php or search.php
687 $delete_url = $base_uri . "src/$where";
25e57ed2 688 $menu_row .= '<form name="deleteMessageForm" action="'.$delete_url.'" method="post" style="display: inline">';
a128c967 689
4669e892 690 if (!(isset($passed_ent_id) && $passed_ent_id)) {
324ac3c5 691 $menu_row .= addHidden('mailbox', $aMailbox['NAME']);
692 $menu_row .= addHidden('msg[0]', $passed_id);
7fcab811 693 $menu_row .= addHidden('startMessage', $startMessage);
e1728a7a 694 $menu_row .= getButton('submit', 'delete', _("Delete"));
ff0969a0 695 $menu_row .= '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash");
324ac3c5 696 } else {
e1728a7a 697 $menu_row .= getButton('submit', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled
abafb676 698 }
abafb676 699
4669e892 700 $menu_row .= '</form>';
701 }
abafb676 702
1e150c97 703 // Add top move link
704 $menu_row .= '</small></td><td align="right">';
4669e892 705 if ( !(isset($passed_ent_id) && $passed_ent_id) &&
324ac3c5 706 in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) {
b2811304 707
25e57ed2 708 $menu_row .= '<form name="moveMessageForm" action="'.$base_uri.'src/'.$where.'?'.'" method="post" style="display: inline">'.
64c9e87e 709 '<small>'.
324ac3c5 710
711 addHidden('mailbox',$aMailbox['NAME']) .
712 addHidden('msg[0]', $passed_id) . _("Move to:") .
1e150c97 713 '<select name="targetMailbox" style="padding: 0px; margin: 0px">';
b2811304 714
1e150c97 715 if (isset($lastTargetMailbox) && !empty($lastTargetMailbox)) {
716 $menu_row .= sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)));
717 } else {
718 $menu_row .= sqimap_mailbox_option_list($imapConnection);
719 }
b2811304 720 $menu_row .= '</select> ';
721
24bb7e49 722 $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n";
723
724 // Add msg copy button
725 if ($show_copy_buttons) {
726 $menu_row .= getButton('submit', 'copyButton', _("Copy"));
727 }
728
729 $menu_row .= '</form>';
1e150c97 730 }
731 $menu_row .= '</td></tr>';
d9c1dccc 732
1e150c97 733 // echo rows, with hooks
764971df 734 $ret = do_hook_function('read_body_menu_top', array($nav_row, $menu_row));
988e24f6 735 if (is_array($ret)) {
736 if (isset($ret[0]) && !empty($ret[0])) {
737 $nav_row = $ret[0];
738 }
739 if (isset($ret[1]) && !empty($ret[1])) {
740 $menu_row = $ret[1];
741 }
764971df 742 }
1e150c97 743 echo '<table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
744 echo $nav_on_top ? $nav_row . $menu_row : $menu_row . $nav_row;
745 echo '</table>'."\n";
d62c4938 746 do_hook('read_body_menu_bottom');
c615b1da 747}
748
749function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
40a34e57 750 global $base_uri, $where, $what, $download_and_unsafe_link;
4669e892 751
d9c1dccc 752 $urlMailbox = urlencode($mailbox);
78909469 753 $urlPassed_id = urlencode($passed_id);
754 $urlPassed_ent_id = urlencode($passed_ent_id);
4669e892 755
78909469 756 $query_string = 'mailbox=' . $urlMailbox . '&amp;passed_id=' . $urlPassed_id . '&amp;passed_ent_id=' . $urlPassed_ent_id;
4669e892 757
78909469 758 if (!empty($where)) {
759 $query_string .= '&amp;where=' . urlencode($where);
760 }
761
762 if (!empty($what)) {
763 $query_string .= '&amp;what=' . urlencode($what);
764 }
765
e95c04ec 766 $url = $base_uri.'src/view_header.php?'.$query_string;
d9c1dccc 767
3c621ba1 768 $s = "<tr>\n" .
769 html_tag( 'td', '', 'right', '', 'valign="middle" width="20%"' ) . '<b>' . _("Options") . ":&nbsp;&nbsp;</b></td>\n" .
770 html_tag( 'td', '', 'left', '', 'valign="middle" width="80%"' ) . '<small>' .
d9c1dccc 771 '<a href="'.$url.'">'._("View Full Header").'</a>';
772
773 /* Output the printer friendly link if we are in subtle mode. */
774 $s .= '&nbsp;|&nbsp;' .
1e150c97 775 printer_friendly_link($mailbox, $passed_id, $passed_ent_id);
d9c1dccc 776 echo $s;
7277191e 777 echo view_as_html_link($mailbox, $passed_id, $passed_ent_id, $message);
40a34e57 778
779 /* Output the download and/or unsafe images link/-s, if any. */
780 if ($download_and_unsafe_link) {
f3dc9c62 781 echo $download_and_unsafe_link;
40a34e57 782 }
783
d9c1dccc 784 do_hook("read_body_header_right");
3c621ba1 785 $s = "</small></td>\n" .
786 "</tr>\n";
d9c1dccc 787 echo $s;
a128c967 788
4d0cd98b 789}
790
91c27aee 791/**
792 * Creates button
793 *
794 * @deprecated see form functions available in 1.5.1 and 1.4.3.
795 * @param string $type
796 * @param string $name
797 * @param string $value
798 * @param string $js
799 * @param bool $enabled
800 */
801function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
802 $disabled = ( $enabled ? '' : 'disabled ' );
803 $js = ( $js ? $js.' ' : '' );
804 return '<input '.$disabled.$js.
805 'type="'.$type.
806 '" name="'.$name.
807 '" value="'.$value .
808 '" style="padding: 0px; margin: 0px" />';
809}
810
811
6206f6c4 812/***************************/
2ffa3f57 813/* Main of read_body.php */
6206f6c4 814/***************************/
57257333 815
0b97a708 816/* get the globals we may need */
817
e95c04ec 818sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
e95c04ec 819sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION);
e95c04ec 820if (!sqgetGlobalVar('messages', $messages, SQ_SESSION) ) {
821 $messages = array();
ce274df9 822}
81de00c0 823sqgetGlobalVar('delayed_errors', $delayed_errors, SQ_SESSION);
824if (is_array($delayed_errors)) {
825 $oErrorHandler->AssignDelayedErrors($delayed_errors);
826 sqsession_unregister("delayed_errors");
827}
e95c04ec 828/** GET VARS */
829sqgetGlobalVar('sendreceipt', $sendreceipt, SQ_GET);
324ac3c5 830if (!sqgetGlobalVar('where', $where, SQ_GET) ) {
831 $where = 'right_main.php';
832}
d0b119a5 833/*
834 * Used as entry key to the list of uid's cached in the mailbox cache
835 * we use the cached uid's to get the next and prev message.
836 */
324ac3c5 837if (!sqgetGlobalVar('what', $what, SQ_GET) ){
838 $what = 0;
839}
e95c04ec 840if ( sqgetGlobalVar('show_more', $temp, SQ_GET) ) {
841 $show_more = (int) $temp;
1b9f3c04 842}
e95c04ec 843if ( sqgetGlobalVar('show_more_cc', $temp, SQ_GET) ) {
844 $show_more_cc = (int) $temp;
0b97a708 845}
e95c04ec 846if ( sqgetGlobalVar('show_more_bcc', $temp, SQ_GET) ) {
847 $show_more_bcc = (int) $temp;
0b97a708 848}
e95c04ec 849if ( sqgetGlobalVar('view_hdr', $temp, SQ_GET) ) {
850 $view_hdr = (int) $temp;
0b97a708 851}
e95c04ec 852
91c27aee 853if ( sqgetGlobalVar('account', $temp, SQ_GET) ) {
854 $iAccount = (int) $temp;
855} else {
856 $iAccount = 0;
857}
858
e95c04ec 859/** GET/POST VARS */
860sqgetGlobalVar('passed_ent_id', $passed_ent_id);
861sqgetGlobalVar('mailbox', $mailbox);
862
863if ( sqgetGlobalVar('passed_id', $temp) ) {
864 $passed_id = (int) $temp;
0b97a708 865}
e95c04ec 866if ( sqgetGlobalVar('sort', $temp) ) {
867 $sort = (int) $temp;
0b97a708 868}
e95c04ec 869if ( sqgetGlobalVar('startMessage', $temp) ) {
870 $startMessage = (int) $temp;
324ac3c5 871} else {
872 $startMessage = 1;
ce274df9 873}
7277191e 874if(sqgetGlobalVar('show_html_default', $temp)) {
875 $show_html_default = (int) $temp;
876}
877
878if(sqgetGlobalVar('view_unsafe_images', $temp)) {
879 $view_unsafe_images = (int) $temp;
880 if($view_unsafe_images == 1) {
881 $show_html_default = 1;
882 }
883} else {
884 $view_unsafe_images = 0;
885}
324ac3c5 886/**
887 * Retrieve mailbox cache
888 */
889sqgetGlobalVar('mailbox_cache',$mailbox_cache,SQ_SESSION);
0b97a708 890
ce274df9 891/* end of get globals */
6201339c 892global $sqimap_capabilities, $lastTargetMailbox;
38c944cc 893
906f7e9f 894$imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
91c27aee 895$aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array());
896
c3731db5 897
91c27aee 898/**
c3731db5 899 Start code to set the columns to fetch in case of hitting the next/prev link
900 The reason for this is the fact that the cache can be invalidated which means that the headers
901 to fetch aren't there anymore. Before they got calculated when the messagelist was shown.
902
903 Todo, better central handling of setting the mailbox options so we do not need to do the stuff below
904*/
905
906/**
907 * Replace From => To in case it concerns a draft or sent folder
908 */
199ff86a 909$aColumns = array();
c3731db5 910if (($mailbox == $sent_folder || $mailbox == $draft_folder) &&
911 !in_array(SQM_COL_TO,$index_order)) {
912 $aNewOrder = array(); // nice var name ;)
913 foreach($index_order as $iCol) {
914 if ($iCol == SQM_COL_FROM) {
915 $iCol = SQM_COL_TO;
916 }
199ff86a 917 $aColumns[$iCol] = array();
c3731db5 918 }
c3731db5 919} else {
199ff86a 920 foreach ($index_order as $iCol) {
921 $aColumns[$iCol] = array();
922 }
c3731db5 923}
924
925$aProps = array(
926 'columns' => $aColumns, // columns bound settings
927 'config' => array(
928 'highlight_list' => $message_highlight_list, // row highlighting rules
929 'trash_folder' => $trash_folder,
930 'sent_folder' => $sent_folder,
931 'draft_folder' => $draft_folder));
932
933calcFetchColumns($aMailbox,$aProps);
934
935/**
936 End code to set the columns to fetch in case of hitting the next/prev link
937*/
938
939
940
941/**
942 * Check if cache is still valid, $what contains the key
943 * which gives us acces to the array with uid's. At this moment
944 * 0 is used for a normal message list and search uses 1 as key. This can be
945 * changed / extended in the future.
946 * If on a select of a mailbox we detect that the cache should be invalidated due to
947 * the delete of messages or due to new messages we empty the list with uid's and
948 * that's what we detect below.
949 */
91c27aee 950if (!is_array($aMailbox['UIDSET'][$what])) {
d0b119a5 951 fetchMessageHeaders($imapConnection, $aMailbox);
91c27aee 952}
38c944cc 953
d0b119a5 954$iSetIndex = $aMailbox['SETINDEX'];
955$aMailbox['CURRENT_MSG'][$iSetIndex] = $passed_id;
956
324ac3c5 957/**
958 * Update the seen state
959 * and ignore in_array('\\seen',$aMailbox['PERMANENTFLAGS'],true)
960 */
961if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS'])) {
962 $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\seen'] = true;
e0e30169 963}
e0e30169 964
1e150c97 965/**
966 * Process Delete from delete-move-next
967 * but only if delete_id was set
968 */
969if ( sqgetGlobalVar('delete_id', $delete_id, SQ_GET) ) {
324ac3c5 970 handleMessageListForm($imapConnection,$aMailbox,$sButton='setDeleted', array($delete_id));
1e150c97 971}
972
973/**
38c944cc 974 * $message contains all information about the message
975 * including header and body
976 */
37d2a6ee 977
324ac3c5 978if (isset($aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'])) {
979 $message = $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'];
980 $FirstTimeSee = !$message->is_seen;
38c944cc 981} else {
324ac3c5 982 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
983 $FirstTimeSee = !$message->is_seen;
984 $message->is_seen = true;
985 $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
5200c026 986}
dd628162 987if (isset($passed_ent_id) && $passed_ent_id) {
324ac3c5 988 $message = $message->getEntity($passed_ent_id);
989 if ($message->type0 != 'message' && $message->type1 != 'rfc822') {
990 $message = $message->parent;
991 }
992 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, TRUE);
993 $rfc822_header = new Rfc822Header();
994 $rfc822_header->parseHeader($read);
995 $message->rfc822_header = $rfc822_header;
91c27aee 996} else if ($message->type0 == 'message' && $message->type1 == 'rfc822' && isset($message->entities[0])) {
997 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[1.HEADER]", true, $response, $msg, TRUE);
998 $rfc822_header = new Rfc822Header();
999 $rfc822_header->parseHeader($read);
1000 $message->rfc822_header = $rfc822_header;
c615b1da 1001} else {
324ac3c5 1002 $passed_ent_id = 0;
38c944cc 1003}
5200c026 1004$header = $message->header;
57257333 1005
57257333 1006
6206f6c4 1007/****************************************/
1008/* Block for handling incoming url vars */
1009/****************************************/
5200c026 1010
5200c026 1011if (isset($sendreceipt)) {
1012 if ( !$message->is_mdnsent ) {
27a1d10a 1013 $final_recipient = '';
134e4174 1014 if ((isset($identity)) && ($identity != 0)) //Main identity
27a1d10a 1015 $final_recipient = trim(getPref($data_dir, $username, 'email_address' . $identity, '' ));
1016 if ($final_recipient == '' )
1017 $final_recipient = trim(getPref($data_dir, $username, 'email_address', '' ));
324ac3c5 1018 $supportMDN = ServerMDNSupport($aMailbox["PERMANENTFLAGS"]);
fc224f68 1019 if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) {
6201339c 1020 ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id);
5200c026 1021 $message->is_mdnsent = true;
1012f961 1022 $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
5200c026 1023 }
5200c026 1024 }
1025}
6206f6c4 1026/***********************************************/
1027/* End of block for handling incoming url vars */
1028/***********************************************/
1029
9f42bfc8 1030$messagebody = '';
c4ad259b 1031do_hook('read_body_top');
1032if ($show_html_default == 1) {
1033 $ent_ar = $message->findDisplayEntity(array());
1034} else {
1035 $ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
1036}
a128c967 1037$cnt = count($ent_ar);
1038for ($i = 0; $i < $cnt; $i++) {
6a108031 1039 $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
a128c967 1040 if ($i != $cnt-1) {
83ae18bc 1041 $messagebody .= '<hr style="height: 1px;" />';
a128c967 1042 }
38c944cc 1043}
e55c441a 1044
202bcbcc 1045/**
1046 * Write mailbox with updated seen flag information back to cache.
1047 */
1048$mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
1049sqsession_register($mailbox_cache,'mailbox_cache');
1050$_SESSION['mailbox_cache'] = $mailbox_cache;
202bcbcc 1051
b89ceca6 1052displayPageHeader($color, $mailbox,'','');
324ac3c5 1053formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message,false);
e0e30169 1054formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
a94c1db1 1055echo '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">';
6206f6c4 1056echo ' <tr><td>';
a94c1db1 1057echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">';
a128c967 1058echo ' <tr><td>';
a94c1db1 1059echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
6206f6c4 1060echo ' <tr bgcolor="'.$color[4].'"><td>';
98fb28fd 1061// echo ' <table cellpadding="1" cellspacing="5" align="left" border="0">';
605ce385 1062echo html_tag( 'table' ,'' , 'left', '', 'width="100%" cellpadding="1" cellspacing="5" border="0"' );
3c621ba1 1063echo ' <tr>' . html_tag( 'td', '<br />'. $messagebody."\n", 'left')
6c7b5d8c 1064 . '</tr>';
6206f6c4 1065echo ' </table>';
4669e892 1066echo ' </td></tr>';
6206f6c4 1067echo ' </table></td></tr>';
2ffa3f57 1068echo ' </table>';
1069echo ' </td></tr>';
a128c967 1070
3c621ba1 1071echo '<tr><td height="5" colspan="2" bgcolor="'.
1072 $color[4].'"></td></tr>'."\n";
d0a2476a 1073
a128c967 1074$attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id);
1075if ($attachmentsdisplay) {
8acd2fb5 1076 echo ' </table>';
6206f6c4 1077 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
2ffa3f57 1078 echo ' <tr><td>';
d0a2476a 1079 echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
4669e892 1080 echo ' <tr>' . html_tag( 'td', '', 'left', $color[9] );
6206f6c4 1081 echo ' <b>' . _("Attachments") . ':</b>';
1082 echo ' </td></tr>';
1083 echo ' <tr><td>';
1084 echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[0].'"><tr><td>';
1085 echo $attachmentsdisplay;
1086 echo ' </td></tr></table>';
6c7b5d8c 1087 echo ' </td></tr></table>';
6206f6c4 1088 echo ' </td></tr>';
3c621ba1 1089 echo '<tr><td height="5" colspan="2" bgcolor="'.
1090 $color[4].'"></td></tr>';
a128c967 1091}
c615b1da 1092echo '</table>';
a07cd1a4 1093
1094/* show attached images inline -- if pref'fed so */
5be9f195 1095if (($attachment_common_show_images) &&
a07cd1a4 1096 is_array($attachment_common_show_images_list)) {
1097 foreach ($attachment_common_show_images_list as $img) {
ce274df9 1098 $imgurl = SM_PATH . 'src/download.php' .
57257333 1099 '?' .
cd7b8833 1100 'passed_id=' . urlencode($img['passed_id']) .
3d570ba0 1101 '&amp;mailbox=' . urlencode($mailbox) .
ff9d4297 1102 '&amp;ent_id=' . urlencode($img['ent_id']) .
3d570ba0 1103 '&amp;absolute_dl=true';
5be9f195 1104
b5058e9e 1105 echo html_tag( 'table', "\n" .
d9c1dccc 1106 html_tag( 'tr', "\n" .
3c621ba1 1107 html_tag( 'td', '<img src="' . $imgurl . '" />' ."\n", 'left'
d9c1dccc 1108 )
1109 ) ,
3c621ba1 1110 'center', '', 'cellspacing="0" border="0" cellpadding="2"');
10f0ce72 1111 }
a07cd1a4 1112}
1113
324ac3c5 1114formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message, false, FALSE);
1e150c97 1115
c615b1da 1116do_hook('read_body_bottom');
a07cd1a4 1117sqimap_logout($imapConnection);
51d66ea2 1118$oTemplate->display('footer.tpl');
7277191e 1119?>