From d125f864ea31cf0b6ecce462f711467fc6441747 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 25 Mar 2016 08:41:11 -0400
Subject: [PATCH] Message/rfc822 previewer compatibility with Enigma
---
skins/larry/templates/messagepart.html | 4 ++--
program/steps/mail/get.inc | 11 ++++++++---
program/js/app.js | 4 ++--
skins/classic/templates/messagepart.html | 4 ++--
4 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/program/js/app.js b/program/js/app.js
index 00028f7..75560e7 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -341,7 +341,7 @@
}
else if (this.env.action == 'get') {
this.enable_command('download', 'print', true);
- if (this.env.mimetype == 'message/rfc822') {
+ if (this.env.is_message) {
this.enable_command('reply', 'reply-all', 'forward', 'forward-inline', 'forward-attachment', true);
if (this.env.list_post)
this.enable_command('reply-list', true);
@@ -1217,7 +1217,7 @@
this.open_window(this.env.comm_path + url, true, true);
}
}
- else if (this.env.action == 'get' && this.env.mimetype != 'message/rfc822') {
+ else if (this.env.action == 'get' && !this.env.is_message) {
this.gui_objects.messagepartframe.contentWindow.print();
}
else if (uid = this.get_single_uid()) {
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index 019c063..0191502 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -63,9 +63,14 @@
));
$mimetype = $part ? rcmail_fix_mimetype($part->mimetype) : '';
- if ($part_id && $mimetype == 'message/rfc822') {
+
+ // message/rfc822 preview (Note: handle also multipart/ parts, they can
+ // come from Enigma, which replaces message/rfc822 with real mimetype)
+ if ($part_id && ($mimetype == 'message/rfc822' || strpos($mimetype, 'multipart/') === 0)) {
$uid = preg_replace('/\.[0-9.]+/', '', $uid);
$uid .= '.' . $part_id;
+
+ $OUTPUT->set_env('is_message', true);
}
$OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
@@ -458,9 +463,8 @@
{
global $RCMAIL;
- $mimetype = $RCMAIL->output->get_env('mimetype');
- if ($mimetype == 'message/rfc822') {
+ if ($RCMAIL->output->get_env('is_message')) {
$attrib['src'] = $RCMAIL->url(array(
'task' => 'mail',
'action' => 'preview',
@@ -470,6 +474,7 @@
));
}
else {
+ $mimetype = $RCMAIL->output->get_env('mimetype');
$frame_replace = strpos($mimetype, 'text/') === 0 ? '_embed=' : '_preload=';
$attrib['src'] = './?' . str_replace('_frame=', $frame_replace, $_SERVER['QUERY_STRING']);
}
diff --git a/skins/classic/templates/messagepart.html b/skins/classic/templates/messagepart.html
index 326f7a4..fe5a380 100644
--- a/skins/classic/templates/messagepart.html
+++ b/skins/classic/templates/messagepart.html
@@ -17,7 +17,7 @@
<roundcube:button command="download" type="link" class="button download" classAct="button download" classSel="button downloadSel" title="download" content=" " />
<roundcube:button command="print" type="link" class="button print" classAct="button print" classSel="button printSel" title="print" content=" " />
<roundcube:container name="toolbar" id="messagetoolbar" />
- <roundcube:if condition="env:mimetype == 'message/rfc822'" />
+ <roundcube:if condition="env:is_message" />
<span class="toolbarseparator"> </span>
<roundcube:button command="reply" type="link" class="buttonPas reply" classAct="button reply" classSel="button replySel" title="replytomessage" content=" " />
<span class="dropbutton">
@@ -43,7 +43,7 @@
</div>
</div>
-<roundcube:if condition="env:mimetype == 'message/rfc822'" />
+<roundcube:if condition="env:is_message" />
<div id="forwardmenu" class="popupmenu">
<ul id="forwardmenumenu">
<roundcube:button type="link-menuitem" command="forward-inline" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" />
diff --git a/skins/larry/templates/messagepart.html b/skins/larry/templates/messagepart.html
index b242c34..e9e7cc0 100644
--- a/skins/larry/templates/messagepart.html
+++ b/skins/larry/templates/messagepart.html
@@ -17,7 +17,7 @@
<roundcube:button command="download" type="link" class="button download disabled" classAct="button download" classSel="button download pressed" label="download" title="download" />
<roundcube:button command="print" type="link" class="button print disabled" classAct="button print" classSel="button print pressed" label="print" title="print" />
<roundcube:container name="toolbar" id="messagetoolbar" />
- <roundcube:if condition="env:mimetype == 'message/rfc822'" />
+ <roundcube:if condition="env:is_message" />
<span class="spacer"></span>
<roundcube:button command="reply" type="link" class="button reply disabled" classAct="button reply" classSel="button reply pressed" label="reply" title="replytomessage" />
<span class="dropbutton">
@@ -50,7 +50,7 @@
</div>
</div>
-<roundcube:if condition="env:mimetype == 'message/rfc822'" />
+<roundcube:if condition="env:is_message" />
<div id="forwardmenu" class="popupmenu" aria-hidden="true">
<h3 id="aria-label-forwardmenu" class="voice"><roundcube:label name="arialabelforwardingoptions" /></h3>
<ul id="forwardmenu-menu" class="toolbarmenu" role="menu" aria-labelledby="aria-label-forwardmenu">
--
Gitblit v1.9.1