From 166b615dbb67d403845b0dc4aed5ed56caf8b6de Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 14 Jun 2008 14:09:53 -0400
Subject: [PATCH] - Added option to disable displaying of attached images below the message body

---
 CHANGELOG                             |    4 ++++
 program/steps/mail/func.inc           |   10 +++++++---
 program/steps/settings/func.inc       |   11 +++++++++++
 program/localization/en_US/labels.inc |    2 +-
 program/localization/pl_PL/labels.inc |    1 +
 config/main.inc.php.dist              |   31 +++++++++++++++++--------------
 program/steps/settings/save_prefs.inc |    1 +
 7 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 69f323a..e25081e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
 CHANGELOG RoundCube Webmail
 ---------------------------
 
+2008/06/14 (alec)
+----------
+- Added option to disable displaying of attached images below the message body
+
 2008/06/13 (alec)
 ----------
 - Added option to display images in messages from known senders (#1484601)
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 14ce518..17ba0a0 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -298,6 +298,21 @@
 // ONLY ENABLE IT IF YOU'RE REALLY SURE WHAT YOU'RE DOING!
 $rcmail_config['enable_installer'] = false;
 
+// Log successful logins
+$rcmail_config['log_logins'] = false;
+
+/**
+ * 'Delete always'
+ * This setting reflects if mail should be always marked as deleted,
+ * even if moving to "Trash" fails. This is necessary in some setups
+ * because a) people may not have a Trash folder or b) they are over
+ * quota (and Trash is included in the quota).
+ *
+ * This is a failover setting for iil_C_Move when a message is moved
+ * to the Trash, and not the same as "delete_right_away".
+ */
+$rcmail_config['delete_always'] = false;
+
 /***** these settings can be overwritten by user's preferences *****/
 
 // show up to X items in list view
@@ -333,20 +348,8 @@
 // Compact INBOX on logout
 $rcmail_config['logout_expunge'] = FALSE;
 
-/**
- * 'Delete always'
- * This setting reflects if mail should be always marked as deleted,
- * even if moving to "Trash" fails. This is necessary in some setups
- * because a) people may not have a Trash folder or b) they are over
- * quota (and Trash is included in the quota).
- *
- * This is a failover setting for iil_C_Move when a message is moved
- * to the Trash, and not the same as "delete_right_away".
- */
-$rcmail_config['delete_always'] = false;
-
-// Log successful logins
-$rcmail_config['log_logins'] = false;
+// Display attached images below the message body 
+$rcmail_config['inline_images'] = TRUE;
 
 // end of config file
 ?>
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 4dfdb63..cf7c54c 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -263,7 +263,7 @@
 $labels['ignore'] = 'ignore';
 $labels['readwhendeleted'] = 'Mark the message as read on delete';
 $labels['flagfordeletion'] = 'Flag the message for deletion instead of delete';
-
+$labels['showinlineimages'] = 'Display attached images below the message';
 $labels['autosavedraft']  = 'Automatically save draft';
 $labels['everynminutes']  = 'every $n minutes';
 $labels['never']  = 'never';
diff --git a/program/localization/pl_PL/labels.inc b/program/localization/pl_PL/labels.inc
index 1fa322e..725fc38 100644
--- a/program/localization/pl_PL/labels.inc
+++ b/program/localization/pl_PL/labels.inc
@@ -59,6 +59,7 @@
 $labels['htmlmessage'] = 'Wiadomość HTML';
 $labels['showknownimages'] = 'Wyświetlaj obrazki od znanych nadawców';
 $labels['prettydate'] = 'Ładne daty';
+$labels['showinlineimages'] = 'Wyświetlaj załączone obrazki pod treścią wiadomości';
 $labels['messagesdisplaying'] = 'Wyświetlanie wiadomości';
 $labels['messagescomposition'] = 'Tworzenie wiadomości';
 $labels['addtoaddressbook'] = 'Dodaj do książki adresowej ';
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index af3f6e7..a27023f 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -745,10 +745,14 @@
 
   $ctype_primary = strtolower($MESSAGE->structure->ctype_primary);
   $ctype_secondary = strtolower($MESSAGE->structure->ctype_secondary);
-  
+
   // list images after mail body
-  if (get_boolean($attrib['showimages']) && $ctype_primary == 'multipart' &&
-      !empty($MESSAGE->attachments) && !strstr($message_body, '<html')) {
+  if (get_boolean($attrib['showimages']) 
+	&& $CONFIG['inline_images']
+	&& $ctype_primary == 'multipart'
+        && !empty($MESSAGE->attachments) 
+	&& !strstr($message_body, '<html'))
+    {
     foreach ($MESSAGE->attachments as $attach_prop) {
       if (strpos($attach_prop->mimetype, 'image/') === 0) {
         $out .= html::tag('hr') . html::p(array('align' => "center"),
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index c52daf9..c520253 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -200,6 +200,17 @@
                     $input_addrbook_show_images->show($config['addrbook_show_images']?1:0));
     }
 
+  if (!isset($no_override['inline_images']))
+    {
+    $field_id = 'rcmfd_inline_images';
+    $input_inline_images = new html_checkbox(array('name' => '_inline_images', 'id' => $field_id, 'value' => 1));
+
+    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
+                    $field_id,
+                    Q(rcube_label('showinlineimages')),
+                    $input_inline_images->show($config['inline_images']?1:0));
+    }
+
   $out .= "</table></fieldset>\n<fieldset><legend>" . Q(rcube_label('messagescomposition')) . "</legend>\n<table" . $attrib_str . ">\n\n";
 
   // Show checkbox for HTML Editor
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index 08e5eec..4498b7b 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -27,6 +27,7 @@
   'prefer_html'  => isset($_POST['_prefer_html']) ? TRUE : FALSE,
   'addrbook_show_images' => isset($_POST['_addrbook_show_images']) ? TRUE : FALSE,
   'htmleditor'   => isset($_POST['_htmleditor']) ? TRUE : FALSE,
+  'inline_images'   => isset($_POST['_inline_images']) ? TRUE : FALSE,
   'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE,
   'read_when_deleted' => isset($_POST['_read_when_deleted']) ? TRUE : FALSE,
   'flag_for_deletion' => isset($_POST['_flag_for_deletion']) ? TRUE : FALSE,

--
Gitblit v1.9.1