From: Michael M Slusarz Date: Thu, 26 Aug 2010 19:49:44 +0000 (-0600) Subject: Add hook to skip MDN prompting based on content of message headers X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e26ea7014c3ec0d85ef2c1ec1d79d30f06771b65;p=horde.git Add hook to skip MDN prompting based on content of message headers --- diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index 18a1979f6..90e5ae17a 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -466,6 +466,7 @@ class IMP_Hooks // : $label; // } + /** * Mark a mailbox as read-only. * @@ -481,6 +482,27 @@ class IMP_Hooks /** + * Determine whether to prompt a user to send a Message Disposition + * Notification (MDN; a/k/a read-receipt) if their preferences require + * a prompt. Useful if MDNs should automatically be sent for a certain + * subset of messages, e.g. e-mail addresses within the domain. + * + * @param Horde_Mime_Headers $headers A headers object. + * + * @return boolean Should the user be prompted to send a MDN? + */ +// public function mdn_check($headers) +// { +// // Example #1: Don't require MDN prompt if the message is sent by +// // someone within the same domain (NOTE: this does no checking on +// // spoofed e-mail addresses; further verification should probably +// // be done before automatically sending out a MDN). +// $from = $headers->getOb('from'); +// return (strcasecmp($from['host'], 'example.com') !== 0); +// } + + + /** * Allow additional information to be added/edited from the data that is * passed to the mailbox display template: * imp: imp/templates/mailbox/mailbox.html @@ -598,6 +620,7 @@ class IMP_Hooks // return array($quota[1] * 1024, $quota[2] * 1024); // } + /** * Retrieves public S/MIME keys of message recipients. * @@ -640,6 +663,7 @@ class IMP_Hooks // return $information[0][$attribute][0]; // } + /** * Retrieves public PGP keys of message recipients. * @@ -683,6 +707,7 @@ class IMP_Hooks // return $information[0][$attribute][0]; // } + /** * DIMP: Allow additional information to be added to the array that is * passed to the message text display template: @@ -720,7 +745,8 @@ class IMP_Hooks * second element is an array of javascript commands, one * command per array value. */ -// public function dimp_previewview($msg) { +// public function dimp_previewview($msg) +// { // // Example #1: Alter the subject // $msg['subject'] .= 'test'; // diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index b00edcd2f..6a4950ef0 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[mms] Add hook to skip MDN prompt based on content of message headers. [mms] Allow expand/collapse of folders in MIMP. [mms] Use single, unified mailbox cache. [mms] Add support for setting/retrieving special-use mailboxes from IMAP diff --git a/imp/lib/Ui/Message.php b/imp/lib/Ui/Message.php index eff16dced..3d9a3da5e 100644 --- a/imp/lib/Ui/Message.php +++ b/imp/lib/Ui/Message.php @@ -61,10 +61,10 @@ class IMP_Ui_Message /** * Check if we need to send a MDN, and send if needed. * - * @param string $mailbox The mailbox of the message. - * @param integer $uid The UID of the message. - * @param array $headers The headers of the message. - * @param boolean $confirmed Has the MDN request been confirmed? + * @param string $mailbox The mailbox of the message. + * @param integer $uid The UID of the message. + * @param Horde_Mime_Headers $headers The headers of the message. + * @param boolean $confirmed Has the MDN request been confirmed? * * @return boolean True if the MDN request needs to be confirmed. */ @@ -114,7 +114,13 @@ class IMP_Ui_Message if (!$confirmed && ((intval($pref_val) == 1) || $mdn->userConfirmationNeeded())) { - return true; + try { + if (Horde::callHook('mdn_check', array($headers), 'imp')) { + return true; + } + } catch (Horde_Exception_HookNotSet $e) { + return true; + } } /* Send out the MDN now. */