Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/239575

Change subject: Add target and sender user objects to hooks in Special:Emailuser
......................................................................

Add target and sender user objects to hooks in Special:Emailuser

This would allow extensions to give hints to the correct user, because
the email address is not unique when trying to re-lookup the correct
user.

Change-Id: I1c5636dc378667ef2798c69659b43f70734f4144
---
M RELEASE-NOTES-1.26
M docs/hooks.txt
M includes/specials/SpecialEmailuser.php
3 files changed, 17 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/75/239575/1

diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26
index 13239de..eda74bc 100644
--- a/RELEASE-NOTES-1.26
+++ b/RELEASE-NOTES-1.26
@@ -188,6 +188,8 @@
   are deprecated. Applications using those can work via the OAuth
   extension instead. New tokens types should not be added.
 * DatabaseBase::errorCount() was removed (unused).
+* Hooks EmailUser, EmailUserCC and EmailUserComplete now have a parameter for
+  the receiving user and sending user.
 
 == Compatibility ==
 
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 54ab46c..19707d8 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -1275,18 +1275,24 @@
 $from: address of sending user
 $subject: subject of the mail
 $text: text of the mail
+$target: User object of the receiving user
+$sender: User object of the sending user
 
 'EmailUserCC': Before sending the copy of the email to the author.
 $to: address of receiving user
 $from: address of sending user
 $subject: subject of the mail
 $text: text of the mail
+$target: User object of the receiving user
+$sender: User object of the sending user
 
 'EmailUserComplete': After sending email from one user to another.
 $to: address of receiving user
 $from: address of sending user
 $subject: subject of the mail
 $text: text of the mail
+$target: User object of the receiving user
+$sender: User object of the sending user
 
 'EmailUserForm': After building the email user form object.
 $form: HTMLForm object
diff --git a/includes/specials/SpecialEmailuser.php 
b/includes/specials/SpecialEmailuser.php
index 1754471..ea9e793 100644
--- a/includes/specials/SpecialEmailuser.php
+++ b/includes/specials/SpecialEmailuser.php
@@ -312,9 +312,10 @@
                        // Messages used here: notargettext, noemailtext, 
nowikiemailtext
                        return $context->msg( $target . 'text' 
)->parseAsBlock();
                }
+               $sender = $context->getUser();
 
                $to = MailAddress::newFromUser( $target );
-               $from = MailAddress::newFromUser( $context->getUser() );
+               $from = MailAddress::newFromUser( $sender );
                $subject = $data['Subject'];
                $text = $data['Text'];
 
@@ -324,7 +325,7 @@
                        $from->name, $to->name )->inContentLanguage()->text();
 
                $error = '';
-               if ( !Hooks::run( 'EmailUser', array( &$to, &$from, &$subject, 
&$text, &$error ) ) ) {
+               if ( !Hooks::run( 'EmailUser', array( &$to, &$from, &$subject, 
&$text, &$error, $target, $sender ) ) ) {
                        return $error;
                }
 
@@ -369,12 +370,16 @@
                        if ( $data['CCMe'] && $to != $from ) {
                                $cc_subject = $context->msg( 'emailccsubject' 
)->rawParams(
                                        $target->getName(), $subject )->text();
-                               Hooks::run( 'EmailUserCC', array( &$from, 
&$from, &$cc_subject, &$text ) );
+
+                               // Keep the hook signature similar to hook 
'EmailUser'
+                               Hooks::run( 'EmailUserCC', array( &$from, 
&$from, &$cc_subject, &$text, $sender, $sender ) );
+
                                $ccStatus = UserMailer::send( $from, $from, 
$cc_subject, $text );
                                $status->merge( $ccStatus );
                        }
 
-                       Hooks::run( 'EmailUserComplete', array( $to, $from, 
$subject, $text ) );
+                       // Keep the hook signature similar to hook 'EmailUser'
+                       Hooks::run( 'EmailUserComplete', array( $to, $from, 
$subject, $text, $target, $sender ) );
 
                        return $status;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/239575
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c5636dc378667ef2798c69659b43f70734f4144
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to