25use InvalidArgumentException;
111 $options += $defaults;
162 $language = RequestContext::getMain()->getLanguage();
163 return $this->reason->message->inLanguage( $language )->plain();
183 $this->reason = CommentStoreComment::newUnsavedComment(
$reason );
203 $this->mHideName = $hideName;
229 return wfSetVar( $this->blockCreateAccount, $x );
242 return wfSetVar( $this->mBlockEmail, $x );
255 return wfSetVar( $this->allowUsertalk, $x );
270 $config = RequestContext::getMain()->getConfig();
271 $blockDisablesLogin = $config->get(
'BlockDisablesLogin' );
279 case 'createaccount':
296 if ( !
$res && $blockDisablesLogin ) {
301 $res = $permissionManager->userHasRight( $anon, $right ) ?
$res :
true;
318 $config = RequestContext::getMain()->getConfig();
319 $blockDisablesLogin = $config->get(
'BlockDisablesLogin' );
320 $blockAllowsUTEdit = $config->get(
'BlockAllowsUTEdit' );
325 # For now... <evil laugh>
328 case 'createaccount':
338 case 'editownusertalk':
343 wfSetVar( $this->allowUsertalk, $x ===
null ?
null : !$x );
347 if ( !$blockAllowsUTEdit ) {
358 if ( !
$res && $blockDisablesLogin ) {
363 $res = $permissionManager->userHasRight( $anon, $action ) ?
$res :
true;
381 # We may have been through this before
389 } elseif (
$target ===
null ) {
390 return [
null, null ];
395 if ( IPUtils::isValid(
$target ) ) {
396 # We can still create a User if it's an IP address, but we need to turn
397 # off validation checking (which would exclude IP addresses)
403 } elseif ( IPUtils::isValidRange(
$target ) ) {
404 # Can't create a User from an IP range
408 # Consider the possibility that this is not a username at all
409 # but actually an old subpage (T31797)
410 if ( strpos(
$target,
'/' ) !==
false ) {
411 # An old subpage, drill down to the user behind it
416 if ( $userObj instanceof
User ) {
417 # Note that since numbers are valid usernames, a $target of "12345" will be
418 # considered a User. If you want to pass a block ID, prepend a hash "#12345",
419 # since hash characters are not valid in usernames or titles generally.
422 } elseif ( preg_match(
'/^#\d+$/',
$target ) ) {
423 # Autoblock reference in the form "#12345"
427 return [
null, null ];
480 $this->mExpiry = $expiry;
500 $this->mTimestamp = $timestamp;
508 list( $this->target, $this->type ) = static::parseTarget(
$target );
541 ->getBlockErrorFormatter()->getMessage(
547 return array_merge( [ [ $message->getKey() ], $message->getParams() ] );
562 ->getBlockErrorFormatter()->getMessage(
599 if ( $this->target instanceof
User ) {
600 $usertalk = $this->target->getTalkPage();
602 throw new InvalidArgumentException(
603 '$usertalk must be provided if block target is not a user/IP'
609 throw new InvalidArgumentException(
610 '$usertalk must be a user talk page'
625 $config = RequestContext::getMain()->getConfig();
626 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)
Logs a warning that $function is deprecated.
The Message class deals with fetching and processing of interface message into a variety of formats.
Group all the pieces relevant to the context of a request into one instance @newable.
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 newFromIdentity(UserIdentity $identity)
Returns a User object corresponding to the given UserIdentity.
Interface for objects which can provide a MediaWiki context on request.