summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-03-15 10:30:53 +0100
committerAleksander Machniak <alec@alec.pl>2013-03-15 10:30:53 +0100
commita02c77c584906f629d382409e76f0df4d2cfaf01 (patch)
treead7fdd393e02b4be1dc2d49db3cfe59614b97049 /program/steps/mail
parent0ef894ec2949100aee8624701edbf38087ea9047 (diff)
Add ability to toggle between view as HTML and text while viewing a message (#1486939)
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/compose.inc19
-rw-r--r--program/steps/mail/show.inc27
2 files changed, 36 insertions, 10 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 640272400..6a579f754 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -183,9 +183,18 @@ $LINE_LENGTH = $RCMAIL->config->get('line_length', 72);
if (!empty($msg_uid) && empty($COMPOSE['as_attachment']))
{
- // similar as in program/steps/mail/show.inc
- // re-set 'prefer_html' to have possibility to use html part for compose
- $CONFIG['prefer_html'] = $CONFIG['prefer_html'] || $CONFIG['htmleditor'] || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT;
+ $mbox_name = $RCMAIL->storage->get_folder();
+
+ // set format before rcube_message construction
+ // use the same format as for the message view
+ if (isset($_SESSION['msg_formats'][$mbox_name.':'.$msg_uid])) {
+ $RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$msg_uid]);
+ }
+ else {
+ $prefer_html = $CONFIG['prefer_html'] || $CONFIG['htmleditor'] || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT;
+ $RCMAIL->config->set('prefer_html', $prefer_html);
+ }
+
$MESSAGE = new rcube_message($msg_uid);
// make sure message is marked as read
@@ -538,8 +547,8 @@ function rcmail_compose_editor_mode()
function rcmail_message_is_html()
{
- global $MESSAGE;
- return ($MESSAGE instanceof rcube_message) && $MESSAGE->has_html_part(true);
+ global $RCMAIL, $MESSAGE;
+ return $RCMAIL->config->get('prefer_html') && ($MESSAGE instanceof rcube_message) && $MESSAGE->has_html_part(true);
}
function rcmail_prepare_message_body()
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 87555cbbe..552c180f5 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -19,7 +19,7 @@
+-----------------------------------------------------------------------+
*/
-$PRINT_MODE = $RCMAIL->action=='print' ? TRUE : FALSE;
+$PRINT_MODE = $RCMAIL->action == 'print' ? TRUE : FALSE;
// Read browser capabilities and store them in session
if ($caps = get_input_value('_caps', RCUBE_INPUT_GET)) {
@@ -31,8 +31,21 @@ if ($caps = get_input_value('_caps', RCUBE_INPUT_GET)) {
$_SESSION['browser_caps'] = $browser_caps;
}
+$uid = get_input_value('_uid', RCUBE_INPUT_GET);
+$mbox_name = $RCMAIL->storage->get_folder();
+
// similar code as in program/steps/mail/get.inc
-if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
+if ($uid) {
+ // set message format (need to be done before rcube_message construction)
+ if (!empty($_GET['_format'])) {
+ $prefer_html = $_GET['_format'] == 'html';
+ $RCMAIL->config->set('prefer_html', $prefer_html);
+ $_SESSION['msg_formats'][$mbox_name.':'.$uid] = $prefer_html;
+ }
+ else if (isset($_SESSION['msg_formats'][$mbox_name.':'.$uid])) {
+ $RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$uid]);
+ }
+
$MESSAGE = new rcube_message($uid);
// if message not found (wrong UID)...
@@ -40,7 +53,6 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
rcmail_message_error($uid);
}
- $mbox_name = $RCMAIL->storage->get_folder();
// show images?
rcmail_check_safe($MESSAGE);
@@ -106,6 +118,11 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
$OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
'movingmessage', 'deletingmessage', 'markingmessage');
+ $prefer_html = $RCMAIL->config->get('prefer_html');
+ if ($MESSAGE->has_html_part()) {
+ $OUTPUT->set_env('optional_format', $prefer_html ? 'text' : 'html');
+ }
+
// check for unset disposition notification
if ($MESSAGE->headers->mdn_to
&& empty($MESSAGE->headers->flags['MDNSENT'])
@@ -288,9 +305,9 @@ $OUTPUT->add_handlers(array(
));
-if ($RCMAIL->action=='print' && $OUTPUT->template_exists('messageprint'))
+if ($RCMAIL->action == 'print' && $OUTPUT->template_exists('messageprint'))
$OUTPUT->send('messageprint', false);
-else if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview'))
+else if ($RCMAIL->action == 'preview' && $OUTPUT->template_exists('messagepreview'))
$OUTPUT->send('messagepreview', false);
else
$OUTPUT->send('message', false);