summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_message.php6
-rw-r--r--program/js/app.js9
-rw-r--r--program/localization/de_CH/labels.inc1
-rw-r--r--program/localization/de_DE/labels.inc1
-rw-r--r--program/localization/en_US/labels.inc1
-rw-r--r--program/steps/mail/show.inc49
6 files changed, 36 insertions, 31 deletions
diff --git a/program/include/rcube_message.php b/program/include/rcube_message.php
index d810ef3fa..6654c3f90 100644
--- a/program/include/rcube_message.php
+++ b/program/include/rcube_message.php
@@ -42,6 +42,7 @@ class rcube_message
public $mime_parts = array();
public $attachments = array();
public $subject = '';
+ public $sender = null;
public $is_safe = false;
@@ -53,9 +54,10 @@ class rcube_message
$this->uid = $uid;
$this->headers = $this->imap->get_headers($uid);
$this->subject = rcube_imap::decode_mime_string($this->headers->subject, $this->headers->charset);
+ list(, $this->sender) = each($this->imap->decode_address_list($this->headers->from));
- $this->is_safe = (intval($_GET['_safe']) || $_SESSION['safe_messages'][$uid]) ? true : false;
- $_SESSION['safe_messages'][$uid] = $this->is_safe;
+ $this->set_safe((intval($_GET['_safe']) || $_SESSION['safe_messages'][$uid]));
+ $this->set_safe(0);
$this->opt = array(
'safe' => $this->is_safe,
diff --git a/program/js/app.js b/program/js/app.js
index 667b9fbbf..e04da5519 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -185,7 +185,7 @@ function rcube_webmail()
{
if (this.gui_objects.remoteobjectsmsg)
this.gui_objects.remoteobjectsmsg.style.display = 'block';
- this.enable_command('load-images', true);
+ this.enable_command('load-images', 'always-load', true);
}
if (this.env.action=='compose')
@@ -705,6 +705,13 @@ function rcube_webmail()
this.mark_message(flag, uid);
break;
+ case 'always-load':
+ if (this.env.uid && this.env.sender) {
+ this.add_contact(urlencode(this.env.sender));
+ window.setTimeout(function(){ ref.command('load-images'); }, 300);
+ break;
+ }
+
case 'load-images':
if (this.env.uid)
this.show_message(this.env.uid, true, this.env.action=='preview');
diff --git a/program/localization/de_CH/labels.inc b/program/localization/de_CH/labels.inc
index 79b0c5ddb..3851a9f93 100644
--- a/program/localization/de_CH/labels.inc
+++ b/program/localization/de_CH/labels.inc
@@ -184,6 +184,7 @@ $labels['highest'] = 'Höchste';
$labels['nosubject'] = '(kein Betreff)';
$labels['showimages'] = 'Bilder anzeigen';
+$labels['alwaysshow'] = 'Bilder von $sender immer zeigen';
$labels['htmltoggle'] = 'HTML';
$labels['plaintoggle'] = 'Klartext';
diff --git a/program/localization/de_DE/labels.inc b/program/localization/de_DE/labels.inc
index 856599301..8a13f12cf 100644
--- a/program/localization/de_DE/labels.inc
+++ b/program/localization/de_DE/labels.inc
@@ -146,6 +146,7 @@ $labels['high'] = 'Hoch';
$labels['highest'] = 'Höchste';
$labels['nosubject'] = '(kein Betreff)';
$labels['showimages'] = 'Bilder anzeigen';
+$labels['alwaysshow'] = 'Bilder von $sender immer zeigen';
$labels['htmltoggle'] = 'HTML';
$labels['plaintoggle'] = 'Nur-Text';
$labels['addcc'] = 'Cc hinzufügen';
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 6eae419a2..4dfdb637c 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -184,6 +184,7 @@ $labels['highest'] = 'Highest';
$labels['nosubject'] = '(no subject)';
$labels['showimages'] = 'Display images';
+$labels['alwaysshow'] = 'Always show images from $sender';
$labels['htmltoggle'] = 'HTML';
$labels['plaintoggle'] = 'Plain text';
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index ed44edde0..8b6ce5809 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -47,21 +47,15 @@ if ($_GET['_uid']) {
// 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;
- }
+ && !empty($MESSAGE->sender['mailto'])
+ && $RCMAIL->config->get('addrbook_show_images')
+ && $MESSAGE->has_html_part()) {
+ $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
+
+ if ($CONTACTS->search('email', $MESSAGE->sender['mailto'], true, false)->count) {
+ $MESSAGE->set_safe(true);
}
+ }
// allow caching, unless remote images are present
if ((bool)$MESSAGE->is_safe)
@@ -85,6 +79,7 @@ if ($_GET['_uid']) {
// give message uid to the client
$OUTPUT->set_env('uid', $MESSAGE->uid);
$OUTPUT->set_env('safemode', $MESSAGE->is_safe);
+ $OUTPUT->set_env('sender', $MESSAGE->sender['string']);
// check for unset disposition notification
if ($MESSAGE->headers->mdn_to && !$MESSAGE->headers->mdn_sent &&
@@ -174,26 +169,24 @@ function rcmail_message_attachments($attrib)
function rcmail_remote_objects_msg($attrib)
- {
- global $CONFIG, $OUTPUT;
+{
+ global $MESSAGE, $RCMAIL;
if (!$attrib['id'])
$attrib['id'] = 'rcmremoteobjmsg';
-
- // allow the following attributes to be added to the <div> tag
- $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
- $out = '<div' . $attrib_str . ">";
-
- $out .= sprintf('%s&nbsp;<a href="#loadimages" onclick="%s.command(\'load-images\')">%s</a>',
- Q(rcube_label('blockedimages')),
- JS_OBJECT_NAME,
- Q(rcube_label('showimages')));
- $out .= '</div>';
+ $msg = Q(rcube_label('blockedimages')) . '&nbsp;';
+ $msg .= html::a(array('href' => "#loadimages", 'onclick' => JS_OBJECT_NAME.".command('load-images')"), Q(rcube_label('showimages')));
- $OUTPUT->add_gui_object('remoteobjectsmsg', $attrib['id']);
- return $out;
+ // add link to save sender in addressbook and reload message
+ if ($MESSAGE->sender['mailto'] && $RCMAIL->config->get('addrbook_show_images')) {
+ $msg .= ' ' . html::a(array('href' => "#alwaysload", 'onclick' => JS_OBJECT_NAME.".command('always-load')", 'style' => "white-space:nowrap"),
+ Q(rcube_label(array('name' => 'alwaysshow', 'vars' => array('sender' => $MESSAGE->sender['mailto'])))));
}
+
+ $RCMAIL->output->add_gui_object('remoteobjectsmsg', $attrib['id']);
+ return html::div($attrib, $msg);
+}
$OUTPUT->add_handlers(array(