58 parent::__construct(
'Block',
'block' );
72 parent::checkExecutePermissions( $user );
73 # T17810: blocked admins should have limited access here
75 if ( $status !==
true ) {
95 # Extract variables from the request. Try not to get into a situation where we
96 # need to extract *every* variable from the form just for processing here, but
97 # there are legitimate uses for some variables
100 if ( $this->target instanceof
User ) {
101 # Set the 'relevant user' in the skin, so it displays links like Contributions,
102 # User logs, UserRights, etc.
103 $this->
getSkin()->setRelevantUser( $this->target );
106 list( $this->previousTarget, ) =
107 DatabaseBlock::parseTarget( $request->getVal(
'wpPreviousTarget' ) );
108 $this->requestedHideUser = $request->getBool(
'wpHideUser' );
120 $msg = $this->alreadyBlocked ?
'ipb-change-block' :
'ipbsubmit';
125 # Don't need to do anything if the form has been posted
126 if ( !$this->
getRequest()->wasPosted() && $this->preErrors ) {
131 [
'class' =>
'error' ],
148 $enablePartialBlocks = $conf->get(
'EnablePartialBlocks' );
149 $blockAllowsUTEdit = $conf->get(
'BlockAllowsUTEdit' );
163 'id' =>
'mw-bi-target',
167 'validation-callback' => [ __CLASS__,
'validateTargetField' ],
168 'section' =>
'target',
173 'label-message' =>
'block-prevent-edit',
175 'section' =>
'actions',
176 'disabled' => $enablePartialBlocks ? false :
true,
179 if ( $enablePartialBlocks ) {
180 $a[
'EditingRestriction'] = [
182 'cssclass' =>
'mw-block-editing-restriction',
184 $this->
msg(
'ipb-sitewide' )->escaped() .
185 new \OOUI\LabelWidget( [
186 'classes' => [
'oo-ui-inline-help' ],
187 'label' => $this->
msg(
'ipb-sitewide-help' )->text(),
189 $this->
msg(
'ipb-partial' )->escaped() .
190 new \OOUI\LabelWidget( [
191 'classes' => [
'oo-ui-inline-help' ],
192 'label' => $this->
msg(
'ipb-partial-help' )->text(),
195 'section' =>
'actions',
197 $a[
'PageRestrictions'] = [
198 'type' =>
'titlesmultiselect',
199 'label' => $this->
msg(
'ipb-pages-label' )->text(),
202 'cssclass' =>
'mw-block-restriction',
203 'showMissing' =>
false,
204 'excludeDynamicNamespaces' =>
true,
206 'autocomplete' => false
208 'section' =>
'actions',
210 $a[
'NamespaceRestrictions'] = [
211 'type' =>
'namespacesmultiselect',
212 'label' => $this->
msg(
'ipb-namespaces-label' )->text(),
214 'cssclass' =>
'mw-block-restriction',
216 'autocomplete' => false
218 'section' =>
'actions',
222 $a[
'CreateAccount'] = [
224 'label-message' =>
'ipbcreateaccount',
226 'section' =>
'actions',
229 if ( self::canBlockEmail( $user ) ) {
230 $a[
'DisableEmail'] = [
232 'label-message' =>
'ipbemailban',
233 'section' =>
'actions',
237 if ( $blockAllowsUTEdit ) {
238 $a[
'DisableUTEdit'] = [
240 'label-message' =>
'ipb-disableusertalk',
242 'section' =>
'actions',
249 'options' => $suggestedDurations,
250 'default' => $this->
msg(
'ipb-default-expiry' )->inContentLanguage()->text(),
251 'section' =>
'expiry',
255 'type' =>
'selectandother',
259 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
260 'maxlength-unit' =>
'codepoints',
261 'options-message' =>
'ipbreason-dropdown',
262 'section' =>
'reason',
267 'label-message' =>
'ipbenableautoblock',
269 'section' =>
'options',
272 # Allow some users to hide name from block log, blocklist and listusers
273 if ( MediaWikiServices::getInstance()
275 ->userHasRight( $user,
'hideuser' )
279 'label-message' =>
'ipbhidename',
280 'cssclass' =>
'mw-block-hideuser',
281 'section' =>
'options',
285 # Watchlist their user page? (Only if user is logged in)
286 if ( $user->isLoggedIn() ) {
289 'label-message' =>
'ipbwatchuser',
290 'section' =>
'options',
296 'label-message' =>
'ipb-hardblock',
298 'section' =>
'options',
301 # This is basically a copy of the Target field, but the user can't change it, so we
302 # can see if the warnings we maybe showed to the user before still apply
303 $a[
'PreviousTarget'] = [
308 # We'll turn this into a checkbox if we need to
312 'label-message' =>
'ipb-confirm',
313 'cssclass' =>
'mw-block-confirm',
319 Hooks::run(
'SpecialBlockModifyFormFields', [ $this, &$a ] );
330 # This will be overwritten by request data
331 $fields[
'Target'][
'default'] = (string)$this->target;
333 if ( $this->target ) {
335 if ( !$status->isOK() ) {
336 $errors = $status->getErrorsArray();
337 $this->preErrors = array_merge( $this->preErrors, $errors );
342 $fields[
'PreviousTarget'][
'default'] = (string)$this->target;
344 $block = DatabaseBlock::newFromTarget( $this->target );
349 && ( $this->type != DatabaseBlock::TYPE_RANGE
350 || $block->getTarget() == $this->target )
352 $fields[
'HardBlock'][
'default'] = $block->isHardblock();
353 $fields[
'CreateAccount'][
'default'] = $block->isCreateAccountBlocked();
354 $fields[
'AutoBlock'][
'default'] = $block->isAutoblocking();
356 if ( isset( $fields[
'DisableEmail'] ) ) {
357 $fields[
'DisableEmail'][
'default'] = $block->isEmailBlocked();
360 if ( isset( $fields[
'HideUser'] ) ) {
361 $fields[
'HideUser'][
'default'] = $block->getHideName();
364 if ( isset( $fields[
'DisableUTEdit'] ) ) {
365 $fields[
'DisableUTEdit'][
'default'] = !$block->isUsertalkEditAllowed();
370 if ( !$block->getHideName() || MediaWikiServices::getInstance()
371 ->getPermissionManager()
372 ->userHasRight( $this->getUser(),
'hideuser' )
374 $fields[
'Reason'][
'default'] = $block->getReason();
376 $fields[
'Reason'][
'default'] =
'';
380 # Ok, so we got a POST submission asking us to reblock a user. So show the
381 # confirm checkbox; the user will only see it if they haven't previously
382 $fields[
'Confirm'][
'type'] =
'check';
384 # We got a target, but it wasn't a POST request, so the user must have gone
385 # to a link like [[Special:Block/User]]. We don't need to show the checkbox
386 # as long as they go ahead and block *that* user
387 $fields[
'Confirm'][
'default'] = 1;
390 if ( $block->getExpiry() ==
'infinity' ) {
391 $fields[
'Expiry'][
'default'] =
'infinite';
393 $fields[
'Expiry'][
'default'] =
wfTimestamp( TS_RFC2822, $block->getExpiry() );
396 $this->alreadyBlocked =
true;
397 $this->preErrors[] = [
'ipb-needreblock',
wfEscapeWikiText( (
string)$block->getTarget() ) ];
400 if ( $this->alreadyBlocked || $this->
getRequest()->wasPosted()
401 || $this->
getRequest()->getCheck(
'wpCreateAccount' )
403 $this->
getOutput()->addJsConfigVars(
'wgCreateAccountDirty',
true );
406 # We always need confirmation to do HideUser
407 if ( $this->requestedHideUser ) {
408 $fields[
'Confirm'][
'type'] =
'check';
409 unset( $fields[
'Confirm'][
'default'] );
410 $this->preErrors[] = [
'ipb-confirmhideuser',
'ipb-confirmaction' ];
413 # Or if the user is trying to block themselves
415 $fields[
'Confirm'][
'type'] =
'check';
416 unset( $fields[
'Confirm'][
'default'] );
417 $this->preErrors[] = [
'ipb-blockingself',
'ipb-confirmaction' ];
420 if ( $this->
getConfig()->
get(
'EnablePartialBlocks' ) ) {
422 $fields[
'EditingRestriction'][
'default'] =
'partial';
424 $fields[
'EditingRestriction'][
'default'] =
'sitewide';
428 $pageRestrictions = [];
429 $namespaceRestrictions = [];
430 foreach ( $block->getRestrictions() as $restriction ) {
431 switch ( $restriction->getType() ) {
432 case PageRestriction::TYPE:
434 '@phan-var PageRestriction $restriction';
435 if ( $restriction->getTitle() ) {
436 $pageRestrictions[] = $restriction->getTitle()->getPrefixedText();
439 case NamespaceRestriction::TYPE:
440 $namespaceRestrictions[] = $restriction->getValue();
446 !$block->isSitewide() &&
447 empty( $pageRestrictions ) &&
448 empty( $namespaceRestrictions )
450 $fields[
'Editing'][
'default'] =
false;
454 sort( $pageRestrictions );
455 $fields[
'PageRestrictions'][
'default'] = implode(
"\n", $pageRestrictions );
456 sort( $namespaceRestrictions );
457 $fields[
'NamespaceRestrictions'][
'default'] = implode(
"\n", $namespaceRestrictions );
468 'mediawiki.widgets.TagMultiselectWidget.styles',
471 $this->
getOutput()->addModules( [
'mediawiki.special.block' ] );
473 $blockCIDRLimit = $this->
getConfig()->get(
'BlockCIDRLimit' );
474 $text = $this->
msg(
'blockiptext', $blockCIDRLimit[
'IPv4'], $blockCIDRLimit[
'IPv6'] )->parse();
476 $otherBlockMessages = [];
477 if ( $this->target !==
null ) {
479 if ( $this->target instanceof
User ) {
480 $targetName = $this->target->
getName();
482 # Get other blocks, i.e. from GlobalBlocking or TorBlock extension
483 Hooks::run(
'OtherBlockLogLink', [ &$otherBlockMessages, $targetName ] );
485 if ( count( $otherBlockMessages ) ) {
486 $s = Html::rawElement(
489 $this->
msg(
'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse()
494 foreach ( $otherBlockMessages as $link ) {
495 $list .= Html::rawElement(
'li', [], $link ) .
"\n";
498 $s .= Html::rawElement(
500 [
'class' =>
'mw-blockip-alreadyblocked' ],
518 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
521 # Link to the user's contributions, if applicable
522 if ( $this->target instanceof
User ) {
526 $this->
msg(
'ipb-blocklist-contribs', $this->target->getName() )->text()
530 # Link to unblock the specified user, or to a blank unblock form
531 if ( $this->target instanceof
User ) {
532 $message = $this->
msg(
538 $message = $this->
msg(
'ipb-unblock' )->parse();
546 # Link to the block list
549 $this->
msg(
'ipb-blocklist' )->text()
554 # Link to edit the block dropdown reasons, if applicable
555 $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
556 if ( $permissionManager->userHasRight( $user,
'editinterface' ) ) {
558 $this->
msg(
'ipbreason-dropdown' )->inContentLanguage()->
getTitle(),
559 $this->
msg(
'ipb-edit-dropdown' )->text(),
561 [
'action' =>
'edit' ]
565 $text = Html::rawElement(
567 [
'class' =>
'mw-ipb-conveniencelinks' ],
573 # Get relevant extracts from the block and suppression logs, if possible
583 'msgKey' => [
'blocklog-showlog', $userTitle->getText() ],
584 'showIfEmpty' =>
false
589 # Add suppression block entries if allowed
590 if ( $permissionManager->userHasRight( $user,
'suppressionlog' ) ) {
598 'conds' => [
'log_action' => [
'block',
'reblock',
'unblock' ] ],
599 'msgKey' => [
'blocklog-showsuppresslog', $userTitle->getText() ],
600 'showIfEmpty' =>
false
620 } elseif ( IP::isIPAddress(
$target ) ) {
643 # The HTMLForm will check wpTarget first and only if it doesn't get
644 # a value use the default, which will be generated from the options
645 # below; so this has to have a higher precedence here than $par, or
646 # we could end up with different values in $this->target and the HTMLForm!
648 $target = $request->getText(
'wpTarget',
null );
656 $target = $request->getText(
'ip',
null );
662 $target = $request->getText(
'wpBlockAddress',
null );
671 if (
$type !==
null ) {
676 return [
null, null ];
689 if ( !$status->isOK() ) {
690 $errors = $status->getErrorsArray();
692 return $form->msg( ...$errors[0] );
711 $status = Status::newGood(
$target );
713 if (
$type == DatabaseBlock::TYPE_USER ) {
722 if ( $unblockStatus !==
true ) {
723 $status->fatal(
'badaccess', $unblockStatus );
725 } elseif (
$type == DatabaseBlock::TYPE_RANGE ) {
726 list( $ip, $range ) = explode(
'/',
$target, 2 );
733 $status->fatal(
'range_block_disabled' );
737 ( IP::isIPv4( $ip ) && $range > 32 ) ||
738 ( IP::isIPv6( $ip ) && $range > 128 )
741 $status->fatal(
'ip_range_invalid' );
751 } elseif (
$type == DatabaseBlock::TYPE_IP ) {
754 $status->fatal(
'badipaddress' );
769 $enablePartialBlocks =
$context->getConfig()->get(
'EnablePartialBlocks' );
770 $isPartialBlock = $enablePartialBlocks &&
771 isset( $data[
'EditingRestriction'] ) &&
772 $data[
'EditingRestriction'] ===
'partial';
774 # This might have been a hidden field or a checkbox, so interesting data
776 $data[
'Confirm'] = !in_array( $data[
'Confirm'], [
'',
'0',
null,
false ],
true );
780 if (
$type == DatabaseBlock::TYPE_USER ) {
783 $userId = $user->getId();
785 # Give admins a heads-up before they go and block themselves. Much messier
786 # to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
787 # permission anyway, although the code does allow for it.
788 # Note: Important to use $target instead of $data['Target']
789 # since both $data['PreviousTarget'] and $target are normalized
790 # but $data['target'] gets overridden by (non-normalized) request variable
791 # from previous request.
793 ( $data[
'PreviousTarget'] !==
$target || !$data[
'Confirm'] )
795 return [
'ipb-blockingself',
'ipb-confirmaction' ];
797 } elseif (
$type == DatabaseBlock::TYPE_RANGE ) {
800 } elseif (
$type == DatabaseBlock::TYPE_IP ) {
805 # This should have been caught in the form field validation
806 return [
'badipaddress' ];
813 ( strlen( $data[
'Expiry'] ) == 0 ) ||
815 ( strlen( $data[
'Expiry'] ) > 50 ) ||
819 return [
'ipb_expiry_invalid' ];
825 return [
'ipb_expiry_old' ];
828 if ( !isset( $data[
'DisableEmail'] ) ) {
829 $data[
'DisableEmail'] =
false;
832 # If the user has done the form 'properly', they won't even have been given the
833 # option to suppress-block unless they have the 'hideuser' permission
834 if ( !isset( $data[
'HideUser'] ) ) {
835 $data[
'HideUser'] =
false;
838 if ( $data[
'HideUser'] ) {
839 if ( !MediaWikiServices::getInstance()
841 ->userHasRight( $performer,
'hideuser' )
843 # this codepath is unreachable except by a malicious user spoofing forms,
844 # or by race conditions (user has hideuser and block rights, loads block form,
845 # and loses hideuser rights before submission); so need to fail completely
846 # rather than just silently disable hiding
847 return [
'badaccess-group0' ];
850 if ( $isPartialBlock ) {
851 return [
'ipb_hide_partial' ];
854 # Recheck params here...
855 $hideUserContribLimit =
$context->getConfig()->get(
'HideUserContribLimit' );
856 if (
$type != DatabaseBlock::TYPE_USER ) {
857 $data[
'HideUser'] =
false; #
IP users should not be hidden
860 return [
'ipb_expiry_temp' ];
861 } elseif ( $hideUserContribLimit !==
false
862 && $user->getEditCount() > $hideUserContribLimit
864 # Typically, the user should have a handful of edits.
865 # Disallow hiding users with many edits for performance.
866 return [ [
'ipb_hide_invalid',
868 } elseif ( !$data[
'Confirm'] ) {
869 return [
'ipb-confirmhideuser',
'ipb-confirmaction' ];
873 $blockAllowsUTEdit =
$context->getConfig()->get(
'BlockAllowsUTEdit' );
874 $userTalkEditAllowed = !$blockAllowsUTEdit || !$data[
'DisableUTEdit'];
875 if ( !$userTalkEditAllowed &&
877 !in_array(
NS_USER_TALK, explode(
"\n", $data[
'NamespaceRestrictions'] ) )
879 return [
'ipb-prevent-user-talk-edit' ];
882 # Create block object.
885 $block->setBlocker( $performer );
886 $block->setReason( $data[
'Reason'][0] );
888 $block->isCreateAccountBlocked( $data[
'CreateAccount'] );
889 $block->isUsertalkEditAllowed( $userTalkEditAllowed );
890 $block->isEmailBlocked( $data[
'DisableEmail'] );
891 $block->isHardblock( $data[
'HardBlock'] );
892 $block->isAutoblocking( $data[
'AutoBlock'] );
893 $block->setHideName( $data[
'HideUser'] );
895 if ( $isPartialBlock ) {
896 $block->isSitewide(
false );
899 $reason = [
'hookaborted' ];
900 if ( !Hooks::run(
'BlockIp', [ &$block, &$performer, &$reason ] ) ) {
904 $pageRestrictions = [];
905 $namespaceRestrictions = [];
906 if ( $enablePartialBlocks ) {
907 if ( $data[
'PageRestrictions'] !==
'' ) {
908 $pageRestrictions = array_map(
function ( $text ) {
909 $title = Title::newFromText( $text );
913 $restriction->setTitle(
$title );
915 }, explode(
"\n", $data[
'PageRestrictions'] ) );
917 if ( $data[
'NamespaceRestrictions'] !==
'' ) {
918 $namespaceRestrictions = array_map(
function ( $id ) {
920 }, explode(
"\n", $data[
'NamespaceRestrictions'] ) );
923 $restrictions = ( array_merge( $pageRestrictions, $namespaceRestrictions ) );
924 $block->setRestrictions( $restrictions );
928 # Try to insert block. Is there a conflicting block?
929 $status = $block->insert();
931 # Indicates whether the user is confirming the block and is aware of
932 # the conflict (did not change the block target in the meantime)
933 $blockNotConfirmed = !$data[
'Confirm'] || ( array_key_exists(
'PreviousTarget', $data )
934 && $data[
'PreviousTarget'] !==
$target );
936 # Special case for API - T34434
937 $reblockNotAllowed = ( array_key_exists(
'Reblock', $data ) && !$data[
'Reblock'] );
939 # Show form unless the user is already aware of this...
940 if ( $blockNotConfirmed || $reblockNotAllowed ) {
941 return [ [
'ipb_already_blocked', $block->getTarget() ] ];
942 # Otherwise, try to update the block...
944 # This returns direct blocks before autoblocks/rangeblocks, since we should
945 # be sure the user is blocked by now it should work for our purposes
946 $currentBlock = DatabaseBlock::newFromTarget(
$target );
947 if ( $block->equals( $currentBlock ) ) {
948 return [ [
'ipb_already_blocked', $block->getTarget() ] ];
950 # If the name was hidden and the blocking user cannot hide
951 # names, then don't allow any block changes...
952 if ( $currentBlock->getHideName() && !MediaWikiServices::getInstance()
953 ->getPermissionManager()
954 ->userHasRight( $performer,
'hideuser' )
956 return [
'cant-see-hidden-user' ];
959 $priorBlock = clone $currentBlock;
960 $currentBlock->isHardblock( $block->isHardblock() );
961 $currentBlock->isCreateAccountBlocked( $block->isCreateAccountBlocked() );
962 $currentBlock->setExpiry( $block->getExpiry() );
963 $currentBlock->isAutoblocking( $block->isAutoblocking() );
964 $currentBlock->setHideName( $block->getHideName() );
965 $currentBlock->isEmailBlocked( $block->isEmailBlocked() );
966 $currentBlock->isUsertalkEditAllowed( $block->isUsertalkEditAllowed() );
967 $currentBlock->setReason( $block->getReason() );
969 if ( $enablePartialBlocks ) {
972 $currentBlock->isSitewide( $block->isSitewide() );
975 $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
976 $currentBlock->setRestrictions(
977 $blockRestrictionStore->setBlockId( $currentBlock->getId(), $restrictions )
981 $status = $currentBlock->update();
984 $logaction =
'reblock';
986 # Unset _deleted fields if requested
987 if ( $currentBlock->getHideName() && !$data[
'HideUser'] ) {
991 # If hiding/unhiding a name, this should go in the private logs
992 if ( (
bool)$currentBlock->getHideName() ) {
993 $data[
'HideUser'] =
true;
996 $block = $currentBlock;
999 $logaction =
'block';
1002 Hooks::run(
'BlockIpComplete', [ $block, $performer, $priorBlock ] );
1004 # Set *_deleted fields if requested
1005 if ( $data[
'HideUser'] ) {
1009 # Can't watch a rangeblock
1010 if (
$type != DatabaseBlock::TYPE_RANGE && $data[
'Watch'] ) {
1014 User::IGNORE_USER_RIGHTS
1018 # DatabaseBlock constructor sanitizes certain block options on insert
1019 $data[
'BlockEmail'] = $block->isEmailBlocked();
1020 $data[
'AutoBlock'] = $block->isAutoblocking();
1022 # Prepare log parameters
1024 $logParams[
'5::duration'] = $data[
'Expiry'];
1026 $logParams[
'sitewide'] = $block->isSitewide();
1028 if ( $enablePartialBlocks && !$block->isSitewide() ) {
1029 if ( $data[
'PageRestrictions'] !==
'' ) {
1030 $logParams[
'7::restrictions'][
'pages'] = explode(
"\n", $data[
'PageRestrictions'] );
1033 if ( $data[
'NamespaceRestrictions'] !==
'' ) {
1034 $logParams[
'7::restrictions'][
'namespaces'] = explode(
"\n", $data[
'NamespaceRestrictions'] );
1038 # Make log entry, if the name is hidden, put it in the suppression log
1039 $log_type = $data[
'HideUser'] ?
'suppress' :
'block';
1042 $logEntry->setComment( $data[
'Reason'][0] );
1043 $logEntry->setPerformer( $performer );
1044 $logEntry->setParameters( $logParams );
1045 # Relate log ID to block ID (T27763)
1046 $logEntry->setRelations( [
'ipb_id' => $block->getId() ] );
1047 $logId = $logEntry->insert();
1049 if ( !empty( $data[
'Tags'] ) ) {
1050 $logEntry->addTags( $data[
'Tags'] );
1053 $logEntry->publish( $logId );
1070 $msg =
$lang ===
null
1071 ?
wfMessage(
'ipboptions' )->inContentLanguage()->text()
1074 if ( $msg ==
'-' ) {
1078 foreach ( explode(
',', $msg ) as $option ) {
1079 if ( strpos( $option,
':' ) ===
false ) {
1080 $option =
"$option:$option";
1083 list( $show, $value ) = explode(
':', $option );
1087 if ( $a && $includeOther ) {
1090 $a[
wfMessage(
'ipbother' )->text() ] =
'other';
1112 $expiry = strtotime( $expiry );
1114 if ( $expiry < 0 || $expiry ===
false ) {
1131 ->userHasRight( $user,
'blockemail' ) );
1151 } elseif ( is_string(
$target ) ) {
1156 # User is trying to unblock themselves
1157 if ( MediaWikiServices::getInstance()
1159 ->userHasRight( $performer,
'unblockself' )
1162 # User blocked themselves and is now trying to reverse it
1166 return 'ipbnounblockself';
1182 # User is trying to block/unblock someone else
1183 return 'ipbblocked';
1198 $config = RequestContext::getMain()->getConfig();
1200 $blockAllowsUTEdit = $config->get(
'BlockAllowsUTEdit' );
1204 # when blocking a user the option 'anononly' is not available/has no effect
1205 # -> do not write this into log
1206 if ( !$data[
'HardBlock'] &&
$type != DatabaseBlock::TYPE_USER ) {
1208 $flags[] =
'anononly';
1211 if ( $data[
'CreateAccount'] ) {
1213 $flags[] =
'nocreate';
1216 # Same as anononly, this is not displayed when blocking an IP address
1217 if ( !$data[
'AutoBlock'] &&
$type == DatabaseBlock::TYPE_USER ) {
1219 $flags[] =
'noautoblock';
1222 if ( $data[
'DisableEmail'] ) {
1224 $flags[] =
'noemail';
1227 if ( $blockAllowsUTEdit && $data[
'DisableUTEdit'] ) {
1229 $flags[] =
'nousertalk';
1232 if ( $data[
'HideUser'] ) {
1234 $flags[] =
'hiddenname';
1237 return implode(
',', $flags );
1249 if ( isset( $data[
'Editing'] ) && $data[
'Editing'] ===
false ) {
1250 $data[
'EditingRestriction'] =
'partial';
1251 $data[
'PageRestrictions'] =
'';
1252 $data[
'NamespaceRestrictions'] =
'';
1263 $out->setPageTitle( $this->
msg(
'blockipsuccesssub' ) );
1264 $out->addWikiMsg(
'blockipsuccesstext',
wfEscapeWikiText( $this->target ) );
1276 $user = User::newFromName( $search );
$wgBlockCIDRLimit
Limits on the possible sizes of range blocks.
$wgEnableUserEmail
Set to true to enable user-to-user e-mail.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfIsInfinity( $str)
Determine input string is represents as infinity.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
An error page which can definitely be safely rendered using the OutputPage.
Special page which uses an HTMLForm to handle processing.
string null $par
The sub-page of the special page.
Marks HTML that shouldn't be escaped.
A collection of public static functions to play with IP address and IP ranges.
Internationalisation code.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Class for creating new log entries and inserting them into the database.
static suppressUserName( $name, $userId, IDatabase $dbw=null)
static unsuppressUserName( $name, $userId, IDatabase $dbw=null)
A special page that allows users with 'block' right to block users from editing pages and other actio...
int $type
DatabaseBlock::TYPE_ constant.
requiresUnblock()
We allow certain special cases where user is blocked.
preText()
Add header elements like block log entries, etc.
static processForm(array $data, IContextSource $context)
Given the form data, actually implement a block.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
static validateTarget( $value, User $user)
Validate a block target.
static parseExpiryInput( $expiry)
Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute ("24 May 2034",...
static getTargetAndType( $par, WebRequest $request=null)
Determine the target of the block, and the type of target.
static validateTargetField( $value, $alldata, $form)
HTMLForm field validation-callback for Target field.
bool $requestedHideUser
Whether the previous submission of the form asked for HideUser.
maybeAlterFormDefaults(&$fields)
If the user has already been blocked with similar settings, load that block and change the defaults f...
getFormFields()
Get the HTMLForm descriptor array for the block form.
postText()
Add footer elements to the form.
getDisplayFormat()
Get display format for the form.
static checkUnblockSelf( $target, User $performer)
T17810: blocked admins should not be able to block/unblock others, and probably shouldn't be able to ...
setParameter( $par)
Handle some magic here.
User string $previousTarget
The previous block target.
checkExecutePermissions(User $user)
Checks that the user can unblock themselves if they are trying to do so.
alterForm(HTMLForm $form)
Customizes the HTMLForm a bit.
static getTargetUserTitle( $target)
Get a user page target for things like logs.
User string null $target
User to be blocked, as passed either by parameter (url?wpTarget=Foo) or as subpage (Special:Block/Foo...
static canBlockEmail(UserIdentity $user)
Can we do an email block?
doesWrites()
Indicates whether this special page may perform database writes.
onSubmit(array $data, HTMLForm $form=null)
Process the form on POST submission.
static blockLogFlags(array $data, $type)
Return a comma-delimited list of "flags" to be passed to the log reader for this block,...
static getSuggestedDurations(Language $lang=null, $includeOther=true)
Get an array of suggested block durations from MediaWiki:Ipboptions.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getName()
Get the name of this Special Page.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getSkin()
Shortcut to get the skin being used for this instance.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
MediaWiki Linker LinkRenderer null $linkRenderer
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
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.
getUserPage()
Get this user's personal page title.
blockedBy()
If user is blocked, return the name of the user who placed the block.
getBlock( $fromReplica=true)
Get the block affecting the user, or null if the user is not blocked.
isAnon()
Get whether the user is anonymous.
static doWatch(Title $title, User $user, $checkRights=User::CHECK_USER_RIGHTS)
Watch a page.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang