33 use ApiBlockInfoTrait;
45 $this->
dieWithError(
'apierror-permissiondenied-unblock',
'permissiondenied' );
47 # T17810: blocked admins should have limited access here
48 $block = $user->getBlock();
51 if ( $status !==
true ) {
55 [
'blockinfo' => $this->getBlockDetails( $block ) ]
61 if ( !is_null( $params[
'tags'] ) ) {
63 if ( !$ableToTag->isOK() ) {
68 if ( $params[
'userid'] !==
null ) {
71 if ( $username ===
false ) {
72 $this->
dieWithError( [
'apierror-nosuchuserid', $params[
'userid'] ],
'nosuchuserid' );
74 $params[
'user'] = $username;
79 'Target' => is_null( $params[
'id'] ) ? $params[
'user'] :
"#{$params['id']}",
80 'Reason' => $params[
'reason'],
81 'Tags' => $params[
'tags']
83 $block = DatabaseBlock::newFromTarget( $data[
'Target'] );
85 if ( $retval !==
true ) {
89 $target = $block->getType() == DatabaseBlock::TYPE_AUTO ?
'' : $block->getTarget();
91 'id' => $block->getId(),
92 'user' => $target instanceof
User ? $target->
getName() : $target,
93 'userid' => $target instanceof
User ? $target->
getId() : 0,
94 'reason' => $params[
'reason']
130 'action=unblock&id=105'
131 =>
'apihelp-unblock-example-id',
132 'action=unblock&user=Bob&reason=Sorry%20Bob'
133 =>
'apihelp-unblock-example-user',
138 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=null)
Abort execution with an error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
errorArrayToStatus(array $errors, User $user=null)
Turn an array of message keys or key+param arrays into a Status.
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.
requireOnlyOneParameter( $params, $required)
Die if none or more than one of a certain set of parameters is set and not false.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
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.
getExamplesMessages()
Returns usage examples for this module.
getContext()
Get the base IContextSource object.
static checkUnblockSelf( $target, User $performer)
T17810: blocked admins should not be able to block/unblock others, and probably shouldn't be able to ...
static processUnblock(array $data, IContextSource $context)
Process the form.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getName()
Get the user name, or the IP of an anonymous user.
getId()
Get the user's ID.
static whoIs( $id)
Get the username corresponding to a given user ID.