MediaWiki master
MediaWiki\User\UserGroupAssignmentServiceBase Class Reference

This class represents a base for service that provides high-level operations on user groups. More...

Inherited by MediaWiki\User\UserGroupAssignmentService.

Public Member Functions

 __construct (private readonly HookRunner $hookRunner,)
 
 getChangeableGroups (Authority $performer, UserIdentity $target, bool $evaluatePrivateConditionsForRestrictedGroups=true)
 Returns the groups that the performer can add or remove from the target user.
 
 logAccessToPrivateConditions (Authority $performer, UserIdentity $target, array $addGroups, array $newExpiries, array $existingUGMs,)
 Triggers a hook that allows extensions to log when user read some private conditions.
 
 validateUserGroups (Authority $performer, UserIdentity $target, array $addGroups, array $removeGroups, array $newExpiries, array $groupMemberships,)
 Validates the requested changes to user groups and returns an array, specifying if some groups are unchangeable and for what reasons.
 

Static Public Member Functions

static enforceChangeGroupPermissions (array &$addGroups, array &$removeGroups, array &$newExpiries, array $existingUGMs, array $permittedChanges)
 Ensures that the content of $addGroups, $removeGroups and $newExpiries is compliant with the possible changes defined in $permittedChanges.
 
static expiryToTimestamp ( $expiry)
 Converts a user group membership expiry string into a timestamp.
 

Protected Member Functions

 getKnownGroups (UserIdentity $target)
 Returns a list of possible known groups for a given identity.
 
 getRestrictedGroupChecker (UserIdentity $target)
 Returns an instance of {.
 

Detailed Description

This class represents a base for service that provides high-level operations on user groups.

It is responsible for common operations, such as validation and logging primitives.

Since
1.46

Definition at line 21 of file UserGroupAssignmentServiceBase.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\UserGroupAssignmentServiceBase::__construct ( private readonly HookRunner $hookRunner)

Definition at line 23 of file UserGroupAssignmentServiceBase.php.

Member Function Documentation

◆ enforceChangeGroupPermissions()

static MediaWiki\User\UserGroupAssignmentServiceBase::enforceChangeGroupPermissions ( array & $addGroups,
array & $removeGroups,
array & $newExpiries,
array $existingUGMs,
array $permittedChanges )
static

Ensures that the content of $addGroups, $removeGroups and $newExpiries is compliant with the possible changes defined in $permittedChanges.

If there's a change that is not permitted, it is removed from the respective array.

Parameters
list<string>&$addGroups
list<string>&$removeGroups
array<string,?string>&$newExpiries
array<string,UserGroupMembership>$existingUGMs
array{add:list<string>,remove:list<string>}$permittedChanges
Returns
void

Definition at line 225 of file UserGroupAssignmentServiceBase.php.

◆ expiryToTimestamp()

static MediaWiki\User\UserGroupAssignmentServiceBase::expiryToTimestamp ( $expiry)
static

Converts a user group membership expiry string into a timestamp.

Words like 'existing' or 'other' should have been filtered out before calling this function.

Parameters
string$expiry
Returns
string|null|false A string containing a valid timestamp, or null if the expiry is infinite, or false if the timestamp is not valid

Definition at line 329 of file UserGroupAssignmentServiceBase.php.

References wfIsInfinity(), and wfTimestamp().

◆ getChangeableGroups()

MediaWiki\User\UserGroupAssignmentServiceBase::getChangeableGroups ( Authority $performer,
UserIdentity $target,
bool $evaluatePrivateConditionsForRestrictedGroups = true )
abstract

Returns the groups that the performer can add or remove from the target user.

The result of this function is cached for the duration of the request.

Parameters
Authority$performer
UserIdentity$target
bool$evaluatePrivateConditionsForRestrictedGroupsIf true, all conditions for restricted groups will be evaluated (including private). If false, private conditions will be left unevaluated and 'condition-met' can be potentially null, if the result depends on private conditions.
Returns
array [ 'add' => [ addablegroups ], 'remove' => [ removablegroups ], 'restricted' => [ groupname => [ 'condition-met' => ?bool, 'ignore-condition' => bool, 'message' => string ] ] ]

Reimplemented in MediaWiki\User\UserGroupAssignmentService.

◆ getKnownGroups()

MediaWiki\User\UserGroupAssignmentServiceBase::getKnownGroups ( UserIdentity $target)
abstractprotected

Returns a list of possible known groups for a given identity.

The result of this function is used to skip undefined pre-existing groups when validating group changes.

Parameters
UserIdentity$targetThe target user
Returns
string[]

Reimplemented in MediaWiki\User\UserGroupAssignmentService.

◆ getRestrictedGroupChecker()

MediaWiki\User\UserGroupAssignmentServiceBase::getRestrictedGroupChecker ( UserIdentity $target)
abstractprotected

Returns an instance of {.

See also
RestrictedUserGroupChecker} suitable for use with the target user.

Reimplemented in MediaWiki\User\UserGroupAssignmentService.

◆ logAccessToPrivateConditions()

MediaWiki\User\UserGroupAssignmentServiceBase::logAccessToPrivateConditions ( Authority $performer,
UserIdentity $target,
array $addGroups,
array $newExpiries,
array $existingUGMs )

Triggers a hook that allows extensions to log when user read some private conditions.

Parameters
Authority$performerThe user who submitted request to change the user groups
UserIdentity$targetThe user whose groups are changed
list<string>$addGroups A list of groups that were attempted to be added (or have expiry changed)
array<string,?string>$newExpiries New expiration times for the groups (null or missing means infinity)
array<string,UserGroupMembership>$existingUGMs Existing group memberships for the target user
Returns
void

Definition at line 126 of file UserGroupAssignmentServiceBase.php.

◆ validateUserGroups()

MediaWiki\User\UserGroupAssignmentServiceBase::validateUserGroups ( Authority $performer,
UserIdentity $target,
array $addGroups,
array $removeGroups,
array $newExpiries,
array $groupMemberships )

Validates the requested changes to user groups and returns an array, specifying if some groups are unchangeable and for what reasons.

Parameters
Authority$performer
UserIdentity$target
list<string>$addGroups
list<string>$removeGroups
array<string,?string>$newExpiries
array<string,UserGroupMembership>$groupMemberships
Returns
array<string, string> Map of user groups to the reason why they cannot be given, removed or updated, keyed by the group names. The supported reasons are: 'rights', 'restricted', 'private-condition'.

Definition at line 65 of file UserGroupAssignmentServiceBase.php.


The documentation for this class was generated from the following file: