From a99968259d001ebc8bd98f0f2a0aa544ed4740e8 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Wed, 29 Sep 2010 08:56:10 -0400 Subject: [PATCH] - Add option to automatically send read notifications for known senders (1485883) --- CHANGELOG | 1 program/steps/mail/func.inc | 14 +++++- program/steps/settings/func.inc | 1 program/localization/en_US/labels.inc | 9 ++-- program/steps/mail/show.inc | 30 +++++++++++---- program/localization/pl_PL/labels.inc | 7 ++- 6 files changed, 44 insertions(+), 18 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2013dd5..82270ab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ - Messages caching: performance improvements, fixed syncing, fixes related with #1486748 - Add link to identities in compose window (#1486729) - Add Internationalized Domain Name (IDNA) support (#1483894) +- Add option to automatically send read notifications for known senders (1485883) RELEASE 0.4.1 ------------- diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index 3fe75e8..704a84b 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -315,9 +315,10 @@ $labels['uisettings'] = 'User Interface'; $labels['serversettings'] = 'Server Settings'; $labels['mailboxview'] = 'Mailbox View'; -$labels['mdnrequests'] = 'Sender notifications'; -$labels['askuser'] = 'ask the user'; -$labels['autosend'] = 'send automatically'; +$labels['mdnrequests'] = 'On request for return receipt'; +$labels['askuser'] = 'ask me'; +$labels['autosend'] = 'send receipt'; +$labels['autosendknown'] = 'send receipt to my contacts only'; $labels['ignore'] = 'ignore'; $labels['readwhendeleted'] = 'Mark the message as read on delete'; $labels['flagfordeletion'] = 'Flag the message for deletion instead of delete'; @@ -405,5 +406,5 @@ $labels['japanese'] = 'Japanese'; $labels['korean'] = 'Korean'; $labels['chinese'] = 'Chinese'; - + ?> diff --git a/program/localization/pl_PL/labels.inc b/program/localization/pl_PL/labels.inc index 821f244..0aeae8d 100644 --- a/program/localization/pl_PL/labels.inc +++ b/program/localization/pl_PL/labels.inc @@ -260,9 +260,10 @@ $labels['uisettings'] = 'Interfejs użytkownika'; $labels['serversettings'] = 'Ustawienia serwera'; $labels['mailboxview'] = 'Widok skrzynki pocztowej'; -$labels['mdnrequests'] = 'Potwierdzenia odbioru'; -$labels['askuser'] = 'pytaj'; -$labels['autosend'] = 'wyślij automatycznie'; +$labels['mdnrequests'] = 'Na żadanie potwierdzenia odbioru'; +$labels['askuser'] = 'pytaj mnie'; +$labels['autosend'] = 'wyślij potwierdzenie'; +$labels['autosendknown'] = 'wyślij potwierdzenie tylko do moich kontaktów'; $labels['ignore'] = 'ignoruj'; $labels['readwhendeleted'] = 'Podczas usuwania oznacz wiadomość jako przeczytaną'; $labels['flagfordeletion'] = 'Oznacz wiadomość do usunięcia zamiast ją usuwać'; diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 95bae0b..d7c6523 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -1584,12 +1584,20 @@ return $sent; } - -function rcmail_send_mdn($uid, &$smtp_error) +/** + * Send the MDN response + * + * @param mixed $message Original message object (rcube_message) or UID + * @param array $smtp_error SMTP error array (reference) + * + * @return boolean Send status + */ +function rcmail_send_mdn($message, &$smtp_error) { global $RCMAIL, $IMAP; - $message = new rcube_message($uid); + if (!is_a($message, rcube_message)) + $message = new rcube_message($message); if ($message->headers->mdn_to && !$message->headers->mdn_sent && ($IMAP->check_permflag('MDNSENT') || $IMAP->check_permflag('*'))) diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 382733f..bc208ab 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -72,17 +72,19 @@ $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 @@ return $out; } - - function rcmail_remote_objects_msg($attrib) { global $MESSAGE, $RCMAIL; @@ -201,6 +201,21 @@ $RCMAIL->output->add_gui_object('remoteobjectsmsg', $attrib['id']); 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; } @@ -227,5 +242,4 @@ } exit; - diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index b039478..e35edde 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -323,6 +323,7 @@ $select_mdn_requests = new html_select(array('name' => '_mdn_requests', 'id' => $field_id)); $select_mdn_requests->add(rcube_label('askuser'), 0); $select_mdn_requests->add(rcube_label('autosend'), 1); + $select_mdn_requests->add(rcube_label('autosendknown'), 3); $select_mdn_requests->add(rcube_label('ignore'), 2); $blocks['main']['options']['mdn_requests'] = array( -- Gitblit v1.9.1