59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * compose.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This code sends a mail. |
10 | * |
11 | * There are 4 modes of operation: |
12 | * - Start new mail |
13 | * - Add an attachment |
14 | * - Send mail |
15 | * - Save As Draft |
16 | * |
17 | * $Id$ |
18 | */ |
f7fb20fe |
19 | |
35586184 |
20 | require_once('../src/validate.php'); |
21 | require_once('../functions/imap.php'); |
22 | require_once('../functions/date.php'); |
23 | require_once('../functions/mime.php'); |
24 | require_once('../functions/smtp.php'); |
35586184 |
25 | require_once('../functions/plugin.php'); |
41b94d65 |
26 | require_once('../functions/display_messages.php'); |
09044055 |
27 | /* --------------------- Specific Functions ------------------------------ */ |
28 | |
41b94d65 |
29 | function replyAllString($header) { |
30 | global $include_self_reply_all, $username, $data_dir; |
31 | $excl_arr = array(); |
32 | /** |
33 | * 1) Remove the addresses we'll be sending the message 'to' |
34 | */ |
35 | $url_replytoall_avoid_addrs = ''; |
36 | if (isset($header->replyto)) { |
37 | $excl_ar = $header->getAddr_a('replyto'); |
38 | } |
39 | /** |
40 | * 2) Remove our identities from the CC list (they still can be in the |
41 | * TO list) only if $include_self_reply_all is turned off |
42 | */ |
43 | if (!$include_self_reply_all) { |
44 | $email_address = trim(getPref($data_dir, $username, 'email_address')); |
45 | $excl_ar[$email_address] = ''; |
46 | |
47 | $idents = getPref($data_dir, $username, 'identities'); |
48 | if ($idents != '' && $idents > 1) { |
49 | for ($i = 1; $i < $idents; $i ++) { |
50 | $cur_email_address = getPref($data_dir, $username, |
51 | 'email_address' . $i); |
52 | $cur_email_address = strtolower($cur_email_address); |
53 | $excl_ar[$cur_email_address] = ''; |
54 | } |
55 | } |
56 | } |
57 | |
58 | /** |
59 | * 3) get the addresses. |
60 | */ |
61 | $url_replytoall_ar = $header->getAddr_a(array('to','cc'), $excl_ar); |
62 | |
63 | /** |
64 | * 4) generate the string. |
65 | */ |
66 | $url_replytoallcc = ''; |
67 | foreach( $url_replytoall_ar as $email => $personal) { |
68 | if ($personal) { |
69 | $url_replytoallcc .= ", \"$personal\" <$email>"; |
70 | } else { |
71 | $url_replytoallcc .= ', '. $email; |
72 | } |
73 | } |
74 | $url_replytoallcc = substr($url_replytoallcc,2); |
75 | return $url_replytoallcc; |
09044055 |
76 | } |
77 | |
41b94d65 |
78 | function getforwardHeader($orig_header) { |
a45887d7 |
79 | $display = array( |
80 | _("Subject") => strlen(_("Subject")), |
81 | _("From") => strlen(_("From")), |
82 | _("Date") => strlen(_("Date")), |
83 | _("To") => strlen(_("To")), |
84 | _("Cc") => strlen(_("Cc")) |
85 | ); |
86 | $maxsize = max($display); |
87 | $indent = str_pad('',$maxsize+2); |
88 | foreach($display as $key => $val) { |
89 | $display[$key] = $key .': '. str_pad('', $maxsize - $val); |
90 | } |
91 | $bodyTop = str_pad(' '._("Original Message").' ',78, '-',STR_PAD_BOTH); |
92 | $bodyTop .= "\n". $display[_("Subject")] . $orig_header->subject . "\n" . |
93 | $display[_("From")] . $orig_header->getAddr_s('from',"\n$indent") . "\n" . |
94 | $display[_("Date")] . getLongDateString( $orig_header->date ). "\n" . |
95 | $display[_("To")] . $orig_header->getAddr_s('to',"\n$indent") ."\n"; |
41b94d65 |
96 | if ($orig_header->cc != array() && $orig_header->cc !='') { |
a45887d7 |
97 | $bodyTop .= $display[_("Cc")] . $orig_header->getAddr_s('cc',"\n$indent") . "\n"; |
41b94d65 |
98 | } |
a45887d7 |
99 | $bodyTop .= str_pad('',78, '-'); |
41b94d65 |
100 | $bodyTop .= "\n"; |
101 | return $bodyTop; |
102 | } |
09044055 |
103 | /* ----------------------------------------------------------------------- */ |
104 | |
44560457 |
105 | /* |
106 | * If the session is expired during a post this restores the compose session |
107 | * vars. |
108 | */ |
109 | //$session_expired = false; |
110 | if (session_is_registered('session_expired_post')) { |
111 | global $session_expired_post, $session_expired; |
112 | /* |
113 | * extra check for username so we don't display previous post data from |
114 | * another user during this session. |
115 | */ |
116 | if ($session_expired_post['username'] != $username) { |
117 | session_unregister('session_expired_post'); |
118 | session_unregister('session_expired'); |
119 | } else { |
120 | foreach ($session_expired_post as $postvar => $val) { |
121 | if (isset($val)) { |
122 | $$postvar = $val; |
123 | } else { |
124 | $$postvar = ''; |
125 | } |
126 | } |
127 | if (isset($send)) { |
128 | unset($send); |
129 | } |
130 | $session_expired = true; |
131 | } |
132 | session_unregister('session_expired_post'); |
133 | session_unregister('session_expired'); |
3f6b1b6f |
134 | if (!isset($mailbox)) { |
135 | $mailbox = ''; |
136 | } |
44560457 |
137 | if ($compose_new_win == '1') { |
138 | compose_Header($color, $mailbox); |
139 | } else { |
140 | displayPageHeader($color, $mailbox); |
141 | } |
142 | showInputForm($session, false); |
143 | exit(); |
144 | } |
145 | |
48985d59 |
146 | if (!isset($attachments)) { |
147 | $attachments = array(); |
148 | session_register('attachments'); |
149 | } |
150 | |
da95c4b6 |
151 | if (!isset($composesession)) { |
152 | $composesession = 0; |
153 | session_register('composesession'); |
154 | } |
155 | |
d7f8e6e6 |
156 | if (!isset($session) || (isset($newmessage) && $newmessage)) { |
da95c4b6 |
157 | $session = "$composesession" +1; |
158 | $composesession = $session; |
d7f8e6e6 |
159 | } |
da95c4b6 |
160 | |
00793a25 |
161 | if (!isset($mailbox) || $mailbox == '' || ($mailbox == 'None')) { |
162 | $mailbox = 'INBOX'; |
163 | } |
164 | |
165 | if (isset($draft)) { |
715225af |
166 | include_once ('../src/draft_actions.php'); |
3f6b1b6f |
167 | if (! isset($passed_id)) { |
168 | $passed_id = 0; |
113e5e9d |
169 | } |
7058a2a9 |
170 | if (! isset($MDN)) { |
171 | $MDN = 'False'; |
113e5e9d |
172 | } |
fa77d354 |
173 | if (! isset($mailprio)) { |
174 | $mailprio = ''; |
175 | } |
3f6b1b6f |
176 | if (!saveMessageAsDraft($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $passed_id, $mailprio, $session)) { |
da95c4b6 |
177 | showInputForm($session); |
00793a25 |
178 | exit(); |
734f4ee6 |
179 | } else { |
00793a25 |
180 | $draft_message = _("Draft Email Saved"); |
181 | /* If this is a resumed draft, then delete the original */ |
182 | if(isset($delete_draft)) { |
7058a2a9 |
183 | Header("Location: delete_message.php?mailbox=" . urlencode($draft_folder) . |
fae72101 |
184 | "&message=$delete_draft&sort=$sort&startMessage=1&saved_draft=yes"); |
00793a25 |
185 | exit(); |
7058a2a9 |
186 | } |
9c3e6cd4 |
187 | else { |
188 | if ($compose_new_win == '1') { |
da95c4b6 |
189 | Header("Location: compose.php?saved_draft=yes&session=$composesession"); |
9c3e6cd4 |
190 | exit(); |
191 | } |
192 | else { |
fae72101 |
193 | Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort". |
2017ebeb |
194 | "&startMessage=1¬e=".urlencode($draft_message)); |
00793a25 |
195 | exit(); |
9c3e6cd4 |
196 | } |
00793a25 |
197 | } |
198 | } |
199 | } |
200 | |
201 | if (isset($send)) { |
202 | if (isset($HTTP_POST_FILES['attachfile']) && |
203 | $HTTP_POST_FILES['attachfile']['tmp_name'] && |
204 | $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none') { |
da95c4b6 |
205 | $AttachFailure = saveAttachedFiles($session); |
00793a25 |
206 | } |
207 | if (checkInput(false) && !isset($AttachFailure)) { |
208 | $urlMailbox = urlencode (trim($mailbox)); |
3f6b1b6f |
209 | if (! isset($passed_id)) { |
210 | $passed_id = 0; |
00793a25 |
211 | } |
212 | /* |
213 | * Set $default_charset to correspond with the user's selection |
7058a2a9 |
214 | * of language interface. |
00793a25 |
215 | */ |
216 | set_my_charset(); |
217 | |
218 | /* |
219 | * This is to change all newlines to \n |
7058a2a9 |
220 | * We'll change them to \r\n later (in the sendMessage function) |
00793a25 |
221 | */ |
222 | $body = str_replace("\r\n", "\n", $body); |
223 | $body = str_replace("\r", "\n", $body); |
224 | |
225 | /* |
226 | * Rewrap $body so that no line is bigger than $editor_size |
227 | * This should only really kick in the sqWordWrap function |
f302d704 |
228 | * if the browser doesn't support "VIRTUAL" as the wrap type. |
00793a25 |
229 | */ |
230 | $body = explode("\n", $body); |
231 | $newBody = ''; |
232 | foreach ($body as $line) { |
233 | if( $line <> '-- ' ) { |
234 | $line = rtrim($line); |
235 | } |
236 | if (strlen($line) <= $editor_size + 1) { |
237 | $newBody .= $line . "\n"; |
734f4ee6 |
238 | } else { |
e0858036 |
239 | sqWordWrap($line, $editor_size); |
240 | $newBody .= $line . "\n"; |
00793a25 |
241 | } |
242 | } |
243 | $body = $newBody; |
244 | |
e02775fe |
245 | do_hook('compose_send'); |
246 | |
57257333 |
247 | $MDN = False; // we are not sending a mdn response |
00793a25 |
248 | if (! isset($mailprio)) { |
249 | $Result = sendMessage($send_to, $send_to_cc, $send_to_bcc, |
3f6b1b6f |
250 | $subject, $body, $passed_id, $MDN, '', $session); |
734f4ee6 |
251 | } else { |
00793a25 |
252 | $Result = sendMessage($send_to, $send_to_cc, $send_to_bcc, |
3f6b1b6f |
253 | $subject, $body, $passed_id, $MDN, $mailprio, $session); |
00793a25 |
254 | } |
255 | if (! $Result) { |
da95c4b6 |
256 | showInputForm($session); |
00793a25 |
257 | exit(); |
258 | } |
259 | if ( isset($delete_draft)) { |
7058a2a9 |
260 | Header("Location: delete_message.php?mailbox=" . urlencode( $draft_folder ). |
fae72101 |
261 | "&message=$delete_draft&sort=$sort&startMessage=1&mail_sent=yes"); |
00793a25 |
262 | exit(); |
263 | } |
9c3e6cd4 |
264 | if ($compose_new_win == '1') { |
d7f8e6e6 |
265 | Header("Location: compose.php?mail_sent=yes"); |
9c3e6cd4 |
266 | } |
267 | else { |
fae72101 |
268 | Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort". |
269 | "&startMessage=1"); |
9c3e6cd4 |
270 | } |
734f4ee6 |
271 | } else { |
00793a25 |
272 | /* |
273 | *$imapConnection = sqimap_login($username, $key, $imapServerAddress, |
274 | * $imapPort, 0); |
275 | */ |
9c3e6cd4 |
276 | if ($compose_new_win == '1') { |
277 | compose_Header($color, $mailbox); |
278 | } |
279 | else { |
280 | displayPageHeader($color, $mailbox); |
281 | } |
00793a25 |
282 | if (isset($AttachFailure)) { |
283 | plain_error_message(_("Could not move/copy file. File not attached"), |
284 | $color); |
285 | } |
00793a25 |
286 | checkInput(true); |
da95c4b6 |
287 | showInputForm($session); |
00793a25 |
288 | /* sqimap_logout($imapConnection); */ |
289 | } |
e02775fe |
290 | } elseif (isset($html_addr_search_done)) { |
9c3e6cd4 |
291 | if ($compose_new_win == '1') { |
292 | compose_Header($color, $mailbox); |
293 | } |
294 | else { |
295 | displayPageHeader($color, $mailbox); |
296 | } |
00793a25 |
297 | |
298 | if (isset($send_to_search) && is_array($send_to_search)) { |
299 | foreach ($send_to_search as $k => $v) { |
300 | if (substr($k, 0, 1) == 'T') { |
301 | if ($send_to) { |
302 | $send_to .= ', '; |
303 | } |
304 | $send_to .= $v; |
305 | } |
306 | elseif (substr($k, 0, 1) == 'C') { |
307 | if ($send_to_cc) { |
308 | $send_to_cc .= ', '; |
309 | } |
310 | $send_to_cc .= $v; |
311 | } |
312 | elseif (substr($k, 0, 1) == 'B') { |
313 | if ($send_to_bcc) { |
314 | $send_to_bcc .= ', '; |
315 | } |
316 | $send_to_bcc .= $v; |
317 | } |
318 | } |
319 | } |
da95c4b6 |
320 | showInputForm($session); |
e02775fe |
321 | } elseif (isset($html_addr_search)) { |
00793a25 |
322 | if (isset($HTTP_POST_FILES['attachfile']) && |
323 | $HTTP_POST_FILES['attachfile']['tmp_name'] && |
324 | $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none') { |
da95c4b6 |
325 | if (saveAttachedFiles($session)) { |
00793a25 |
326 | plain_error_message(_("Could not move/copy file. File not attached"), $color); |
327 | } |
328 | } |
329 | /* |
330 | * I am using an include so as to elminiate an extra unnecessary |
331 | * click. If you can think of a better way, please implement it. |
332 | */ |
333 | include_once('./addrbook_search_html.php'); |
e02775fe |
334 | } elseif (isset($attach)) { |
da95c4b6 |
335 | if (saveAttachedFiles($session)) { |
00793a25 |
336 | plain_error_message(_("Could not move/copy file. File not attached"), $color); |
337 | } |
9c3e6cd4 |
338 | if ($compose_new_win == '1') { |
339 | compose_Header($color, $mailbox); |
340 | } |
341 | else { |
342 | displayPageHeader($color, $mailbox); |
343 | } |
da95c4b6 |
344 | showInputForm($session); |
01265fba |
345 | } |
346 | elseif (isset($sigappend)) { |
347 | $idents = getPref($data_dir, $username, 'identities', 0); |
348 | if ($idents > 1) { |
349 | if ($identity == 'default') { |
350 | $no = 'g'; |
351 | } else { |
352 | $no = $identity; |
353 | } |
354 | $signature = getSig($data_dir, $username, $no); |
355 | } |
356 | $body .= "\n\n".($prefix_sig==true? "-- \n":'').$signature; |
357 | if ($compose_new_win == '1') { |
358 | compose_Header($color, $mailbox); |
359 | } else { |
360 | displayPageHeader($color, $mailbox); |
361 | } |
da95c4b6 |
362 | showInputForm($session); |
e02775fe |
363 | } elseif (isset($do_delete)) { |
9c3e6cd4 |
364 | if ($compose_new_win == '1') { |
365 | compose_Header($color, $mailbox); |
366 | } |
367 | else { |
368 | displayPageHeader($color, $mailbox); |
369 | } |
00793a25 |
370 | |
371 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
372 | if (isset($delete) && is_array($delete)) { |
373 | foreach($delete as $index) { |
374 | $attached_file = $hashed_attachment_dir . '/' |
375 | . $attachments[$index]['localfilename']; |
da95c4b6 |
376 | unlink ($attached_file); |
377 | unset ($attachments[$index]); |
00793a25 |
378 | } |
3f6b1b6f |
379 | setPref($data_dir, $username, 'attachments', serialize($attachments)); |
00793a25 |
380 | } |
381 | |
da95c4b6 |
382 | showInputForm($session); |
734f4ee6 |
383 | } else { |
00793a25 |
384 | /* |
385 | * This handles the default case as well as the error case |
386 | * (they had the same code) --> if (isset($smtpErrors)) |
387 | */ |
44560457 |
388 | |
389 | if ($compose_new_win == '1') { |
390 | compose_Header($color, $mailbox); |
391 | } else { |
392 | displayPageHeader($color, $mailbox); |
393 | } |
00793a25 |
394 | |
395 | $newmail = true; |
396 | |
41b94d65 |
397 | if (!isset($passed_ent_id)) $passed_ent_id = ''; |
398 | if (!isset($passed_id)) $passed_id = ''; |
399 | if (!isset($mailbox)) $mailbox = ''; |
400 | if (!isset($action)) $action = ''; |
401 | |
44560457 |
402 | $values = newMail($mailbox,$passed_id,$passed_ent_id, $action, $session); |
b9928adc |
403 | |
404 | /* in case the origin is not read_body.php */ |
405 | if (isset($send_to)) { |
406 | $values['send_to'] = $send_to; |
407 | } |
408 | if (isset($send_to_cc)) { |
44560457 |
409 | $values['send_to_cc'] = $send_to_cc; |
b9928adc |
410 | } |
411 | if (isset($send_to_bcc)) { |
44560457 |
412 | $values['send_to_bcc'] = $send_to_bcc; |
b9928adc |
413 | } |
41b94d65 |
414 | showInputForm($session, $values); |
00793a25 |
415 | } |
416 | |
417 | exit(); |
418 | |
00793a25 |
419 | /**************** Only function definitions go below *************/ |
420 | |
421 | |
48985d59 |
422 | /* This function is used when not sending or adding attachments */ |
44560457 |
423 | function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $session='') { |
41b94d65 |
424 | global $editor_size, $default_use_priority, |
44560457 |
425 | $use_signature, $composesession, $data_dir, $username, |
426 | $username, $key, $imapServerAddress, $imapPort; |
e7f1a81d |
427 | |
bdb92db3 |
428 | $send_to = $send_to_cc = $send_to_bcc = $subject = $body = $identity = ''; |
429 | $mailprio = 3; |
44560457 |
430 | |
41b94d65 |
431 | if ($passed_id) { |
44560457 |
432 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, |
433 | $imapPort, 0); |
434 | |
48985d59 |
435 | sqimap_mailbox_select($imapConnection, $mailbox); |
41b94d65 |
436 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
437 | $body = ''; |
438 | if ($passed_ent_id) { |
439 | /* redefine the messsage in case of message/rfc822 */ |
440 | $message = $message->getEntity($passed_ent_id); |
441 | /* message is an entity which contains the envelope and type0=message |
442 | * and type1=rfc822. The actual entities are childs from |
443 | * $message->entities[0]. That's where the encoding and is located |
444 | */ |
445 | |
446 | $entities = $message->entities[0]->findDisplayEntity |
447 | (array(), $alt_order = array('text/plain')); |
448 | if (!count($entities)) { |
449 | $entities = $message->entities[0]->findDisplayEntity |
450 | (array(), $alt_order = array('text/plain','html/plain')); |
451 | } |
a45887d7 |
452 | $orig_header = $message->rfc822_header; /* here is the envelope located */ |
41b94d65 |
453 | /* redefine the message for picking up the attachments */ |
454 | $message = $message->entities[0]; |
455 | |
456 | } else { |
457 | $entities = $message->findDisplayEntity (array(), $alt_order = array('text/plain')); |
458 | if (!count($entities)) { |
459 | $entities = $message->findDisplayEntity (array(), $alt_order = array('text/plain','html/plain')); |
460 | } |
a45887d7 |
461 | $orig_header = $message->rfc822_header; |
41b94d65 |
462 | } |
463 | $encoding = $message->header->encoding; |
464 | $type0 = $message->type0; |
465 | $type1 = $message->type1; |
466 | |
467 | foreach ($entities as $ent) { |
468 | $bodypart = decodeBody( |
469 | mime_fetch_body($imapConnection, $passed_id, $ent), |
470 | $encoding); |
471 | if ($type1 == 'html') { |
472 | $bodypart = strip_tags($bodypart); |
473 | } |
474 | $body .= $bodypart; |
475 | } |
476 | if ($default_use_priority) { |
477 | $mailprio = substr($orig_header->priority,0,1); |
a45887d7 |
478 | if (!$mailprio) { |
479 | $mailprio = 3; |
480 | } |
41b94d65 |
481 | } else { |
482 | $mailprio = ''; |
483 | } |
484 | ClearAttachments($session); |
bdb92db3 |
485 | |
486 | $identity = ''; |
487 | $idents = getPref($data_dir, $username, 'identities'); |
a45887d7 |
488 | $from_o = $orig_header->from; |
bdb92db3 |
489 | if (is_object($from_o)) { |
490 | $orig_from = $from_o->getAddress(); |
491 | } else { |
492 | $orig_from = ''; |
493 | } |
494 | if (!empty($idents) && $idents > 1) { |
495 | for ($i = 1; $i < $idents; $i++) { |
496 | $enc_from_name = '"'. |
497 | getPref($data_dir, |
498 | $username, |
499 | 'full_name' . $i) . |
500 | '" <' . getPref($data_dir, $username, |
501 | 'email_address' . $i) . '>'; |
502 | if ($enc_from_name == $orig_from) { |
503 | $identity = $i; |
504 | break; |
505 | } |
506 | } |
507 | } |
508 | |
41b94d65 |
509 | switch ($action) { |
a45887d7 |
510 | case ('draft'): |
511 | $use_signature = FALSE; |
512 | $send_to = $orig_header->getAddr_s('to'); |
513 | $send_to_cc = $orig_header->getAddr_s('cc'); |
514 | $send_to_bcc = $orig_header->getAddr_s('bcc'); |
515 | $subject = $orig_header->subject; |
516 | |
517 | $body_ary = explode("\n", $body); |
518 | $cnt = count($body_ary) ; |
519 | $body = ''; |
520 | for ($i=0; $i < $cnt; $i++) { |
521 | if (!ereg("^[>\\s]*$", $body_ary[$i])) { |
522 | sqWordWrap($body_ary[$i], $editor_size ); |
523 | $body .= $body_ary[$i] . "\n"; |
524 | } |
525 | unset($body_ary[$i]); |
526 | } |
527 | sqUnWordWrap($body); |
528 | getAttachments($message, $session, $passed_id, $entities, $imapConnection); |
529 | break; |
530 | case ('edit_as_new'): |
531 | $send_to = $orig_header->getAddr_s('to'); |
532 | $send_to_cc = $orig_header->getAddr_s('cc'); |
533 | $send_to_bcc = $orig_header->getAddr_s('bcc'); |
534 | $subject = $orig_header->subject; |
535 | $mailprio = $orig_header->priority; |
536 | $orig_from = ''; |
537 | getAttachments($message, $session, $passed_id, $entities, $imapConnection); |
538 | sqUnWordWrap($body); |
539 | break; |
540 | case ('forward'): |
541 | $send_to = ''; |
542 | $subject = $orig_header->subject; |
543 | if ((substr(strtolower($subject), 0, 4) != 'fwd:') && |
544 | (substr(strtolower($subject), 0, 5) != '[fwd:') && |
545 | (substr(strtolower($subject), 0, 6) != '[ fwd:')) { |
546 | $subject = '[Fwd: ' . $subject . ']'; |
547 | } |
548 | $body = getforwardHeader($orig_header) . $body; |
549 | sqUnWordWrap($body); |
550 | getAttachments($message, $session, $passed_id, $entities, $imapConnection); |
551 | break; |
552 | case ('reply_all'): |
553 | $send_to_cc = replyAllString($orig_header); |
554 | case ('reply'): |
555 | $send_to = $orig_header->reply_to; |
556 | if (is_object($send_to)) { |
557 | $send_to = $send_to->getAddr_s('reply_to'); |
558 | } else { |
559 | $send_to = $orig_header->getAddr_s('from'); |
560 | } |
561 | $subject = $orig_header->subject; |
562 | $subject = str_replace('"', "'", $subject); |
563 | $subject = trim($subject); |
564 | if (substr(strtolower($subject), 0, 3) != 're:') { |
565 | $subject = 'Re: ' . $subject; |
566 | } |
567 | /* this corrects some wrapping/quoting problems on replies */ |
568 | $rewrap_body = explode("\n", $body); |
569 | $body = getReplyCitation($orig_header->from->personal); |
570 | $cnt = count($rewrap_body); |
571 | for ($i=0;$i<$cnt;$i++) { |
572 | sqWordWrap($rewrap_body[$i], ($editor_size - 2)); |
573 | if (preg_match("/^(>+)/", $rewrap_body[$i], $matches)) { |
574 | $gt = $matches[1]; |
575 | $body .= '>' . str_replace("\n", "\n$gt ", $rewrap_body[$i]) ."\n"; |
576 | } else { |
577 | $body .= '> ' . $rewrap_body[$i] . "\n"; |
578 | } |
579 | unset($rewrap_body[$i]); |
580 | } |
581 | break; |
582 | default: |
583 | break; |
41b94d65 |
584 | } |
44560457 |
585 | sqimap_logout($imapConnection); |
41b94d65 |
586 | } |
587 | $ret = array( |
588 | 'send_to' => $send_to, |
589 | 'send_to_cc' => $send_to_cc, |
590 | 'send_to_bcc' => $send_to_bcc, |
591 | 'subject' => $subject, |
592 | 'mailprio' => $mailprio, |
bdb92db3 |
593 | 'body' => $body, |
594 | 'identity' => $identity |
41b94d65 |
595 | ); |
596 | |
597 | return ($ret); |
48985d59 |
598 | } /* function newMail() */ |
599 | |
78509c54 |
600 | |
41b94d65 |
601 | function getAttachments($message, $session, $passed_id, $entities, $imapConnection) { |
3f6b1b6f |
602 | global $attachments, $attachment_dir, $username, $data_dir; |
41b94d65 |
603 | |
48985d59 |
604 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
41b94d65 |
605 | if (!count($message->entities) || |
606 | ($message->type0 == 'message' && $message->type1 == 'rfc822')) { |
607 | if ( !in_array($message->entity_id, $entities) && $message->entity_id) { |
608 | if ($message->type0 == 'message' && $message->type1 == 'rfc822') { |
a45887d7 |
609 | $filename = decodeHeader($message->rfc822_header->subject.'.eml'); |
41b94d65 |
610 | if ($filename == "") { |
611 | $filename = "untitled-".$message->entity_id.'.eml'; |
612 | } |
613 | } else { |
614 | $filename = decodeHeader($message->header->filename); |
615 | if ($filename == "") { |
616 | $filename = "untitled-".$message->entity_id; |
617 | } |
48985d59 |
618 | } |
48985d59 |
619 | $localfilename = GenerateRandomString(32, '', 7); |
620 | $full_localfilename = "$hashed_attachment_dir/$localfilename"; |
621 | while (file_exists($full_localfilename)) { |
622 | $localfilename = GenerateRandomString(32, '', 7); |
623 | $full_localfilename = "$hashed_attachment_dir/$localfilename"; |
624 | } |
0a17f9dd |
625 | |
48985d59 |
626 | $newAttachment = array(); |
627 | $newAttachment['localfilename'] = $localfilename; |
628 | $newAttachment['remotefilename'] = $filename; |
41b94d65 |
629 | $newAttachment['type'] = strtolower($message->type0 . |
630 | '/' . $message->type1); |
da95c4b6 |
631 | $newAttachment['id'] = strtolower($message->header->id); |
632 | $newAttachment['session'] = $session; |
48985d59 |
633 | |
634 | /* Write Attachment to file */ |
635 | $fp = fopen ("$hashed_attachment_dir/$localfilename", 'w'); |
636 | fputs($fp, decodeBody(mime_fetch_body($imapConnection, |
41b94d65 |
637 | $passed_id, $message->entity_id), |
48985d59 |
638 | $message->header->encoding)); |
639 | fclose ($fp); |
640 | |
641 | $attachments[] = $newAttachment; |
a45887d7 |
642 | setPref($data_dir, $username, 'attachments', $attachments); |
48985d59 |
643 | } |
734f4ee6 |
644 | } else { |
48985d59 |
645 | for ($i = 0; $i < count($message->entities); $i++) { |
41b94d65 |
646 | getAttachments($message->entities[$i], $session, $passed_id, $entities, $imapConnection); |
48985d59 |
647 | } |
648 | } |
649 | return; |
650 | } |
651 | |
41b94d65 |
652 | function showInputForm ($session, $values=false) { |
653 | global $send_to, $send_to_cc, $body, |
48985d59 |
654 | $passed_body, $color, $use_signature, $signature, $prefix_sig, |
655 | $editor_size, $attachments, $subject, $newmail, |
41b94d65 |
656 | $use_javascript_addr_book, $send_to_bcc, $passed_id, $mailbox, |
48985d59 |
657 | $from_htmladdr_search, $location_of_buttons, $attachment_dir, |
658 | $username, $data_dir, $identity, $draft_id, $delete_draft, |
9c3e6cd4 |
659 | $mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win, |
44560457 |
660 | $saved_draft, $mail_sent, $sig_first, $edit_as_new, $action, |
661 | $username; |
48985d59 |
662 | |
3b487216 |
663 | $subject = decodeHeader($subject, false); |
41b94d65 |
664 | if ($values) { |
665 | $send_to = $values['send_to']; |
666 | $send_to_cc = $values['send_to_cc']; |
667 | $send_to_bcc = $values['send_to_bcc']; |
668 | $subject = $values['subject']; |
669 | $mailprio = $values['mailprio']; |
670 | $body = $values['body']; |
bdb92db3 |
671 | $identity = $values['identity']; |
41b94d65 |
672 | } |
673 | |
48985d59 |
674 | if ($use_javascript_addr_book) { |
675 | echo "\n". '<SCRIPT LANGUAGE=JavaScript><!--' . "\n" . |
676 | 'function open_abook() { ' . "\n" . |
677 | ' var nwin = window.open("addrbook_popup.php","abookpopup",' . |
678 | '"width=670,height=300,resizable=yes,scrollbars=yes");' . "\n" . |
679 | ' if((!nwin.opener) && (document.windows != null))' . "\n" . |
680 | ' nwin.opener = document.windows;' . "\n" . |
681 | "}\n" . |
682 | '// --></SCRIPT>' . "\n\n"; |
683 | } |
684 | |
41b94d65 |
685 | echo "\n" . '<FORM name=compose action="compose.php" METHOD=POST ' . |
686 | 'ENCTYPE="multipart/form-data"'; |
48985d59 |
687 | do_hook("compose_form"); |
e02775fe |
688 | |
57257333 |
689 | |
48985d59 |
690 | echo ">\n"; |
691 | |
41b94d65 |
692 | if ($action == 'draft') { |
693 | echo '<input type="hidden" name="delete_draft" value="' . $passed_id . "\">\n"; |
48985d59 |
694 | } |
695 | if (isset($delete_draft)) { |
696 | echo '<input type="hidden" name="delete_draft" value="' . $delete_draft. "\">\n"; |
697 | } |
da95c4b6 |
698 | if (isset($session)) { |
44560457 |
699 | echo '<input type="hidden" name="session" value="' . $session . "\">\n"; |
da95c4b6 |
700 | } |
701 | |
44560457 |
702 | |
9c3e6cd4 |
703 | if ($saved_draft == 'yes') { |
704 | echo '<BR><CENTER><B>'. _("Draft Saved").'</CENTER></B>'; |
705 | } |
706 | if ($mail_sent == 'yes') { |
707 | echo '<BR><CENTER><B>'. _("Your Message has been sent").'</CENTER></B>'; |
708 | } |
41b94d65 |
709 | echo '<TABLE WIDTH="100%" ALIGN=center CELLSPACING=0 BORDER=0>' . "\n"; |
9c3e6cd4 |
710 | if ($compose_new_win == '1') { |
41b94d65 |
711 | echo '<TABLE ALIGN=CENTER BGCOLOR="'.$color[0].'" WIDTH="100%" BORDER=0>'."\n"; |
712 | echo ' <TR><TD></TD><TD ALIGN="RIGHT"><INPUT TYPE="BUTTON" NAME="Close" onClick="return self.close()" VALUE='._("Close").'></TD></TR>'."\n"; |
9c3e6cd4 |
713 | } |
78a35fcd |
714 | if ($location_of_buttons == 'top') { |
715 | showComposeButtonRow(); |
716 | } |
48985d59 |
717 | |
715225af |
718 | $idents = getPref($data_dir, $username, 'identities', 0); |
719 | if ($idents > 1) { |
41b94d65 |
720 | echo ' <TR>' . "\n" . |
721 | ' <TD BGCOLOR="' . $color[4] . '" WIDTH="10%" ALIGN=RIGHT>' . |
722 | "\n" . |
723 | _("From:") . |
724 | ' </TD><TD BGCOLOR="' . $color[4] . '" WIDTH="90%">' . "\n" . |
48985d59 |
725 | '<select name=identity>' . "\n" . |
726 | '<option value=default>' . |
727 | htmlspecialchars(getPref($data_dir, $username, 'full_name')); |
728 | $em = getPref($data_dir, $username, 'email_address'); |
729 | if ($em != '') { |
248bfebb |
730 | echo htmlspecialchars(' <' . $em . '>') . "\n"; |
48985d59 |
731 | } |
732 | for ($i = 1; $i < $idents; $i ++) { |
248bfebb |
733 | echo '<option value="' . $i . '"'; |
48985d59 |
734 | if (isset($identity) && $identity == $i) { |
78a35fcd |
735 | echo ' SELECTED'; |
48985d59 |
736 | } |
737 | echo '>' . htmlspecialchars(getPref($data_dir, $username, |
738 | 'full_name' . $i)); |
248bfebb |
739 | $em = getPref($data_dir, $username, 'email_address' . $i); |
48985d59 |
740 | if ($em != '') { |
78a35fcd |
741 | echo htmlspecialchars(' <' . $em . '>') . "\n"; |
48985d59 |
742 | } |
9f599fe3 |
743 | echo '</option>'; |
48985d59 |
744 | } |
745 | echo '</select>' . "\n" . |
41b94d65 |
746 | ' </TD>' . "\n" . |
747 | ' </TR>' . "\n"; |
748 | } |
749 | echo ' <TR>' . "\n" . |
750 | ' <TD BGCOLOR="' . $color[4] . '" WIDTH="10%" ALIGN=RIGHT>' . "\n" . |
751 | _("To:") . |
752 | ' </TD><TD BGCOLOR="' . $color[4] . '" WIDTH="90%">' . "\n" . |
753 | ' <INPUT TYPE=text NAME="send_to" VALUE="' . |
754 | htmlspecialchars($send_to) . '" SIZE=60><BR>' . "\n" . |
755 | ' </TD>' . "\n" . |
756 | ' </TR>' . "\n" . |
757 | ' <TR>' . "\n" . |
758 | ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" . |
759 | _("CC:") . |
760 | ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n" . |
761 | ' <INPUT TYPE=text NAME="send_to_cc" SIZE=60 VALUE="' . |
762 | htmlspecialchars($send_to_cc) . '"><BR>' . "\n" . |
763 | ' </TD>' . "\n" . |
764 | ' </TR>' . "\n" . |
765 | ' <TR>' . "\n" . |
766 | ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" . |
767 | _("BCC:") . |
768 | ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n" . |
769 | ' <INPUT TYPE=text NAME="send_to_bcc" VALUE="' . |
770 | htmlspecialchars($send_to_bcc) . '" SIZE=60><BR>' . "\n" . |
771 | '</TD></TR>' . "\n" . |
772 | ' <TR>' . "\n" . |
773 | ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" . |
774 | _("Subject:") . |
775 | ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n"; |
776 | echo ' <INPUT TYPE=text NAME=subject SIZE=60 VALUE="' . |
777 | htmlspecialchars($subject) . '">'; |
778 | echo '</td></tr>' . "\n\n"; |
48985d59 |
779 | |
78a35fcd |
780 | if ($location_of_buttons == 'between') { |
781 | showComposeButtonRow(); |
782 | } |
fdc83c55 |
783 | if ($compose_new_win == '1') { |
41b94d65 |
784 | echo ' <TR>' . "\n" . |
785 | ' <TD BGCOLOR="' . $color[0] . '" COLSPAN=2 ALIGN=CENTER>' . "\n" . |
786 | ' <TEXTAREA NAME=body ROWS=20 COLS="' . |
787 | $editor_size . '" WRAP="VIRTUAL">'; |
fdc83c55 |
788 | } |
789 | else { |
41b94d65 |
790 | echo ' <TR>' . "\n" . |
791 | ' <TD BGCOLOR="' . $color[4] . '" COLSPAN=2>' . "\n" . |
792 | ' <TEXTAREA NAME=body ROWS=20 COLS="' . |
793 | $editor_size . '" WRAP="VIRTUAL">'; |
fdc83c55 |
794 | } |
48985d59 |
795 | if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) { |
3b17e952 |
796 | if ($sig_first == '1') { |
797 | echo "\n\n".($prefix_sig==true? "-- \n":'').htmlspecialchars($signature); |
798 | echo "\n\n".htmlspecialchars($body); |
799 | } |
800 | else { |
801 | echo "\n\n".htmlspecialchars($body); |
802 | echo "\n\n".($prefix_sig==true? "-- \n":'').htmlspecialchars($signature); |
803 | } |
804 | } |
805 | else { |
806 | echo htmlspecialchars($body); |
48985d59 |
807 | } |
41b94d65 |
808 | echo '</TEXTAREA><BR>' . "\n" . |
809 | ' </TD>' . "\n" . |
810 | ' </TR>' . "\n"; |
48985d59 |
811 | |
812 | if ($location_of_buttons == 'bottom') { |
813 | showComposeButtonRow(); |
814 | } else { |
41b94d65 |
815 | echo ' <TR><TD COLSPAN=2 ALIGN=LEFT>'; |
816 | echo ' <INPUT TYPE=SUBMIT NAME=send VALUE="' . _("Send") . '"></TD></TR>' . "\n"; |
48985d59 |
817 | } |
46bb8da8 |
818 | |
48985d59 |
819 | /* This code is for attachments */ |
41b94d65 |
820 | echo ' <TR>' . "\n" . |
821 | ' <TD VALIGN=MIDDLE ALIGN=RIGHT>' . "\n" . |
822 | _("Attach:") . |
823 | ' </TD>' . "\n" . |
824 | ' <TD VALIGN=MIDDLE ALIGN=LEFT>' . "\n" . |
825 | ' <INPUT NAME="attachfile" SIZE=48 TYPE="file">' . "\n" . |
826 | ' <input type="submit" name="attach"' . |
827 | ' value="' . _("Add") .'">' . "\n" . |
828 | ' </TD>' . "\n" . |
829 | ' </TR>' . "\n"; |
830 | |
831 | if (count($attachments)) { |
832 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
833 | echo '<tr><td bgcolor="' . $color[0] . '" align=right>' . "\n" . |
834 | ' ' . |
835 | '</td><td align=left bgcolor="' . $color[0] . '">'; |
836 | foreach ($attachments as $key => $info) { |
837 | if ($info['session'] == $session) { |
838 | $attached_file = "$hashed_attachment_dir/$info[localfilename]"; |
839 | echo '<input type="checkbox" name="delete[]" value="' . $key . "\">\n" . |
840 | $info['remotefilename'] . ' - ' . $info['type'] . ' (' . |
841 | show_readable_size( filesize( $attached_file ) ) . ")<br>\n"; |
842 | } |
843 | } |
844 | |
845 | echo '<input type="submit" name="do_delete" value="' . |
846 | _("Delete selected attachments") . "\">\n" . |
847 | '</td></tr>'; |
848 | } |
849 | /* End of attachment code */ |
07687736 |
850 | if ($compose_new_win == '1') { |
41b94d65 |
851 | echo '</TABLE>'."\n"; |
07687736 |
852 | } |
41b94d65 |
853 | echo '</TABLE>' . "\n"; |
44560457 |
854 | |
855 | echo '<input type="hidden" name="username" value="'. $username . "\">\n"; |
856 | echo '<input type=hidden name=action value=' . $action . ">\n"; |
48985d59 |
857 | echo '<INPUT TYPE=hidden NAME=mailbox VALUE="' . htmlspecialchars($mailbox) . |
858 | "\">\n" . |
859 | '</FORM>'; |
9f599fe3 |
860 | do_hook('compose_bottom'); |
48985d59 |
861 | echo '</BODY></HTML>' . "\n"; |
862 | } |
863 | |
864 | |
70c4fd84 |
865 | function showComposeButtonRow() { |
78a35fcd |
866 | global $use_javascript_addr_book, $save_as_draft, |
70c4fd84 |
867 | $default_use_priority, $mailprio, $default_use_mdn, |
b2a7e5bc |
868 | $request_mdn, $request_dr, |
70c4fd84 |
869 | $data_dir, $username; |
870 | |
41b94d65 |
871 | echo " <TR><TD>\n</TD><TD>\n"; |
ae25968c |
872 | if ($default_use_priority) { |
873 | if(!isset($mailprio)) { |
874 | $mailprio = "3"; |
70c4fd84 |
875 | } |
876 | echo _("Priority") .': <select name="mailprio">'. |
877 | '<option value="1"'.($mailprio=='1'?' selected':'').'>'. _("High") .'</option>'. |
878 | '<option value="3"'.($mailprio=='3'?' selected':'').'>'. _("Normal") .'</option>'. |
879 | '<option value="5"'.($mailprio=='5'?' selected':'').'>'. _("Low").'</option>'. |
880 | "</select>"; |
ae25968c |
881 | } |
882 | $mdn_user_support=getPref($data_dir, $username, 'mdn_user_support',$default_use_mdn); |
883 | if ($default_use_mdn) { |
70c4fd84 |
884 | if ($mdn_user_support) { |
885 | echo "\n\t". _("Receipt") .': '. |
b2a7e5bc |
886 | '<input type="checkbox" name="request_mdn" value=1'. |
887 | ($request_mdn=='1'?' checked':'') .'>'. _("On read"). |
888 | ' <input type="checkbox" name="request_dr" value=1'. |
889 | ($request_dr=='1'?' checked':'') .'>'. _("On Delivery"); |
70c4fd84 |
890 | } |
ae25968c |
891 | } |
48985d59 |
892 | |
41b94d65 |
893 | echo " </td></tr>\n <TR><td>\n </td><td>\n"; |
01265fba |
894 | echo "\n <INPUT TYPE=SUBMIT NAME=\"sigappend\" VALUE=\"". _("Signature") . "\">\n"; |
78a35fcd |
895 | if ($use_javascript_addr_book) { |
46bb8da8 |
896 | echo " <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"". |
897 | " <input type=button value=\\\""._("Addresses"). |
898 | "\\\" onclick='javascript:open_abook();'>\");". |
899 | " // --></SCRIPT><NOSCRIPT>\n". |
900 | " <input type=submit name=\"html_addr_search\" value=\"". |
901 | _("Addresses")."\">". |
902 | " </NOSCRIPT>\n"; |
734f4ee6 |
903 | } else { |
78a35fcd |
904 | echo " <input type=submit name=\"html_addr_search\" value=\"". |
905 | _("Addresses")."\">"; |
906 | } |
907 | echo "\n <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n"; |
48985d59 |
908 | |
78a35fcd |
909 | if ($save_as_draft) { |
910 | echo '<input type="submit" name ="draft" value="' . _("Save Draft") . "\">\n"; |
911 | } |
0a17f9dd |
912 | |
78a35fcd |
913 | do_hook('compose_button_row'); |
441f2d33 |
914 | |
41b94d65 |
915 | echo " </TD></TR>\n\n"; |
78a35fcd |
916 | } |
b278172f |
917 | |
70c4fd84 |
918 | function checkInput ($show) { |
78a35fcd |
919 | /* |
920 | * I implemented the $show variable because the error messages |
921 | * were getting sent before the page header. So, I check once |
922 | * using $show=false, and then when i'm ready to display the error |
923 | * message, show=true |
924 | */ |
925 | global $body, $send_to, $subject, $color; |
926 | |
927 | if ($send_to == "") { |
928 | if ($show) { |
0ad7dbda |
929 | plain_error_message(_("You have not filled in the \"To:\" field."), $color); |
78a35fcd |
930 | } |
931 | return false; |
932 | } |
933 | return true; |
934 | } /* function checkInput() */ |
df15de21 |
935 | |
3806fa52 |
936 | |
00793a25 |
937 | /* True if FAILURE */ |
da95c4b6 |
938 | function saveAttachedFiles($session) { |
3f6b1b6f |
939 | global $HTTP_POST_FILES, $attachment_dir, $attachments, $username, |
940 | $data_dir; |
4c9d2242 |
941 | |
942 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
943 | $localfilename = GenerateRandomString(32, '', 7); |
944 | $full_localfilename = "$hashed_attachment_dir/$localfilename"; |
945 | while (file_exists($full_localfilename)) { |
946 | $localfilename = GenerateRandomString(32, '', 7); |
947 | $full_localfilename = "$hashed_attachment_dir/$localfilename"; |
948 | } |
949 | |
950 | if (!@rename($HTTP_POST_FILES['attachfile']['tmp_name'], $full_localfilename)) { |
ceca62d3 |
951 | if (function_exists("move_uploaded_file")) { |
952 | if (!@move_uploaded_file($HTTP_POST_FILES['attachfile']['tmp_name'], $full_localfilename)) { |
056ddad7 |
953 | return true; |
ceca62d3 |
954 | } |
955 | } else { |
ceca62d3 |
956 | if (!@copy($HTTP_POST_FILES['attachfile']['tmp_name'], $full_localfilename)) { |
957 | return true; |
958 | } |
959 | } |
960 | |
4c9d2242 |
961 | } |
4c9d2242 |
962 | $newAttachment['localfilename'] = $localfilename; |
963 | $newAttachment['remotefilename'] = $HTTP_POST_FILES['attachfile']['name']; |
964 | $newAttachment['type'] = strtolower($HTTP_POST_FILES['attachfile']['type']); |
da95c4b6 |
965 | $newAttachment['session'] = $session; |
8ef72f33 |
966 | |
4c9d2242 |
967 | if ($newAttachment['type'] == "") { |
8ef72f33 |
968 | $newAttachment['type'] = 'application/octet-stream'; |
056ddad7 |
969 | } |
4c9d2242 |
970 | $attachments[] = $newAttachment; |
3f6b1b6f |
971 | setPref($data_dir, $username, 'attachments', serialize($attachments)); |
4c9d2242 |
972 | } |
973 | |
4c9d2242 |
974 | |
da95c4b6 |
975 | function ClearAttachments($session) |
4c9d2242 |
976 | { |
3f6b1b6f |
977 | global $username, $attachments, $attachment_dir, $data_dir; |
4c9d2242 |
978 | $hashed_attachment_dir = getHashedDir($username, $attachment_dir); |
979 | |
da95c4b6 |
980 | $rem_attachments = array(); |
8712abea |
981 | if (is_array($attachments)) { |
982 | foreach ($attachments as $info) { |
983 | if ($info['session'] == $session) { |
984 | $attached_file = "$hashed_attachment_dir/$info[localfilename]"; |
985 | if (file_exists($attached_file)) { |
986 | unlink($attached_file); |
987 | } |
988 | } |
989 | else { |
990 | $rem_attachments[] = $info; |
991 | } |
992 | } |
da95c4b6 |
993 | } |
994 | $attachments = $rem_attachments; |
3f6b1b6f |
995 | setPref($data_dir, $username, 'attachments', serialize($attachments)); |
4c9d2242 |
996 | } |
997 | |
da95c4b6 |
998 | |
4c9d2242 |
999 | function getReplyCitation($orig_from) |
1000 | { |
1001 | global $reply_citation_style, $reply_citation_start, $reply_citation_end; |
1002 | |
1003 | /* First, return an empty string when no citation style selected. */ |
1004 | if (($reply_citation_style == '') || ($reply_citation_style == 'none')) { |
1005 | return ''; |
1006 | } |
1007 | |
4c9d2242 |
1008 | /* Make sure our final value isn't an empty string. */ |
1009 | if ($orig_from == '') { |
1010 | return ''; |
1011 | } |
1012 | |
1013 | /* Otherwise, try to select the desired citation style. */ |
1014 | switch ($reply_citation_style) { |
1015 | case 'author_said': |
1016 | $start = ''; |
1017 | $end = ' ' . _("said") . ':'; |
1018 | break; |
1019 | case 'quote_who': |
1020 | $start = '<' . _("quote") . ' ' . _("who") . '="'; |
1021 | $end = '">'; |
1022 | break; |
1023 | case 'user-defined': |
1ecabe54 |
1024 | $start = $reply_citation_start . ' '; |
4c9d2242 |
1025 | $end = $reply_citation_end; |
1026 | break; |
1027 | default: |
1028 | return ''; |
1029 | } |
1030 | |
1031 | /* Build and return the citation string. */ |
1032 | return ($start . $orig_from . $end . "\n"); |
1033 | } |
1034 | |
5e9e90fd |
1035 | ?> |