24use InvalidArgumentException;
111 $options += $defaults;
115 if ( $options[
'by'] ) {
171 $this->mReason = $reason;
191 $this->mHideName = $hideName;
217 return wfSetVar( $this->blockCreateAccount, $x );
230 return wfSetVar( $this->mBlockEmail, $x );
243 return wfSetVar( $this->allowUsertalk, $x );
258 $config = RequestContext::getMain()->getConfig();
259 $blockDisablesLogin = $config->get(
'BlockDisablesLogin' );
267 case 'createaccount':
284 if ( !
$res && $blockDisablesLogin ) {
289 $res = $permissionManager->userHasRight( $anon, $right ) ?
$res :
true;
305 $config = RequestContext::getMain()->getConfig();
306 $blockDisablesLogin = $config->get(
'BlockDisablesLogin' );
307 $blockAllowsUTEdit = $config->get(
'BlockAllowsUTEdit' );
312 # For now... <evil laugh>
315 case 'createaccount':
325 case 'editownusertalk':
330 wfSetVar( $this->allowUsertalk, $x ===
null ?
null : !$x );
334 if ( !$blockAllowsUTEdit ) {
345 if ( !
$res && $blockDisablesLogin ) {
350 $res = $permissionManager->userHasRight( $anon, $action ) ?
$res :
true;
366 # We may have been through this before
373 } elseif (
$target ===
null ) {
374 return [
null, null ];
379 if ( IP::isValid(
$target ) ) {
380 # We can still create a User if it's an IP address, but we need to turn
381 # off validation checking (which would exclude IP addresses)
387 } elseif ( IP::isValidRange(
$target ) ) {
388 # Can't create a User from an IP range
392 # Consider the possibility that this is not a username at all
393 # but actually an old subpage (T31797)
394 if ( strpos(
$target,
'/' ) !==
false ) {
395 # An old subpage, drill down to the user behind it
400 if ( $userObj instanceof
User ) {
401 # Note that since numbers are valid usernames, a $target of "12345" will be
402 # considered a User. If you want to pass a block ID, prepend a hash "#12345",
403 # since hash characters are not valid in usernames or titles generally.
406 } elseif ( preg_match(
'/^#\d+$/',
$target ) ) {
407 # Autoblock reference in the form "#12345"
411 return [
null, null ];
461 $this->mExpiry = $expiry;
481 $this->mTimestamp = $timestamp;
489 list( $this->target, $this->type ) = static::parseTarget(
$target );
505 if ( is_string( $user ) ) {
510 throw new InvalidArgumentException(
511 'Blocker must be a local user or a name that cannot be a local user'
515 $this->blocker = $user;
540 $blockerText =
$lang->embedBidi( $blockerUserpage->getText() );
541 $link =
"[[{$blockerUserpage->getPrefixedText()}|{$blockerText}]]";
547 if ( $reason ==
'' ) {
548 $reason =
$context->msg(
'blockednoreason' )->text();
564 $lang->embedBidi( $intended ),
598 if ( $this->target instanceof
User ) {
599 $usertalk = $this->target->getTalkPage();
601 throw new InvalidArgumentException(
602 '$usertalk must be provided if block target is not a user/IP'
608 throw new InvalidArgumentException(
609 '$usertalk must be a user talk page'
624 $config = RequestContext::getMain()->getConfig();
625 if ( !$config->get(
'BlockAllowsUTEdit' ) ) {
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
A collection of public static functions to play with IP address and IP ranges.
Group all the pieces relevant to the context of a request into one instance.
Represents a title within MediaWiki.
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.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static newFromId( $id)
Static factory method for creation from a given user ID.
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
getUserPage()
Get this user's personal page title.
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang