MediaWiki master
|
Manages user groups. More...
Public Member Functions | |
__construct (ServiceOptions $options, ReadOnlyMode $readOnlyMode, ILBFactory $lbFactory, HookContainer $hookContainer, UserEditTracker $userEditTracker, GroupPermissionsLookup $groupPermissionsLookup, JobQueueGroup $jobQueueGroup, LoggerInterface $logger, TempUserConfig $tempUserConfig, array $clearCacheCallbacks=[], $wikiId=UserIdentity::LOCAL) | |
addUserToAutopromoteOnceGroups (UserIdentity $user, string $event) | |
Add the user to the group if he/she meets given criteria. | |
addUserToGroup (UserIdentity $user, string $group, string $expiry=null, bool $allowUpdate=false) | |
Add the user to the given group. | |
addUserToMultipleGroups (UserIdentity $user, array $groups, string $expiry=null, bool $allowUpdate=false) | |
Add the user to the given list of groups. | |
clearCache (UserIdentity $user) | |
Cleans cached group memberships for a given user. | |
getGroupsChangeableBy (Authority $authority) | |
Returns an array of groups that this $actor can add and remove. | |
getGroupsChangeableByGroup (string $group) | |
Returns an array of the groups that a particular group can add/remove. | |
getUserAutopromoteGroups (UserIdentity $user) | |
Get the groups for the given user based on $wgAutopromote. | |
getUserAutopromoteOnceGroups (UserIdentity $user, string $event) | |
Get the groups for the given user based on the given criteria. | |
getUserEffectiveGroups (UserIdentity $user, int $queryFlags=IDBAccessObject::READ_NORMAL, bool $recache=false) | |
Get the list of implicit group memberships the user has. | |
getUserFormerGroups (UserIdentity $user, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
Returns the groups the user has belonged to. | |
getUserGroupMemberships (UserIdentity $user, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
Loads and returns UserGroupMembership objects for all the groups a user currently belongs to. | |
getUserGroups (UserIdentity $user, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
Get the list of explicit group memberships this user has. | |
getUserImplicitGroups (UserIdentity $user, int $queryFlags=IDBAccessObject::READ_NORMAL, bool $recache=false) | |
Get the list of implicit group memberships this user has. | |
getUserPrivilegedGroups (UserIdentity $user, int $queryFlags=IDBAccessObject::READ_NORMAL, bool $recache=false) | |
Returns the list of privileged groups that $user belongs to. | |
listAllGroups () | |
Return the set of defined explicit groups. | |
listAllImplicitGroups () | |
Get a list of all configured implicit groups. | |
loadGroupMembershipsFromArray (UserIdentity $user, array $userGroups, int $queryFlags=IDBAccessObject::READ_NORMAL) | |
Load the user groups cache from the provided user groups data. | |
newGroupMembershipFromRow (\stdClass $row) | |
Creates a new UserGroupMembership instance from $row. | |
newQueryBuilder (IReadableDatabase $db) | |
Return the query builder to build upon and query. | |
purgeExpired () | |
Purge expired memberships from the user_groups table. | |
removeUserFromGroup (UserIdentity $user, string $group) | |
Remove the user from the given group. | |
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
const | VALID_OPS = [ '&', '|', '^', '!' ] |
Logical operators recognized in $wgAutopromote. | |
MediaWiki\User\UserGroupManager::__construct | ( | ServiceOptions | $options, |
ReadOnlyMode | $readOnlyMode, | ||
ILBFactory | $lbFactory, | ||
HookContainer | $hookContainer, | ||
UserEditTracker | $userEditTracker, | ||
GroupPermissionsLookup | $groupPermissionsLookup, | ||
JobQueueGroup | $jobQueueGroup, | ||
LoggerInterface | $logger, | ||
TempUserConfig | $tempUserConfig, | ||
array | $clearCacheCallbacks = [], | ||
$wikiId = UserIdentity::LOCAL ) |
ServiceOptions | $options | |
ReadOnlyMode | $readOnlyMode | |
ILBFactory | $lbFactory | |
HookContainer | $hookContainer | |
UserEditTracker | $userEditTracker | |
GroupPermissionsLookup | $groupPermissionsLookup | |
JobQueueGroup | $jobQueueGroup | |
LoggerInterface | $logger | |
TempUserConfig | $tempUserConfig | |
callable[] | $clearCacheCallbacks | |
string | false | $wikiId |
Definition at line 155 of file UserGroupManager.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions().
MediaWiki\User\UserGroupManager::addUserToAutopromoteOnceGroups | ( | UserIdentity | $user, |
string | $event ) |
Add the user to the group if he/she meets given criteria.
Contrary to autopromotion by $wgAutopromote, the group will be possible to remove manually via Special:UserRights. In such case it will not be re-added automatically. The user will also not lose the group if they no longer meet the criteria.
UserIdentity | $user | User to add to the groups |
string | $event | Key in $wgAutopromoteOnce (each event has groups/criteria) |
Definition at line 669 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::addUserToGroup | ( | UserIdentity | $user, |
string | $group, | ||
string | $expiry = null, | ||
bool | $allowUpdate = false ) |
Add the user to the given group.
This takes immediate effect. If the user is already in the group, the expiry time will be updated to the new expiry time. (If $expiry is omitted or null, the membership will be altered to never expire.)
UserIdentity | $user | |
string | $group | Name of the group to add |
string | null | $expiry | Optional expiry timestamp in any format acceptable to wfTimestamp(), or null if the group assignment should not expire |
bool | $allowUpdate | Whether to perform "upsert" instead of INSERT |
InvalidArgumentException |
Definition at line 806 of file UserGroupManager.php.
Referenced by MediaWiki\Specials\SpecialUserRights\doSaveUserGroups().
MediaWiki\User\UserGroupManager::addUserToMultipleGroups | ( | UserIdentity | $user, |
array | $groups, | ||
string | $expiry = null, | ||
bool | $allowUpdate = false ) |
Add the user to the given list of groups.
UserIdentity | $user | |
string[] | $groups | Names of the groups to add |
string | null | $expiry | Optional expiry timestamp in any format acceptable to wfTimestamp(), or null if the group assignment should not expire |
bool | $allowUpdate | Whether to perform "upsert" instead of INSERT |
InvalidArgumentException |
Definition at line 931 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::clearCache | ( | UserIdentity | $user | ) |
Cleans cached group memberships for a given user.
UserIdentity | $user |
Definition at line 1182 of file UserGroupManager.php.
References MediaWiki\DAO\WikiAwareEntity\assertWiki(), and getCacheKey().
MediaWiki\User\UserGroupManager::getGroupsChangeableBy | ( | Authority | $authority | ) |
Returns an array of groups that this $actor can add and remove.
Authority | $authority |
Definition at line 1141 of file UserGroupManager.php.
Referenced by MediaWiki\Specials\SpecialUserRights\doSaveUserGroups(), and MediaWiki\Specials\SpecialUserRights\userCanChangeRights().
MediaWiki\User\UserGroupManager::getGroupsChangeableByGroup | ( | string | $group | ) |
Returns an array of the groups that a particular group can add/remove.
string | $group | The group to check for whether it can add/remove |
Definition at line 1111 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserAutopromoteGroups | ( | UserIdentity | $user | ) |
Get the groups for the given user based on $wgAutopromote.
UserIdentity | $user | The user to get the groups for |
Definition at line 398 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserAutopromoteOnceGroups | ( | UserIdentity | $user, |
string | $event ) |
Get the groups for the given user based on the given criteria.
Does not return groups the user already belongs to or has once belonged.
UserIdentity | $user | The user to get the groups for |
string | $event | Key in $wgAutopromoteOnce (each event has groups/criteria) |
Definition at line 428 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserEffectiveGroups | ( | UserIdentity | $user, |
int | $queryFlags = IDBAccessObject::READ_NORMAL, | ||
bool | $recache = false ) |
Get the list of implicit group memberships the user has.
This includes all explicit groups, plus 'user' if logged in, '*' for all accounts, and autopromoted groups
UserIdentity | $user | |
int | $queryFlags | |
bool | $recache | Whether to avoid the cache |
Definition at line 313 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserFormerGroups | ( | UserIdentity | $user, |
int | $queryFlags = IDBAccessObject::READ_NORMAL ) |
Returns the groups the user has belonged to.
The user may still belong to the returned groups. Compare with getUserGroups().
The function will not return groups the user had belonged to before MW 1.17
UserIdentity | $user | |
int | $queryFlags |
Definition at line 357 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserGroupMemberships | ( | UserIdentity | $user, |
int | $queryFlags = IDBAccessObject::READ_NORMAL ) |
Loads and returns UserGroupMembership objects for all the groups a user currently belongs to.
UserIdentity | $user | the user to search for |
int | $queryFlags |
Definition at line 752 of file UserGroupManager.php.
Referenced by MediaWiki\Specials\SpecialUserRights\doSaveUserGroups().
MediaWiki\User\UserGroupManager::getUserGroups | ( | UserIdentity | $user, |
int | $queryFlags = IDBAccessObject::READ_NORMAL ) |
Get the list of explicit group memberships this user has.
The implicit * and user groups are not included.
UserIdentity | $user | |
int | $queryFlags |
Definition at line 737 of file UserGroupManager.php.
Referenced by MediaWiki\Specials\SpecialUserRights\doSaveUserGroups().
MediaWiki\User\UserGroupManager::getUserImplicitGroups | ( | UserIdentity | $user, |
int | $queryFlags = IDBAccessObject::READ_NORMAL, | ||
bool | $recache = false ) |
Get the list of implicit group memberships this user has.
This includes 'user' if logged in, '*' for all accounts, and autopromoted groups
UserIdentity | $user | |
int | $queryFlags | |
bool | $recache | Whether to avoid the cache |
Definition at line 268 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserPrivilegedGroups | ( | UserIdentity | $user, |
int | $queryFlags = IDBAccessObject::READ_NORMAL, | ||
bool | $recache = false ) |
Returns the list of privileged groups that $user belongs to.
Privileged groups are ones that can be abused in a dangerous way.
Depending on how extensions extend this method, it might return values that are not strictly user groups (ACL list names, etc.). It is meant for logging/auditing, not for passing to methods that expect group names.
UserIdentity | $user | |
int | $queryFlags | |
bool | $recache | Whether to avoid the cache |
Definition at line 479 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::listAllGroups | ( | ) |
Return the set of defined explicit groups.
The implicit groups (by default *, 'user' and 'autoconfirmed') are not included, as they are defined automatically, not in the database.
Definition at line 189 of file UserGroupManager.php.
Referenced by MediaWiki\Pager\UsersPager\__construct().
MediaWiki\User\UserGroupManager::listAllImplicitGroups | ( | ) |
Get a list of all configured implicit groups.
Definition at line 206 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::loadGroupMembershipsFromArray | ( | UserIdentity | $user, |
array | $userGroups, | ||
int | $queryFlags = IDBAccessObject::READ_NORMAL ) |
Load the user groups cache from the provided user groups data.
UserIdentity | $user | |
array | $userGroups | an array of database query results |
int | $queryFlags |
Definition at line 237 of file UserGroupManager.php.
References MediaWiki\DAO\WikiAwareEntity\assertWiki(), and getCacheKey().
MediaWiki\User\UserGroupManager::newGroupMembershipFromRow | ( | \stdClass | $row | ) |
Creates a new UserGroupMembership instance from $row.
The fields required to build an instance could be found using getQueryInfo() method.
\\stdClass | $row | A database result object |
Definition at line 219 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::newQueryBuilder | ( | IReadableDatabase | $db | ) |
Return the query builder to build upon and query.
IReadableDatabase | $db |
Definition at line 1010 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::purgeExpired | ( | ) |
Purge expired memberships from the user_groups table.
Definition at line 1027 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::removeUserFromGroup | ( | UserIdentity | $user, |
string | $group ) |
Remove the user from the given group.
This takes immediate effect.
UserIdentity | $user | |
string | $group | Name of the group to remove |
InvalidArgumentException |
Definition at line 950 of file UserGroupManager.php.
Referenced by MediaWiki\Specials\SpecialUserRights\doSaveUserGroups().
const MediaWiki\User\UserGroupManager::CONSTRUCTOR_OPTIONS |
Definition at line 57 of file UserGroupManager.php.
const MediaWiki\User\UserGroupManager::VALID_OPS = [ '&', '|', '^', '!' ] |
Logical operators recognized in $wgAutopromote.
Definition at line 80 of file UserGroupManager.php.