From 712b30dd2de49763f68ee6c8f7b8b24bdadb19d9 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Fri, 13 Jun 2008 08:57:52 -0400 Subject: [PATCH] - Added option to display images in messages from known senders (#1484601) --- CHANGELOG | 4 ++ program/steps/settings/func.inc | 18 ++++++++- program/localization/en_US/labels.inc | 1 program/steps/mail/show.inc | 18 +++++++++ program/localization/pl_PL/labels.inc | 1 config/main.inc.php.dist | 3 + program/include/rcube_message.php | 10 +++++ program/localization/nl_NL/labels.inc | 1 program/js/app.js | 8 ++++ program/steps/settings/save_prefs.inc | 1 10 files changed, 63 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8333d09..9f4ed98 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ CHANGELOG RoundCube Webmail --------------------------- +2008/06/13 (alec) +---------- +- Added option to display images in messages from known senders (#1484601) + 2008/06/12 (alec) ---------- - Fix corrupted MIME headers of messages in Sent folder (#1485111) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index 0be6d47..14ce518 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -312,6 +312,9 @@ // prefer displaying HTML messages $rcmail_config['prefer_html'] = TRUE; +// display images in mail from known senders +$rcmail_config['addrbook_show_images'] = FALSE; + // compose html formatted messages by default $rcmail_config['htmleditor'] = FALSE; diff --git a/program/include/rcube_message.php b/program/include/rcube_message.php index 4d3cb6c..d810ef3 100644 --- a/program/include/rcube_message.php +++ b/program/include/rcube_message.php @@ -86,6 +86,16 @@ return $raw ? $value : $this->imap->decode_header($value); } + /** + * Set is_safe var and session data + * + * @param bool enable/disable + */ + public function set_safe($safe = true) + { + $this->is_safe = $safe; + $_SESSION['safe_messages'][$this->uid] = $this->is_safe; + } /** * Compose a valid URL for getting a message part diff --git a/program/js/app.js b/program/js/app.js index 96c9ec3..667b9fb 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3399,6 +3399,14 @@ }; + this.toggle_prefer_html = function(checkbox) + { + var addrbook_show_images; + if (addrbook_show_images = document.getElementById('rcmfd_addrbook_show_images')) + addrbook_show_images.disabled = !checkbox.checked; + } + + /********************************************************/ /********* remote request methods *********/ diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index e917caa..1b69ec5 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -66,6 +66,7 @@ $labels['preferhtml'] = 'Display HTML'; $labels['htmlmessage'] = 'HTML Message'; +$labels['showknownimages'] = 'Show images from known senders'; $labels['prettydate'] = 'Pretty dates'; $labels['addtoaddressbook'] = 'Add to address book'; diff --git a/program/localization/nl_NL/labels.inc b/program/localization/nl_NL/labels.inc index 66a03ab..fa8525a 100644 --- a/program/localization/nl_NL/labels.inc +++ b/program/localization/nl_NL/labels.inc @@ -52,6 +52,7 @@ $labels['filesize'] = 'Bestandsgrootte'; $labels['preferhtml'] = 'Toon HTML'; $labels['htmlmessage'] = 'HTML Bericht'; +$labels['showknownimages'] = 'Toon afbeeldingen van bekende afzenders'; $labels['prettydate'] = 'Opgemaakte datums'; $labels['addtoaddressbook'] = 'Toevoegen aan adresboek'; $labels['sun'] = 'Zo'; diff --git a/program/localization/pl_PL/labels.inc b/program/localization/pl_PL/labels.inc index 5c9570d..fcee150 100644 --- a/program/localization/pl_PL/labels.inc +++ b/program/localization/pl_PL/labels.inc @@ -57,6 +57,7 @@ $labels['filesize'] = 'Rozmiar pliku'; $labels['preferhtml'] = 'Domyślny HTML'; $labels['htmlmessage'] = 'Wiadomość HTML'; +$labels['showknownimages'] = 'Wyświetlaj obrazki od znanych nadawców'; $labels['prettydate'] = 'Ładne daty'; $labels['addtoaddressbook'] = 'Dodaj do książki adresowej '; $labels['sun'] = 'Nd'; diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 0984973..ed44edd 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -45,6 +45,24 @@ // calculate Etag for this request $etag = md5($MESSAGE->uid.$mbox_name.session_id().intval($MESSAGE->headers->mdn_sent).intval($MESSAGE->is_safe).intval($PRINT_MODE)); + // check known senders to display images + if (!$MESSAGE->is_safe + && !$_SESSION['safe_messages'][$MESSAGE->uid] + && !isset($_GET['_safe']) + && $RCMAIL->config->get('addrbook_show_images') + && $MESSAGE->has_html_part()) + { + $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']); + $senders = $IMAP->decode_address_list($MESSAGE->headers->from); + + foreach ($senders as $sender) + if ($sender['mailto'] && $CONTACTS->search('email', $sender['mailto'], true, false)->count) + { + $MESSAGE->set_safe(); + break; + } + } + // allow caching, unless remote images are present if ((bool)$MESSAGE->is_safe) send_nocacheing_headers(); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 5c64857..e35a27a 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -150,12 +150,26 @@ if (!isset($no_override['prefer_html'])) { $field_id = 'rcmfd_htmlmsg'; - $input_pagesize = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1)); + $input_preferhtml = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1, + 'onchange' => JS_OBJECT_NAME.'.toggle_prefer_html(this)')); $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", $field_id, Q(rcube_label('preferhtml')), - $input_pagesize->show($config['prefer_html']?1:0)); + $input_preferhtml->show($config['prefer_html']?1:0)); + } + + // show checkbox for displaying images from people in the addressbook + if (!isset($no_override['addrbook_show_images'])) + { + $field_id = 'rcmfd_addrbook_show_images'; + $input_addrbook_show_images = new html_checkbox(array('name' => '_addrbook_show_images', 'id' => $field_id, + 'value' => 1, 'disabled' => $config['prefer_html']?0:1)); + + $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", + $field_id, + Q(rcube_label('showknownimages')), + $input_addrbook_show_images->show($config['addrbook_show_images']?1:0)); } // Show checkbox for HTML Editor diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index f8cf267..08e5eec 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -25,6 +25,7 @@ 'pagesize' => is_numeric($_POST['_pagesize']) ? max(2, intval($_POST['_pagesize'])) : $CONFIG['pagesize'], 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE, 'prefer_html' => isset($_POST['_prefer_html']) ? TRUE : FALSE, + 'addrbook_show_images' => isset($_POST['_addrbook_show_images']) ? TRUE : FALSE, 'htmleditor' => isset($_POST['_htmleditor']) ? TRUE : FALSE, 'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE, 'read_when_deleted' => isset($_POST['_read_when_deleted']) ? TRUE : FALSE, -- Gitblit v1.9.1