Allow extensions to abort (and replace) email notifications
authorAndrew Garrett <agarrett@wikimedia.org>
Tue, 17 Jul 2012 19:58:53 +0000 (12:58 -0700)
committerAndrew Garrett <agarrett@wikimedia.org>
Tue, 17 Jul 2012 19:59:54 +0000 (12:59 -0700)
Change-Id: I769ad24fcd6f3e3c03fb67122eab25a8472047b6

docs/hooks.txt
includes/RecentChange.php

index 47654ce..5a836ae 100644 (file)
@@ -245,6 +245,10 @@ $block: The block from which the autoblock is coming.
 'AbortDiffCache': Can be used to cancel the caching of a diff
 &$diffEngine: DifferenceEngine object
 
+'AbortEmailNotification': Can be used to cancel email notifications for an edit.
+$editor: The User who made the change.
+$title: The Title of the page that was edited.
+
 'AbortLogin': Return false to cancel account login.
 $user: the User object being authenticated against
 $password: the password being submitted, not yet checked for validity
index fb8e022..20e7909 100644 (file)
@@ -231,13 +231,15 @@ class RecentChange {
                        }
                        $title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
 
-                       # @todo FIXME: This would be better as an extension hook
-                       $enotif = new EmailNotification();
-                       $status = $enotif->notifyOnPageChange( $editor, $title,
-                               $this->mAttribs['rc_timestamp'],
-                               $this->mAttribs['rc_comment'],
-                               $this->mAttribs['rc_minor'],
-                               $this->mAttribs['rc_last_oldid'] );
+                       if ( wfRunHooks( 'AbortEmailNotification', array($editor, $title) ) ) {
+                               # @todo FIXME: This would be better as an extension hook
+                               $enotif = new EmailNotification();
+                               $status = $enotif->notifyOnPageChange( $editor, $title,
+                                       $this->mAttribs['rc_timestamp'],
+                                       $this->mAttribs['rc_comment'],
+                                       $this->mAttribs['rc_minor'],
+                                       $this->mAttribs['rc_last_oldid'] );
+                       }
                }
        }