From: Justin Du Date: Sat, 31 Dec 2016 02:39:44 +0000 (-0600) Subject: Add a 'ChangeUserGroups' hook in Special:Userrights X-Git-Tag: 1.31.0-rc.0~4443 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=8ec41052560336d61914e1be1da296c12626c8a5;p=lhc%2Fweb%2Fwiklou.git Add a 'ChangeUserGroups' hook in Special:Userrights Currently, there is no hook that runs before a user's groups are changed. Adding a hook here will allow for action before the groups are changed. Bug: T49338 Change-Id: I87dbb6a8eb897f4a40215d33d1a0b24af7efa871 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index b6d37e07e1..e8335cd5a7 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1079,6 +1079,12 @@ $params: tag params $rc: RecentChange being tagged when the tagging accompanies the action or null $user: User who performed the tagging when the tagging is subsequent to the action or null +'ChangeUserGroups': Called before user groups are changed. +$performer: The User who will perform the change +$user: The User whose groups will be changed +&$add: The groups that will be added +&$remove: The groups that will be removed + 'Collation::factory': Called if $wgCategoryCollation is an unknown collation. $collationName: Name of the collation in question &$collationObject: Null. Replace with a subclass of the Collation class that diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index df98f33555..c86952861c 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -250,6 +250,8 @@ class UserrightsPage extends SpecialPage { $groups ) ); + Hooks::run( 'ChangeUserGroups', [ $this->getUser(), $user, &$add, &$remove ] ); + $oldGroups = $user->getGroups(); $newGroups = $oldGroups;