Add a 'ChangeUserGroups' hook in Special:Userrights
authorJustin Du <justin.d128@gmail.com>
Sat, 31 Dec 2016 02:39:44 +0000 (20:39 -0600)
committerJustin Du <justin.d128@gmail.com>
Sat, 31 Dec 2016 03:00:45 +0000 (21:00 -0600)
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
includes/specials/SpecialUserrights.php

index b6d37e0..e8335cd 100644 (file)
@@ -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
index df98f33..c869528 100644 (file)
@@ -250,6 +250,8 @@ class UserrightsPage extends SpecialPage {
                        $groups )
                );
 
+               Hooks::run( 'ChangeUserGroups', [ $this->getUser(), $user, &$add, &$remove ] );
+
                $oldGroups = $user->getGroups();
                $newGroups = $oldGroups;