- Add forward-as-attachment feature
1 files added
9 files modified
| | |
| | | CHANGELOG Roundcube Webmail |
| | | =========================== |
| | | |
| | | - Add forward-as-attachment feature |
| | | - jQuery-1.6.1 (#1487913, #1487144) |
| | | - Improve display name composition when saving contacts (#1487143) |
| | | - Fixed handling of folder with name "0" in folder selector |
| | |
| | | |
| | | |
| | | /** |
| | | * 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 |
| | | * |
| | | * @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); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | 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); |
| | |
| | | } |
| | | 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': |
| | |
| | | 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()]; |
| | |
| | | $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'; |
| | |
| | | $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)'; |
| | |
| | | { |
| | | $_SESSION['compose']['forward_uid'] = $msg_uid; |
| | | $OUTPUT->set_env('compose_mode', 'forward'); |
| | | |
| | | if (!empty($_SESSION['compose']['param']['attachment'])) |
| | | $MESSAGE->forward_attachment = true; |
| | | } |
| | | } |
| | | |
| | |
| | | else if ($_SESSION['compose']['param']['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) { |
| | |
| | | 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 |
| | |
| | | |
| | | // 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')) { |
| | |
| | | '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']); |
| | |
| | | this.popups = { |
| | | markmenu: {id:'markmessagemenu'}, |
| | | replyallmenu: {id:'replyallmenu'}, |
| | | forwardmenu: {id:'forwardmenu'}, |
| | | searchmenu: {id:'searchmenu', editable:1}, |
| | | messagemenu: {id:'messagemenu'}, |
| | | listmenu: {id:'listmenu', editable:1}, |
New file |
| | |
| | | <div id="forwardmenu" class="popupmenu"> |
| | | <ul> |
| | | <li><roundcube:button command="forward" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" /></li> |
| | | <li><roundcube:button command="forward-attachment" label="forwardattachment" prop="sub" classAct="forwardattachmentlink active" class="forwardattachmentlink" /></li> |
| | | <roundcube:container name="forwardmenu" id="forwardmenu" /> |
| | | </ul> |
| | | </div> |
| | |
| | | <roundcube:button command="reply" type="link" class="buttonPas reply" classAct="button reply" classSel="button replySel" title="replytomessage" content=" " /> |
| | | <span class="dropbutton"> |
| | | <roundcube:button command="reply-all" type="link" class="buttonPas replyAll" classAct="button replyAll" classSel="button replyAllSel" title="replytoallmessage" content=" " /> |
| | | <span id="replyallmenulink" onclick="rcmail_ui.show_popup('replyallmenu');return false"></span></span> |
| | | <span id="replyallmenulink" onclick="rcmail_ui.show_popup('replyallmenu');return false"></span> |
| | | </span> |
| | | <span class="dropbutton"> |
| | | <roundcube:button command="forward" type="link" class="buttonPas forward" classAct="button forward" classSel="button forwardSel" title="forwardmessage" content=" " /> |
| | | <span id="forwardmenulink" onclick="rcmail_ui.show_popup('forwardmenu');return false"></span> |
| | | </span> |
| | | <roundcube:button command="delete" type="link" class="buttonPas delete" classAct="button delete" classSel="button deleteSel" title="deletemessage" content=" " /> |
| | | <roundcube:container name="toolbar" id="messagetoolbar" /> |
| | | <roundcube:button name="markmenulink" id="markmenulink" type="link" class="button markmessage" title="markmessages" onclick="rcmail_ui.show_popup('markmenu');return false" content=" " /> |
| | |
| | | </div> |
| | | |
| | | <roundcube:include file="/includes/replyallmenu.html" /> |
| | | <roundcube:include file="/includes/forwardmenu.html" /> |
| | | <roundcube:include file="/includes/messagemenu.html" /> |
| | | |
| | | <div id="searchmenu" class="popupmenu"> |
| | |
| | | <roundcube:button command="reply" type="link" class="buttonPas reply" classAct="button reply" classSel="button replySel" title="replytomessage" content=" " /> |
| | | <span class="dropbutton"> |
| | | <roundcube:button command="reply-all" type="link" class="buttonPas replyAll" classAct="button replyAll" classSel="button replyAllSel" title="replytoallmessage" content=" " /> |
| | | <span id="replyallmenulink" onclick="rcmail_ui.show_popup('replyallmenu');return false"></span></span> |
| | | <span id="replyallmenulink" onclick="rcmail_ui.show_popup('replyallmenu');return false"></span> |
| | | </span> |
| | | <span class="dropbutton"> |
| | | <roundcube:button command="forward" type="link" class="buttonPas forward" classAct="button forward" classSel="button forwardSel" title="forwardmessage" content=" " /> |
| | | <span id="forwardmenulink" onclick="rcmail_ui.show_popup('forwardmenu');return false"></span> |
| | | </span> |
| | | <roundcube:button command="delete" type="link" class="buttonPas delete" classAct="button delete" classSel="button deleteSel" title="deletemessage" content=" " /> |
| | | <roundcube:container name="toolbar" id="messagetoolbar" /> |
| | | <roundcube:button name="messagemenulink" id="messagemenulink" type="link" class="button messagemenu" title="messageactions" onclick="rcmail_ui.show_popup('messagemenu');return false" content=" " /> |
| | |
| | | </div> |
| | | |
| | | <roundcube:include file="/includes/replyallmenu.html" /> |
| | | <roundcube:include file="/includes/forwardmenu.html" /> |
| | | <roundcube:include file="/includes/messagemenu.html" /> |
| | | |
| | | <div id="mainscreen"> |