66 parent::__construct(
'Block',
'block' );
68 $this->permissionManager = $permissionManager;
82 parent::checkExecutePermissions( $user );
83 # T17810: blocked admins should have limited access here
84 $status = self::checkUnblockSelf( $this->target, $user );
85 if ( $status !==
true ) {
105 # Extract variables from the request. Try not to get into a situation where we
106 # need to extract *every* variable from the form just for processing here, but
107 # there are legitimate uses for some variables
109 list( $this->target, $this->type ) = self::getTargetAndType(
$par, $request );
110 if ( $this->target instanceof
User ) {
111 # Set the 'relevant user' in the skin, so it displays links like Contributions,
112 # User logs, UserRights, etc.
113 $this->
getSkin()->setRelevantUser( $this->target );
116 list( $this->previousTarget, ) =
117 DatabaseBlock::parseTarget( $request->getVal(
'wpPreviousTarget' ) );
118 $this->requestedHideUser = $request->getBool(
'wpHideUser' );
130 $msg = $this->alreadyBlocked ?
'ipb-change-block' :
'ipbsubmit';
135 # Don't need to do anything if the form has been posted
136 if ( !$this->
getRequest()->wasPosted() && $this->preErrors ) {
141 [
'class' =>
'error' ],
158 $blockAllowsUTEdit = $conf->get(
'BlockAllowsUTEdit' );
164 $suggestedDurations = self::getSuggestedDurations();
172 'id' =>
'mw-bi-target',
176 'validation-callback' => [ __CLASS__,
'validateTargetField' ],
177 'section' =>
'target',
182 'label-message' =>
'block-prevent-edit',
184 'section' =>
'actions',
187 $a[
'EditingRestriction'] = [
189 'cssclass' =>
'mw-block-editing-restriction',
190 'default' =>
'sitewide',
192 $this->
msg(
'ipb-sitewide' )->escaped() .
193 new \OOUI\LabelWidget( [
194 'classes' => [
'oo-ui-inline-help' ],
195 'label' => $this->
msg(
'ipb-sitewide-help' )->text(),
197 $this->
msg(
'ipb-partial' )->escaped() .
198 new \OOUI\LabelWidget( [
199 'classes' => [
'oo-ui-inline-help' ],
200 'label' => $this->
msg(
'ipb-partial-help' )->text(),
203 'section' =>
'actions',
206 $a[
'PageRestrictions'] = [
207 'type' =>
'titlesmultiselect',
208 'label' => $this->
msg(
'ipb-pages-label' )->text(),
211 'cssclass' =>
'mw-block-restriction',
213 'showMissing' =>
false,
214 'excludeDynamicNamespaces' =>
true,
216 'autocomplete' => false
218 'section' =>
'actions',
221 $a[
'NamespaceRestrictions'] = [
222 'type' =>
'namespacesmultiselect',
223 'label' => $this->
msg(
'ipb-namespaces-label' )->text(),
225 'cssclass' =>
'mw-block-restriction',
228 'autocomplete' => false
230 'section' =>
'actions',
233 $a[
'CreateAccount'] = [
235 'label-message' =>
'ipbcreateaccount',
237 'section' =>
'actions',
240 if ( self::canBlockEmail( $user ) ) {
241 $a[
'DisableEmail'] = [
243 'label-message' =>
'ipbemailban',
244 'section' =>
'actions',
248 if ( $blockAllowsUTEdit ) {
249 $a[
'DisableUTEdit'] = [
251 'label-message' =>
'ipb-disableusertalk',
253 'section' =>
'actions',
257 $defaultExpiry = $this->
msg(
'ipb-default-expiry' )->inContentLanguage();
258 if ( $this->type === DatabaseBlock::TYPE_RANGE || $this->type === DatabaseBlock::TYPE_IP ) {
259 $defaultExpiryIP = $this->
msg(
'ipb-default-expiry-ip' )->inContentLanguage();
260 if ( !$defaultExpiryIP->isDisabled() ) {
261 $defaultExpiry = $defaultExpiryIP;
268 'options' => $suggestedDurations,
269 'default' => $defaultExpiry->text(),
270 'section' =>
'expiry',
274 'type' =>
'selectandother',
278 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
279 'maxlength-unit' =>
'codepoints',
280 'options-message' =>
'ipbreason-dropdown',
281 'section' =>
'reason',
286 'label-message' =>
'ipbenableautoblock',
288 'section' =>
'options',
291 # Allow some users to hide name from block log, blocklist and listusers
292 if ( $this->permissionManager->userHasRight( $user,
'hideuser' ) ) {
295 'label-message' =>
'ipbhidename',
296 'cssclass' =>
'mw-block-hideuser',
297 'section' =>
'options',
301 # Watchlist their user page? (Only if user is logged in)
302 if ( $user->isLoggedIn() ) {
305 'label-message' =>
'ipbwatchuser',
306 'section' =>
'options',
312 'label-message' =>
'ipb-hardblock',
314 'section' =>
'options',
317 # This is basically a copy of the Target field, but the user can't change it, so we
318 # can see if the warnings we maybe showed to the user before still apply
319 $a[
'PreviousTarget'] = [
324 # We'll turn this into a checkbox if we need to
328 'label-message' =>
'ipb-confirm',
329 'cssclass' =>
'mw-block-confirm',
335 $this->
getHookRunner()->onSpecialBlockModifyFormFields( $this, $a );
346 # This will be overwritten by request data
347 $fields[
'Target'][
'default'] = (string)$this->target;
349 if ( $this->target ) {
350 $status = self::validateTarget( $this->target, $this->
getUser() );
351 if ( !$status->isOK() ) {
352 $errors = $status->getErrorsArray();
353 $this->preErrors = array_merge( $this->preErrors, $errors );
358 $fields[
'PreviousTarget'][
'default'] = (string)$this->target;
360 $block = DatabaseBlock::newFromTarget( $this->target );
365 && ( $this->type != DatabaseBlock::TYPE_RANGE
366 || $block->getTarget() == $this->target )
368 $fields[
'HardBlock'][
'default'] = $block->isHardblock();
369 $fields[
'CreateAccount'][
'default'] = $block->isCreateAccountBlocked();
370 $fields[
'AutoBlock'][
'default'] = $block->isAutoblocking();
372 if ( isset( $fields[
'DisableEmail'] ) ) {
373 $fields[
'DisableEmail'][
'default'] = $block->isEmailBlocked();
376 if ( isset( $fields[
'HideUser'] ) ) {
377 $fields[
'HideUser'][
'default'] = $block->getHideName();
380 if ( isset( $fields[
'DisableUTEdit'] ) ) {
381 $fields[
'DisableUTEdit'][
'default'] = !$block->isUsertalkEditAllowed();
386 if ( !$block->getHideName() || $this->permissionManager
387 ->userHasRight( $this->getUser(),
'hideuser' )
389 $fields[
'Reason'][
'default'] = $block->getReasonComment()->text;
391 $fields[
'Reason'][
'default'] =
'';
395 # Ok, so we got a POST submission asking us to reblock a user. So show the
396 # confirm checkbox; the user will only see it if they haven't previously
397 $fields[
'Confirm'][
'type'] =
'check';
399 # We got a target, but it wasn't a POST request, so the user must have gone
400 # to a link like [[Special:Block/User]]. We don't need to show the checkbox
401 # as long as they go ahead and block *that* user
402 $fields[
'Confirm'][
'default'] = 1;
405 if ( $block->getExpiry() ==
'infinity' ) {
406 $fields[
'Expiry'][
'default'] =
'infinite';
408 $fields[
'Expiry'][
'default'] =
wfTimestamp( TS_RFC2822, $block->getExpiry() );
411 if ( !$block->isSitewide() ) {
412 $fields[
'EditingRestriction'][
'default'] =
'partial';
414 $pageRestrictions = [];
415 $namespaceRestrictions = [];
416 foreach ( $block->getRestrictions() as $restriction ) {
418 $pageRestrictions[] = $restriction->getTitle()->getPrefixedText();
420 $namespaceRestrictions[] = $restriction->getValue();
425 sort( $pageRestrictions );
426 $fields[
'PageRestrictions'][
'default'] = implode(
"\n", $pageRestrictions );
427 sort( $namespaceRestrictions );
428 $fields[
'NamespaceRestrictions'][
'default'] = implode(
"\n", $namespaceRestrictions );
431 empty( $pageRestrictions ) &&
432 empty( $namespaceRestrictions )
434 $fields[
'Editing'][
'default'] =
false;
438 $this->alreadyBlocked =
true;
439 $this->preErrors[] = [
'ipb-needreblock',
wfEscapeWikiText( (
string)$block->getTarget() ) ];
442 if ( $this->alreadyBlocked || $this->
getRequest()->wasPosted()
443 || $this->
getRequest()->getCheck(
'wpCreateAccount' )
445 $this->
getOutput()->addJsConfigVars(
'wgCreateAccountDirty',
true );
448 # We always need confirmation to do HideUser
449 if ( $this->requestedHideUser ) {
450 $fields[
'Confirm'][
'type'] =
'check';
451 unset( $fields[
'Confirm'][
'default'] );
452 $this->preErrors[] = [
'ipb-confirmhideuser',
'ipb-confirmaction' ];
455 # Or if the user is trying to block themselves
457 $fields[
'Confirm'][
'type'] =
'check';
458 unset( $fields[
'Confirm'][
'default'] );
459 $this->preErrors[] = [
'ipb-blockingself',
'ipb-confirmaction' ];
469 'mediawiki.widgets.TagMultiselectWidget.styles',
472 $this->
getOutput()->addModules( [
'mediawiki.special.block' ] );
474 $blockCIDRLimit = $this->
getConfig()->get(
'BlockCIDRLimit' );
475 $text = $this->
msg(
'blockiptext', $blockCIDRLimit[
'IPv4'], $blockCIDRLimit[
'IPv6'] )->parse();
477 $otherBlockMessages = [];
478 if ( $this->target !==
null ) {
479 $targetName = $this->target;
480 if ( $this->target instanceof
User ) {
481 $targetName = $this->target->getName();
483 # Get other blocks, i.e. from GlobalBlocking or TorBlock extension
485 $otherBlockMessages, $targetName );
487 if ( count( $otherBlockMessages ) ) {
488 $s = Html::rawElement(
491 $this->
msg(
'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse()
496 foreach ( $otherBlockMessages as $link ) {
497 $list .= Html::rawElement(
'li', [], $link ) .
"\n";
500 $s .= Html::rawElement(
502 [
'class' =>
'mw-blockip-alreadyblocked' ],
520 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
523 # Link to the user's contributions, if applicable
524 if ( $this->target instanceof
User ) {
528 $this->
msg(
'ipb-blocklist-contribs', $this->target->getName() )->text()
532 # Link to unblock the specified user, or to a blank unblock form
533 if ( $this->target instanceof
User ) {
534 $message = $this->
msg(
540 $message = $this->
msg(
'ipb-unblock' )->parse();
548 # Link to the block list
551 $this->
msg(
'ipb-blocklist' )->text()
556 # Link to edit the block dropdown reasons, if applicable
557 if ( $this->permissionManager->userHasRight( $user,
'editinterface' ) ) {
559 $this->
msg(
'ipbreason-dropdown' )->inContentLanguage()->
getTitle(),
560 $this->
msg(
'ipb-edit-dropdown' )->text(),
562 [
'action' =>
'edit' ]
566 $text = Html::rawElement(
568 [
'class' =>
'mw-ipb-conveniencelinks' ],
572 $userTitle = self::getTargetUserTitle( $this->target );
574 # Get relevant extracts from the block and suppression logs, if possible
577 LogEventsList::showLogExtract(
584 'msgKey' => [
'blocklog-showlog', $userTitle->getText() ],
585 'showIfEmpty' =>
false
590 # Add suppression block entries if allowed
591 if ( $this->permissionManager->userHasRight( $user,
'suppressionlog' ) ) {
592 LogEventsList::showLogExtract(
599 'conds' => [
'log_action' => [
'block',
'reblock',
'unblock' ] ],
600 'msgKey' => [
'blocklog-showsuppresslog', $userTitle->getText() ],
601 'showIfEmpty' =>
false
646 # The HTMLForm will check wpTarget first and only if it doesn't get
647 # a value use the default, which will be generated from the options
648 # below; so this has to have a higher precedence here than $par, or
649 # we could end up with different values in $this->target and the HTMLForm!
651 $target = $request->getText(
'wpTarget',
null );
659 $target = $request->getText(
'ip',
null );
665 $target = $request->getText(
'wpBlockAddress',
null );
674 if (
$type !==
null ) {
679 return [
null, null ];
691 $status = self::validateTarget( $value, $form->getUser() );
692 if ( !$status->isOK() ) {
693 $errors = $status->getErrorsArray();
695 return $form->msg( ...$errors[0] );
713 list(
$target,
$type ) = self::getTargetAndType( $value );
714 $status = Status::newGood(
$target );
716 if (
$type == DatabaseBlock::TYPE_USER ) {
724 $unblockStatus = self::checkUnblockSelf(
$target, $user );
725 if ( $unblockStatus !==
true ) {
726 $status->fatal(
'badaccess', $unblockStatus );
728 } elseif (
$type == DatabaseBlock::TYPE_RANGE ) {
729 list( $ip, $range ) = explode(
'/',
$target, 2 );
736 $status->fatal(
'range_block_disabled' );
740 ( IPUtils::isIPv4( $ip ) && $range > 32 ) ||
741 ( IPUtils::isIPv6( $ip ) && $range > 128 )
744 $status->fatal(
'ip_range_invalid' );
754 } elseif (
$type == DatabaseBlock::TYPE_IP ) {
757 $status->fatal(
'badipaddress' );
771 $performer = $context->
getUser();
772 $isPartialBlock = isset( $data[
'EditingRestriction'] ) &&
773 $data[
'EditingRestriction'] ===
'partial';
775 # This might have been a hidden field or a checkbox, so interesting data
777 $data[
'Confirm'] = !in_array( $data[
'Confirm'], [
'',
'0',
null,
false ],
true );
780 list(
$target,
$type ) = self::getTargetAndType( $data[
'Target'] );
781 if (
$type == DatabaseBlock::TYPE_USER ) {
784 $userId = $user->getId();
786 # Give admins a heads-up before they go and block themselves. Much messier
787 # to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
788 # permission anyway, although the code does allow for it.
789 # Note: Important to use $target instead of $data['Target']
790 # since both $data['PreviousTarget'] and $target are normalized
791 # but $data['target'] gets overridden by (non-normalized) request variable
792 # from previous request.
794 ( $data[
'PreviousTarget'] !==
$target || !$data[
'Confirm'] )
796 return [
'ipb-blockingself',
'ipb-confirmaction' ];
798 } elseif (
$type == DatabaseBlock::TYPE_RANGE ) {
801 } elseif (
$type == DatabaseBlock::TYPE_IP ) {
806 # This should have been caught in the form field validation
807 return [
'badipaddress' ];
813 $blockReason = isset( $data[
'Reason'][0] ) ? $data[
'Reason'][0] :
'';
815 $expiryTime = self::parseExpiryInput( $data[
'Expiry'] );
819 ( strlen( $data[
'Expiry'] ) == 0 ) ||
821 ( strlen( $data[
'Expiry'] ) > 50 ) ||
825 return [
'ipb_expiry_invalid' ];
831 return [
'ipb_expiry_old' ];
834 if ( !isset( $data[
'DisableEmail'] ) ) {
835 $data[
'DisableEmail'] =
false;
838 # If the user has done the form 'properly', they won't even have been given the
839 # option to suppress-block unless they have the 'hideuser' permission
840 if ( !isset( $data[
'HideUser'] ) ) {
841 $data[
'HideUser'] =
false;
844 if ( $data[
'HideUser'] ) {
845 if ( !MediaWikiServices::getInstance()
847 ->userHasRight( $performer,
'hideuser' )
849 # this codepath is unreachable except by a malicious user spoofing forms,
850 # or by race conditions (user has hideuser and block rights, loads block form,
851 # and loses hideuser rights before submission); so need to fail completely
852 # rather than just silently disable hiding
853 return [
'badaccess-group0' ];
856 if ( $isPartialBlock ) {
857 return [
'ipb_hide_partial' ];
860 # Recheck params here...
861 $hideUserContribLimit = $context->
getConfig()->get(
'HideUserContribLimit' );
862 if (
$type != DatabaseBlock::TYPE_USER ) {
863 $data[
'HideUser'] =
false; #
IP users should not be hidden
866 return [
'ipb_expiry_temp' ];
867 } elseif ( $hideUserContribLimit !==
false
868 && $user->getEditCount() > $hideUserContribLimit
870 # Typically, the user should have a handful of edits.
871 # Disallow hiding users with many edits for performance.
872 return [ [
'ipb_hide_invalid',
874 } elseif ( !$data[
'Confirm'] ) {
875 return [
'ipb-confirmhideuser',
'ipb-confirmaction' ];
880 $blockAllowsUTEdit = $context->
getConfig()->get(
'BlockAllowsUTEdit' );
881 $isUserTalkNamespaceBlock = !$isPartialBlock ||
882 in_array(
NS_USER_TALK, explode(
"\n", $data[
'NamespaceRestrictions'] ) );
883 if ( $isUserTalkNamespaceBlock ) {
886 $userTalkEditAllowed = $blockAllowsUTEdit ? !$data[
'DisableUTEdit'] :
false;
891 if ( isset( $data[
'DisableUTEdit'] ) && $data[
'DisableUTEdit'] ) {
892 return [
'ipb-prevent-user-talk-edit' ];
894 $userTalkEditAllowed =
true;
899 if ( $isPartialBlock &&
900 !( isset( $data[
'PageRestrictions'] ) && $data[
'PageRestrictions'] !==
'' ) &&
901 !( isset( $data[
'NamespaceRestrictions'] ) && $data[
'NamespaceRestrictions'] !==
'' ) &&
902 $data[
'DisableEmail'] ===
false &&
903 ( $userTalkEditAllowed || !$blockAllowsUTEdit ) &&
904 !$data[
'CreateAccount']
906 return [
'ipb-empty-block' ];
909 # Create block object.
912 $block->setBlocker( $performer );
913 $block->setReason( $blockReason );
914 $block->setExpiry( $expiryTime );
915 $block->isCreateAccountBlocked( $data[
'CreateAccount'] );
916 $block->isUsertalkEditAllowed( $userTalkEditAllowed );
917 $block->isEmailBlocked( $data[
'DisableEmail'] );
918 $block->isHardblock( $data[
'HardBlock'] );
919 $block->isAutoblocking( $data[
'AutoBlock'] );
920 $block->setHideName( $data[
'HideUser'] );
922 if ( $isPartialBlock ) {
923 $block->isSitewide(
false );
926 $reason = [
'hookaborted' ];
927 if ( !Hooks::runner()->onBlockIp( $block, $performer, $reason ) ) {
931 $pageRestrictions = [];
932 $namespaceRestrictions = [];
933 if ( isset( $data[
'PageRestrictions'] ) && $data[
'PageRestrictions'] !==
'' ) {
934 $pageRestrictions = array_map(
function ( $text ) {
935 $title = Title::newFromText( $text );
939 $restriction->setTitle(
$title );
941 }, explode(
"\n", $data[
'PageRestrictions'] ) );
943 if ( isset( $data[
'NamespaceRestrictions'] ) && $data[
'NamespaceRestrictions'] !==
'' ) {
944 $namespaceRestrictions = array_map(
function ( $id ) {
946 }, explode(
"\n", $data[
'NamespaceRestrictions'] ) );
949 $restrictions = ( array_merge( $pageRestrictions, $namespaceRestrictions ) );
950 $block->setRestrictions( $restrictions );
953 # Try to insert block. Is there a conflicting block?
954 $status = $block->insert();
956 # Indicates whether the user is confirming the block and is aware of
957 # the conflict (did not change the block target in the meantime)
958 $blockNotConfirmed = !$data[
'Confirm'] || ( array_key_exists(
'PreviousTarget', $data )
959 && $data[
'PreviousTarget'] !==
$target );
961 # Special case for API - T34434
962 $reblockNotAllowed = ( array_key_exists(
'Reblock', $data ) && !$data[
'Reblock'] );
964 # Show form unless the user is already aware of this...
965 if ( $blockNotConfirmed || $reblockNotAllowed ) {
966 return [ [
'ipb_already_blocked', $block->getTarget() ] ];
967 # Otherwise, try to update the block...
969 # This returns direct blocks before autoblocks/rangeblocks, since we should
970 # be sure the user is blocked by now it should work for our purposes
971 $currentBlock = DatabaseBlock::newFromTarget(
$target );
973 $logger = LoggerFactory::getInstance(
'BlockManager' );
974 $logger->warning(
'Block could not be inserted. No existing block was found.' );
975 return [ [
'ipb-block-not-found', $block->getTarget() ] ];
977 if ( $block->equals( $currentBlock ) ) {
978 return [ [
'ipb_already_blocked', $block->getTarget() ] ];
980 # If the name was hidden and the blocking user cannot hide
981 # names, then don't allow any block changes...
982 if ( $currentBlock->getHideName() && !MediaWikiServices::getInstance()
983 ->getPermissionManager()
984 ->userHasRight( $performer,
'hideuser' )
986 return [
'cant-see-hidden-user' ];
989 $priorBlock = clone $currentBlock;
990 $currentBlock->setBlocker( $performer );
991 $currentBlock->isHardblock( $block->isHardblock() );
992 $currentBlock->isCreateAccountBlocked( $block->isCreateAccountBlocked() );
993 $currentBlock->setExpiry( $block->getExpiry() );
994 $currentBlock->isAutoblocking( $block->isAutoblocking() );
995 $currentBlock->setHideName( $block->getHideName() );
996 $currentBlock->isEmailBlocked( $block->isEmailBlocked() );
997 $currentBlock->isUsertalkEditAllowed( $block->isUsertalkEditAllowed() );
998 $currentBlock->setReason( $block->getReasonComment() );
1002 $currentBlock->isSitewide( $block->isSitewide() );
1005 $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
1006 $currentBlock->setRestrictions(
1007 $blockRestrictionStore->setBlockId( $currentBlock->getId(), $restrictions )
1010 $status = $currentBlock->update();
1013 $logaction =
'reblock';
1015 # Unset _deleted fields if requested
1016 if ( $currentBlock->getHideName() && !$data[
'HideUser'] ) {
1020 # If hiding/unhiding a name, this should go in the private logs
1021 if ( (
bool)$currentBlock->getHideName() ) {
1022 $data[
'HideUser'] =
true;
1025 $block = $currentBlock;
1028 $logaction =
'block';
1031 Hooks::runner()->onBlockIpComplete( $block, $performer, $priorBlock );
1033 # Set *_deleted fields if requested
1034 if ( $data[
'HideUser'] ) {
1038 # Can't watch a rangeblock
1039 if (
$type != DatabaseBlock::TYPE_RANGE && $data[
'Watch'] ) {
1043 User::IGNORE_USER_RIGHTS
1047 # DatabaseBlock constructor sanitizes certain block options on insert
1048 $data[
'BlockEmail'] = $block->isEmailBlocked();
1049 $data[
'AutoBlock'] = $block->isAutoblocking();
1051 # Prepare log parameters
1054 $rawExpiry = $data[
'Expiry'];
1055 $logExpiry =
wfIsInfinity( $rawExpiry ) ?
'infinity' : $rawExpiry;
1057 $logParams[
'5::duration'] = $logExpiry;
1058 $logParams[
'6::flags'] = self::blockLogFlags( $data,
$type );
1059 $logParams[
'sitewide'] = $block->isSitewide();
1061 if ( !$block->isSitewide() ) {
1062 if ( $data[
'PageRestrictions'] !==
'' ) {
1063 $logParams[
'7::restrictions'][
'pages'] = explode(
"\n", $data[
'PageRestrictions'] );
1066 if ( $data[
'NamespaceRestrictions'] !==
'' ) {
1067 $logParams[
'7::restrictions'][
'namespaces'] = explode(
"\n", $data[
'NamespaceRestrictions'] );
1071 # Make log entry, if the name is hidden, put it in the suppression log
1072 $log_type = $data[
'HideUser'] ?
'suppress' :
'block';
1075 $logEntry->setComment( $blockReason );
1076 $logEntry->setPerformer( $performer );
1077 $logEntry->setParameters( $logParams );
1078 # Relate log ID to block ID (T27763)
1079 $logEntry->setRelations( [
'ipb_id' => $block->getId() ] );
1080 $logId = $logEntry->insert();
1082 if ( !empty( $data[
'Tags'] ) ) {
1083 $logEntry->addTags( $data[
'Tags'] );
1086 $logEntry->publish( $logId );
1102 $msg =
$lang ===
null
1103 ?
wfMessage(
'ipboptions' )->inContentLanguage()->text()
1106 if ( $msg ==
'-' ) {
1112 if ( $a && $includeOther ) {
1115 $a[
wfMessage(
'ipbother' )->text() ] =
'other';
1137 $expiry = strtotime( $expiry );
1139 if ( $expiry < 0 || $expiry ===
false ) {
1156 ->userHasRight( $user,
'blockemail' ) );
1173 return MediaWikiServices::getInstance()
1174 ->getBlockPermissionCheckerFactory()
1175 ->newBlockPermissionChecker(
$target, $performer )
1176 ->checkBlockPermissions();
1187 $config = RequestContext::getMain()->getConfig();
1189 $blockAllowsUTEdit = $config->get(
'BlockAllowsUTEdit' );
1193 # when blocking a user the option 'anononly' is not available/has no effect
1194 # -> do not write this into log
1195 if ( !$data[
'HardBlock'] &&
$type != DatabaseBlock::TYPE_USER ) {
1197 $flags[] =
'anononly';
1200 if ( $data[
'CreateAccount'] ) {
1202 $flags[] =
'nocreate';
1205 # Same as anononly, this is not displayed when blocking an IP address
1206 if ( !$data[
'AutoBlock'] &&
$type == DatabaseBlock::TYPE_USER ) {
1208 $flags[] =
'noautoblock';
1211 if ( $data[
'DisableEmail'] ) {
1213 $flags[] =
'noemail';
1216 if ( $blockAllowsUTEdit && $data[
'DisableUTEdit'] ) {
1218 $flags[] =
'nousertalk';
1221 if ( $data[
'HideUser'] ) {
1223 $flags[] =
'hiddenname';
1226 return implode(
',', $flags );
1238 if ( isset( $data[
'Editing'] ) && $data[
'Editing'] ===
false ) {
1239 $data[
'EditingRestriction'] =
'partial';
1240 $data[
'PageRestrictions'] =
'';
1241 $data[
'NamespaceRestrictions'] =
'';
1243 return self::processForm( $data, $form->getContext() );
1252 $out->setPageTitle( $this->
msg(
'blockipsuccesssub' ) );
1253 $out->addWikiMsg(
'blockipsuccesstext',
wfEscapeWikiText( $this->target ) );
1265 $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.
Pre-librarized class name for IPUtils.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
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",...
__construct(PermissionManager $permissionManager)
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.
PermissionManager $permissionManager
static checkUnblockSelf( $target, User $performer)
T17810: Sitewide blocked admins should not be able to block/unblock others with one exception; they c...
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.
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.
getUserPage()
Get this user's personal page title.
isAnon()
Get whether the user is anonymous.
static doWatch(Title $title, User $user, $checkRights=User::CHECK_USER_RIGHTS, ?string $expiry=null)
Watch a page.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
static parseOptionsMessage(string $msg)
Parse labels and values out of a comma- and colon-separated list of options, such as is used for expi...
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
if(!isset( $args[0])) $lang