Add new hook AbortTalkPageEmailNotification
authorbsitu <bsitu@wikimedia.org>
Mon, 10 Jun 2013 22:11:39 +0000 (15:11 -0700)
committerbsitu <bsitu@wikimedia.org>
Mon, 10 Jun 2013 22:37:18 +0000 (15:37 -0700)
This hook will allow extension to disable the regular talk page email notification,
Echo is doing this with a hackish solution of setting global variable
wgEnotifUserTalk to false on the fly, this approach is problematic and will
be replaced with this hook

Change-Id: Ie043d9a1a771d64e4b05b7ddeca75c7542a6c575

RELEASE-NOTES-1.22
docs/hooks.txt
includes/UserMailer.php

index 6534215..0b1d88a 100644 (file)
@@ -109,6 +109,8 @@ production.
   for extensions such as OAuth:
 ** editmyusercss controls whether a user may edit their own CSS subpages.
 ** editmyuserjs controls whether a user may edit their own JS subpages.
+* Add new hook AbortTalkPageEmailNotification, this will be used to determine
+  whether to send the regular talk page email notification
 
 === Bug fixes in 1.22 ===
 * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one
index 66b5068..ff0a864 100644 (file)
@@ -270,6 +270,10 @@ $reason: the reason for the move (added in 1.13)
 $user: the User object about to be created (read-only, incomplete)
 &$msg: out parameter: HTML to display on abort
 
+'AbortTalkPageEmailNotification': Return false to cancel talk page email notification
+$targetUser: the user whom to send talk page email notification
+$title: the page title
+
 'AbortChangePassword': Return false to cancel password change.
 $user: the User object to which the password change is occuring
 $mOldpass: the old password provided by the user
index e48070a..2a549ac 100644 (file)
@@ -668,11 +668,13 @@ class EmailNotification {
                        } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) &&
                                ( !$minorEdit || $targetUser->getOption( 'enotifminoredits' ) ) )
                        {
-                               if ( $targetUser->isEmailConfirmed() ) {
+                               if ( !$targetUser->isEmailConfirmed() ) {
+                                       wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" );
+                               } elseif ( !wfRunHooks( 'AbortTalkPageEmailNotification', array( $targetUser, $title ) ) ) {
+                                       wfDebug( __METHOD__ . ": talk page update notification is aborted for this user\n" );
+                               } else {
                                        wfDebug( __METHOD__ . ": sending talk page update notification\n" );
                                        return true;
-                               } else {
-                                       wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" );
                                }
                        } else {
                                wfDebug( __METHOD__ . ": talk page owner doesn't want notifications\n" );