41 private $permissionCheckerFactory;
44 private $unblockUserFactory;
47 private $userIdentityLookup;
56 parent::__construct( $main, $action );
58 $this->permissionCheckerFactory = $permissionCheckerFactory;
59 $this->unblockUserFactory = $unblockUserFactory;
60 $this->userIdentityLookup = $userIdentityLookup;
73 $this->
dieWithError(
'apierror-permissiondenied-unblock',
'permissiondenied' );
76 if ( $params[
'userid'] !==
null ) {
77 $identity = $this->userIdentityLookup->getUserIdentityByUserId( $params[
'userid'] );
79 $this->
dieWithError( [
'apierror-nosuchuserid', $params[
'userid'] ],
'nosuchuserid' );
81 $params[
'user'] = $identity->getName();
84 $target = $params[
'id'] ===
null ? $params[
'user'] :
"#{$params['id']}";
86 # T17810: blocked admins should have limited access here
87 $status = $this->permissionCheckerFactory
88 ->newBlockPermissionChecker(
91 )->checkBlockPermissions();
92 if ( $status !==
true ) {
97 [
'blockinfo' => $this->getBlockDetails( $performer->getBlock() ) ]
101 $status = $this->unblockUserFactory->newUnblockUser(
105 $params[
'tags'] ?? []
108 if ( !$status->isOK() ) {
112 $block = $status->getValue();
113 $targetName = $block->getType() === DatabaseBlock::TYPE_AUTO ?
'' : $block->getTargetName();
114 $targetUserId = $block->getTargetUserIdentity() ? $block->getTargetUserIdentity()->getId() : 0;
116 'id' => $block->getId(),
117 'user' => $targetName,
118 'userid' => $targetUserId,
119 'reason' => $params[
'reason']
135 ParamValidator::PARAM_TYPE =>
'integer',
138 ParamValidator::PARAM_TYPE =>
'user',
139 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'cidr',
'id' ],
142 ParamValidator::PARAM_TYPE =>
'integer',
143 ParamValidator::PARAM_DEPRECATED =>
true,
147 ParamValidator::PARAM_TYPE =>
'tags',
148 ParamValidator::PARAM_ISMULTI =>
true,
159 'action=unblock&id=105'
160 =>
'apihelp-unblock-example-id',
161 'action=unblock&user=Bob&reason=Sorry%20Bob'
162 =>
'apihelp-unblock-example-user',
167 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.
__construct(ApiMain $main, $action, BlockPermissionCheckerFactory $permissionCheckerFactory, UnblockUserFactory $unblockUserFactory, UserIdentityLookup $userIdentityLookup)
getExamplesMessages()
Returns usage examples for this module.