46 $this->
dieWithError(
'apierror-permissiondenied-unblock',
'permissiondenied' );
48 # T17810: blocked admins should have limited access here
49 $block = $user->getBlock();
51 $status = SpecialBlock::checkUnblockSelf( $params[
'user'], $user );
52 if ( $status !==
true ) {
56 [
'blockinfo' => $this->getBlockDetails( $block ) ]
62 if ( $params[
'tags'] !==
null ) {
64 if ( !$ableToTag->isOK() ) {
69 if ( $params[
'userid'] !==
null ) {
70 $username = User::whoIs( $params[
'userid'] );
72 if ( $username ===
false ) {
73 $this->
dieWithError( [
'apierror-nosuchuserid', $params[
'userid'] ],
'nosuchuserid' );
75 $params[
'user'] = $username;
80 'Target' => $params[
'id'] ===
null ? $params[
'user'] :
"#{$params['id']}",
81 'Reason' => $params[
'reason'],
82 'Tags' => $params[
'tags']
84 $block = DatabaseBlock::newFromTarget( $data[
'Target'] );
86 if ( $retval !==
true ) {
90 $target = $block->getType() == DatabaseBlock::TYPE_AUTO ?
'' : $block->getTarget();
92 'id' => $block->getId(),
93 'user' => $target instanceof
User ? $target->
getName() : $target,
94 'userid' => $target instanceof
User ? $target->
getId() : 0,
95 'reason' => $params[
'reason']
115 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name',
'ip',
'cidr',
'id' ],
135 'action=unblock&id=105'
136 =>
'apihelp-unblock-example-id',
137 'action=unblock&user=Bob&reason=Sorry%20Bob'
138 =>
'apihelp-unblock-example-user',
143 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.
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.
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.
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 Stable to override.
getExamplesMessages()
Returns usage examples for this module.
getUser()
Stable to override.
getContext()
Get the base IContextSource object.
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.