MediaWiki
master
|
Managers user groups. More...
Public Member Functions | |
__construct (ServiceOptions $options, ConfiguredReadOnlyMode $configuredReadOnlyMode, ILBFactory $loadBalancerFactory, HookContainer $hookContainer, UserEditTracker $userEditTracker, GroupPermissionsLookup $groupPermissionsLookup, JobQueueGroup $jobQueueGroup, LoggerInterface $logger, TempUserConfig $tempUserConfig, array $clearCacheCallbacks=[], $dbDomain=false) | |
addUserToAutopromoteOnceGroups (UserIdentity $user, string $event) | |
Add the user to the group if he/she meets given criteria. More... | |
addUserToGroup (UserIdentity $user, string $group, string $expiry=null, bool $allowUpdate=false) | |
Add the user to the given group. More... | |
addUserToMultipleGroups (UserIdentity $user, array $groups, string $expiry=null, bool $allowUpdate=false) | |
Add the user to the given list of groups. More... | |
clearCache (UserIdentity $user) | |
Cleans cached group memberships for a given user. More... | |
getGroupsChangeableBy (Authority $authority) | |
Returns an array of groups that this $actor can add and remove. More... | |
getGroupsChangeableByGroup (string $group) | |
Returns an array of the groups that a particular group can add/remove. More... | |
getQueryInfo () | |
Return the tables and fields to be selected to construct new UserGroupMembership object using newGroupMembershipFromRow method. More... | |
getUserAutopromoteGroups (UserIdentity $user) | |
Get the groups for the given user based on $wgAutopromote. More... | |
getUserAutopromoteOnceGroups (UserIdentity $user, string $event) | |
Get the groups for the given user based on the given criteria. More... | |
getUserEffectiveGroups (UserIdentity $user, int $queryFlags=self::READ_NORMAL, bool $recache=false) | |
Get the list of implicit group memberships the user has. More... | |
getUserFormerGroups (UserIdentity $user, int $queryFlags=self::READ_NORMAL) | |
Returns the groups the user has belonged to. More... | |
getUserGroupMemberships (UserIdentity $user, int $queryFlags=self::READ_NORMAL) | |
Loads and returns UserGroupMembership objects for all the groups a user currently belongs to. More... | |
getUserGroups (UserIdentity $user, int $queryFlags=self::READ_NORMAL) | |
Get the list of explicit group memberships this user has. More... | |
getUserImplicitGroups (UserIdentity $user, int $queryFlags=self::READ_NORMAL, bool $recache=false) | |
Get the list of implicit group memberships this user has. More... | |
listAllGroups () | |
Return the set of defined explicit groups. More... | |
listAllImplicitGroups () | |
Get a list of all configured implicit groups. More... | |
loadGroupMembershipsFromArray (UserIdentity $user, array $userGroups, int $queryFlags=self::READ_NORMAL) | |
Load the user groups cache from the provided user groups data. More... | |
newGroupMembershipFromRow (\stdClass $row) | |
Creates a new UserGroupMembership instance from $row. More... | |
purgeExpired () | |
Purge expired memberships from the user_groups table. More... | |
removeUserFromGroup (UserIdentity $user, string $group) | |
Remove the user from the given group. More... | |
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
![]() | |
const | READ_NONE = -1 |
Constants for object loading bitfield flags (higher => higher QoS) More... | |
Private Member Functions | |
canUseCachedValues (UserIdentity $user, string $cacheKind, int $queryFlags) | |
Determines if it's ok to use cached options values for a given user and query flags. More... | |
checkCondition (array $cond, User $user) | |
As recCheckCondition, but not recursive. More... | |
clearUserCacheForKind (UserIdentity $user, string $cacheKind) | |
Clears a cached group membership and query key for a given user. More... | |
expandChangeableGroupConfig (array $config, string $group) | |
getCacheKey (UserIdentity $user) | |
Gets a unique key for various caches. More... | |
getDBConnectionRefForQueryFlags (int $queryFlags) | |
recCheckCondition ( $cond, User $user) | |
Recursively check a condition. More... | |
setCache (string $userKey, string $cacheKind, array $groupValue, int $queryFlags) | |
Sets cached group memberships and query flags for a given user. More... | |
Private Attributes | |
callable[] | $clearCacheCallbacks |
string false | $dbDomain |
GroupPermissionsLookup | $groupPermissionsLookup |
HookContainer | $hookContainer |
HookRunner | $hookRunner |
JobQueueGroup | $jobQueueGroup |
for this $dbDomain More... | |
ILoadBalancer | $loadBalancer |
ILBFactory | $loadBalancerFactory |
LoggerInterface | $logger |
ServiceOptions | $options |
array | $queryFlagsUsedForCaching = [] |
An assoc. More... | |
ReadOnlyMode | $readOnlyMode |
TempUserConfig | $tempUserConfig |
UserEditTracker | $userEditTracker |
array | $userGroupCache = [] |
Service caches, an assoc. More... | |
const | CACHE_EFFECTIVE = 'effective' |
string key for effective groups cache More... | |
const | CACHE_FORMER = 'former' |
string key for former groups cache More... | |
const | CACHE_IMPLICIT = 'implicit' |
string key for implicit groups cache More... | |
const | CACHE_MEMBERSHIP = 'membership' |
string key for group memberships cache More... | |
MediaWiki\User\UserGroupManager::__construct | ( | ServiceOptions | $options, |
ConfiguredReadOnlyMode | $configuredReadOnlyMode, | ||
ILBFactory | $loadBalancerFactory, | ||
HookContainer | $hookContainer, | ||
UserEditTracker | $userEditTracker, | ||
GroupPermissionsLookup | $groupPermissionsLookup, | ||
JobQueueGroup | $jobQueueGroup, | ||
LoggerInterface | $logger, | ||
TempUserConfig | $tempUserConfig, | ||
array | $clearCacheCallbacks = [] , |
||
$dbDomain = false |
|||
) |
ServiceOptions | $options | |
ConfiguredReadOnlyMode | $configuredReadOnlyMode | |
ILBFactory | $loadBalancerFactory | |
HookContainer | $hookContainer | |
UserEditTracker | $userEditTracker | |
GroupPermissionsLookup | $groupPermissionsLookup | |
JobQueueGroup | $jobQueueGroup | for this $dbDomain |
LoggerInterface | $logger | |
TempUserConfig | $tempUserConfig | |
callable[] | $clearCacheCallbacks | |
string | bool | $dbDomain |
Definition at line 166 of file UserGroupManager.php.
References MediaWiki\User\UserGroupManager\$clearCacheCallbacks, MediaWiki\User\UserGroupManager\$dbDomain, MediaWiki\User\UserGroupManager\$groupPermissionsLookup, MediaWiki\User\UserGroupManager\$hookContainer, MediaWiki\User\UserGroupManager\$jobQueueGroup, MediaWiki\User\UserGroupManager\$loadBalancerFactory, MediaWiki\User\UserGroupManager\$logger, MediaWiki\User\UserGroupManager\$options, MediaWiki\User\UserGroupManager\$tempUserConfig, MediaWiki\User\UserGroupManager\$userEditTracker, MediaWiki\Config\ServiceOptions\assertRequiredOptions(), and Wikimedia\Rdbms\ILBFactory\getMainLB().
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 618 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 754 of file UserGroupManager.php.
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 872 of file UserGroupManager.php.
|
private |
Determines if it's ok to use cached options values for a given user and query flags.
UserIdentity | $user | |
string | $cacheKind | one of self::CACHE_* constants |
int | $queryFlags |
Definition at line 1197 of file UserGroupManager.php.
|
private |
As recCheckCondition, but not recursive.
The only valid conditions are those whose first element is one of APCOND_* defined in Defines.php. Other types will throw an exception if no extension evaluates them.
array | $cond | A condition, which must not contain other conditions |
User | $user | The user to check the condition against |
InvalidArgumentException | if autopromote condition was not recognized. |
Definition at line 540 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::clearCache | ( | UserIdentity | $user | ) |
Cleans cached group memberships for a given user.
UserIdentity | $user |
Definition at line 1136 of file UserGroupManager.php.
|
private |
Clears a cached group membership and query key for a given user.
UserIdentity | $user | |
string | $cacheKind | one of self::CACHE_* constants |
Definition at line 1166 of file UserGroupManager.php.
|
private |
array | $config | |
string | $group |
Definition at line 1043 of file UserGroupManager.php.
|
private |
Gets a unique key for various caches.
UserIdentity | $user |
Definition at line 1186 of file UserGroupManager.php.
|
private |
int | $queryFlags | a bit field composed of READ_XXX flags |
Definition at line 1176 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getGroupsChangeableBy | ( | Authority | $authority | ) |
Returns an array of groups that this $actor can add and remove.
Authority | $authority |
Definition at line 1095 of file UserGroupManager.php.
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 1066 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getQueryInfo | ( | ) |
Return the tables and fields to be selected to construct new UserGroupMembership object using newGroupMembershipFromRow method.
$table
to IDatabase->select()
$vars
to IDatabase->select()
$joins
to IDatabase->select()
Definition at line 956 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 408 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 434 of file UserGroupManager.php.
References User\newFromIdentity().
MediaWiki\User\UserGroupManager::getUserEffectiveGroups | ( | UserIdentity | $user, |
int | $queryFlags = self::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 324 of file UserGroupManager.php.
References User\newFromIdentity().
MediaWiki\User\UserGroupManager::getUserFormerGroups | ( | UserIdentity | $user, |
int | $queryFlags = self::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 367 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserGroupMemberships | ( | UserIdentity | $user, |
int | $queryFlags = self::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 696 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserGroups | ( | UserIdentity | $user, |
int | $queryFlags = self::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 681 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::getUserImplicitGroups | ( | UserIdentity | $user, |
int | $queryFlags = self::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 280 of file UserGroupManager.php.
References MediaWiki\User\UserIdentity\getName(), and MediaWiki\User\UserIdentity\isRegistered().
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 202 of file UserGroupManager.php.
Referenced by UsersPager\__construct().
MediaWiki\User\UserGroupManager::listAllImplicitGroups | ( | ) |
Get a list of all configured implicit groups.
Definition at line 219 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::loadGroupMembershipsFromArray | ( | UserIdentity | $user, |
array | $userGroups, | ||
int | $queryFlags = self::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 250 of file UserGroupManager.php.
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 232 of file UserGroupManager.php.
MediaWiki\User\UserGroupManager::purgeExpired | ( | ) |
Purge expired memberships from the user_groups table.
Definition at line 975 of file UserGroupManager.php.
References $res, DB_PRIMARY, LIST_AND, and LIST_OR.
|
private |
Recursively check a condition.
Conditions are in the form [ '&' or '|' or '^' or '!', cond1, cond2, ... ] where cond1, cond2, ... are themselves conditions; OR APCOND_EMAILCONFIRMED, OR [ APCOND_EMAILCONFIRMED ], OR [ APCOND_EDITCOUNT, number of edits ], OR [ APCOND_AGE, seconds since registration ], OR similar constructs defined by extensions. This function evaluates the former type recursively, and passes off to checkCondition for evaluation of the latter type.
mixed | $cond | A condition, possibly containing other conditions |
User | $user | The user to check the conditions against |
Definition at line 481 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 891 of file UserGroupManager.php.
References User\newFromIdentity().
|
private |
Sets cached group memberships and query flags for a given user.
string | $userKey | |
string | $cacheKind | one of self::CACHE_KIND_* constants |
array | $groupValue | |
int | $queryFlags |
Definition at line 1150 of file UserGroupManager.php.
|
private |
Definition at line 110 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Definition at line 113 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Definition at line 98 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Definition at line 86 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Definition at line 89 of file UserGroupManager.php.
|
private |
for this $dbDomain
Definition at line 101 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Definition at line 83 of file UserGroupManager.php.
|
private |
Definition at line 80 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Definition at line 104 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Definition at line 77 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
An assoc.
array that stores query flags used to retrieve user groups from the database and is stored in the following format:
userKey => [ self::CACHE_IMPLICIT => implicit groups query flag self::CACHE_EFFECTIVE => effective groups query flag self::CACHE_MEMBERSHIP => membership groups query flag self::CACHE_FORMER => former groups query flag ]
Definition at line 151 of file UserGroupManager.php.
|
private |
Definition at line 92 of file UserGroupManager.php.
|
private |
Definition at line 107 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Definition at line 95 of file UserGroupManager.php.
Referenced by MediaWiki\User\UserGroupManager\__construct().
|
private |
Service caches, an assoc.
array keyed after the user-keys generated by the getCacheKey method and storing values in the following format:
userKey => [ self::CACHE_IMPLICIT => implicit groups cache self::CACHE_EFFECTIVE => effective groups cache self::CACHE_MEMBERSHIP => [ ] // Array of UserGroupMembership objects self::CACHE_FORMER => former groups cache ]
Definition at line 138 of file UserGroupManager.php.
|
private |
string key for effective groups cache
Definition at line 119 of file UserGroupManager.php.
|
private |
string key for former groups cache
Definition at line 125 of file UserGroupManager.php.
|
private |
string key for implicit groups cache
Definition at line 116 of file UserGroupManager.php.
|
private |
string key for group memberships cache
Definition at line 122 of file UserGroupManager.php.
const MediaWiki\User\UserGroupManager::CONSTRUCTOR_OPTIONS |
Definition at line 59 of file UserGroupManager.php.