|
MediaWiki master
|
This class represents a service that provides high-level operations on user groups. More...
Public Member Functions | |
| __construct (private readonly UserGroupManagerFactory $userGroupManagerFactory, private readonly UserNameUtils $userNameUtils, private readonly UserFactory $userFactory, private readonly RestrictedUserGroupChecker $restrictedGroupChecker, private readonly HookRunner $hookRunner, private readonly ServiceOptions $options, private readonly TempUserConfig $tempUserConfig,) | |
| getChangeableGroups (Authority $performer, UserIdentity $target) | |
| Returns the groups that the performer can add or remove from the target user. | |
| getPageTitleForTargetUser (UserIdentity $target) | |
| 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=[]) | |
| Changes the user groups, ensuring that the performer has the necessary permissions and that the changes are logged. | |
| targetCanHaveUserGroups (UserIdentity $target) | |
| Checks whether the target user can have groups assigned at all. | |
| userCanChangeRights (Authority $performer, UserIdentity $target) | |
| Check whether the given user can change the target user's rights. | |
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. | |
Public Attributes | |
| const | CONSTRUCTOR_OPTIONS |
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 29 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::__construct | ( | private readonly UserGroupManagerFactory | $userGroupManagerFactory, |
| private readonly UserNameUtils | $userNameUtils, | ||
| private readonly UserFactory | $userFactory, | ||
| private readonly RestrictedUserGroupChecker | $restrictedGroupChecker, | ||
| private readonly HookRunner | $hookRunner, | ||
| private readonly ServiceOptions | $options, | ||
| private readonly TempUserConfig | $tempUserConfig ) |
Definition at line 38 of file UserGroupAssignmentService.php.
|
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.
| list<string> | &$addGroups |
| list<string> | &$removeGroups |
| array<string,?string> | &$newExpiries |
| array<string,UserGroupMembership> | $existingUGMs |
| array{add:list<string>,remove:list<string>} | $permittedChanges |
Definition at line 315 of file UserGroupAssignmentService.php.
|
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.
| string | $expiry |
Definition at line 396 of file UserGroupAssignmentService.php.
References wfIsInfinity(), and wfTimestamp().
| MediaWiki\User\UserGroupAssignmentService::getChangeableGroups | ( | Authority | $performer, |
| UserIdentity | $target ) |
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.
Definition at line 108 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::getPageTitleForTargetUser | ( | UserIdentity | $target | ) |
Returns the title of page representing the target user, suitable for use in log entries.
The returned value doesn't include the namespace.
Definition at line 287 of file UserGroupAssignmentService.php.
References MediaWiki\DAO\WikiAwareEntity\getWikiId().
| MediaWiki\User\UserGroupAssignmentService::saveChangesToUserGroups | ( | Authority | $performer, |
| UserIdentity | $target, | ||
| array | $addGroups, | ||
| array | $removeGroups, | ||
| array | $newExpiries, | ||
| string | $reason = '', | ||
| array | $tags = [] ) |
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 |
Definition at line 186 of file UserGroupAssignmentService.php.
| MediaWiki\User\UserGroupAssignmentService::targetCanHaveUserGroups | ( | UserIdentity | $target | ) |
Checks whether the target user can have groups assigned at all.
Definition at line 53 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 81 of file UserGroupAssignmentService.php.
| const MediaWiki\User\UserGroupAssignmentService::CONSTRUCTOR_OPTIONS |
Definition at line 32 of file UserGroupAssignmentService.php.