From a509bb677ca626315d71e07afc8342a0690b6859 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 16 May 2011 09:53:08 -0400
Subject: [PATCH] - Add option to set default action of Forward button to "Forward as attachment"
---
skins/default/common.css | 5 +++++
program/steps/mail/func.inc | 6 +++---
skins/default/includes/messagetoolbar.html | 12 +++++++++---
program/steps/mail/show.inc | 2 ++
config/main.inc.php.dist | 3 +++
skins/default/functions.js | 7 +++++++
program/js/app.js | 11 +++++++----
7 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 381795d..3391d16 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -695,4 +695,7 @@
// Place replies in the folder of the message being replied to
$rcmail_config['reply_same_folder'] = false;
+// Sets default mode of Forward feature to "forward as attachment"
+$rcmail_config['forward_attachment'] = false;
+
// end of config file
diff --git a/program/js/app.js b/program/js/app.js
index 3f103de..c4aa509 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -931,10 +931,13 @@
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)
- + (command == 'forward-attachment' ? '&_attachment=1' : ''), true);
+ var uid, url;
+ if (uid = this.get_single_uid()) {
+ url = '_forward_uid='+uid+'&_mbox='+urlencode(this.env.mailbox);
+ if (command == 'forward-attachment' || (!props && this.env.forward_attachment))
+ url += '&_attachment=1';
+ this.goto_url('compose', url, true);
+ }
break;
case 'print':
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 36b4c02..e0504e6 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -106,6 +106,7 @@
$OUTPUT->set_env('delimiter', $IMAP->get_hierarchy_delimiter());
$OUTPUT->set_env('threading', (bool) $IMAP->threading);
$OUTPUT->set_env('threads', $IMAP->threading || $IMAP->get_capability('THREAD'));
+ $OUTPUT->set_env('preview_pane_mark_read', $RCMAIL->config->get('preview_pane_mark_read', 0));
if ($CONFIG['flag_for_deletion'])
$OUTPUT->set_env('flag_for_deletion', true);
@@ -115,9 +116,8 @@
$OUTPUT->set_env('skip_deleted', true);
if ($CONFIG['display_next'])
$OUTPUT->set_env('display_next', true);
-
- $OUTPUT->set_env('preview_pane_mark_read', $RCMAIL->config->get('preview_pane_mark_read', 0));
-
+ if ($CONFIG['forward_attachment'])
+ $OUTPUT->set_env('forward_attachment', true);
if ($CONFIG['trash_mbox'])
$OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']);
if ($CONFIG['drafts_mbox'])
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 1d7a326..8c063e8 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -64,6 +64,8 @@
$OUTPUT->set_env('display_next', true);
if ($MESSAGE->headers->others['list-post'])
$OUTPUT->set_env('list_post', true);
+ if ($CONFIG['forward_attachment'])
+ $OUTPUT->set_env('forward_attachment', true);
if (!$OUTPUT->ajax_call)
$OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
diff --git a/skins/default/common.css b/skins/default/common.css
index b1696ef..6f1f264 100644
--- a/skins/default/common.css
+++ b/skins/default/common.css
@@ -490,6 +490,11 @@
background-color: #c00;
}
+.popupmenu li input
+{
+ float: left;
+}
+
.darkbg
{
background-color: #F2F2F2 !important;
diff --git a/skins/default/functions.js b/skins/default/functions.js
index c1dd8c2..9057d97 100644
--- a/skins/default/functions.js
+++ b/skins/default/functions.js
@@ -148,6 +148,13 @@
this.popups.dragmessagemenu.obj[show?'show':'hide']();
},
+forwardmenu: function(show)
+{
+ $("input[name='forwardtype'][value="+(rcmail.env.forward_attachment ? 1 : 0)+"]", this.popups.forwardmenu.obj)
+ .prop('checked', true);
+ this.show_popupmenu('forwardmenu', show);
+},
+
uploadmenu: function(show)
{
if (typeof show == 'object') // called as event handler
diff --git a/skins/default/includes/messagetoolbar.html b/skins/default/includes/messagetoolbar.html
index dcc27ca..2ac23a1 100644
--- a/skins/default/includes/messagetoolbar.html
+++ b/skins/default/includes/messagetoolbar.html
@@ -26,9 +26,15 @@
</div>
<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>
+ <ul class="toolbarmenu">
+ <li>
+ <input type="radio" name="forwardtype" value="0" onchange="rcmail.command('save-pref', {name: 'forward_attachment', value: 0, env: 'forward_attachment'});" />
+ <roundcube:button command="forward" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" />
+ </li>
+ <li>
+ <input type="radio" name="forwardtype" value="1" onchange="rcmail.command('save-pref', {name: 'forward_attachment', value: 1, env: 'forward_attachment'})" />
+ <roundcube:button command="forward-attachment" label="forwardattachment" prop="sub" classAct="forwardattachmentlink active" class="forwardattachmentlink" />
+ </li>
<roundcube:container name="forwardmenu" id="forwardmenu" />
</ul>
</div>
--
Gitblit v1.9.1