- Add forward-as-attachment feature

release-0.6
alecpl 13 years ago
parent 79275b4df5
commit a208a4fa68

@ -1,6 +1,7 @@
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

@ -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);
}

@ -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()];

@ -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';

@ -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)';

@ -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']);

@ -82,6 +82,7 @@ function rcube_mail_ui()
this.popups = {
markmenu: {id:'markmessagemenu'},
replyallmenu: {id:'replyallmenu'},
forwardmenu: {id:'forwardmenu'},
searchmenu: {id:'searchmenu', editable:1},
messagemenu: {id:'messagemenu'},
listmenu: {id:'listmenu', editable:1},

@ -0,0 +1,7 @@
<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>

@ -112,8 +112,12 @@
<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=" " />
@ -131,6 +135,7 @@
</div>
<roundcube:include file="/includes/replyallmenu.html" />
<roundcube:include file="/includes/forwardmenu.html" />
<roundcube:include file="/includes/messagemenu.html" />
<div id="searchmenu" class="popupmenu">

@ -23,8 +23,12 @@
<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=" " />
@ -32,6 +36,7 @@
</div>
<roundcube:include file="/includes/replyallmenu.html" />
<roundcube:include file="/includes/forwardmenu.html" />
<roundcube:include file="/includes/messagemenu.html" />
<div id="mainscreen">

Loading…
Cancel
Save