57 $block = $pUser->getBlock();
58 if ( $block && $block->isSitewide() ) {
67 if ( isset( $params[
'expiry'] ) ) {
68 $expiry = (array)$params[
'expiry'];
70 $expiry = [
'infinity' ];
72 $add = (array)$params[
'add'];
75 } elseif ( count( $expiry ) !== count( $add ) ) {
76 if ( count( $expiry ) === 1 ) {
77 $expiry = array_fill( 0, count( $add ), $expiry[0] );
80 'apierror-toofewexpiries',
89 foreach ( $expiry as $index => $expiryValue ) {
90 $group = $add[$index];
93 if ( $groupExpiries[$group] ===
false ) {
98 if ( $groupExpiries[$group] && $groupExpiries[$group] <
wfTimestampNow() ) {
105 $tags = $params[
'tags'];
108 if ( $tags !==
null ) {
110 if ( !$ableToTag->isOK() ) {
118 $r[
'user'] = $user->getName();
119 $r[
'userid'] = $user->getId();
120 list( $r[
'added'], $r[
'removed'] ) = $form->doSaveUserGroups(
122 $user, $add, (array)$params[
'remove'],
123 $params[
'reason'], (array)$tags, $groupExpiries
127 ApiResult::setIndexedTagName( $r[
'added'],
'group' );
128 ApiResult::setIndexedTagName( $r[
'removed'],
'group' );
137 if ( $this->mUser !==
null ) {
143 $user = $params[
'user'] ??
'#' . $params[
'userid'];
147 $status = $form->fetchUser( $user );
148 if ( !$status->isOK() ) {
152 $this->mUser = $status->value;
154 return $status->value;
175 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'id' ],
176 UserDef::PARAM_RETURN_OBJECT =>
true,
209 unset( $a[
'expiry'] );
219 return $this->
getUrUser( $params )->getName();
224 'action=userrights&user=FooBot&add=bot&remove=sysop|bureaucrat&token=123ABC'
225 =>
'apihelp-userrights-example-user',
226 'action=userrights&userid=123&add=bot&remove=sysop|bureaucrat&token=123ABC'
227 =>
'apihelp-userrights-example-userid',
230 $a[
'action=userrights&user=SometimeSysop&add=sysop&expiry=1%20month&token=123ABC']
231 =
'apihelp-userrights-example-expiry';
237 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:User_group_membership';
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
const PARAM_ALLOW_DUPLICATES
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
requireOnlyOneParameter( $params,... $required)
Die if none or more than one of a certain set of parameters is set and not false.
dieBlocked(AbstractBlock $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
getModuleName()
Get the name of the module being executed by this instance.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams( $flags=0)
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
mustBePosted()
Indicates whether this module must be called with a POST request Stable to override.
getUserRightsPage()
Get a UserrightsPage object, or subclass.
needsToken()
Returns the token type this module requires in order to execute.
getAllGroups()
Get all available groups.
isWriteMode()
Indicates whether this module requires write mode.
getExamplesMessages()
Returns usage examples for this module.
getWebUITokenSalt(array $params)
Fetch the salt used in the Web UI corresponding to this module.
getUser()
Stable to override.
getContext()
Get the base IContextSource object.
static getAllGroups()
Return the set of defined explicit groups.
Special page to allow managing user group membership.
static expiryToTimestamp( $expiry)
Converts a user group membership expiry string into a timestamp.