55 parent::__construct( $main, $action );
72 $this->
dieWithError(
'apierror-permissiondenied-unblock',
'permissiondenied' );
75 if ( $params[
'userid'] !==
null ) {
76 $identity = $this->userIdentityLookup->getUserIdentityByUserId( $params[
'userid'] );
78 $this->
dieWithError( [
'apierror-nosuchuserid', $params[
'userid'] ],
'nosuchuserid' );
80 $params[
'user'] = $identity->getName();
83 $target = $params[
'id'] ===
null ? $params[
'user'] :
"#{$params['id']}";
85 # T17810: blocked admins should have limited access here
86 $status = $this->permissionCheckerFactory
87 ->newBlockPermissionChecker(
90 )->checkBlockPermissions();
91 if ( $status !==
true ) {
95 [
'blockinfo' => $this->getBlockDetails( $performer->getBlock() ) ]
99 $status = $this->unblockUserFactory->newUnblockUser(
103 $params[
'tags'] ?? []
106 if ( !$status->isOK() ) {
110 $block = $status->getValue();
111 $targetName = $block->getType() === DatabaseBlock::TYPE_AUTO ?
'' : $block->getTargetName();
112 $targetUserId = $block->getTargetUserIdentity() ? $block->getTargetUserIdentity()->getId() : 0;
114 'id' => $block->getId(),
115 'user' => $targetName,
116 'userid' => $targetUserId,
117 'reason' => $params[
'reason']
137 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'cidr',
'id' ],
157 'action=unblock&id=105'
158 =>
'apihelp-unblock-example-id',
159 'action=unblock&user=Bob&reason=Sorry%20Bob'
160 =>
'apihelp-unblock-example-user',
165 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Block';
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.
requireOnlyOneParameter( $params,... $required)
Die if none or more than one of a certain set of parameters is set and not false.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
This is the main API class, used for both external and internal processing.
API module that facilitates the unblocking of users.
isWriteMode()
Indicates whether this module requires write mode.
needsToken()
Returns the token type this module requires in order to execute.
execute()
Unblocks the specified user or provides the reason the unblock failed.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
mustBePosted()
Indicates whether this module must be called with a POST request.
BlockPermissionCheckerFactory $permissionCheckerFactory
__construct(ApiMain $main, $action, BlockPermissionCheckerFactory $permissionCheckerFactory, UnblockUserFactory $unblockUserFactory, UserIdentityLookup $userIdentityLookup)
UserIdentityLookup $userIdentityLookup
UnblockUserFactory $unblockUserFactory
getExamplesMessages()
Returns usage examples for this module.