X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcompose.php;h=53581cb83a268fd09e2b3e3edb60d65d1e29e447;hb=51698ad98fed2ffee3b9ccb88ab3f43aeb2140b9;hp=38e101f508c4c66309ccb8e41a63f052f3eba033;hpb=50706f77ec7e6e107ec2d41691a9e3b125b7088f;p=squirrelmail.git diff --git a/src/compose.php b/src/compose.php index 38e101f5..53581cb8 100644 --- a/src/compose.php +++ b/src/compose.php @@ -170,7 +170,12 @@ function getReplyCitation($orig_from, $orig_date) { global $reply_citation_style, $reply_citation_start, $reply_citation_end; // FIXME: why object is rewritten with string. - $orig_from = decodeHeader($orig_from->getAddress(false),false,false,true); + if (!is_object($orig_from)) { + $orig_from = ''; + } else { + $orig_from = decodeHeader($orig_from->getAddress(false),false,false,true); + } + // $from = decodeHeader($orig_header->getAddr_s('from',"\n$indent"),false,false); /* First, return an empty string when no citation style selected. */ @@ -189,7 +194,7 @@ function getReplyCitation($orig_from, $orig_date) { /** * To translators: %s is for author's name */ - $full_reply_citation = sprintf(_("%s said:"),$orig_from); + $full_reply_citation = sprintf(_("%s wrote:"),$orig_from); break; case 'quote_who': // FIXME: do we have to translate xml formating? @@ -200,14 +205,14 @@ function getReplyCitation($orig_from, $orig_date) { case 'date_time_author': /** * To translators: - * first %s is for date string, second %s is for author's name. Date uses + * first %s is for date string, second %s is for author's name. Date uses * formating from "D, F j, Y g:i a" and "D, F j, Y H:i" translations. * Example string: - * "On Sat, December 24, 2004 23:59, Santa said:" + * "On Sat, December 24, 2004 23:59, Santa wrote:" * If you have to put author's name in front of date string, check comments about * argument swapping at http://www.php.net/sprintf */ - $full_reply_citation = sprintf(_("On %s, %s said:"), getLongDateString($orig_date), $orig_from); + $full_reply_citation = sprintf(_("On %s, %s wrote:"), getLongDateString($orig_date), $orig_from); break; case 'user-defined': $start = $reply_citation_start . @@ -226,9 +231,9 @@ function getReplyCitation($orig_from, $orig_date) { /** * Creates header fields in forwarded email body * - * $default_charset global must be set correctly before you call this function. + * $default_charset global must be set correctly before you call this function. * @param object $orig_header - * @return $string + * @return $string */ function getforwardHeader($orig_header) { global $editor_size, $default_charset; @@ -307,7 +312,13 @@ if (sqsession_is_registered('session_expired_post')) { if ($compose_new_win == '1') { compose_Header($color, $mailbox); } else { - displayPageHeader($color, $mailbox); + $sHeaderJs = (isset($sHeaderJs)) ? $sHeaderJs : ''; + if (strpos($action, 'reply') !== false && $reply_focus) { + $sBodyTagJs = 'onload="checkForm(\''.$replyfocus.'\');"'; + } else { + $sBodyTagJs = 'onload="checkForm();"'; + } + displayPageHeader($color, $mailbox,$sHeaderJs,$sBodyTagJs); } showInputForm($session, false); exit(); @@ -326,6 +337,7 @@ if (!isset($session) || (isset($newmessage) && $newmessage)) { if (!isset($compose_messages)) { $compose_messages = array(); } + if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) { /* if (!array_key_exists($session, $compose_messages)) { /* We can only do this in PHP >= 4.1 */ $composeMessage = new Message(); @@ -333,6 +345,7 @@ if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL) $composeMessage->rfc822_header = $rfc822_header; $composeMessage->reply_rfc822_header = ''; $compose_messages[$session] = $composeMessage; + sqsession_register($compose_messages,'compose_messages'); } else { $composeMessage=$compose_messages[$session]; @@ -357,20 +370,24 @@ if ($draft) { $draft_message = _("Draft Email Saved"); /* If this is a resumed draft, then delete the original */ if(isset($delete_draft)) { - Header("Location: $location/delete_message.php?mailbox=" . urlencode($draft_folder) . - "&message=$delete_draft&startMessage=1&saved_draft=yes"); - exit(); - } - else { - if ($compose_new_win == '1') { - Header("Location: $location/compose.php?saved_draft=yes&session=$composesession"); - exit(); - } - else { - Header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) . - "&startMessage=1¬e=".urlencode($draft_message)); - exit(); + $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, false); + sqimap_mailbox_select($imap_stream, $draft_folder); + // force bypass_trash=true because message should be saved when deliverMessage() returns true. + // in current implementation of sqimap_msgs_list_flag() single message id can + // be submitted as string. docs state that it should be array. + sqimap_msgs_list_delete($imap_stream, $draft_folder, $delete_draft, true); + if ($auto_expunge) { + sqimap_mailbox_expunge($imap_stream, $draft_folder, true); } + sqimap_logout($imap_stream); + } + if ($compose_new_win == '1') { + Header("Location: $location/compose.php?saved_draft=yes&session=$composesession"); + exit(); + } else { + Header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) . + "&startMessage=1¬e=".urlencode($draft_message)); + exit(); } } } @@ -411,10 +428,10 @@ if ($send) { if( $line <> '-- ' ) { $line = rtrim($line); } - if (strlen($line) <= $editor_size + 1) { + if (sq_strlen($line,$default_charset) <= $editor_size + 1) { $newBody .= $line . "\n"; } else { - sqWordWrap($line, $editor_size); + sqWordWrap($line, $editor_size,$default_charset); $newBody .= $line . "\n"; } @@ -430,18 +447,24 @@ if ($send) { exit(); } unset($compose_messages[$session]); + /* if it is resumed draft, delete draft message */ if ( isset($delete_draft)) { - Header("Location: $location/delete_message.php?mailbox=" . urlencode( $draft_folder ). - "&message=$delete_draft&startMessage=1&mail_sent=yes"); - exit(); + $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, false); + sqimap_mailbox_select($imap_stream, $draft_folder); + // bypass_trash=true because message should be saved when deliverMessage() returns true. + // in current implementation of sqimap_msgs_list_flag() single message id can + // be submitted as string. docs state that it should be array. + sqimap_msgs_list_delete($imap_stream, $draft_folder, $delete_draft, true); + if ($auto_expunge) { + sqimap_mailbox_expunge($imap_stream, $draft_folder, true); + } + sqimap_logout($imap_stream); } if ($compose_new_win == '1') { - Header("Location: $location/compose.php?mail_sent=yes"); - } - else { + }else { Header("Location: $location/right_main.php?mailbox=$urlMailbox". - "&startMessage=$startMessage&mail_sent=yes"); + "&startMessage=$startMessage&mail_sent=yes"); } } else { if ($compose_new_win == '1') { @@ -779,6 +802,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se // forwarded message text should be as undisturbed as possible, so commenting out this call // sqUnWordWrap($body); $composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection); + //add a blank line after the forward headers $body = "\n" . $body; break; @@ -864,7 +888,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se * @param integer $passed_id * @param mixed $entities * @param mixed $imapConnection - * @return object + * @return object */ function getAttachments($message, &$composeMessage, $passed_id, $entities, $imapConnection) { global $attachment_dir, $username, $data_dir, $squirrelmail_language, $languages; @@ -909,9 +933,7 @@ function getAttachments($message, &$composeMessage, $passed_id, $entities, $imap /* Write Attachment to file */ $fp = fopen ("$hashed_attachment_dir/$localfilename", 'wb'); - fputs($fp, decodeBody(mime_fetch_body($imapConnection, - $passed_id, $message->entity_id), - $message->header->encoding)); + mime_print_body_lines ($imapConnection, $passed_id, $message->entity_id, $message->header->encoding, $fp); fclose ($fp); } } else { @@ -965,6 +987,7 @@ function showInputForm ($session, $values=false) { $mailprio, $compose_new_win, $saved_draft, $mail_sent, $sig_first, $username, $compose_messages, $composesession, $default_charset; + $composeMessage = $compose_messages[$session]; if ($values) { $send_to = $values['send_to']; @@ -1102,7 +1125,7 @@ function showInputForm ($session, $values=false) { /* * FIXME: test is specific to ja_JP translation implementation. * This test might apply incorrect conversion to other translations, but - * use of 7bit iso-2022-jp charset in other translations might have other + * use of 7bit iso-2022-jp charset in other translations might have other * issues too. */ if ($default_charset == 'iso-2022-jp') { @@ -1328,7 +1351,6 @@ function checkInput ($show) { function saveAttachedFiles($session) { global $_FILES, $attachment_dir, $attachments, $username, $data_dir, $compose_messages; - /* get out of here if no file was attached at all */ if (! is_uploaded_file($_FILES['attachfile']['tmp_name']) ) { return true; @@ -1554,7 +1576,7 @@ function deliverMessage($composeMessage, $draft=false) { } if (!$succes) { $msg = $deliver->dlv_msg . '
' . - _("Server replied: ") . $deliver->dlv_ret_nr . ' '. + _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' . $deliver->dlv_server_msg; plain_error_message($msg, $color); } else { @@ -1601,7 +1623,7 @@ function deliverMessage($composeMessage, $draft=false) { ClearAttachments($composeMessage); if ($action == 'reply' || $action == 'reply_all') { sqimap_mailbox_select ($imap_stream, $mailbox); - sqimap_messages_flag ($imap_stream, $passed_id, $passed_id, 'Answered', false); + sqimap_toggle_flag($imap_stream, array($passed_id), '\\Answered', true, false); } sqimap_logout($imap_stream); }