Go to the documentation of this file.
45 if ( !
$user->isAllowed(
'block' ) ) {
49 # bug 15810: blocked admins should have limited access here
50 if (
$user->isBlocked() ) {
52 if ( $status !==
true ) {
60 if ( $target instanceof
User &&
66 if (
$params[
'hidename'] && !
$user->isAllowed(
'hideuser' ) ) {
74 'PreviousTarget' =>
$params[
'user'],
81 'Expiry' =>
$params[
'expiry'] ==
'never' ?
'infinite' :
$params[
'expiry'],
82 'HardBlock' => !
$params[
'anononly'],
83 'CreateAccount' =>
$params[
'nocreate'],
84 'AutoBlock' =>
$params[
'autoblock'],
85 'DisableEmail' =>
$params[
'noemail'],
86 'HideUser' =>
$params[
'hidename'],
87 'DisableUTEdit' => !
$params[
'allowusertalk'],
88 'Reblock' =>
$params[
'reblock'],
89 'Watch' =>
$params[
'watchuser'],
101 $res[
'userID'] = $target instanceof
User ? $target->
getId() : 0;
104 if ( $block instanceof
Block ) {
105 $res[
'expiry'] = $block->mExpiry == $this->
getDB()->getInfinity()
108 $res[
'id'] = $block->getId();
110 # should be unreachable
117 $res[
'anononly'] =
'';
120 $res[
'nocreate'] =
'';
123 $res[
'autoblock'] =
'';
126 $res[
'noemail'] =
'';
129 $res[
'hidename'] =
'';
131 if (
$params[
'allowusertalk'] ) {
132 $res[
'allowusertalk'] =
'';
135 $res[
'watchuser'] =
'';
160 'autoblock' =>
false,
163 'allowusertalk' =>
false,
165 'watchuser' =>
false,
171 'user' =>
'Username, IP address or IP range you want to block',
172 'token' =>
'A block token previously obtained through prop=info',
173 'expiry' =>
'Relative expiry time, e.g. \'5 months\' or \'2 weeks\'. ' .
174 'If set to \'infinite\', \'indefinite\' or \'never\', the block will never expire.',
175 'reason' =>
'Reason for block',
176 'anononly' =>
'Block anonymous users only (i.e. disable anonymous edits for this IP)',
177 'nocreate' =>
'Prevent account creation',
178 'autoblock' =>
'Automatically block the last used IP address, and ' .
179 'any subsequent IP addresses they try to login from',
181 =>
'Prevent user from sending email through the wiki. (Requires the "blockemail" right.)',
182 'hidename' =>
'Hide the username from the block log. (Requires the "hideuser" right.)',
184 =>
'Allow the user to edit their own talk page (depends on $wgBlockAllowsUTEdit)',
185 'reblock' =>
'If the user is already blocked, overwrite the existing block',
186 'watchuser' =>
'Watch the user/IP\'s user and talk pages',
213 'anononly' =>
'boolean',
214 'nocreate' =>
'boolean',
215 'autoblock' =>
'boolean',
216 'noemail' =>
'boolean',
217 'hidename' =>
'boolean',
218 'allowusertalk' =>
'boolean',
219 'watchuser' =>
'boolean'
225 return 'Block a user.';
229 return array_merge( parent::getPossibleErrors(),
array(
230 array(
'cantblock' ),
232 array(
'cantblock-email' ),
233 array(
'ipbblocked' ),
234 array(
'ipbnounblockself' ),
248 'api.php?action=block&user=123.5.5.12&expiry=3%20days&reason=First%20strike',
249 'api.php?action=block&user=Vandal&expiry=never&reason=Vandalism&nocreate=&autoblock=&noemail='
254 return 'https://www.mediawiki.org/wiki/API:Block';
getContext()
Get the RequestContext object.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getId()
Get the user's ID.
static processForm(array $data, IContextSource $context)
Given the form data, actually implement a block.
dieUsageMsg( $error)
Output the error message related to a certain array.
static canBlockEmail( $user)
Can we do an email block?
mustBePosted()
Indicates whether this module must be called with a POST request.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getResult()
Get the result object.
isWriteMode()
Indicates whether this module requires write mode.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
getDB()
Gets a default slave database connection object.
getUser()
Get the User object.
getTokenSalt()
Returns the token salt if there is one, '' if the module doesn't require a salt, else false if the mo...
needsToken()
Returns whether this module requires a token to execute It is used to show possible errors in action=...
This abstract class implements many basic API functions, and is the base of all API classes.
getExamples()
Returns usage examples for this module.
API module that facilitates the blocking of users.
getDescription()
Returns the description string for this module.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getResultProperties()
Returns possible properties in the result, grouped by the value of the prop parameter that shows them...
getParamDescription()
Returns an array of parameter descriptions.
getPossibleErrors()
Returns a list of all possible errors returned by the module.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
execute()
Blocks the user specified in the parameters for the given expiry, with the given reason,...
getModuleName()
Get the name of the module being executed by this instance.
static checkUnblockSelf( $user, User $performer)
bug 15810: blocked admins should not be able to block/unblock others, and probably shouldn't be able ...
static getTargetAndType( $par, WebRequest $request=null)
Determine the target of the block, and the type of target TODO: should be in Block....
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval