|
MediaWiki master
|
This class represents a service that provides high-level operations on user groups. More...
Inherits MediaWiki\User\UserGroupAssignmentServiceBase.

Public Member Functions | ||||||||||
| __construct (private readonly UserGroupManagerFactory $userGroupManagerFactory, private readonly UserNameUtils $userNameUtils, private readonly UserFactory $userFactory, private readonly RestrictedUserGroupCheckerFactory $restrictedGroupCheckerFactory, private readonly HookRunner $hookRunner, private readonly ServiceOptions $options, private readonly TempUserConfig $tempUserConfig, private readonly IConnectionProvider $connectionProvider, private readonly PageStoreFactory $pageStoreFactory,) | ||||||||||
| getChangeableGroups (Authority $performer, UserIdentity $target, bool $evaluatePrivateConditionsForRestrictedGroups=true) | ||||||||||
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.
| ||||||||||
| getPageTitleForTargetUser (UserIdentity $target, string|false $referenceWiki=UserIdentity::LOCAL) | ||||||||||
| Returns the title of page representing the target user, suitable for use in log entries. | ||||||||||
| saveChangesToUserGroups (Authority $performer, UserIdentity $target, array $addGroups, array $removeGroups, array $newExpiries, string $reason='', array $tags=[], array $logAtAdditionalWikis=[]) | ||||||||||
| Changes the user groups, ensuring that the performer has the necessary permissions and that the changes are logged. | ||||||||||
| targetCanHaveUserGroups (UserIdentity $target) | ||||||||||
| userCanChangeRights (Authority $performer, UserIdentity $target) | ||||||||||
| Check whether the given user can change the target user's rights. | ||||||||||
Public Member Functions inherited from MediaWiki\User\UserGroupAssignmentServiceBase | ||||||||||
| __construct (private readonly HookRunner $hookRunner,) | ||||||||||
| 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. | ||||||||||
Public Attributes | |
| const | CONSTRUCTOR_OPTIONS |
Protected Member Functions | ||||
| getKnownGroups (UserIdentity $target) | ||||
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.
| ||||
| getRestrictedGroupChecker (UserIdentity $target) | ||||
Returns an instance of {.
| ||||
Additional Inherited Members | |
Static Public Member Functions inherited from MediaWiki\User\UserGroupAssignmentServiceBase | |
| 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. | |
This class represents a service that provides high-level operations on user groups.
Contrary to UserGroupManager, this class is not interested in details of how user groups are stored or defined, but rather in the business logic of assigning and removing groups.
Therefore, it combines group management with logging and provides permission checks. Additionally, the method interfaces are designed to be suitable for calls from user-facing code.
Definition at line 33 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::__construct | ( | private readonly UserGroupManagerFactory | $userGroupManagerFactory, |
| private readonly UserNameUtils | $userNameUtils, | ||
| private readonly UserFactory | $userFactory, | ||
| private readonly RestrictedUserGroupCheckerFactory | $restrictedGroupCheckerFactory, | ||
| private readonly HookRunner | $hookRunner, | ||
| private readonly ServiceOptions | $options, | ||
| private readonly TempUserConfig | $tempUserConfig, | ||
| private readonly IConnectionProvider | $connectionProvider, | ||
| private readonly PageStoreFactory | $pageStoreFactory ) |
Definition at line 42 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::getChangeableGroups | ( | Authority | $performer, |
| UserIdentity | $target, | ||
| bool | $evaluatePrivateConditionsForRestrictedGroups = true ) |
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.
| Authority | $performer | |
| UserIdentity | $target | |
| bool | $evaluatePrivateConditionsForRestrictedGroups | If 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. |
Reimplemented from MediaWiki\User\UserGroupAssignmentServiceBase.
Definition at line 103 of file UserGroupAssignmentService.php.
|
protected |
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.
| UserIdentity | $target | The target user |
Reimplemented from MediaWiki\User\UserGroupAssignmentServiceBase.
Definition at line 263 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::getPageTitleForTargetUser | ( | UserIdentity | $target, |
| string|false | $referenceWiki = UserIdentity::LOCAL ) |
Returns the title of page representing the target user, suitable for use in log entries.
The returned value doesn't include the namespace.
Interwiki suffix will be added to the title only if the target user's wiki is different from the reference wiki.
| UserIdentity | $target | The target user (only name and wiki ID are relevant for this method) |
| string | false | $referenceWiki | The wiki to use as a reference for formatting the title. If the wiki is different from the target user's wiki, the returned title will include the interwiki suffix. |
Definition at line 374 of file UserGroupAssignmentService.php.
|
protected |
Returns an instance of {.
Reimplemented from MediaWiki\User\UserGroupAssignmentServiceBase.
Definition at line 269 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::saveChangesToUserGroups | ( | Authority | $performer, |
| UserIdentity | $target, | ||
| array | $addGroups, | ||
| array | $removeGroups, | ||
| array | $newExpiries, | ||
| string | $reason = '', | ||
| array | $tags = [], | ||
| array | $logAtAdditionalWikis = [] ) |
Changes the user groups, ensuring that the performer has the necessary permissions and that the changes are logged.
| Authority | $performer | |
| UserIdentity | $target | |
| list<string> | $addGroups The groups to add (or change expiry of) | |
| list<string> | $removeGroups The groups to remove | |
| array<string,?string> | $newExpiries Map of group name to new expiry (string timestamp or null for infinite). If a group is in $addGroups but not in this array, it won't expire. | |
| string | $reason | |
| array | $tags | |
| list<string> | $logAtAdditionalWikis List of wiki IDs where the log entry should be added, in addition to the current wiki and the target user's wiki. Wikis to which the log entry will be added are deduplicated, so no double logging will happen. |
Definition at line 198 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::targetCanHaveUserGroups | ( | UserIdentity | $target | ) |
Definition at line 58 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::userCanChangeRights | ( | Authority | $performer, |
| UserIdentity | $target ) |
Check whether the given user can change the target user's rights.
| Authority | $performer | User who is attempting to change the target's rights |
| UserIdentity | $target | User whose rights are being changed |
Definition at line 86 of file UserGroupAssignmentService.php.
| const MediaWiki\User\UserGroupAssignmentService::CONSTRUCTOR_OPTIONS |
Definition at line 36 of file UserGroupAssignmentService.php.