From 6ca1e6add155c8c52949a55ac3e442cd44fcc216 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 29 Aug 2015 09:08:50 -0400
Subject: [PATCH] Add option to enable HTML editor always, except when replying to plain text messages (#1489365)

---
 CHANGELOG                             |    1 +
 program/steps/mail/compose.inc        |    7 ++++---
 program/steps/settings/func.inc       |    3 ++-
 program/localization/en_US/labels.inc |    1 +
 config/defaults.inc.php               |    6 +++++-
 5 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 6e72efb..75242e9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Add option to enable HTML editor always, except when replying to plain text messages (#1489365)
 - Emoticons: Added option to switch on/off emoticons in compose editor (#1485732)
 - Emoticons: Added option to switch on/off emoticons in plain text messages
 - Emoticons: All emoticons-related functionality is handled by the plugin now
diff --git a/config/defaults.inc.php b/config/defaults.inc.php
index 39e541c..7646935 100644
--- a/config/defaults.inc.php
+++ b/config/defaults.inc.php
@@ -1015,7 +1015,11 @@
 $config['compose_extwin'] = false;
 
 // compose html formatted messages by default
-// 0 - never, 1 - always, 2 - on reply to HTML message, 3 - on forward or reply to HTML message
+//  0 - never,
+//  1 - always,
+//  2 - on reply to HTML message,
+//  3 - on forward or reply to HTML message
+//  4 - always, except when replying to plain text message
 $config['htmleditor'] = 0;
 
 // save copies of compose messages in the browser's local storage
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 8202b14..e3f6fc8 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -474,6 +474,7 @@
 $labels['showremoteimages'] = 'Display remote inline images';
 $labels['fromknownsenders'] = 'from known senders';
 $labels['always'] = 'always';
+$labels['alwaysbutplain'] = 'always, except when replying to plain text';
 $labels['showinlineimages'] = 'Display attached images below the message';
 $labels['autosavedraft']  = 'Automatically save draft';
 $labels['everynminutes']  = 'every $n minute(s)';
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 85e5e27..96db7e6 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -716,13 +716,14 @@
         $useHtml = rcmail_message_is_html();
     }
     else if ($compose_mode == RCUBE_COMPOSE_REPLY) {
-        $useHtml = ($html_editor == 1 || ($html_editor >= 2 && rcmail_message_is_html()));
+        $useHtml = $html_editor == 1 || ($html_editor >= 2 && rcmail_message_is_html());
     }
     else if ($compose_mode == RCUBE_COMPOSE_FORWARD) {
-        $useHtml = ($html_editor == 1 || ($html_editor == 3 && rcmail_message_is_html()));
+        $useHtml = $html_editor == 1 || $html_editor == 4
+            || ($html_editor == 3 && rcmail_message_is_html());
     }
     else {
-        $useHtml = ($html_editor == 1);
+        $useHtml = $html_editor == 1 || $html_editor == 4;
     }
 
     return $useHtml;
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index 0218325..22c02ee 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -672,9 +672,10 @@
                 $select   = new html_select(array('name' => '_htmleditor', 'id' => $field_id));
 
                 $select->add($RCMAIL->gettext('never'), 0);
-                $select->add($RCMAIL->gettext('always'), 1);
                 $select->add($RCMAIL->gettext('htmlonreply'), 2);
                 $select->add($RCMAIL->gettext('htmlonreplyandforward'), 3);
+                $select->add($RCMAIL->gettext('always'), 1);
+                $select->add($RCMAIL->gettext('alwaysbutplain'), 4);
 
                 $blocks['main']['options']['htmleditor'] = array(
                     'title'   => html::label($field_id, rcube::Q($RCMAIL->gettext('htmleditor'))),

--
Gitblit v1.9.1