From a99968259d001ebc8bd98f0f2a0aa544ed4740e8 Mon Sep 17 00:00:00 2001 From: alecpl Date: Wed, 29 Sep 2010 12:56:10 +0000 Subject: - Add option to automatically send read notifications for known senders (1485883) --- program/steps/mail/show.inc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'program/steps/mail/show.inc') diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 382733f5e..bc208ab7c 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -72,17 +72,19 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) { $mbox_name != $CONFIG['drafts_mbox'] && $mbox_name != $CONFIG['sent_mbox']) { - if (intval($CONFIG['mdn_requests']) === 1) - { - if (rcmail_send_mdn($MESSAGE->uid, $smtp_error)) + $mdn_cfg = intval($CONFIG['mdn_requests']); + + if ($mdn_cfg == 1 || ($mdn_cfg == 3 && rcmail_contact_exists($MESSAGE->sender['mailto']))) { + // Send MDN + if (rcmail_send_mdn($MESSAGE, $smtp_error)) $OUTPUT->show_message('receiptsent', 'confirmation'); else if ($smtp_error) $OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']); else $OUTPUT->show_message('errorsendingreceipt', 'error'); } - else if (empty($CONFIG['mdn_requests'])) - { + else if ($mdn_cfg != 2) { + // Ask user $OUTPUT->add_label('mdnrequest'); $OUTPUT->set_env('mdn_request', true); } @@ -181,8 +183,6 @@ function rcmail_message_attachments($attrib) return $out; } - - function rcmail_remote_objects_msg($attrib) { global $MESSAGE, $RCMAIL; @@ -203,6 +203,21 @@ function rcmail_remote_objects_msg($attrib) return html::div($attrib, $msg); } +function rcmail_contact_exists($email) +{ + global $RCMAIL; + + if ($email) { + // @TODO: search in all address books? + $CONTACTS = $RCMAIL->get_address_book(null, true); + $existing = $CONTACTS->search('email', $email, true, false); + if ($existing->count) + return true; + } + + return false; +} + $OUTPUT->add_handlers(array( 'messageattachments' => 'rcmail_message_attachments', @@ -228,4 +243,3 @@ if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen && exit; - -- cgit v1.2.3