fixed bug #426128
[squirrelmail.git] / src / compose.php
1 <?php
2 /**
3 * compose.php
4 *
5 * Copyright (c) 1999-2000 The SquirrelMail development team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This code sends a mail.
9 *
10 * There are 4 modes of operation:
11 * - Start new mail
12 * - Add an attachment
13 * - Send mail
14 * - Save As Draft
15 *
16 * $Id$
17 **/
18
19 require_once('../src/validate.php');
20 require_once('../functions/imap.php');
21 require_once('../functions/date.php');
22 require_once('../functions/mime.php');
23 require_once('../functions/smtp.php');
24 require_once('../functions/display_messages.php');
25 require_once('../functions/plugin.php');
26
27 if (!isset($attachments))
28 {
29 $attachments = array();
30 session_register('attachments');
31 }
32
33
34 // This function is used when not sending or adding attachments
35 function newMail () {
36 global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body,
37 $reply_id, $send_to, $send_to_cc, $mailbox, $send_to_bcc, $editor_size,
38 $draft_id, $use_signature;
39
40 $send_to = decodeHeader($send_to);
41 $send_to_cc = decodeHeader($send_to_cc);
42 $send_to_bcc = decodeHeader($send_to_bcc);
43
44 if ($forward_id)
45 $id = $forward_id;
46 elseif ($reply_id)
47 $id = $reply_id;
48
49 if ($draft_id){
50 $id = $draft_id;
51 $use_signature = FALSE;
52 }
53
54 if (isset($id)) {
55 sqimap_mailbox_select($imapConnection, $mailbox);
56 $message = sqimap_get_message($imapConnection, $id, $mailbox);
57 $orig_header = $message->header;
58 if ($ent_num)
59 $message = getEntity($message, $ent_num);
60
61 if ($message->header->type0 == 'text' || $message->header->type1 == 'message') {
62 if ($ent_num)
63 $body = decodeBody(mime_fetch_body($imapConnection, $id, $ent_num), $message->header->encoding);
64 else
65 $body = decodeBody(mime_fetch_body($imapConnection, $id, 1), $message->header->encoding);
66 } else {
67 $body = "";
68 }
69
70 if ($message->header->type1 == "html")
71 $body = strip_tags($body);
72
73 sqUnWordWrap($body);
74 $body_ary = explode("\n", $body);
75 $i = count($body_ary) - 1;
76 while ($i >= 0 && ereg("^[>\\s]*$", $body_ary[$i])) {
77 unset($body_ary[$i]);
78 $i --;
79 }
80 $body = "";
81 for ($i=0; isset($body_ary[$i]); $i++) {
82 if ($reply_id)
83 {
84 if (ereg('^[ >]+', $body_ary[$i]))
85 {
86 $body_ary[$i] = '>' . $body_ary[$i];
87 }
88 else
89 {
90 $body_ary[$i] = '> ' . $body_ary[$i];
91 }
92 }
93 if (!$draft_id) {
94 sqWordWrap($body_ary[$i], $editor_size - 1);
95 }
96 $body .= $body_ary[$i] . "\n";
97 unset($body_ary[$i]);
98 }
99 if ($forward_id)
100 {
101 $bodyTop = "-------- " . _("Original Message") . " --------\n";
102 $bodyTop .= _("Subject") . ": " . $orig_header->subject . "\n";
103 $bodyTop .= _("From") . ": " . $orig_header->from . "\n";
104 $bodyTop .= _("To") . ": " . $orig_header->to[0] . "\n";
105 if (count($orig_header->to) > 1) {
106 for ($x=1; $x < count($orig_header->to); $x++) {
107 $bodyTop .= " " . $orig_header->to[$x] . "\n";
108 }
109 }
110 $bodyTop .= "\n";
111 $body = $bodyTop . $body;
112 } else if ($reply_id) {
113 $orig_from = decodeHeader($orig_header->from);
114 $orig_from = trim(substr($orig_from,0,strpos($orig_from,'<')));
115 $orig_from = str_replace('"','',$orig_from);
116 $orig_from = str_replace("'",'',$orig_from);
117 $body = getReplyCitation($orig_from) . $body;
118 }
119
120 return;
121 }
122
123 if (!$send_to) {
124 $send_to = sqimap_find_email($send_to);
125 }
126
127 /** This formats a CC string if they hit "reply all" **/
128 if ($send_to_cc != "") {
129 $send_to_cc = ereg_replace( '"[^"]*"', "", $send_to_cc);
130 $send_to_cc = ereg_replace(";", ",", $send_to_cc);
131 $sendcc = explode(",", $send_to_cc);
132 $send_to_cc = "";
133
134 for ($i = 0; $i < count($sendcc); $i++) {
135 $sendcc[$i] = trim($sendcc[$i]);
136 if ($sendcc[$i] == "")
137 continue;
138
139 $sendcc[$i] = sqimap_find_email($sendcc[$i]);
140 $whofrom = sqimap_find_displayable_name($msg["HEADER"]["FROM"]);
141 $whoreplyto = sqimap_find_email($msg["HEADER"]["REPLYTO"]);
142
143 if ((strtolower(trim($sendcc[$i])) != strtolower(trim($whofrom))) &&
144 (strtolower(trim($sendcc[$i])) != strtolower(trim($whoreplyto))) &&
145 (trim($sendcc[$i]) != "")) {
146 $send_to_cc .= trim($sendcc[$i]) . ", ";
147 }
148 }
149 $send_to_cc = trim($send_to_cc);
150 if (substr($send_to_cc, -1) == ",") {
151 $send_to_cc = substr($send_to_cc, 0, strlen($send_to_cc) - 1);
152 }
153 }
154 } // function newMail()
155
156 function getAttachments($message) {
157 global $mailbox, $attachments, $attachment_dir, $imapConnection,
158 $ent_num, $forward_id, $draft_id;
159
160 if (isset($draft_id))
161 $id = $draft_id;
162 else
163 $id = $forward_id;
164
165 if (!$message) {
166 sqimap_mailbox_select($imapConnection, $mailbox);
167 $message = sqimap_get_message($imapConnection, $id,
168 $mailbox);
169 }
170
171 if (count($message->entities) == 0) {
172 if ($message->header->entity_id != $ent_num) {
173 $filename = decodeHeader($message->header->filename);
174
175 if ($filename == "")
176 $filename = "untitled-".$message->header->entity_id;
177
178 $localfilename = GenerateRandomString(32, '', 7);
179 while (file_exists($attachment_dir . $localfilename))
180 $localfilename = GenerateRandomString(32, '', 7);
181
182 $newAttachment = array();
183 $newAttachment['localfilename'] = $localfilename;
184 $newAttachment['remotefilename'] = $filename;
185 $newAttachment['type'] = strtolower($message->header->type0 .
186 '/' . $message->header->type1);
187
188 // Write Attachment to file
189 $fp = fopen ($attachment_dir.$localfilename, 'w');
190 fputs ($fp, decodeBody(mime_fetch_body($imapConnection,
191 $id, $message->header->entity_id),
192 $message->header->encoding));
193 fclose ($fp);
194
195 $attachments[] = $newAttachment;
196 }
197 } else {
198 for ($i = 0; $i < count($message->entities); $i++) {
199 getAttachments($message->entities[$i]);
200 }
201 }
202 return;
203 }
204
205 function showInputForm () {
206 global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body,
207 $passed_body, $color, $use_signature, $signature, $prefix_sig,
208 $editor_size, $attachments, $subject, $newmail,
209 $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox,
210 $from_htmladdr_search, $location_of_buttons, $attachment_dir,
211 $username, $data_dir, $identity, $draft_id, $delete_draft;
212
213 $subject = decodeHeader($subject);
214 $reply_subj = decodeHeader($reply_subj);
215 $forward_subj = decodeHeader($forward_subj);
216
217 if ($use_javascript_addr_book) {
218 echo "\n<SCRIPT LANGUAGE=JavaScript><!--\n";
219 echo "function open_abook() { \n";
220 echo " var nwin = window.open(\"addrbook_popup.php\",\"abookpopup\",";
221 echo "\"width=670,height=300,resizable=yes,scrollbars=yes\");\n";
222 echo " if((!nwin.opener) && (document.windows != null))\n";
223 echo " nwin.opener = document.windows;\n";
224 echo "}\n";
225 echo "// --></SCRIPT>\n\n";
226 }
227
228 echo "\n<FORM name=compose action=\"compose.php\" METHOD=POST ENCTYPE=\"multipart/form-data\"";
229 do_hook("compose_form");
230 echo ">\n";
231
232 if (isset($draft_id)) {
233 echo "<input type=\"hidden\" name=\"delete_draft\" value=\"$draft_id\">\n";
234 }
235 if (isset($delete_draft)) {
236 echo "<input type=\"hidden\" name=\"delete_draft\" value=\"$delete_draft\">\n";
237 }
238
239 echo "<TABLE WIDTH=\"100%\" ALIGN=center CELLSPACING=0 BORDER=0>\n";
240
241 if ($location_of_buttons == 'top') showComposeButtonRow();
242
243 $idents = getPref($data_dir, $username, 'identities');
244 if ($idents != '' && $idents > 1) {
245 echo " <TR>\n";
246 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=\"10%\" ALIGN=RIGHT>\n";
247 echo _("From:");
248 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=\"90%\">\n";
249 echo "<select name=identity>\n";
250 echo "<option value=default>" .
251 htmlspecialchars(getPref($data_dir, $username, 'full_name'));
252 $em = getPref($data_dir, $username, 'email_address');
253 if ($em != '')
254 echo htmlspecialchars(' <' . $em . '>') . "\n";
255 for ($i = 1; $i < $idents; $i ++) {
256 echo '<option value="' . $i . '"';
257 if (isset($identity) && $identity == $i)
258 echo ' SELECTED';
259 echo '>';
260 echo htmlspecialchars(getPref($data_dir, $username, 'full_name' .
261 $i));
262 $em = getPref($data_dir, $username, 'email_address' . $i);
263 if ($em != '')
264 echo htmlspecialchars(' <' . $em . '>') . "\n";
265 }
266 echo "</select>\n";
267 echo " </TD>\n";
268 echo " </TR>\n";
269 }
270 echo " <TR>\n";
271 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=\"10%\" ALIGN=RIGHT>\n";
272 echo _("To:");
273 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=\"90%\">\n";
274 printf(" <INPUT TYPE=text NAME=\"send_to\" VALUE=\"%s\" SIZE=60><BR>\n",
275 htmlspecialchars($send_to));
276 echo " </TD>\n";
277 echo " </TR>\n";
278 echo " <TR>\n";
279 echo " <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
280 echo _("CC:");
281 echo " </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
282 printf(" <INPUT TYPE=text NAME=\"send_to_cc\" SIZE=60 VALUE=\"%s\"><BR>\n",
283 htmlspecialchars($send_to_cc));
284 echo " </TD>\n";
285 echo " </TR>\n";
286 echo " <TR>\n";
287 echo " <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
288 echo _("BCC:");
289 echo " </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
290 printf(" <INPUT TYPE=text NAME=\"send_to_bcc\" VALUE=\"%s\" SIZE=60><BR>\n",
291 htmlspecialchars($send_to_bcc));
292 echo "</TD></TR>\n";
293
294 echo " <TR>\n";
295 echo " <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
296 echo _("Subject:");
297 echo " </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
298 if ($reply_subj) {
299 $reply_subj = str_replace("\"", "'", $reply_subj);
300 $reply_subj = trim($reply_subj);
301 if (substr(strtolower($reply_subj), 0, 3) != "re:")
302 $reply_subj = "Re: $reply_subj";
303 printf(" <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
304 htmlspecialchars($reply_subj));
305 } else if ($forward_subj) {
306 $forward_subj = trim($forward_subj);
307 if ((substr(strtolower($forward_subj), 0, 4) != 'fwd:') &&
308 (substr(strtolower($forward_subj), 0, 5) != '[fwd:') &&
309 (substr(strtolower($forward_subj), 0, 6) != '[ fwd:'))
310 $forward_subj = "[Fwd: $forward_subj]";
311 printf(" <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
312 htmlspecialchars($forward_subj));
313 } else {
314 printf(" <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
315 htmlspecialchars($subject));
316 }
317 echo "</td></tr>\n\n";
318
319 if ($location_of_buttons == 'between') showComposeButtonRow();
320
321 echo " <TR>\n";
322 echo " <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
323 echo " &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>";
324 echo htmlspecialchars($body);
325 if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
326 if ( $prefix_sig == true )
327 echo "\n\n-- \n" . htmlspecialchars($signature);
328 else
329 echo "\n\n" . htmlspecialchars($signature);
330 }
331 echo "</TEXTAREA><BR>\n";
332 echo " </TD>\n";
333 echo " </TR>\n";
334
335 if ($location_of_buttons == 'bottom')
336 showComposeButtonRow();
337 else {
338 echo " <TR><TD>&nbsp;</TD><TD ALIGN=LEFT><INPUT TYPE=SUBMIT NAME=send VALUE=\""._("Send")."\"></TD></TR>\n";
339 }
340
341 // This code is for attachments
342 echo " <tr>\n";
343 echo " <TD BGCOLOR=\"$color[0]\" VALIGN=TOP ALIGN=RIGHT>\n";
344 echo " <SMALL><BR></SMALL>"._("Attach:");
345 echo " </td><td ALIGN=left BGCOLOR=\"$color[0]\">\n";
346 echo " <INPUT NAME=\"attachfile\" SIZE=48 TYPE=\"file\">\n";
347 echo " &nbsp;&nbsp;<input type=\"submit\" name=\"attach\"";
348 echo " value=\"" . _("Add") ."\">\n";
349 echo " </td>\n";
350 echo " </tr>\n";
351 if (count($attachments))
352 {
353 echo "<tr><td bgcolor=\"$color[0]\" align=right>\n";
354 echo "&nbsp;";
355 echo "</td><td align=left bgcolor=\"$color[0]\">";
356 foreach ($attachments as $key => $info) {
357 echo "<input type=\"checkbox\" name=\"delete[]\" value=\"$key\">\n";
358 echo $info['remotefilename'] . " - " . $info['type'] . " (";
359 echo show_readable_size(filesize($attachment_dir .
360 $info['localfilename'])) . ")<br>\n";
361 }
362
363 echo "<input type=\"submit\" name=\"do_delete\" value=\""._("Delete selected attachments")."\">\n";
364 echo "</td></tr>";
365 }
366 // End of attachment code
367
368 echo "</TABLE>\n";
369 if ($reply_id) {
370 echo "<input type=hidden name=reply_id value=$reply_id>\n";
371 }
372 printf("<INPUT TYPE=hidden NAME=mailbox VALUE=\"%s\">\n", htmlspecialchars($mailbox));
373 echo "</FORM>";
374 do_hook("compose_bottom");
375 echo "</BODY></HTML>\n";
376 }
377
378 function showComposeButtonRow() {
379 global $use_javascript_addr_book, $save_as_draft;
380
381 echo " <TR><td>\n </td><td>\n";
382 if ($use_javascript_addr_book) {
383 echo " <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"";
384 echo " <input type=button value=\\\""._("Addresses")."\\\" onclick='javascript:open_abook();'>\");";
385 echo " // --></SCRIPT><NOSCRIPT>\n";
386 echo " <input type=submit name=\"html_addr_search\" value=\""._("Addresses")."\">";
387 echo " </NOSCRIPT>\n";
388 } else {
389 echo " <input type=submit name=\"html_addr_search\" value=\""._("Addresses")."\">";
390 }
391 echo "\n <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
392
393 if ($save_as_draft) {
394 echo "<input type=\"submit\" name =\"draft\" value=\"Save Draft\">\n";
395 }
396
397 do_hook("compose_button_row");
398
399 echo " </TD>\n";
400 echo " </TR>\n\n";
401 }
402
403 function checkInput ($show) {
404 /** I implemented the $show variable because the error messages
405 were getting sent before the page header. So, I check once
406 using $show=false, and then when i'm ready to display the
407 error message, show=true **/
408 global $body, $send_to, $subject, $color;
409
410 if ($send_to == "") {
411 if ($show)
412 plain_error_message(_("You have not filled in the \"To:\" field."), $color);
413 return false;
414 }
415 return true;
416 } // function checkInput()
417
418
419 // True if FAILURE
420 function saveAttachedFiles() {
421 global $HTTP_POST_FILES, $attachment_dir, $attachments;
422
423 $localfilename = GenerateRandomString(32, '', 7);
424 while (file_exists($attachment_dir . $localfilename))
425 $localfilename = GenerateRandomString(32, '', 7);
426
427 if (!@rename($HTTP_POST_FILES['attachfile']['tmp_name'], $attachment_dir.$localfilename)) {
428 if (!@copy($HTTP_POST_FILES['attachfile']['tmp_name'], $attachment_dir.$localfilename)) {
429 return true;
430 }
431 }
432
433 $newAttachment['localfilename'] = $localfilename;
434 $newAttachment['remotefilename'] = $HTTP_POST_FILES['attachfile']['name'];
435 $newAttachment['type'] =
436 strtolower($HTTP_POST_FILES['attachfile']['type']);
437
438 if ($newAttachment['type'] == "")
439 $newAttachment['type'] = 'application/octet-stream';
440
441 $attachments[] = $newAttachment;
442 }
443
444 if (!isset($mailbox) || $mailbox == "" || ($mailbox == "None"))
445 $mailbox = "INBOX";
446
447 if (isset($draft)) {
448 require_once ('../src/draft_actions.php');
449 if (!saveMessageAsDraft($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id)) {
450 showInputForm();
451 exit();
452 } else {
453 $draft_message = _("Draft Email Saved");
454 /* If this is a resumed draft, then delete the original */
455 if(isset($delete_draft)) {
456 Header("Location: delete_message.php?mailbox=$draft_folder&message=$delete_draft&sort=$sort&startMessage=1");
457 exit();
458 } else {
459 Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort&startMessage=1&note=$draft_message");
460 exit();
461 }
462 }
463 }
464
465 if (isset($send)) {
466 if (isset($HTTP_POST_FILES['attachfile']) &&
467 $HTTP_POST_FILES['attachfile']['tmp_name'] &&
468 $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none')
469 $AttachFailure = saveAttachedFiles();
470 if (checkInput(false) && !isset($AttachFailure)) {
471 $urlMailbox = urlencode (trim($mailbox));
472 if (! isset($reply_id))
473 $reply_id = 0;
474 // Set $default_charset to correspond with the user's selection
475 // of language interface.
476 set_my_charset();
477
478 // This is to change all newlines to \n
479 // We'll change them to \r\n later (in the sendMessage function)
480 $body = str_replace("\r\n", "\n", $body);
481 $body = str_replace("\r", "\n", $body);
482
483 // Rewrap $body so that no line is bigger than $editor_size
484 // This should only really kick in the sqWordWrap function
485 // if the browser doesn't support "HARD" as the wrap type
486 // Or, in Opera's case, something goes wrong.
487 $body = explode("\n", $body);
488 $newBody = '';
489 foreach ($body as $line) {
490 if( $line <> '-- ' )
491 $line = rtrim($line);
492 if (strlen($line) <= $editor_size + 1)
493 $newBody .= $line . "\n";
494 else {
495 sqWordWrap($line, $editor_size) . "\n";
496 $newBody .= $line;
497 }
498 }
499 $body = $newBody;
500
501 do_hook("compose_send");
502
503 if (! sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id)) {
504 showInputForm();
505 exit();
506 }
507 if ( isset($delete_draft)) {
508 Header("Location: delete_message.php?mailbox=$draft_folder&message=$delete_draft&sort=$sort&startMessage=1");
509 exit();
510 }
511
512 Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1");
513 } else {
514 //$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
515 displayPageHeader($color, $mailbox);
516
517 if (isset($AttachFailure))
518 plain_error_message(_("Could not move/copy file. File not attached"), $color);
519
520 checkInput(true);
521
522 showInputForm();
523 //sqimap_logout($imapConnection);
524 }
525 } else if (isset($html_addr_search_done)) {
526 displayPageHeader($color, $mailbox);
527
528 if (isset($send_to_search) && is_array($send_to_search)) {
529 foreach ($send_to_search as $k => $v) {
530 if (substr($k, 0, 1) == 'T') {
531 if ($send_to)
532 $send_to .= ', ';
533 $send_to .= $v;
534 }
535 elseif (substr($k, 0, 1) == 'C') {
536 if ($send_to_cc)
537 $send_to_cc .= ', ';
538 $send_to_cc .= $v;
539 }
540 elseif (substr($k, 0, 1) == 'B') {
541 if ($send_to_bcc)
542 $send_to_bcc .= ', ';
543 $send_to_bcc .= $v;
544 }
545 }
546 }
547
548 showInputForm();
549 } else if (isset($html_addr_search)) {
550 if (isset($HTTP_POST_FILES['attachfile']) &&
551 $HTTP_POST_FILES['attachfile']['tmp_name'] &&
552 $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none')
553 {
554 if (saveAttachedFiles())
555 plain_error_message(_("Could not move/copy file. File not attached"), $color);
556 }
557 // I am using an include so as to elminiate an extra unnecessary click. If you
558 // can think of a better way, please implement it.
559 include_once('./addrbook_search_html.php');
560 } else if (isset($attach)) {
561 if (saveAttachedFiles())
562 plain_error_message(_("Could not move/copy file. File not attached"), $color);
563 displayPageHeader($color, $mailbox);
564 showInputForm();
565 } else if (isset($do_delete)) {
566 displayPageHeader($color, $mailbox);
567
568 if (isset($delete) && is_array($delete))
569 {
570 foreach($delete as $index)
571 {
572 unlink ($attachment_dir.$attachments[$index]['localfilename']);
573 unset ($attachments[$index]);
574 }
575 }
576
577 showInputForm();
578 } else {
579 // This handles the default case as well as the error case
580 // (they had the same code) --> if (isset($smtpErrors))
581 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
582 $imapPort, 0);
583 displayPageHeader($color, $mailbox);
584
585 $newmail = true;
586
587 ClearAttachments();
588
589 if (isset($forward_id) && $forward_id && isset($ent_num) && $ent_num)
590 getAttachments(0);
591
592 if (isset($draft_id) && $draft_id && isset($ent_num) && $ent_num)
593 getAttachments(0);
594
595 newMail();
596 showInputForm();
597 sqimap_logout($imapConnection);
598 }
599
600 function ClearAttachments() {
601 global $attachments, $attachment_dir;
602
603 foreach ($attachments as $info) {
604 if (file_exists($attachment_dir . $info['localfilename'])) {
605 unlink($attachment_dir . $info['localfilename']);
606 }
607 }
608
609 $attachments = array();
610 }
611
612 function getReplyCitation($orig_from) {
613 global $reply_citation_style, $reply_citation_start, $reply_citation_end;
614
615 /* First, return an empty string when no citation style selected. */
616 if (($reply_citation_style == '') || ($reply_citation_style == 'none')) {
617 return ('');
618 }
619
620 /* Otherwise, try to select the desired citation style. */
621 switch ($reply_citation_style) {
622 case 'author_said':
623 $start = '';
624 $end = ' ' . _("said") . ':';
625 break;
626 case 'quote_who':
627 $start = '<' . _("quote") . ' ' . _("who") . '="';
628 $end = '">';
629 break;
630 case 'user-defined':
631 $start = $reply_citation_start;
632 $end = $reply_citation_end;
633 break;
634 default: return ('');
635 }
636
637 /* Build and return the citation string. */
638 return ($start . $orig_from . $end . "\n");
639 }
640 ?>