diff options
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcube_imap.php | 11 | ||||
-rw-r--r-- | program/js/app.js | 8 | ||||
-rw-r--r-- | program/localization/en_US/labels.inc | 2 | ||||
-rw-r--r-- | program/localization/pl_PL/labels.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/compose.inc | 66 |
5 files changed, 80 insertions, 9 deletions
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index ab2bc2a5e..eb987dca0 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2521,14 +2521,17 @@ class rcube_imap /** - * Returns the whole message source as string + * Returns the whole message source as string (or saves to a file) + * + * @param int $uid Message UID + * @param resource $fp File pointer to save the message * - * @param int $uid Message UID * @return string Message source string */ - function &get_raw_body($uid) + function &get_raw_body($uid, $fp=null) { - return $this->conn->handlePartBody($this->mailbox, $uid, true); + return $this->conn->handlePartBody($this->mailbox, $uid, + true, null, null, false, $fp); } diff --git a/program/js/app.js b/program/js/app.js index 99446d626..aac432f32 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -211,7 +211,7 @@ function rcube_webmail() this.env.message_commands = ['show', 'reply', 'reply-all', 'reply-list', 'forward', 'moveto', 'copy', 'delete', 'open', 'mark', 'edit', 'viewsource', 'download', - 'print', 'load-attachment', 'load-headers']; + 'print', 'load-attachment', 'load-headers', 'forward-attachment']; if (this.env.action=='show' || this.env.action=='preview') { this.enable_command(this.env.message_commands, this.env.uid); @@ -929,10 +929,12 @@ function rcube_webmail() } break; + case 'forward-attachment': case 'forward': var uid; if (uid = this.get_single_uid()) - this.goto_url('compose', '_forward_uid='+uid+'&_mbox='+urlencode(this.env.mailbox), true); + this.goto_url('compose', '_forward_uid='+uid+'&_mbox='+urlencode(this.env.mailbox) + + (command == 'forward-attachment' ? '&_attachment=1' : ''), true); break; case 'print': @@ -1431,7 +1433,7 @@ function rcube_webmail() if (selected) { // Hide certain command buttons when Drafts folder is selected if (this.env.mailbox == this.env.drafts_mailbox) - this.enable_command('reply', 'reply-all', 'reply-list', 'forward', false); + this.enable_command('reply', 'reply-all', 'reply-list', 'forward', 'forward-attachment', false); // Disable reply-list when List-Post header is not set else { var msg = this.env.messages[list.get_single_selection()]; diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index 2175aeac8..e9d6b6b14 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -123,6 +123,8 @@ $labels['replytomessage'] = 'Reply to sender'; $labels['replytoallmessage'] = 'Reply to list or to sender and all recipients'; $labels['replyall'] = 'Reply all'; $labels['replylist'] = 'Reply list'; +$labels['forwardinline'] = 'Forward inline'; +$labels['forwardattachment'] = 'Forward as attachment'; $labels['forwardmessage'] = 'Forward the message'; $labels['deletemessage'] = 'Delete message'; $labels['movemessagetotrash'] = 'Move message to trash'; diff --git a/program/localization/pl_PL/labels.inc b/program/localization/pl_PL/labels.inc index 8607f9594..d51b59e77 100644 --- a/program/localization/pl_PL/labels.inc +++ b/program/localization/pl_PL/labels.inc @@ -346,6 +346,8 @@ $labels['messageoptions'] = 'Opcje wiadomości...'; $labels['followupto'] = 'Kontynuacja do'; $labels['replyall'] = 'Odpowiedz wszystkim'; $labels['replylist'] = 'Odpowiedz na listę'; +$labels['forwardinline'] = 'Prześlij w treści'; +$labels['forwardattachment'] = 'Prześlij jako załącznik'; $labels['editidents'] = 'Edytuj tożsamości'; $labels['addfollowupto'] = 'Dodaj Followup-To'; $labels['dsn'] = 'Status dostarczenia (DSN)'; diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 4fe924409..943c800b5 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -214,6 +214,9 @@ if (!empty($msg_uid)) { $_SESSION['compose']['forward_uid'] = $msg_uid; $OUTPUT->set_env('compose_mode', 'forward'); + + if (!empty($_SESSION['compose']['param']['attachment'])) + $MESSAGE->forward_attachment = true; } } @@ -560,6 +563,13 @@ function rcmail_prepare_message_body() $body = $_SESSION['compose']['param']['body']; $isHtml = false; } + // forward as attachment + else if ($compose_mode == RCUBE_COMPOSE_FORWARD && $MESSAGE->forward_attachment) { + $isHtml = rcmail_compose_editor_mode(); + $body = ''; + if (empty($_SESSION['compose']['attachments'])) + rcmail_write_forward_attachment($MESSAGE); + } // reply/edit/draft/forward else if ($compose_mode) { $has_html_part = $MESSAGE->has_html_part(); @@ -960,8 +970,61 @@ function rcmail_write_inline_attachments(&$message) return $cid_map; } +// Creates an attachment from the forwarded message +function rcmail_write_forward_attachment(&$message) +{ + global $RCMAIL; + + if (strlen($message->subject)) { + $name = mb_substr($message->subject, 0, 64) . '.eml'; + } + else { + $name = 'message_rfc822.eml'; + } + + $mem_limit = parse_bytes(ini_get('memory_limit')); + $curr_mem = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB + $data = $path = null; + + // don't load too big attachments into memory + if ($mem_limit > 0 && $message->size > $mem_limit - $curr_mem) { + $temp_dir = unslashify($RCMAIL->config->get('temp_dir')); + $path = tempnam($temp_dir, 'rcmAttmnt'); + if ($fp = fopen($path, 'w')) { + $RCMAIL->imap->get_raw_body($message->uid, $fp); + fclose($fp); + } else + return false; + } else { + $data = $RCMAIL->imap->get_raw_body($message->uid); + } + + $attachment = array( + 'group' => $_SESSION['compose']['id'], + 'name' => $name, + 'mimetype' => 'message/rfc822', + 'data' => $data, + 'path' => $path, + 'size' => $path ? filesize($path) : strlen($data), + ); + + $attachment = $RCMAIL->plugins->exec_hook('attachment_save', $attachment); + + if ($attachment['status']) { + unset($attachment['data'], $attachment['status'], $attachment['content_id'], $attachment['abort']); + $_SESSION['compose']['attachments'][$attachment['id']] = $attachment; + return true; + } else if ($path) { + @unlink($path); + } + + return false; +} + + function rcmail_save_attachment(&$message, $pid) { + $rcmail = rcmail::get_instance(); $part = $message->mime_parts[$pid]; $mem_limit = parse_bytes(ini_get('memory_limit')); $curr_mem = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB @@ -969,7 +1032,6 @@ function rcmail_save_attachment(&$message, $pid) // don't load too big attachments into memory if ($mem_limit > 0 && $part->size > $mem_limit - $curr_mem) { - $rcmail = rcmail::get_instance(); $temp_dir = unslashify($rcmail->config->get('temp_dir')); $path = tempnam($temp_dir, 'rcmAttmnt'); if ($fp = fopen($path, 'w')) { @@ -991,7 +1053,7 @@ function rcmail_save_attachment(&$message, $pid) 'size' => $path ? filesize($path) : strlen($data), ); - $attachment = rcmail::get_instance()->plugins->exec_hook('attachment_save', $attachment); + $attachment = $rcmail->plugins->exec_hook('attachment_save', $attachment); if ($attachment['status']) { unset($attachment['data'], $attachment['status'], $attachment['content_id'], $attachment['abort']); |