| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\User\Hook; |
| 4 | |
| 5 | use MediaWiki\User\User; |
| 6 | use MediaWiki\User\UserGroupMembership; |
| 7 | use MediaWiki\User\UserIdentity; |
| 8 | |
| 9 | /** |
| 10 | * This is a hook handler interface, see docs/Hooks.md. |
| 11 | * Use the hook name "UserGroupsChanged" to register handlers implementing this interface. |
| 12 | * |
| 13 | * @stable to implement |
| 14 | * @ingroup Hooks |
| 15 | */ |
| 16 | interface UserGroupsChangedHook { |
| 17 | /** |
| 18 | * This hook is called after user groups are changed. |
| 19 | * |
| 20 | * @since 1.35 |
| 21 | * |
| 22 | * @param User|UserIdentity $user User whose groups changed, for local group changes this is a |
| 23 | * User class, for interwiki group changes this was a UserRightsProxy until 1.40 and is a UserIdentity since 1.41 |
| 24 | * @param string[] $added Groups added |
| 25 | * @param string[] $removed Groups removed |
| 26 | * @param User|false $performer User who performed the change, false if via autopromotion |
| 27 | * @param string|false $reason The reason, if any, given by the user performing the change, |
| 28 | * false if via autopromotion. |
| 29 | * @param UserGroupMembership[] $oldUGMs An associative array (group name => UserGroupMembership) |
| 30 | * of the user's group memberships before the change. |
| 31 | * @param UserGroupMembership[] $newUGMs An associative array (group name => UserGroupMembership) |
| 32 | * of the user's current group memberships. |
| 33 | * @return bool|void True or no return value to continue or false to abort |
| 34 | */ |
| 35 | public function onUserGroupsChanged( |
| 36 | $user, |
| 37 | $added, |
| 38 | $removed, |
| 39 | $performer, |
| 40 | $reason, |
| 41 | $oldUGMs, |
| 42 | $newUGMs |
| 43 | ); |
| 44 | } |