Complete implementation of #1484601: add link for saving sender to address book and reload message

release-0.6
thomascube 17 years ago
parent fca66b0ef4
commit 62e43d2c1a

@ -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,

@ -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');

@ -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';

@ -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';

@ -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';

@ -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(

@ -730,10 +730,9 @@ div.message-htmlpart div.rcmBody
#remote-objects-message
{
display: none;
height: 20px;
margin: 8px;
min-height: 20px;
margin: 8px 8px 0px 8px;
padding: 10px 10px 6px 46px;
padding: 10px 10px 6px 46px;
}
#remote-objects-message a

Loading…
Cancel
Save