Add hook to skip MDN prompting based on content of message headers
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 26 Aug 2010 19:49:44 +0000 (13:49 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 26 Aug 2010 19:50:29 +0000 (13:50 -0600)
imp/config/hooks.php.dist
imp/docs/CHANGES
imp/lib/Ui/Message.php

index 18a1979..90e5ae1 100644 (file)
@@ -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';
 //
index b00edcd..6a4950e 100644 (file)
@@ -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
index eff16dc..3d9a3da 100644 (file)
@@ -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. */