From 8ec41052560336d61914e1be1da296c12626c8a5 Mon Sep 17 00:00:00 2001 From: Justin Du Date: Fri, 30 Dec 2016 20:39:44 -0600 Subject: [PATCH] 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 --- docs/hooks.txt | 6 ++++++ includes/specials/SpecialUserrights.php | 2 ++ 2 files changed, 8 insertions(+) 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; -- 2.20.1