59177427 |
1 | <?php |
134e4174 |
2 | |
35586184 |
3 | /** |
4 | * read_body.php |
5 | * |
6c84ba1e |
6 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file is used for reading the msgs array and displaying |
10 | * the resulting emails in the right frame. |
11 | * |
30967a1e |
12 | * @version $Id$ |
8f6f9ba5 |
13 | * @package squirrelmail |
a07cd1a4 |
14 | */ |
35586184 |
15 | |
30967a1e |
16 | /** |
17 | * Path for SquirrelMail required files. |
18 | * @ignore |
19 | */ |
86725763 |
20 | define('SM_PATH','../'); |
21 | |
22 | /* SquirrelMail required files. */ |
08185f2a |
23 | require_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
24 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
25 | require_once(SM_PATH . 'functions/imap.php'); |
26 | require_once(SM_PATH . 'functions/mime.php'); |
27 | require_once(SM_PATH . 'functions/date.php'); |
28 | require_once(SM_PATH . 'functions/url_parser.php'); |
29 | require_once(SM_PATH . 'functions/html.php'); |
e95c04ec |
30 | require_once(SM_PATH . 'functions/global.php'); |
6d021521 |
31 | require_once(SM_PATH . 'functions/identity.php'); |
91c27aee |
32 | include_once(SM_PATH . 'functions/arrays.php'); |
d6b6d221 |
33 | require_once(SM_PATH . 'functions/mailbox_display.php'); |
38c944cc |
34 | |
a07cd1a4 |
35 | /** |
1fca12b5 |
36 | * Given an IMAP message id number, this will look it up in the cached |
1e150c97 |
37 | * and sorted msgs array and return the index of the next message |
1fca12b5 |
38 | * |
1e150c97 |
39 | * @param int $passed_id The current message UID |
1fca12b5 |
40 | * @return the index of the next valid message from the array |
41 | */ |
e0e30169 |
42 | function findNextMessage($uidset,$passed_id='backwards') { |
324ac3c5 |
43 | if (!is_array($uidset)) { |
44 | return -1; |
45 | } |
e0e30169 |
46 | if ($passed_id=='backwards' || !is_array($uidset)) { // check for backwards compattibilty gpg plugin |
47 | $passed_id = $uidset; |
e0e30169 |
48 | } |
91c27aee |
49 | $result = sqm_array_get_value_by_offset($uidset,$passed_id,1); |
50 | if ($result === false) { |
51 | return -1; |
52 | } else { |
53 | return $result; |
10f0ce72 |
54 | } |
a07cd1a4 |
55 | } |
56 | |
1e150c97 |
57 | /** |
58 | * Given an IMAP message id number, this will look it up in the cached |
59 | * and sorted msgs array and return the index of the previous message |
60 | * |
61 | * @param int $passed_id The current message UID |
62 | * @return the index of the next valid message from the array |
63 | */ |
e0e30169 |
64 | |
65 | function findPreviousMessage($uidset, $passed_id) { |
324ac3c5 |
66 | if (!is_array($uidset)) { |
67 | return -1; |
e0e30169 |
68 | } |
91c27aee |
69 | $result = sqm_array_get_value_by_offset($uidset,$passed_id,-1); |
70 | if ($result === false) { |
71 | return -1; |
72 | } else { |
73 | return $result; |
a07cd1a4 |
74 | } |
a07cd1a4 |
75 | } |
10f0ce72 |
76 | |
a07cd1a4 |
77 | /** |
1fca12b5 |
78 | * Displays a link to a page where the message is displayed more |
79 | * "printer friendly". |
1e150c97 |
80 | * @param string $mailbox Name of current mailbox |
4669e892 |
81 | * @param int $passed_id |
1fca12b5 |
82 | */ |
1e150c97 |
83 | function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) { |
ce68b76b |
84 | global $javascript_on; |
a07cd1a4 |
85 | |
e2da1d80 |
86 | /* hackydiehack */ |
87 | if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) { |
88 | $view_unsafe_images = false; |
89 | } else { |
90 | $view_unsafe_images = true; |
91 | } |
164584f0 |
92 | $params = '?passed_ent_id=' . urlencode($passed_ent_id) . |
c2324b26 |
93 | '&mailbox=' . urlencode($mailbox) . |
e2da1d80 |
94 | '&passed_id=' . urlencode($passed_id). |
95 | '&view_unsafe_images='. (bool) $view_unsafe_images; |
10f0ce72 |
96 | |
a07cd1a4 |
97 | $print_text = _("View Printable Version"); |
10f0ce72 |
98 | |
c615b1da |
99 | $result = ''; |
a07cd1a4 |
100 | /* Output the link. */ |
101 | if ($javascript_on) { |
9f42bfc8 |
102 | $result = '<script language="javascript" type="text/javascript">' . "\n" . |
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 |
118 | function 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 |
124 | function 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) { |
ff0969a0 |
266 | $msg = $deliver->dlv_msg . '<br />' . |
0e1a248b |
267 | _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' . |
00ac2f42 |
268 | $deliver->dlv_server_msg; |
d9c1dccc |
269 | require_once(SM_PATH . 'functions/display_messages.php'); |
fc224f68 |
270 | plain_error_message($msg, $color); |
271 | } else { |
272 | unset ($deliver); |
d9c1dccc |
273 | if (sqimap_mailbox_exists ($imapConnection, $sent_folder)) { |
274 | sqimap_append ($imapConnection, $sent_folder, $length); |
275 | require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php'); |
276 | $imap_deliver = new Deliver_IMAP(); |
277 | $imap_deliver->mail($composeMessage, $imapConnection); |
278 | sqimap_append_done ($imapConnection); |
279 | unset ($imap_deliver); |
280 | } |
281 | } |
282 | return $success; |
57257333 |
283 | } |
284 | |
6201339c |
285 | function ToggleMDNflag ($set ,$imapConnection, $mailbox, $passed_id) { |
d9c1dccc |
286 | $sg = $set?'+':'-'; |
287 | $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)'; |
4669e892 |
288 | $read = sqimap_run_command ($imapConnection, $cmd, true, $response, |
6201339c |
289 | $readmessage, TRUE); |
57257333 |
290 | } |
291 | |
292 | function ClearAttachments() { |
d9c1dccc |
293 | global $username, $attachments, $attachment_dir; |
294 | |
295 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
296 | |
297 | $rem_attachments = array(); |
6191bcb1 |
298 | if (isset($attachments)) { |
324ac3c5 |
299 | foreach ($attachments as $info) { |
300 | if ($info['session'] == -1) { |
301 | $attached_file = "$hashed_attachment_dir/$info[localfilename]"; |
302 | if (file_exists($attached_file)) { |
134e4174 |
303 | unlink($attached_file); |
324ac3c5 |
304 | } |
305 | } else { |
306 | $rem_attachments[] = $info; |
307 | } |
308 | } |
d9c1dccc |
309 | } |
310 | $attachments = $rem_attachments; |
57257333 |
311 | } |
312 | |
4d0cd98b |
313 | function formatRecipientString($recipients, $item ) { |
d9c1dccc |
314 | global $show_more_cc, $show_more, $show_more_bcc, |
315 | $PHP_SELF; |
4d0cd98b |
316 | |
d9c1dccc |
317 | $string = ''; |
38c944cc |
318 | if ((is_array($recipients)) && (isset($recipients[0]))) { |
d9c1dccc |
319 | $show = false; |
38c944cc |
320 | |
321 | if ($item == 'to') { |
d9c1dccc |
322 | if ($show_more) { |
323 | $show = true; |
324 | $url = set_url_var($PHP_SELF, 'show_more',0); |
325 | } else { |
326 | $url = set_url_var($PHP_SELF, 'show_more',1); |
327 | } |
328 | } else if ($item == 'cc') { |
329 | if ($show_more_cc) { |
330 | $show = true; |
331 | $url = set_url_var($PHP_SELF, 'show_more_cc',0); |
332 | } else { |
333 | $url = set_url_var($PHP_SELF, 'show_more_cc',1); |
334 | } |
335 | } else if ($item == 'bcc') { |
336 | if ($show_more_bcc) { |
337 | $show = true; |
338 | $url = set_url_var($PHP_SELF, 'show_more_bcc',0); |
339 | } else { |
340 | $url = set_url_var($PHP_SELF, 'show_more_bcc',1); |
341 | } |
342 | } |
343 | |
344 | $cnt = count($recipients); |
345 | foreach($recipients as $r) { |
a91189d6 |
346 | $add = decodeHeader($r->getAddress(true)); |
d9c1dccc |
347 | if ($string) { |
3c621ba1 |
348 | $string .= '<br />' . $add; |
d9c1dccc |
349 | } else { |
350 | $string = $add; |
351 | if ($cnt > 1) { |
3c621ba1 |
352 | $string .= ' (<a href="'.$url; |
d9c1dccc |
353 | if ($show) { |
3c621ba1 |
354 | $string .= '">'._("less").'</a>)'; |
d9c1dccc |
355 | } else { |
3c621ba1 |
356 | $string .= '">'._("more").'</a>)'; |
d9c1dccc |
357 | break; |
358 | } |
359 | } |
360 | } |
1fca12b5 |
361 | } |
4d0cd98b |
362 | } |
c615b1da |
363 | return $string; |
364 | } |
365 | |
e0e30169 |
366 | function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, |
af568a82 |
367 | $color, $FirstTimeSee) { |
ce68b76b |
368 | global $default_use_mdn, $default_use_priority, |
77836429 |
369 | $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on, |
134e4174 |
370 | $squirrelmail_language; |
38bca81c |
371 | |
134e4174 |
372 | $mailbox = $aMailbox['NAME']; |
e0e30169 |
373 | |
d9c1dccc |
374 | $header = $message->rfc822_header; |
375 | $env = array(); |
bdb9ce72 |
376 | $env[_("Subject")] = str_replace(" "," ",decodeHeader($header->subject)); |
7893c8a5 |
377 | |
d9c1dccc |
378 | $from_name = $header->getAddr_s('from'); |
d6b6d221 |
379 | if (!$from_name) |
d9c1dccc |
380 | $from_name = $header->getAddr_s('sender'); |
d6b6d221 |
381 | if (!$from_name) |
382 | $env[_("From")] = _("Unknown sender"); |
383 | else |
384 | $env[_("From")] = decodeHeader($from_name); |
d9c1dccc |
385 | $env[_("Date")] = getLongDateString($header->date); |
386 | $env[_("To")] = formatRecipientString($header->to, "to"); |
387 | $env[_("Cc")] = formatRecipientString($header->cc, "cc"); |
388 | $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc"); |
389 | if ($default_use_priority) { |
0e8006dc |
390 | $env[_("Priority")] = htmlspecialchars(getPriorityStr($header->priority)); |
d9c1dccc |
391 | } |
392 | if ($show_xmailer_default) { |
a91189d6 |
393 | $env[_("Mailer")] = decodeHeader($header->xmailer); |
d9c1dccc |
394 | } |
395 | if ($default_use_mdn) { |
396 | if ($mdn_user_support) { |
397 | if ($header->dnt) { |
398 | if ($message->is_mdnsent) { |
509ce88e |
399 | $env[_("Read receipt")] = _("sent"); |
d9c1dccc |
400 | } else { |
4669e892 |
401 | $env[_("Read receipt")] = _("requested"); |
402 | if (!(handleAsSent($mailbox) || |
d9c1dccc |
403 | $message->is_deleted || |
404 | $passed_ent_id)) { |
405 | $mdn_url = $PHP_SELF . '&sendreceipt=1'; |
406 | if ($FirstTimeSee && $javascript_on) { |
407 | $script = '<script language="JavaScript" type="text/javascript">' . "\n"; |
408 | $script .= '<!--'. "\n"; |
409 | $script .= 'if(window.confirm("' . |
410 | _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") . |
411 | '")) { '."\n" . |
412 | ' sendMDN()'. |
413 | '}' . "\n"; |
414 | $script .= '// -->'. "\n"; |
415 | $script .= '</script>'. "\n"; |
416 | echo $script; |
417 | } |
418 | $env[_("Read receipt")] .= ' <a href="' . $mdn_url . '">[' . |
419 | _("Send read receipt now") . ']</a>'; |
420 | } |
421 | } |
422 | } |
423 | } |
424 | } |
c615b1da |
425 | |
3c621ba1 |
426 | $s = '<table width="100%" cellpadding="0" cellspacing="2" border="0"'; |
427 | $s .= ' align="center" bgcolor="'.$color[0].'">'; |
d9c1dccc |
428 | foreach ($env as $key => $val) { |
429 | if ($val) { |
3c621ba1 |
430 | $s .= '<tr>'; |
431 | $s .= html_tag('td', '<b>' . $key . ': </b>', 'right', '', 'valign="top" width="20%"') . "\n"; |
432 | $s .= html_tag('td', $val, 'left', '', 'valign="top" width="80%"') . "\n"; |
433 | $s .= '</tr>'; |
d9c1dccc |
434 | } |
435 | } |
3c621ba1 |
436 | echo '<table bgcolor="'.$color[9].'" width="100%" cellpadding="1"'. |
437 | ' cellspacing="0" border="0" align="center">'."\n"; |
438 | echo '<tr><td height="5" colspan="2" bgcolor="'. |
439 | $color[4].'"></td></tr><tr><td align="center">'."\n"; |
d9c1dccc |
440 | echo $s; |
00ac2f42 |
441 | do_hook('read_body_header'); |
d9c1dccc |
442 | formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color); |
3c621ba1 |
443 | echo '</table>'; |
444 | echo '</td></tr><tr><td height="5" colspan="2" bgcolor="'.$color[4].'"></td></tr>'."\n"; |
445 | echo '</table>'; |
d9c1dccc |
446 | } |
c615b1da |
447 | |
1e150c97 |
448 | /** |
4669e892 |
449 | * Format message toolbar |
450 | * |
1e150c97 |
451 | * @param string $mailbox Name of current mailbox |
452 | * @param int $passed_id UID of current message |
453 | * @param int $passed_ent_id Id of entity within message |
454 | * @param object $message Current message object |
455 | * @param object $mbx_response |
456 | */ |
324ac3c5 |
457 | function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removedVar, $nav_on_top = TRUE) { |
a94c1db1 |
458 | global $base_uri, $draft_folder, $where, $what, $color, $sort, |
4669e892 |
459 | $startMessage, $PHP_SELF, $save_as_draft, |
1e150c97 |
460 | $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox, |
ce68b76b |
461 | $username, $delete_prev_next_display, |
91c27aee |
462 | $compose_new_win, $javascript_on, $compose_width, $compose_height; |
c615b1da |
463 | |
e0e30169 |
464 | //FIXME cleanup argument list, use $aMailbox where possible |
465 | $mailbox = $aMailbox['NAME']; |
466 | |
d9c1dccc |
467 | $topbar_delimiter = ' | '; |
1e150c97 |
468 | $double_delimiter = ' '; |
d9c1dccc |
469 | $urlMailbox = urlencode($mailbox); |
c615b1da |
470 | |
1e150c97 |
471 | $msgs_url = $base_uri . 'src/'; |
2ffa3f57 |
472 | |
1e150c97 |
473 | // BEGIN NAV ROW - PREV/NEXT, DEL PREV/NEXT, LINKS TO INDEX, etc. |
45c1ed84 |
474 | $nav_row = '<tr><td align="left" colspan="2" style="border: 1px solid '.$color[9].';"><small>'; |
e55c441a |
475 | |
1e150c97 |
476 | // Create Prev & Next links |
477 | // Handle nested entities first (i.e. Mime Attach parts) |
478 | if (isset($passed_ent_id) && $passed_ent_id) { |
479 | // code for navigating through attached message/rfc822 messages |
d9c1dccc |
480 | $url = set_url_var($PHP_SELF, 'passed_ent_id',0); |
70bdc740 |
481 | $entities = array(); |
482 | $entity_count = array(); |
483 | $c = 0; |
f2f03410 |
484 | |
70bdc740 |
485 | foreach($message->parent->entities as $ent) { |
9f42bfc8 |
486 | if ($ent->type0 == 'message' && $ent->type1 == 'rfc822') { |
487 | $c++; |
488 | $entity_count[$c] = $ent->entity_id; |
489 | $entities[$ent->entity_id] = $c; |
490 | } |
70bdc740 |
491 | } |
1e150c97 |
492 | |
70bdc740 |
493 | $prev_link = _("Previous"); |
91c27aee |
494 | if(isset($entities[$passed_ent_id]) && $entities[$passed_ent_id] > 1) { |
70bdc740 |
495 | $prev_ent_id = $entity_count[$entities[$passed_ent_id] - 1]; |
496 | $prev_link = '<a href="' |
497 | . set_url_var($PHP_SELF, 'passed_ent_id', $prev_ent_id) |
498 | . '">' . $prev_link . '</a>'; |
499 | } |
1e150c97 |
500 | |
501 | $next_link = _("Next"); |
91c27aee |
502 | if(isset($entities[$passed_ent_id]) && $entities[$passed_ent_id] < $c) { |
70bdc740 |
503 | $next_ent_id = $entity_count[$entities[$passed_ent_id] + 1]; |
504 | $next_link = '<a href="' |
505 | . set_url_var($PHP_SELF, 'passed_ent_id', $next_ent_id) |
506 | . '">' . $next_link . '</a>'; |
507 | } |
1e150c97 |
508 | |
d9c1dccc |
509 | $par_ent_id = $message->parent->entity_id; |
1e150c97 |
510 | $up_link = ''; |
d9c1dccc |
511 | if ($par_ent_id) { |
512 | $par_ent_id = substr($par_ent_id,0,-2); |
1e150c97 |
513 | if ( $par_ent_id != 0 ) { |
514 | $up_link = $topbar_delimiter; |
515 | $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id); |
516 | $up_link .= '<a href="'.$url.'">'._("Up").'</a>'; |
517 | } |
518 | } |
519 | |
520 | $nav_row .= $prev_link . $up_link . $topbar_delimiter . $next_link; |
abafb676 |
521 | $nav_row .= $double_delimiter . '[<a href="'.$url.'">'._("View Message").'</a>]'; |
1e150c97 |
522 | |
523 | // Prev/Next links for regular messages |
324ac3c5 |
524 | } else if ( true ) { //!(isset($where) && isset($what)) ) { |
324ac3c5 |
525 | $prev = findPreviousMessage($aMailbox['UIDSET'][$what], $passed_id); |
526 | $next = findNextMessage($aMailbox['UIDSET'][$what],$passed_id); |
1e150c97 |
527 | |
528 | $prev_link = _("Previous"); |
529 | if ($prev >= 0) { |
530 | $uri = $base_uri . 'src/read_body.php?passed_id='.$prev. |
531 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
324ac3c5 |
532 | "&where=$where&what=$what" . |
1e150c97 |
533 | '&startMessage='.$startMessage.'&show_more=0'; |
534 | $prev_link = '<a href="'.$uri.'">'.$prev_link.'</a>'; |
d9c1dccc |
535 | } |
1e150c97 |
536 | |
537 | $next_link = _("Next"); |
538 | if ($next >= 0) { |
539 | $uri = $base_uri . 'src/read_body.php?passed_id='.$next. |
540 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
324ac3c5 |
541 | "&where=$where&what=$what" . |
1e150c97 |
542 | '&startMessage='.$startMessage.'&show_more=0'; |
543 | $next_link = '<a href="'.$uri.'">'.$next_link.'</a>'; |
544 | } |
545 | |
1e150c97 |
546 | // Only bother with Delete & Prev and Delete & Next IF |
6201339c |
547 | // top display is enabled. |
4669e892 |
548 | if ( $delete_prev_next_display == 1 && |
324ac3c5 |
549 | in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) { |
45c1ed84 |
550 | $del_prev_link = _("Delete & Prev"); |
1e150c97 |
551 | if ($prev >= 0) { |
552 | $uri = $base_uri . 'src/read_body.php?passed_id='.$prev. |
553 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
554 | '&startMessage='.$startMessage.'&show_more=0'. |
324ac3c5 |
555 | "&where=$where&what=$what" . |
1e150c97 |
556 | '&delete_id='.$passed_id; |
4669e892 |
557 | $del_prev_link = '<a href="'.$uri.'">'.$del_prev_link.'</a>'; |
1e150c97 |
558 | } |
559 | |
45c1ed84 |
560 | $del_next_link = _("Delete & Next"); |
1e150c97 |
561 | if ($next >= 0) { |
562 | $uri = $base_uri . 'src/read_body.php?passed_id='.$next. |
563 | '&mailbox='.$urlMailbox.'&sort='.$sort. |
564 | '&startMessage='.$startMessage.'&show_more=0'. |
324ac3c5 |
565 | "&where=$where&what=$what" . |
1e150c97 |
566 | '&delete_id='.$passed_id; |
45c1ed84 |
567 | $del_next_link = '<a href="'.$uri.'">'.$del_next_link.'</a>'; |
1e150c97 |
568 | } |
1e150c97 |
569 | } |
45c1ed84 |
570 | |
abafb676 |
571 | $nav_row .= '['.$prev_link.$topbar_delimiter.$next_link.']'; |
572 | if ( isset($del_prev_link) && isset($del_next_link) ) |
573 | $nav_row .= $double_delimiter.'['.$del_prev_link.$topbar_delimiter.$del_next_link.']'; |
1e150c97 |
574 | } |
575 | |
576 | // Start with Search Results or Message List link. |
324ac3c5 |
577 | $msgs_url .= "$where?where=read_body.php&what=$what&mailbox=" . $urlMailbox. |
578 | "&startMessage=$startMessage"; |
579 | if ($where == 'search.php') { |
1e150c97 |
580 | $msgs_str = _("Search Results"); |
581 | } else { |
1e150c97 |
582 | $msgs_str = _("Message List"); |
583 | } |
584 | $nav_row .= $double_delimiter . |
abafb676 |
585 | '[<a href="' . $msgs_url . '">' . $msgs_str . '</a>]'; |
1e150c97 |
586 | |
587 | $nav_row .= '</small></td></tr>'; |
588 | |
589 | |
590 | // BEGIN MENU ROW - DELETE/REPLY/FORWARD/MOVE/etc. |
ad2ee09d |
591 | $menu_row = '<tr bgcolor="'.$color[0].'"><td><small>'; |
98a9cc03 |
592 | $comp_uri = $base_uri.'src/compose.php' . |
593 | '?passed_id=' . $passed_id . |
594 | '&mailbox=' . $urlMailbox . |
595 | '&startMessage=' . $startMessage . |
596 | (isset($passed_ent_id) ? '&passed_ent_id='.$passed_ent_id : ''); |
4669e892 |
597 | |
598 | // Start form for reply/reply all/forward.. |
1a531551 |
599 | $target = ''; |
600 | $on_click=''; |
ee66175d |
601 | $method='method="post" '; |
6190378c |
602 | $onsubmit=''; |
1a531551 |
603 | if ($compose_new_win == '1') { |
91c27aee |
604 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
605 | $compose_width = '640'; |
606 | } |
607 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
608 | $compose_height = '550'; |
609 | } |
1a531551 |
610 | if ( $javascript_on ) { |
91c27aee |
611 | $on_click=' onclick="comp_in_new_form(\''.$comp_uri.'\', this, this.form,'. $compose_width .',' . $compose_height .')"'; |
1a531551 |
612 | $comp_uri = 'javascript:void(0)'; |
ee66175d |
613 | $method='method="get" '; |
6190378c |
614 | $onsubmit = 'onsubmit="return false" '; |
1a531551 |
615 | } else { |
616 | $target = 'target="_blank"'; |
1a531551 |
617 | } |
618 | } |
619 | |
6190378c |
620 | $menu_row .= "\n".'<form name="composeForm" action="'.$comp_uri.'" ' |
621 | . $method.$target.$onsubmit.' style="display: inline">'."\n"; |
98a9cc03 |
622 | |
1e150c97 |
623 | // If Draft folder - create Resume link |
624 | if (($mailbox == $draft_folder) && ($save_as_draft)) { |
1a531551 |
625 | $new_button = 'smaction_draft'; |
1e150c97 |
626 | $comp_alt_string = _("Resume Draft"); |
627 | } else if (handleAsSent($mailbox)) { |
628 | // If in Sent folder, edit as new |
1a531551 |
629 | $new_button = 'smaction_edit_new'; |
1e150c97 |
630 | $comp_alt_string = _("Edit Message as New"); |
631 | } |
1e150c97 |
632 | // Show Alt URI for Draft/Sent |
98a9cc03 |
633 | if (isset($comp_alt_string)) |
e1728a7a |
634 | $menu_row .= getButton('submit', $new_button, $comp_alt_string, $on_click) . "\n"; |
1e150c97 |
635 | |
e1728a7a |
636 | $menu_row .= getButton('submit', 'smaction_reply', _("Reply"), $on_click) . "\n"; |
637 | $menu_row .= getButton('submit', 'smaction_reply_all', _("Reply All"), $on_click) ."\n"; |
638 | $menu_row .= getButton('submit', 'smaction_forward', _("Forward"), $on_click); |
98a9cc03 |
639 | if ($enable_forward_as_attachment) |
ff0969a0 |
640 | $menu_row .= '<input type="checkbox" name="smaction_attache" />' . _("As Attachment") .' '."\n"; |
1e150c97 |
641 | |
51eb014b |
642 | $menu_row .= '</form> '; |
c615b1da |
643 | |
324ac3c5 |
644 | if ( in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) { |
645 | // Form for deletion. Form is handled by the originating display in $where. This is right_main.php or search.php |
646 | $delete_url = $base_uri . "src/$where"; |
25e57ed2 |
647 | $menu_row .= '<form name="deleteMessageForm" action="'.$delete_url.'" method="post" style="display: inline">'; |
a128c967 |
648 | |
4669e892 |
649 | if (!(isset($passed_ent_id) && $passed_ent_id)) { |
324ac3c5 |
650 | $menu_row .= addHidden('mailbox', $aMailbox['NAME']); |
651 | $menu_row .= addHidden('msg[0]', $passed_id); |
7fcab811 |
652 | $menu_row .= addHidden('startMessage', $startMessage); |
e1728a7a |
653 | $menu_row .= getButton('submit', 'delete', _("Delete")); |
ff0969a0 |
654 | $menu_row .= '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash"); |
324ac3c5 |
655 | } else { |
e1728a7a |
656 | $menu_row .= getButton('submit', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled |
abafb676 |
657 | } |
abafb676 |
658 | |
4669e892 |
659 | $menu_row .= '</form>'; |
660 | } |
abafb676 |
661 | |
1e150c97 |
662 | // Add top move link |
663 | $menu_row .= '</small></td><td align="right">'; |
4669e892 |
664 | if ( !(isset($passed_ent_id) && $passed_ent_id) && |
324ac3c5 |
665 | in_array('\\deleted', $aMailbox['PERMANENTFLAGS'],true) ) { |
b2811304 |
666 | |
25e57ed2 |
667 | $menu_row .= '<form name="moveMessageForm" action="'.$base_uri.'src/'.$where.'?'.'" method="post" style="display: inline">'. |
64c9e87e |
668 | '<small>'. |
324ac3c5 |
669 | |
670 | addHidden('mailbox',$aMailbox['NAME']) . |
671 | addHidden('msg[0]', $passed_id) . _("Move to:") . |
1e150c97 |
672 | '<select name="targetMailbox" style="padding: 0px; margin: 0px">'; |
b2811304 |
673 | |
1e150c97 |
674 | if (isset($lastTargetMailbox) && !empty($lastTargetMailbox)) { |
675 | $menu_row .= sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox))); |
676 | } else { |
677 | $menu_row .= sqimap_mailbox_option_list($imapConnection); |
678 | } |
b2811304 |
679 | $menu_row .= '</select> '; |
680 | |
e1728a7a |
681 | $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n" . '</form>'; |
1e150c97 |
682 | } |
683 | $menu_row .= '</td></tr>'; |
d9c1dccc |
684 | |
1e150c97 |
685 | // echo rows, with hooks |
764971df |
686 | $ret = do_hook_function('read_body_menu_top', array($nav_row, $menu_row)); |
988e24f6 |
687 | if (is_array($ret)) { |
688 | if (isset($ret[0]) && !empty($ret[0])) { |
689 | $nav_row = $ret[0]; |
690 | } |
691 | if (isset($ret[1]) && !empty($ret[1])) { |
692 | $menu_row = $ret[1]; |
693 | } |
764971df |
694 | } |
1e150c97 |
695 | echo '<table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">'; |
696 | echo $nav_on_top ? $nav_row . $menu_row : $menu_row . $nav_row; |
697 | echo '</table>'."\n"; |
d62c4938 |
698 | do_hook('read_body_menu_bottom'); |
c615b1da |
699 | } |
700 | |
701 | function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) { |
78909469 |
702 | global $base_uri, $where, $what; |
4669e892 |
703 | |
d9c1dccc |
704 | $urlMailbox = urlencode($mailbox); |
78909469 |
705 | $urlPassed_id = urlencode($passed_id); |
706 | $urlPassed_ent_id = urlencode($passed_ent_id); |
4669e892 |
707 | |
78909469 |
708 | $query_string = 'mailbox=' . $urlMailbox . '&passed_id=' . $urlPassed_id . '&passed_ent_id=' . $urlPassed_ent_id; |
4669e892 |
709 | |
78909469 |
710 | if (!empty($where)) { |
711 | $query_string .= '&where=' . urlencode($where); |
712 | } |
713 | |
714 | if (!empty($what)) { |
715 | $query_string .= '&what=' . urlencode($what); |
716 | } |
717 | |
e95c04ec |
718 | $url = $base_uri.'src/view_header.php?'.$query_string; |
d9c1dccc |
719 | |
3c621ba1 |
720 | $s = "<tr>\n" . |
721 | html_tag( 'td', '', 'right', '', 'valign="middle" width="20%"' ) . '<b>' . _("Options") . ": </b></td>\n" . |
722 | html_tag( 'td', '', 'left', '', 'valign="middle" width="80%"' ) . '<small>' . |
d9c1dccc |
723 | '<a href="'.$url.'">'._("View Full Header").'</a>'; |
724 | |
725 | /* Output the printer friendly link if we are in subtle mode. */ |
726 | $s .= ' | ' . |
1e150c97 |
727 | printer_friendly_link($mailbox, $passed_id, $passed_ent_id); |
d9c1dccc |
728 | echo $s; |
729 | do_hook("read_body_header_right"); |
3c621ba1 |
730 | $s = "</small></td>\n" . |
731 | "</tr>\n"; |
d9c1dccc |
732 | echo $s; |
a128c967 |
733 | |
4d0cd98b |
734 | } |
735 | |
91c27aee |
736 | /** |
737 | * Creates button |
738 | * |
739 | * @deprecated see form functions available in 1.5.1 and 1.4.3. |
740 | * @param string $type |
741 | * @param string $name |
742 | * @param string $value |
743 | * @param string $js |
744 | * @param bool $enabled |
745 | */ |
746 | function getButton($type, $name, $value, $js = '', $enabled = TRUE) { |
747 | $disabled = ( $enabled ? '' : 'disabled ' ); |
748 | $js = ( $js ? $js.' ' : '' ); |
749 | return '<input '.$disabled.$js. |
750 | 'type="'.$type. |
751 | '" name="'.$name. |
752 | '" value="'.$value . |
753 | '" style="padding: 0px; margin: 0px" />'; |
754 | } |
755 | |
756 | |
6206f6c4 |
757 | /***************************/ |
2ffa3f57 |
758 | /* Main of read_body.php */ |
6206f6c4 |
759 | /***************************/ |
57257333 |
760 | |
0b97a708 |
761 | /* get the globals we may need */ |
762 | |
1e12d1ff |
763 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
e95c04ec |
764 | sqgetGlobalVar('username', $username, SQ_SESSION); |
765 | sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION); |
e95c04ec |
766 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
1e12d1ff |
767 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
e95c04ec |
768 | sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION); |
e95c04ec |
769 | if (!sqgetGlobalVar('messages', $messages, SQ_SESSION) ) { |
770 | $messages = array(); |
ce274df9 |
771 | } |
772 | |
e95c04ec |
773 | /** GET VARS */ |
774 | sqgetGlobalVar('sendreceipt', $sendreceipt, SQ_GET); |
324ac3c5 |
775 | if (!sqgetGlobalVar('where', $where, SQ_GET) ) { |
776 | $where = 'right_main.php'; |
777 | } |
d0b119a5 |
778 | /* |
779 | * Used as entry key to the list of uid's cached in the mailbox cache |
780 | * we use the cached uid's to get the next and prev message. |
781 | */ |
324ac3c5 |
782 | if (!sqgetGlobalVar('what', $what, SQ_GET) ){ |
783 | $what = 0; |
784 | } |
e95c04ec |
785 | if ( sqgetGlobalVar('show_more', $temp, SQ_GET) ) { |
786 | $show_more = (int) $temp; |
1b9f3c04 |
787 | } |
e95c04ec |
788 | if ( sqgetGlobalVar('show_more_cc', $temp, SQ_GET) ) { |
789 | $show_more_cc = (int) $temp; |
0b97a708 |
790 | } |
e95c04ec |
791 | if ( sqgetGlobalVar('show_more_bcc', $temp, SQ_GET) ) { |
792 | $show_more_bcc = (int) $temp; |
0b97a708 |
793 | } |
e95c04ec |
794 | if ( sqgetGlobalVar('view_hdr', $temp, SQ_GET) ) { |
795 | $view_hdr = (int) $temp; |
0b97a708 |
796 | } |
e95c04ec |
797 | |
91c27aee |
798 | if ( sqgetGlobalVar('account', $temp, SQ_GET) ) { |
799 | $iAccount = (int) $temp; |
800 | } else { |
801 | $iAccount = 0; |
802 | } |
803 | |
e95c04ec |
804 | /** GET/POST VARS */ |
805 | sqgetGlobalVar('passed_ent_id', $passed_ent_id); |
806 | sqgetGlobalVar('mailbox', $mailbox); |
807 | |
808 | if ( sqgetGlobalVar('passed_id', $temp) ) { |
809 | $passed_id = (int) $temp; |
0b97a708 |
810 | } |
e95c04ec |
811 | if ( sqgetGlobalVar('sort', $temp) ) { |
812 | $sort = (int) $temp; |
0b97a708 |
813 | } |
e95c04ec |
814 | if ( sqgetGlobalVar('startMessage', $temp) ) { |
815 | $startMessage = (int) $temp; |
324ac3c5 |
816 | } else { |
817 | $startMessage = 1; |
ce274df9 |
818 | } |
324ac3c5 |
819 | /** |
820 | * Retrieve mailbox cache |
821 | */ |
822 | sqgetGlobalVar('mailbox_cache',$mailbox_cache,SQ_SESSION); |
0b97a708 |
823 | |
ce274df9 |
824 | /* end of get globals */ |
6201339c |
825 | global $sqimap_capabilities, $lastTargetMailbox; |
38c944cc |
826 | |
6206f6c4 |
827 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
91c27aee |
828 | $aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array()); |
829 | |
830 | /** |
d0b119a5 |
831 | * Check if cache is still valid, $what contains the key |
832 | * which gives us acces to the array with uid's. At this moment |
833 | * 0 is used for a normal message list and search uses 1 as key. This can be |
834 | * changed / extended in the future. |
835 | * If on a select of a mailbox we detect that the cache should be invalidated due to |
836 | * the delete of messages or due to new messages we empty the list with uid's and |
837 | * that's what we detect below. |
838 | */ |
91c27aee |
839 | if (!is_array($aMailbox['UIDSET'][$what])) { |
d0b119a5 |
840 | fetchMessageHeaders($imapConnection, $aMailbox); |
91c27aee |
841 | } |
38c944cc |
842 | |
d0b119a5 |
843 | $iSetIndex = $aMailbox['SETINDEX']; |
844 | $aMailbox['CURRENT_MSG'][$iSetIndex] = $passed_id; |
845 | |
324ac3c5 |
846 | /** |
847 | * Update the seen state |
848 | * and ignore in_array('\\seen',$aMailbox['PERMANENTFLAGS'],true) |
849 | */ |
850 | if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS'])) { |
851 | $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\seen'] = true; |
e0e30169 |
852 | } |
e0e30169 |
853 | |
1e150c97 |
854 | /** |
855 | * Process Delete from delete-move-next |
856 | * but only if delete_id was set |
857 | */ |
858 | if ( sqgetGlobalVar('delete_id', $delete_id, SQ_GET) ) { |
324ac3c5 |
859 | handleMessageListForm($imapConnection,$aMailbox,$sButton='setDeleted', array($delete_id)); |
1e150c97 |
860 | } |
861 | |
38c944cc |
862 | /** |
863 | * $message contains all information about the message |
864 | * including header and body |
865 | */ |
37d2a6ee |
866 | |
324ac3c5 |
867 | if (isset($aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'])) { |
868 | $message = $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT']; |
869 | $FirstTimeSee = !$message->is_seen; |
38c944cc |
870 | } else { |
324ac3c5 |
871 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
872 | $FirstTimeSee = !$message->is_seen; |
873 | $message->is_seen = true; |
874 | $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message; |
5200c026 |
875 | } |
af568a82 |
876 | |
dd628162 |
877 | if (isset($passed_ent_id) && $passed_ent_id) { |
324ac3c5 |
878 | $message = $message->getEntity($passed_ent_id); |
879 | if ($message->type0 != 'message' && $message->type1 != 'rfc822') { |
880 | $message = $message->parent; |
881 | } |
882 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, TRUE); |
883 | $rfc822_header = new Rfc822Header(); |
884 | $rfc822_header->parseHeader($read); |
885 | $message->rfc822_header = $rfc822_header; |
91c27aee |
886 | } else if ($message->type0 == 'message' && $message->type1 == 'rfc822' && isset($message->entities[0])) { |
887 | $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[1.HEADER]", true, $response, $msg, TRUE); |
888 | $rfc822_header = new Rfc822Header(); |
889 | $rfc822_header->parseHeader($read); |
890 | $message->rfc822_header = $rfc822_header; |
c615b1da |
891 | } else { |
324ac3c5 |
892 | $passed_ent_id = 0; |
38c944cc |
893 | } |
5200c026 |
894 | $header = $message->header; |
57257333 |
895 | |
91c27aee |
896 | $header = $message->header; |
897 | |
57257333 |
898 | |
6206f6c4 |
899 | /****************************************/ |
900 | /* Block for handling incoming url vars */ |
901 | /****************************************/ |
5200c026 |
902 | |
5200c026 |
903 | if (isset($sendreceipt)) { |
904 | if ( !$message->is_mdnsent ) { |
27a1d10a |
905 | $final_recipient = ''; |
134e4174 |
906 | if ((isset($identity)) && ($identity != 0)) //Main identity |
27a1d10a |
907 | $final_recipient = trim(getPref($data_dir, $username, 'email_address' . $identity, '' )); |
908 | if ($final_recipient == '' ) |
909 | $final_recipient = trim(getPref($data_dir, $username, 'email_address', '' )); |
324ac3c5 |
910 | $supportMDN = ServerMDNSupport($aMailbox["PERMANENTFLAGS"]); |
fc224f68 |
911 | if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) { |
6201339c |
912 | ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id); |
5200c026 |
913 | $message->is_mdnsent = true; |
1012f961 |
914 | $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message; |
5200c026 |
915 | } |
916 | ClearAttachments(); |
917 | } |
918 | } |
6206f6c4 |
919 | /***********************************************/ |
920 | /* End of block for handling incoming url vars */ |
921 | /***********************************************/ |
922 | |
324ac3c5 |
923 | |
9f42bfc8 |
924 | |
925 | $messagebody = ''; |
c4ad259b |
926 | do_hook('read_body_top'); |
927 | if ($show_html_default == 1) { |
928 | $ent_ar = $message->findDisplayEntity(array()); |
929 | } else { |
930 | $ent_ar = $message->findDisplayEntity(array(), array('text/plain')); |
931 | } |
a128c967 |
932 | $cnt = count($ent_ar); |
933 | for ($i = 0; $i < $cnt; $i++) { |
6a108031 |
934 | $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox); |
a128c967 |
935 | if ($i != $cnt-1) { |
83ae18bc |
936 | $messagebody .= '<hr style="height: 1px;" />'; |
a128c967 |
937 | } |
38c944cc |
938 | } |
e55c441a |
939 | |
b89ceca6 |
940 | displayPageHeader($color, $mailbox,'',''); |
324ac3c5 |
941 | formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message,false); |
e0e30169 |
942 | formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee); |
a94c1db1 |
943 | echo '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">'; |
6206f6c4 |
944 | echo ' <tr><td>'; |
a94c1db1 |
945 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'; |
a128c967 |
946 | echo ' <tr><td>'; |
a94c1db1 |
947 | echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">'; |
6206f6c4 |
948 | echo ' <tr bgcolor="'.$color[4].'"><td>'; |
98fb28fd |
949 | // echo ' <table cellpadding="1" cellspacing="5" align="left" border="0">'; |
605ce385 |
950 | echo html_tag( 'table' ,'' , 'left', '', 'width="100%" cellpadding="1" cellspacing="5" border="0"' ); |
3c621ba1 |
951 | echo ' <tr>' . html_tag( 'td', '<br />'. $messagebody."\n", 'left') |
6c7b5d8c |
952 | . '</tr>'; |
6206f6c4 |
953 | echo ' </table>'; |
4669e892 |
954 | echo ' </td></tr>'; |
6206f6c4 |
955 | echo ' </table></td></tr>'; |
2ffa3f57 |
956 | echo ' </table>'; |
957 | echo ' </td></tr>'; |
a128c967 |
958 | |
3c621ba1 |
959 | echo '<tr><td height="5" colspan="2" bgcolor="'. |
960 | $color[4].'"></td></tr>'."\n"; |
d0a2476a |
961 | |
a128c967 |
962 | $attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id); |
963 | if ($attachmentsdisplay) { |
8acd2fb5 |
964 | echo ' </table>'; |
6206f6c4 |
965 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">'; |
2ffa3f57 |
966 | echo ' <tr><td>'; |
d0a2476a |
967 | echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'; |
4669e892 |
968 | echo ' <tr>' . html_tag( 'td', '', 'left', $color[9] ); |
6206f6c4 |
969 | echo ' <b>' . _("Attachments") . ':</b>'; |
970 | echo ' </td></tr>'; |
971 | echo ' <tr><td>'; |
972 | echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[0].'"><tr><td>'; |
973 | echo $attachmentsdisplay; |
974 | echo ' </td></tr></table>'; |
6c7b5d8c |
975 | echo ' </td></tr></table>'; |
6206f6c4 |
976 | echo ' </td></tr>'; |
3c621ba1 |
977 | echo '<tr><td height="5" colspan="2" bgcolor="'. |
978 | $color[4].'"></td></tr>'; |
a128c967 |
979 | } |
c615b1da |
980 | echo '</table>'; |
a07cd1a4 |
981 | |
982 | /* show attached images inline -- if pref'fed so */ |
5be9f195 |
983 | if (($attachment_common_show_images) && |
a07cd1a4 |
984 | is_array($attachment_common_show_images_list)) { |
985 | foreach ($attachment_common_show_images_list as $img) { |
ce274df9 |
986 | $imgurl = SM_PATH . 'src/download.php' . |
57257333 |
987 | '?' . |
cd7b8833 |
988 | 'passed_id=' . urlencode($img['passed_id']) . |
3d570ba0 |
989 | '&mailbox=' . urlencode($mailbox) . |
ff9d4297 |
990 | '&ent_id=' . urlencode($img['ent_id']) . |
3d570ba0 |
991 | '&absolute_dl=true'; |
5be9f195 |
992 | |
b5058e9e |
993 | echo html_tag( 'table', "\n" . |
d9c1dccc |
994 | html_tag( 'tr', "\n" . |
3c621ba1 |
995 | html_tag( 'td', '<img src="' . $imgurl . '" />' ."\n", 'left' |
d9c1dccc |
996 | ) |
997 | ) , |
3c621ba1 |
998 | 'center', '', 'cellspacing="0" border="0" cellpadding="2"'); |
10f0ce72 |
999 | } |
a07cd1a4 |
1000 | } |
1001 | |
324ac3c5 |
1002 | formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message, false, FALSE); |
1e150c97 |
1003 | |
c615b1da |
1004 | do_hook('read_body_bottom'); |
a07cd1a4 |
1005 | sqimap_logout($imapConnection); |
91c27aee |
1006 | |
1007 | /** |
1008 | * Write mailbox with updated seen flag information back to cache. |
1009 | */ |
1010 | $mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox; |
324ac3c5 |
1011 | sqsession_register($mailbox_cache,'mailbox_cache'); |
dcc1cc82 |
1012 | ?> |
83ae18bc |
1013 | </body></html> |