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