'limit_inline_size' => 1048576,
/* Check for phishing exploits? */
- 'phishing_check' => true,
-
- /* A list of from e-mail addresses that are considered "safe" for
- * purposes of image blocking (if image blocking is enabled in the
- * preferences). */
- 'safe_addrs' => array()
+ 'phishing_check' => true
),
/* Default smil driver. */
'allthumbs' => true,
/* Display images inline that are less than this size (in bytes). */
- 'inlinesize' => 262144
+ 'inlinesize' => 262144,
+
+ /* A list of from e-mail addresses that are considered "safe" for
+ * purposes of image blocking (if image blocking is enabled in the
+ * preferences). */
+ 'safe_addrs' => array()
),
/* Enriched text display. */
'desc' => _("Configure how messages are displayed."),
'members' => array(
'filtering', 'strip_attachments', 'alternative_display',
- 'html_image_replacement', 'html_image_addrbook', 'highlight_text',
+ 'image_replacement', 'image_addrbook', 'highlight_text',
'highlight_simple_markup', 'show_quoteblocks', 'dim_signature',
'emoticons', 'parts_display', 'mail_hdr', 'default_msg_charset',
'disposition_send_mdn'
'desc' => _("For messages with alternative representations of the text part, which part should we display?")
);
-// Replace image tags in inline viewed HTML messages with blank images?
-$_prefs['html_image_replacement'] = array(
+// Replace image tags in inline messages with blank images?
+$_prefs['image_replacement'] = array(
'value' => 1,
'type' => 'checkbox',
- 'desc' => _("Block images in inline viewed HTML messages unless they are specifically requested?"),
- 'help' => 'prefs-html_image_replacement'
+ 'desc' => _("Block images in messages unless they are specifically requested?"),
+ 'help' => 'prefs-image_replacement'
);
-// By default, automatically show images in inline viewed HTML messages if the
-// sender is in the user's addressbook?
-$_prefs['html_image_addrbook'] = array(
+// By default, automatically show images in inline messages if the sender is
+// in the user's addressbook?
+$_prefs['image_addrbook'] = array(
'value' => 1,
'type' => 'checkbox',
- 'desc' => _("Automatically show images in inline viewed HTML messages when the sender is in my address book?"),
- 'help' => 'prefs-html_image_addrbook'
+ 'desc' => _("Automatically show images in messages when the sender is in my address book?"),
+ 'help' => 'prefs-image_addrbook'
);
// should we try to mark different conversations with different colors?
v5.0-git
--------
+[mms] Refactor inline message image blocking to operate on all messages, not
+ just HTML messages.
[mms] Add attachment message filter.
[mms] Add post_spam hook called after reporting spam/ham (Request #6455).
[mms] Implement stationery support in DIMP.
fetchmail_menu
filter_on_sidebar
forward_bodytext
+ image_addrbook
+ image_replacement
nav_expanded_sidebar
use_vinbox
use_vtrash
$this->_upgradeAbookPrefs();
$this->_upgradeForwardPrefs();
$this->_upgradeLoginTasksPrefs();
+ $this->_upgradeMsgDisplayPrefs();
$this->_upgradeSortPrefs();
$this->_upgradeVirtualFolders();
}
{
global $prefs;
+ $replace = $prefs->getValue('html_image_replacement');
+ if (!is_null($replace) && !$replace) {
+ $prefs->setValue('image_replacement', 0);
+ }
+
+ $addrbook = $prefs->getValue('html_image_addrbook');
+ if (!is_null($addrbook) && !$addrbook) {
+ $prefs->setValue('image_addrbook', 0);
+ }
+ }
+
+ /**
+ * Upgrade to the new message display preferences.
+ */
+ protected function _upgradeMsgDisplayPrefs()
+ {
+ global $prefs;
+
if (!$prefs->isDefault('initial_page') &&
($prefs->getValue('initial_page') == 'folders.php')) {
$prefs->setValue('initial_page', IMP_Prefs_Ui::PREF_FOLDER_PAGE);
(!$inline && Horde_Util::getFormData('convert_text'))) {
$this->_imptmp = null;
} else {
+ if ($inline) {
+ $imgview = new IMP_Ui_Imageview();
+ $blockimg = !$imgview->showInlineImage($this->getConfigParam('imp_contents'));
+ } else {
+ $blockimg = false;
+ }
+
$this->_imptmp = array(
'blockimg' => null,
'cid' => null,
- 'img' => ($inline && $GLOBALS['prefs']->getValue('html_image_replacement') && !$this->_inAddressBook()),
+ 'img' => $blockimg,
'imgblock' => false,
'inline' => $inline,
'target' => strval(new Horde_Support_Randomid())
/* Only display the image inline if the browser can display it and the
* size of the image is below the config value. */
if ($GLOBALS['browser']->isViewable($this->_getType())) {
- if (isset($this->_conf['inlinesize']) &&
+ if (!isset($this->_conf['inlinesize']) ||
($this->_mimepart->getBytes() < $this->_conf['inlinesize'])) {
- /* Viewing inline, and the browser can handle the image type
- * directly. So output an <img> tag to load the image. */
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_outputImgTag('data', $this->_mimepart->getName(true)),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $this->getConfigParam('charset')
- )
- );
+ $imgview = new IMP_Ui_Imageview();
+ $showimg = $imgview->showInlineImage($this->getConfigParam('imp_contents'));
} else {
+ $showimg = false;
+ }
+
+ if (!$showimg) {
return $this->_renderInfo();
}
+
+ /* Viewing inline, and the browser can handle the image type
+ * directly. So output an <img> tag to load the image. */
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_outputImgTag('data', $this->_mimepart->getName(true)),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $this->getConfigParam('charset')
+ )
+ );
}
/* The browser cannot view this image. Inform the user of this and
if (!$v->canRender('inline')) {
$ui->suppress[] = 'alternative_display';
- $ui->suppress[] = 'html_image_replacement';
- $ui->suppress[] = 'html_image_addrbook';
}
/* Sort encodings. */
--- /dev/null
+<?php
+/**
+ * This class is designed to provide a place to store common code shared among
+ * various MIME Viewers relating to image viewing preferences.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @package IMP
+ */
+class IMP_Ui_Imageview
+{
+ /**
+ * Show inline images in messages?
+ *
+ * @param IMP_Contents $contents The contents object containing the
+ * message.
+ *
+ * @return boolean True if inline image should be shown.
+ */
+ public function showInlineImage($contents)
+ {
+ global $injector, $prefs, $registry;
+
+ if (!$prefs->getValue('image_replacement')) {
+ return true;
+ }
+
+ if (!$contents) {
+ return false;
+ }
+
+ $from = Horde_Mime_Address::bareAddress($contents->getHeaderOb()->getValue('from'));
+ if ($prefs->getValue('image_addrbook') &&
+ $registry->hasMethod('contacts/getField')) {
+ $params = IMP::getAddressbookSearchParams();
+ try {
+ if ($registry->call('contacts/getField', array($from, '__key', $params['sources'], false, true))) {
+ return true;
+ }
+ } catch (Horde_Exception $e) {}
+ }
+
+ /* Check admin defined e-mail list. */
+ list(, $config) = $injector->getInstance('Horde_Core_Factory_MimeViewer')->getViewerConfig('image/*', 'imp');
+ return (!empty($config['safe_addrs']) && in_array($from, $config['safe_addrs']));
+ }
+
+}
</para>
</entry>
-<entry id="prefs-html_image_replacement">
- <title>Preferences: HTML Image Replacement</title>
+<entry id="prefs-image_replacement">
+ <title>Preferences: Image Replacement</title>
<para>
- For HTML messages displayed inline, should all image tags be blocked until you specifically decide to view those images? Note that, if viewing an HTML attachment, the images will always be displayed.
+ For messages displayed inline, should all image tags be blocked until you specifically decide to view those images? Note that, if viewing as an attachment, the images will always be displayed.
</para>
</entry>
-<entry id="prefs-html_image_addrbook">
- <title>Preferences: HTML Image Replacement/Addressbook Show</title>
+<entry id="prefs-image_addrbook">
+ <title>Preferences: Image Replacement/Addressbook Show</title>
<para>
- If blocking images for inline HTML messages, should we automatically display them instead if the sender appears in your addressbook?
+ If blocking images for inline messages, should they be displayed automatically if the sender appears in your addressbook?
</para>
</entry>