| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Specials; |
| 22 |
|
| 23 |
use ErrorPageError; |
| 24 |
use HtmlArmor; |
| 25 |
use LogEventsList; |
| 26 |
use MediaWiki\Block\BlockActionInfo; |
| 27 |
use MediaWiki\Block\BlockPermissionCheckerFactory; |
| 28 |
use MediaWiki\Block\BlockUser; |
| 29 |
use MediaWiki\Block\BlockUserFactory; |
| 30 |
use MediaWiki\Block\BlockUtils; |
| 31 |
use MediaWiki\Block\DatabaseBlock; |
| 32 |
use MediaWiki\Block\DatabaseBlockStore; |
| 33 |
use MediaWiki\Block\Restriction\ActionRestriction; |
| 34 |
use MediaWiki\Block\Restriction\NamespaceRestriction; |
| 35 |
use MediaWiki\Block\Restriction\PageRestriction; |
| 36 |
use MediaWiki\CommentStore\CommentStore; |
| 37 |
use MediaWiki\Context\IContextSource; |
| 38 |
use MediaWiki\Html\Html; |
| 39 |
use MediaWiki\HTMLForm\HTMLForm; |
| 40 |
use MediaWiki\Language\Language; |
| 41 |
use MediaWiki\MainConfigNames; |
| 42 |
use MediaWiki\MediaWikiServices; |
| 43 |
use MediaWiki\Message\Message; |
| 44 |
use MediaWiki\Page\PageReference; |
| 45 |
use MediaWiki\Page\PageReferenceValue; |
| 46 |
use MediaWiki\Permissions\Authority; |
| 47 |
use MediaWiki\Request\WebRequest; |
| 48 |
use MediaWiki\SpecialPage\FormSpecialPage; |
| 49 |
use MediaWiki\SpecialPage\SpecialPage; |
| 50 |
use MediaWiki\Status\Status; |
| 51 |
use MediaWiki\Title\NamespaceInfo; |
| 52 |
use MediaWiki\Title\Title; |
| 53 |
use MediaWiki\Title\TitleFormatter; |
| 54 |
use MediaWiki\User\User; |
| 55 |
use MediaWiki\User\UserIdentity; |
| 56 |
use MediaWiki\User\UserNamePrefixSearch; |
| 57 |
use MediaWiki\User\UserNameUtils; |
| 58 |
use OOUI\FieldLayout; |
| 59 |
use OOUI\HtmlSnippet; |
| 60 |
use OOUI\LabelWidget; |
| 61 |
use OOUI\Widget; |
| 62 |
use Wikimedia\IPUtils; |
| 63 |
use Wikimedia\Message\MessageSpecifier; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
class SpecialBlock extends FormSpecialPage { |
| 72 |
|
| 73 |
private BlockUtils $blockUtils; |
| 74 |
private BlockPermissionCheckerFactory $blockPermissionCheckerFactory; |
| 75 |
private BlockUserFactory $blockUserFactory; |
| 76 |
private DatabaseBlockStore $blockStore; |
| 77 |
private UserNameUtils $userNameUtils; |
| 78 |
private UserNamePrefixSearch $userNamePrefixSearch; |
| 79 |
private BlockActionInfo $blockActionInfo; |
| 80 |
private TitleFormatter $titleFormatter; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
protected $target; |
| 86 |
|
| 87 |
|
| 88 |
protected $type; |
| 89 |
|
| 90 |
|
| 91 |
protected $previousTarget; |
| 92 |
|
| 93 |
|
| 94 |
protected $requestedHideUser; |
| 95 |
|
| 96 |
|
| 97 |
protected $alreadyBlocked; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
protected $preErrors = []; |
| 103 |
|
| 104 |
|
| 105 |
protected bool $useCodex = false; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
protected array $codexFormData = []; |
| 111 |
|
| 112 |
private NamespaceInfo $namespaceInfo; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
public function __construct( |
| 126 |
BlockUtils $blockUtils, |
| 127 |
BlockPermissionCheckerFactory $blockPermissionCheckerFactory, |
| 128 |
BlockUserFactory $blockUserFactory, |
| 129 |
DatabaseBlockStore $blockStore, |
| 130 |
UserNameUtils $userNameUtils, |
| 131 |
UserNamePrefixSearch $userNamePrefixSearch, |
| 132 |
BlockActionInfo $blockActionInfo, |
| 133 |
TitleFormatter $titleFormatter, |
| 134 |
NamespaceInfo $namespaceInfo |
| 135 |
) { |
| 136 |
parent::__construct( 'Block', 'block' ); |
| 137 |
|
| 138 |
$this->blockUtils = $blockUtils; |
| 139 |
$this->blockPermissionCheckerFactory = $blockPermissionCheckerFactory; |
| 140 |
$this->blockUserFactory = $blockUserFactory; |
| 141 |
$this->blockStore = $blockStore; |
| 142 |
$this->userNameUtils = $userNameUtils; |
| 143 |
$this->userNamePrefixSearch = $userNamePrefixSearch; |
| 144 |
$this->blockActionInfo = $blockActionInfo; |
| 145 |
$this->titleFormatter = $titleFormatter; |
| 146 |
$this->namespaceInfo = $namespaceInfo; |
| 147 |
$this->useCodex = $this->getConfig()->get( MainConfigNames::UseCodexSpecialBlock ) || |
| 148 |
$this->getRequest()->getBool( 'usecodex' ); |
| 149 |
} |
| 150 |
|
| 151 |
public function execute( $par ) { |
| 152 |
parent::execute( $par ); |
| 153 |
|
| 154 |
if ( $this->useCodex ) { |
| 155 |
$this->codexFormData[ 'blockTargetUser' ] = $this->target instanceof UserIdentity ? |
| 156 |
$this->target->getName() : |
| 157 |
$this->target ?? null; |
| 158 |
$this->getOutput()->addJsConfigVars( $this->codexFormData ); |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
public function doesWrites() { |
| 163 |
return true; |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
protected function checkExecutePermissions( User $user ) { |
| 173 |
parent::checkExecutePermissions( $user ); |
| 174 |
|
| 175 |
$status = $this->blockPermissionCheckerFactory |
| 176 |
->newBlockPermissionChecker( $this->target, $user ) |
| 177 |
->checkBlockPermissions(); |
| 178 |
if ( $status !== true ) { |
| 179 |
throw new ErrorPageError( 'badaccess', $status ); |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
public function requiresUnblock() { |
| 189 |
return false; |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
protected function setParameter( $par ) { |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
$request = $this->getRequest(); |
| 202 |
[ $this->target, $this->type ] = $this->getTargetAndTypeInternal( $par, $request ); |
| 203 |
if ( $this->target instanceof UserIdentity ) { |
| 204 |
|
| 205 |
|
| 206 |
$this->getSkin()->setRelevantUser( $this->target ); |
| 207 |
} |
| 208 |
|
| 209 |
[ $this->previousTarget, ] = $this->blockUtils |
| 210 |
->parseBlockTarget( $request->getVal( 'wpPreviousTarget' ) ); |
| 211 |
$this->requestedHideUser = $request->getBool( 'wpHideUser' ); |
| 212 |
|
| 213 |
if ( $this->useCodex ) { |
| 214 |
|
| 215 |
$givenExpiry = $request->getVal( 'wpExpiry', '' ); |
| 216 |
if ( wfIsInfinity( $givenExpiry ) ) { |
| 217 |
$this->codexFormData[ 'blockExpiryPreset' ] = 'infinite'; |
| 218 |
} else { |
| 219 |
$expiry = date_parse( $givenExpiry ); |
| 220 |
$this->codexFormData[ 'blockExpiryPreset' ] = isset( $expiry[ 'relative' ] ) ? |
| 221 |
|
| 222 |
$givenExpiry : |
| 223 |
|
| 224 |
$this->formatExpiryForHtml( $request->getVal( 'wpExpiry', '' ) ); |
| 225 |
} |
| 226 |
|
| 227 |
$this->codexFormData[ 'blockTypePreset' ] = |
| 228 |
$request->getVal( 'wpEditingRestriction' ) === 'sitewide' || |
| 229 |
$request->getVal( 'wpEditingRestriction' ) === 'partial' ? |
| 230 |
$request->getVal( 'wpEditingRestriction' ) : |
| 231 |
'sitewide'; |
| 232 |
$this->codexFormData[ 'blockReasonPreset' ] = $request->getVal( 'wpReason' ); |
| 233 |
$this->codexFormData[ 'blockReasonOtherPreset' ] = $request->getVal( 'wpReason-other' ); |
| 234 |
$blockAdditionalDetailsPreset = $blockDetailsPreset = []; |
| 235 |
|
| 236 |
if ( $request->getBool( 'wpCreateAccount' ) ) { |
| 237 |
$blockDetailsPreset[] = 'wpCreateAccount'; |
| 238 |
} |
| 239 |
|
| 240 |
if ( $request->getBool( 'wpDisableEmail' ) ) { |
| 241 |
$blockDetailsPreset[] = 'wpDisableEmail'; |
| 242 |
} |
| 243 |
|
| 244 |
if ( $request->getBool( 'wpDisableUTEdit' ) ) { |
| 245 |
$blockDetailsPreset[] = 'wpDisableUTEdit'; |
| 246 |
} |
| 247 |
|
| 248 |
if ( $request->getVal( 'wpAutoBlock' ) !== '0' ) { |
| 249 |
$blockAdditionalDetailsPreset[] = 'wpAutoBlock'; |
| 250 |
} |
| 251 |
|
| 252 |
if ( $request->getBool( 'wpWatch' ) ) { |
| 253 |
$blockAdditionalDetailsPreset[] = 'wpWatch'; |
| 254 |
} |
| 255 |
|
| 256 |
if ( $request->getBool( 'wpHideName' ) ) { |
| 257 |
$blockAdditionalDetailsPreset[] = 'wpHideName'; |
| 258 |
} |
| 259 |
|
| 260 |
if ( $request->getBool( 'wpHardBlock' ) ) { |
| 261 |
$blockAdditionalDetailsPreset[] = 'wpHardBlock'; |
| 262 |
} |
| 263 |
|
| 264 |
$this->codexFormData[ 'blockDetailsPreset' ] = $blockDetailsPreset; |
| 265 |
$this->codexFormData[ 'blockAdditionalDetailsPreset' ] = $blockAdditionalDetailsPreset; |
| 266 |
$this->codexFormData[ 'blockPageRestrictions' ] = $request->getVal( 'wpPageRestrictions' ); |
| 267 |
$this->codexFormData[ 'blockNamespaceRestrictions' ] = $request->getVal( 'wpNamespaceRestrictions' ); |
| 268 |
} |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
protected function alterForm( HTMLForm $form ) { |
| 277 |
$form->setHeaderHtml( '' ); |
| 278 |
$form->setSubmitDestructive(); |
| 279 |
|
| 280 |
$msg = $this->alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit'; |
| 281 |
$form->setSubmitTextMsg( $msg ); |
| 282 |
|
| 283 |
$this->addHelpLink( 'Help:Blocking users' ); |
| 284 |
|
| 285 |
|
| 286 |
if ( !$this->getRequest()->wasPosted() && $this->preErrors ) { |
| 287 |
|
| 288 |
$form->addHeaderHtml( (string)new FieldLayout( |
| 289 |
new Widget( [] ), |
| 290 |
[ |
| 291 |
'align' => 'top', |
| 292 |
'errors' => array_map( function ( $errMsg ) { |
| 293 |
return new HtmlSnippet( $this->msg( $errMsg )->parse() ); |
| 294 |
}, $this->preErrors ), |
| 295 |
] |
| 296 |
) ); |
| 297 |
|
| 298 |
if ( $this->useCodex ) { |
| 299 |
$this->codexFormData[ 'blockPreErrors' ] = array_map( function ( $errMsg ) { |
| 300 |
return $this->msg( $errMsg )->parse(); |
| 301 |
}, $this->preErrors ); |
| 302 |
} |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
protected function getDisplayFormat() { |
| 307 |
return $this->useCodex ? 'codex' : 'ooui'; |
| 308 |
} |
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
protected function getFormFields() { |
| 315 |
$conf = $this->getConfig(); |
| 316 |
$blockAllowsUTEdit = $conf->get( MainConfigNames::BlockAllowsUTEdit ); |
| 317 |
|
| 318 |
$this->getOutput()->enableOOUI(); |
| 319 |
|
| 320 |
$user = $this->getUser(); |
| 321 |
|
| 322 |
$suggestedDurations = $this->getLanguage()->getBlockDurations(); |
| 323 |
|
| 324 |
$this->codexFormData[ 'blockEnableMultiblocks' ] = $conf->get( MainConfigNames::EnableMultiBlocks ) || |
| 325 |
$this->getRequest()->getBool( 'multiblocks' ); |
| 326 |
|
| 327 |
$a = []; |
| 328 |
|
| 329 |
$a['Target'] = [ |
| 330 |
'type' => 'user', |
| 331 |
'ipallowed' => true, |
| 332 |
'iprange' => true, |
| 333 |
'id' => 'mw-bi-target', |
| 334 |
'size' => '45', |
| 335 |
'autofocus' => true, |
| 336 |
'required' => true, |
| 337 |
'placeholder' => $this->msg( 'block-target-placeholder' )->text(), |
| 338 |
'validation-callback' => function ( $value, $alldata, $form ) { |
| 339 |
$status = $this->blockUtils->validateTarget( $value ); |
| 340 |
if ( !$status->isOK() ) { |
| 341 |
$errors = $status->getMessages(); |
| 342 |
return $form->msg( $errors[0] ); |
| 343 |
} |
| 344 |
return true; |
| 345 |
}, |
| 346 |
'section' => 'target', |
| 347 |
]; |
| 348 |
|
| 349 |
$editingRestrictionOptions = $this->useCodex ? |
| 350 |
|
| 351 |
[ |
| 352 |
'options-messages' => [ |
| 353 |
'ipb-sitewide' => 'sitewide', |
| 354 |
'ipb-partial' => 'partial' |
| 355 |
], |
| 356 |
'option-descriptions-messages' => [ |
| 357 |
'sitewide' => 'ipb-sitewide-help', |
| 358 |
'partial' => 'ipb-partial-help' |
| 359 |
], |
| 360 |
'option-descriptions-messages-parse' => true, |
| 361 |
] : |
| 362 |
|
| 363 |
[ |
| 364 |
'options' => [ |
| 365 |
$this->msg( 'ipb-sitewide' )->escaped() . |
| 366 |
new LabelWidget( [ |
| 367 |
'classes' => [ 'oo-ui-inline-help' ], |
| 368 |
'label' => new HtmlSnippet( $this->msg( 'ipb-sitewide-help' )->parse() ), |
| 369 |
] ) => 'sitewide', |
| 370 |
$this->msg( 'ipb-partial' )->escaped() . |
| 371 |
new LabelWidget( [ |
| 372 |
'classes' => [ 'oo-ui-inline-help' ], |
| 373 |
'label' => new HtmlSnippet( $this->msg( 'ipb-partial-help' )->parse() ), |
| 374 |
] ) => 'partial', |
| 375 |
] |
| 376 |
]; |
| 377 |
|
| 378 |
$a['EditingRestriction'] = [ |
| 379 |
'type' => 'radio', |
| 380 |
'cssclass' => 'mw-block-editing-restriction', |
| 381 |
'default' => 'sitewide', |
| 382 |
'section' => 'actions', |
| 383 |
] + $editingRestrictionOptions; |
| 384 |
|
| 385 |
$a['PageRestrictions'] = [ |
| 386 |
'type' => 'titlesmultiselect', |
| 387 |
'label' => $this->msg( 'ipb-pages-label' )->text(), |
| 388 |
'exists' => true, |
| 389 |
'max' => 10, |
| 390 |
'cssclass' => 'mw-htmlform-checkradio-indent mw-block-partial-restriction', |
| 391 |
'default' => '', |
| 392 |
'showMissing' => false, |
| 393 |
'excludeDynamicNamespaces' => true, |
| 394 |
'input' => [ |
| 395 |
'autocomplete' => false |
| 396 |
], |
| 397 |
'section' => 'actions', |
| 398 |
]; |
| 399 |
|
| 400 |
$a['NamespaceRestrictions'] = [ |
| 401 |
'type' => 'namespacesmultiselect', |
| 402 |
'label' => $this->msg( 'ipb-namespaces-label' )->text(), |
| 403 |
'exists' => true, |
| 404 |
'cssclass' => 'mw-htmlform-checkradio-indent mw-block-partial-restriction', |
| 405 |
'default' => '', |
| 406 |
'input' => [ |
| 407 |
'autocomplete' => false |
| 408 |
], |
| 409 |
'section' => 'actions', |
| 410 |
]; |
| 411 |
|
| 412 |
if ( $conf->get( MainConfigNames::EnablePartialActionBlocks ) ) { |
| 413 |
$blockActions = $this->blockActionInfo->getAllBlockActions(); |
| 414 |
$optionMessages = array_combine( |
| 415 |
array_map( static function ( $action ) { |
| 416 |
return "ipb-action-$action"; |
| 417 |
}, array_keys( $blockActions ) ), |
| 418 |
$blockActions |
| 419 |
); |
| 420 |
|
| 421 |
$this->codexFormData[ 'partialBlockActionOptions'] = $optionMessages; |
| 422 |
|
| 423 |
$a['ActionRestrictions'] = [ |
| 424 |
'type' => 'multiselect', |
| 425 |
'cssclass' => 'mw-htmlform-checkradio-indent mw-block-partial-restriction mw-block-action-restriction', |
| 426 |
'options-messages' => $optionMessages, |
| 427 |
'section' => 'actions', |
| 428 |
]; |
| 429 |
} |
| 430 |
|
| 431 |
$a['CreateAccount'] = [ |
| 432 |
'type' => 'check', |
| 433 |
'cssclass' => 'mw-block-restriction', |
| 434 |
'label-message' => 'ipbcreateaccount', |
| 435 |
'default' => true, |
| 436 |
'section' => 'details', |
| 437 |
]; |
| 438 |
|
| 439 |
if ( $this->blockPermissionCheckerFactory |
| 440 |
->newBlockPermissionChecker( null, $user ) |
| 441 |
->checkEmailPermissions() |
| 442 |
) { |
| 443 |
$a['DisableEmail'] = [ |
| 444 |
'type' => 'check', |
| 445 |
'cssclass' => 'mw-block-restriction', |
| 446 |
'label-message' => 'ipbemailban', |
| 447 |
'section' => 'details', |
| 448 |
]; |
| 449 |
|
| 450 |
$this->codexFormData[ 'blockAllowsEmailBan'] = true; |
| 451 |
} |
| 452 |
|
| 453 |
if ( $blockAllowsUTEdit ) { |
| 454 |
$a['DisableUTEdit'] = [ |
| 455 |
'type' => 'check', |
| 456 |
'cssclass' => 'mw-block-restriction', |
| 457 |
'label-message' => 'ipb-disableusertalk', |
| 458 |
'default' => false, |
| 459 |
'section' => 'details', |
| 460 |
]; |
| 461 |
|
| 462 |
$this->codexFormData[ 'blockAllowsUTEdit'] = true; |
| 463 |
} |
| 464 |
|
| 465 |
$defaultExpiry = $this->msg( 'ipb-default-expiry' )->inContentLanguage(); |
| 466 |
if ( $this->type === DatabaseBlock::TYPE_RANGE || $this->type === DatabaseBlock::TYPE_IP ) { |
| 467 |
$defaultExpiryIP = $this->msg( 'ipb-default-expiry-ip' )->inContentLanguage(); |
| 468 |
if ( !$defaultExpiryIP->isDisabled() ) { |
| 469 |
$defaultExpiry = $defaultExpiryIP; |
| 470 |
} |
| 471 |
} |
| 472 |
|
| 473 |
$a['Expiry'] = [ |
| 474 |
'type' => 'expiry', |
| 475 |
'required' => true, |
| 476 |
'options' => $suggestedDurations, |
| 477 |
'default' => $defaultExpiry->text(), |
| 478 |
'section' => 'expiry', |
| 479 |
]; |
| 480 |
$this->codexFormData[ 'blockExpiryOptions' ] = $suggestedDurations; |
| 481 |
$this->codexFormData[ 'blockExpiryDefault' ] = $defaultExpiry->text(); |
| 482 |
|
| 483 |
$a['Reason'] = [ |
| 484 |
'type' => 'selectandother', |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT, |
| 489 |
'maxlength-unit' => 'codepoints', |
| 490 |
'options-message' => 'ipbreason-dropdown', |
| 491 |
'section' => 'reason', |
| 492 |
]; |
| 493 |
|
| 494 |
if ( $this->useCodex ) { |
| 495 |
$blockReasonOptions = Html::listDropdownOptionsCodex( |
| 496 |
Html::listDropdownOptions( $this->msg( 'ipbreason-dropdown' )->plain(), |
| 497 |
[ 'other' => $this->msg( 'htmlform-selectorother-other' )->text() ] |
| 498 |
) ); |
| 499 |
$this->codexFormData[ 'blockReasonOptions' ] = $blockReasonOptions; |
| 500 |
$this->codexFormData[ 'blockReasonMaxLength' ] = CommentStore::COMMENT_CHARACTER_LIMIT; |
| 501 |
} |
| 502 |
|
| 503 |
$a['AutoBlock'] = [ |
| 504 |
'type' => 'check', |
| 505 |
'label-message' => [ |
| 506 |
'ipbenableautoblock', |
| 507 |
Message::durationParam( $conf->get( MainConfigNames::AutoblockExpiry ) ) |
| 508 |
], |
| 509 |
'default' => true, |
| 510 |
'section' => 'options', |
| 511 |
]; |
| 512 |
$this->codexFormData['blockAutoblockExpiry'] = $this->getLanguage() |
| 513 |
->formatDuration( $conf->get( MainConfigNames::AutoblockExpiry ) ); |
| 514 |
|
| 515 |
|
| 516 |
if ( $this->getAuthority()->isAllowed( 'hideuser' ) ) { |
| 517 |
$a['HideUser'] = [ |
| 518 |
'type' => 'check', |
| 519 |
'label-message' => 'ipbhidename', |
| 520 |
'cssclass' => 'mw-block-hideuser', |
| 521 |
'section' => 'options', |
| 522 |
]; |
| 523 |
|
| 524 |
$this->codexFormData['blockHideUser'] = true; |
| 525 |
} |
| 526 |
|
| 527 |
|
| 528 |
if ( $user->isRegistered() ) { |
| 529 |
$a['Watch'] = [ |
| 530 |
'type' => 'check', |
| 531 |
'label-message' => 'ipbwatchuser', |
| 532 |
'section' => 'options', |
| 533 |
]; |
| 534 |
} |
| 535 |
|
| 536 |
$a['HardBlock'] = [ |
| 537 |
'type' => 'check', |
| 538 |
'label-message' => 'ipb-hardblock', |
| 539 |
'default' => false, |
| 540 |
'section' => 'options', |
| 541 |
]; |
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
$a['PreviousTarget'] = [ |
| 546 |
'type' => 'hidden', |
| 547 |
'default' => false, |
| 548 |
]; |
| 549 |
|
| 550 |
|
| 551 |
$a['Confirm'] = [ |
| 552 |
'type' => 'hidden', |
| 553 |
'default' => '', |
| 554 |
'label-message' => 'ipb-confirm', |
| 555 |
'cssclass' => 'mw-block-confirm', |
| 556 |
]; |
| 557 |
|
| 558 |
$this->maybeAlterFormDefaults( $a ); |
| 559 |
|
| 560 |
|
| 561 |
$this->getHookRunner()->onSpecialBlockModifyFormFields( $this, $a ); |
| 562 |
|
| 563 |
return $a; |
| 564 |
} |
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
protected function maybeAlterFormDefaults( &$fields ) { |
| 572 |
|
| 573 |
$fields['Target']['default'] = (string)$this->target; |
| 574 |
|
| 575 |
if ( $this->target ) { |
| 576 |
$status = $this->blockUtils->validateTarget( $this->target ); |
| 577 |
if ( !$status->isOK() ) { |
| 578 |
$errors = $status->getMessages( 'error' ); |
| 579 |
$this->preErrors = array_merge( $this->preErrors, $errors ); |
| 580 |
} |
| 581 |
} |
| 582 |
|
| 583 |
|
| 584 |
$fields['PreviousTarget']['default'] = (string)$this->target; |
| 585 |
|
| 586 |
$block = $this->blockStore->newFromTarget( $this->target ); |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
if ( $block instanceof DatabaseBlock && $block->getType() !== DatabaseBlock::TYPE_AUTO |
| 591 |
&& ( $this->type != DatabaseBlock::TYPE_RANGE |
| 592 |
|| ( $this->target && $block->isBlocking( $this->target ) ) ) |
| 593 |
) { |
| 594 |
$fields['HardBlock']['default'] = $block->isHardblock(); |
| 595 |
$fields['CreateAccount']['default'] = $block->isCreateAccountBlocked(); |
| 596 |
$fields['AutoBlock']['default'] = $block->isAutoblocking(); |
| 597 |
|
| 598 |
if ( isset( $fields['DisableEmail'] ) ) { |
| 599 |
$fields['DisableEmail']['default'] = $block->isEmailBlocked(); |
| 600 |
} |
| 601 |
|
| 602 |
if ( isset( $fields['HideUser'] ) ) { |
| 603 |
$fields['HideUser']['default'] = $block->getHideName(); |
| 604 |
} |
| 605 |
|
| 606 |
if ( isset( $fields['DisableUTEdit'] ) ) { |
| 607 |
$fields['DisableUTEdit']['default'] = !$block->isUsertalkEditAllowed(); |
| 608 |
} |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
if ( !$block->getHideName() || $this->getAuthority()->isAllowed( 'hideuser' ) ) { |
| 613 |
$fields['Reason']['default'] = $block->getReasonComment()->text; |
| 614 |
} else { |
| 615 |
$fields['Reason']['default'] = ''; |
| 616 |
} |
| 617 |
|
| 618 |
if ( $this->getRequest()->wasPosted() ) { |
| 619 |
|
| 620 |
|
| 621 |
$fields['Confirm']['type'] = 'check'; |
| 622 |
} else { |
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
$fields['Confirm']['default'] = 1; |
| 627 |
} |
| 628 |
|
| 629 |
if ( $block->getExpiry() == 'infinity' ) { |
| 630 |
$fields['Expiry']['default'] = $this->codexFormData[ 'blockExpiryDefault' ] = 'infinite'; |
| 631 |
} else { |
| 632 |
$fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->getExpiry() ); |
| 633 |
|
| 634 |
|
| 635 |
if ( !isset( $this->codexFormData[ 'blockExpiryPreset' ] ) ) { |
| 636 |
$this->codexFormData[ 'blockExpiryPreset' ] = $this->formatExpiryForHtml( $block->getExpiry() ); |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
if ( !$block->isSitewide() ) { |
| 641 |
$fields['EditingRestriction']['default'] = |
| 642 |
$this->codexFormData[ 'blockTypePreset' ] = 'partial'; |
| 643 |
|
| 644 |
$pageRestrictions = []; |
| 645 |
$namespaceRestrictions = []; |
| 646 |
foreach ( $block->getRestrictions() as $restriction ) { |
| 647 |
if ( $restriction instanceof PageRestriction && $restriction->getTitle() ) { |
| 648 |
$pageRestrictions[] = $restriction->getTitle()->getPrefixedText(); |
| 649 |
} elseif ( $restriction instanceof NamespaceRestriction && |
| 650 |
$this->namespaceInfo->exists( $restriction->getValue() ) |
| 651 |
) { |
| 652 |
$namespaceRestrictions[] = $restriction->getValue(); |
| 653 |
} |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
sort( $pageRestrictions ); |
| 658 |
$fields['PageRestrictions']['default'] = |
| 659 |
$this->codexFormData[ 'blockPageRestrictions' ] = implode( "\n", $pageRestrictions ); |
| 660 |
sort( $namespaceRestrictions ); |
| 661 |
$fields['NamespaceRestrictions']['default'] = |
| 662 |
$this->codexFormData[ 'blockNamespaceRestrictions' ] = implode( "\n", $namespaceRestrictions ); |
| 663 |
|
| 664 |
if ( $this->getConfig()->get( MainConfigNames::EnablePartialActionBlocks ) ) { |
| 665 |
$actionRestrictions = []; |
| 666 |
foreach ( $block->getRestrictions() as $restriction ) { |
| 667 |
if ( $restriction instanceof ActionRestriction ) { |
| 668 |
$actionRestrictions[] = $restriction->getValue(); |
| 669 |
} |
| 670 |
} |
| 671 |
$fields['ActionRestrictions']['default'] = $actionRestrictions; |
| 672 |
} |
| 673 |
} |
| 674 |
|
| 675 |
$this->alreadyBlocked = true; |
| 676 |
$this->codexFormData[ 'blockAlreadyBlocked' ] = $this->alreadyBlocked; |
| 677 |
$this->preErrors[] = $this->msg( 'ipb-needreblock', wfEscapeWikiText( $block->getTargetName() ) ); |
| 678 |
} |
| 679 |
|
| 680 |
if ( $this->alreadyBlocked || $this->getRequest()->wasPosted() |
| 681 |
|| $this->getRequest()->getCheck( 'wpCreateAccount' ) |
| 682 |
) { |
| 683 |
$this->getOutput()->addJsConfigVars( 'wgCreateAccountDirty', true ); |
| 684 |
} |
| 685 |
|
| 686 |
|
| 687 |
if ( $this->requestedHideUser ) { |
| 688 |
$fields['Confirm']['type'] = 'check'; |
| 689 |
unset( $fields['Confirm']['default'] ); |
| 690 |
$this->preErrors[] = $this->msg( 'ipb-confirmhideuser', 'ipb-confirmaction' ); |
| 691 |
} |
| 692 |
|
| 693 |
|
| 694 |
if ( (string)$this->target === $this->getUser()->getName() ) { |
| 695 |
$fields['Confirm']['type'] = 'check'; |
| 696 |
unset( $fields['Confirm']['default'] ); |
| 697 |
$this->preErrors[] = $this->msg( 'ipb-blockingself', 'ipb-confirmaction' ); |
| 698 |
} |
| 699 |
} |
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
private function formatExpiryForHtml( string $expiry ): string { |
| 708 |
if ( preg_match( '/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/', $expiry ) === 1 ) { |
| 709 |
|
| 710 |
return substr( $expiry, 0, 16 ); |
| 711 |
} elseif ( $expiry === '' ) { |
| 712 |
|
| 713 |
return ''; |
| 714 |
} |
| 715 |
return substr( wfTimestamp( TS_ISO_8601, $expiry ), 0, 16 ); |
| 716 |
} |
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
protected function preHtml() { |
| 723 |
$this->getOutput()->addModuleStyles( [ 'mediawiki.special' ] ); |
| 724 |
if ( $this->useCodex ) { |
| 725 |
$this->getOutput()->addModules( [ 'mediawiki.special.block.codex' ] ); |
| 726 |
} else { |
| 727 |
$this->getOutput()->addModules( [ 'mediawiki.special.block' ] ); |
| 728 |
} |
| 729 |
|
| 730 |
$blockCIDRLimit = $this->getConfig()->get( MainConfigNames::BlockCIDRLimit ); |
| 731 |
$text = $this->msg( 'blockiptext', $blockCIDRLimit['IPv4'], $blockCIDRLimit['IPv6'] )->parse(); |
| 732 |
|
| 733 |
$otherBlockMessages = []; |
| 734 |
if ( $this->target !== null ) { |
| 735 |
$targetName = $this->target; |
| 736 |
if ( $this->target instanceof UserIdentity ) { |
| 737 |
$targetName = $this->target->getName(); |
| 738 |
} |
| 739 |
|
| 740 |
$this->getHookRunner()->onOtherBlockLogLink( |
| 741 |
$otherBlockMessages, $targetName ); |
| 742 |
|
| 743 |
if ( count( $otherBlockMessages ) ) { |
| 744 |
$s = Html::rawElement( |
| 745 |
'h2', |
| 746 |
[], |
| 747 |
$this->msg( 'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse() |
| 748 |
) . "\n"; |
| 749 |
|
| 750 |
$list = ''; |
| 751 |
|
| 752 |
foreach ( $otherBlockMessages as $link ) { |
| 753 |
$list .= Html::rawElement( 'li', [], $link ) . "\n"; |
| 754 |
} |
| 755 |
|
| 756 |
$s .= Html::rawElement( |
| 757 |
'ul', |
| 758 |
[ 'class' => 'mw-blockip-alreadyblocked' ], |
| 759 |
$list |
| 760 |
) . "\n"; |
| 761 |
|
| 762 |
$text .= $s; |
| 763 |
} |
| 764 |
} |
| 765 |
|
| 766 |
return $text; |
| 767 |
} |
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
protected function postHtml() { |
| 774 |
$links = []; |
| 775 |
|
| 776 |
$this->getOutput()->addModuleStyles( 'mediawiki.special' ); |
| 777 |
|
| 778 |
$linkRenderer = $this->getLinkRenderer(); |
| 779 |
|
| 780 |
if ( $this->target instanceof UserIdentity ) { |
| 781 |
$contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->target->getName() ); |
| 782 |
$links[] = $linkRenderer->makeLink( |
| 783 |
$contribsPage, |
| 784 |
$this->msg( 'ipb-blocklist-contribs', $this->target->getName() )->text() |
| 785 |
); |
| 786 |
} |
| 787 |
|
| 788 |
|
| 789 |
if ( $this->target instanceof UserIdentity ) { |
| 790 |
$message = $this->msg( |
| 791 |
'ipb-unblock-addr', |
| 792 |
wfEscapeWikiText( $this->target->getName() ) |
| 793 |
)->parse(); |
| 794 |
$list = SpecialPage::getTitleFor( 'Unblock', $this->target->getName() ); |
| 795 |
} else { |
| 796 |
$message = $this->msg( 'ipb-unblock' )->parse(); |
| 797 |
$list = SpecialPage::getTitleFor( 'Unblock' ); |
| 798 |
} |
| 799 |
$links[] = $linkRenderer->makeKnownLink( |
| 800 |
$list, |
| 801 |
new HtmlArmor( $message ) |
| 802 |
); |
| 803 |
|
| 804 |
|
| 805 |
$links[] = $linkRenderer->makeKnownLink( |
| 806 |
SpecialPage::getTitleFor( 'BlockList' ), |
| 807 |
$this->msg( 'ipb-blocklist' )->text() |
| 808 |
); |
| 809 |
|
| 810 |
|
| 811 |
if ( $this->getAuthority()->isAllowed( 'editinterface' ) ) { |
| 812 |
$links[] = $linkRenderer->makeKnownLink( |
| 813 |
$this->msg( 'ipbreason-dropdown' )->inContentLanguage()->getTitle(), |
| 814 |
$this->msg( 'ipb-edit-dropdown' )->text(), |
| 815 |
[], |
| 816 |
[ 'action' => 'edit' ] |
| 817 |
); |
| 818 |
} |
| 819 |
|
| 820 |
$text = Html::rawElement( |
| 821 |
'p', |
| 822 |
[ 'class' => 'mw-ipb-conveniencelinks' ], |
| 823 |
$this->getLanguage()->pipeList( $links ) |
| 824 |
); |
| 825 |
|
| 826 |
$userPage = self::getTargetUserTitle( $this->target ); |
| 827 |
if ( $userPage ) { |
| 828 |
|
| 829 |
$out = ''; |
| 830 |
|
| 831 |
LogEventsList::showLogExtract( |
| 832 |
$out, |
| 833 |
'block', |
| 834 |
$userPage, |
| 835 |
'', |
| 836 |
[ |
| 837 |
'lim' => 10, |
| 838 |
'msgKey' => [ |
| 839 |
'blocklog-showlog', |
| 840 |
$this->titleFormatter->getText( $userPage ), |
| 841 |
], |
| 842 |
'showIfEmpty' => false |
| 843 |
] |
| 844 |
); |
| 845 |
$text .= $out; |
| 846 |
|
| 847 |
|
| 848 |
if ( $this->getAuthority()->isAllowed( 'suppressionlog' ) ) { |
| 849 |
LogEventsList::showLogExtract( |
| 850 |
$out, |
| 851 |
'suppress', |
| 852 |
$userPage, |
| 853 |
'', |
| 854 |
[ |
| 855 |
'lim' => 10, |
| 856 |
'conds' => [ 'log_action' => [ 'block', 'reblock', 'unblock' ] ], |
| 857 |
'msgKey' => [ |
| 858 |
'blocklog-showsuppresslog', |
| 859 |
$this->titleFormatter->getText( $userPage ), |
| 860 |
], |
| 861 |
'showIfEmpty' => false |
| 862 |
] |
| 863 |
); |
| 864 |
|
| 865 |
$text .= $out; |
| 866 |
} |
| 867 |
} |
| 868 |
|
| 869 |
return $text; |
| 870 |
} |
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
protected static function getTargetUserTitle( $target ): ?PageReference { |
| 879 |
if ( $target instanceof UserIdentity ) { |
| 880 |
return PageReferenceValue::localReference( NS_USER, $target->getName() ); |
| 881 |
} |
| 882 |
|
| 883 |
if ( is_string( $target ) && IPUtils::isIPAddress( $target ) ) { |
| 884 |
return PageReferenceValue::localReference( NS_USER, $target ); |
| 885 |
} |
| 886 |
|
| 887 |
return null; |
| 888 |
} |
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
private function getTargetAndTypeInternal( ?string $par, WebRequest $request ) { |
| 902 |
$possibleTargets = [ |
| 903 |
$request->getVal( 'wpTarget', null ), |
| 904 |
$par, |
| 905 |
$request->getVal( 'ip', null ), |
| 906 |
|
| 907 |
$request->getVal( 'wpBlockAddress', null ), |
| 908 |
]; |
| 909 |
foreach ( $possibleTargets as $possibleTarget ) { |
| 910 |
$targetAndType = $this->blockUtils |
| 911 |
->parseBlockTarget( $possibleTarget ); |
| 912 |
|
| 913 |
if ( $targetAndType[ 1 ] !== null ) { |
| 914 |
break; |
| 915 |
} |
| 916 |
} |
| 917 |
return $targetAndType; |
| 918 |
} |
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
public static function processForm( array $data, IContextSource $context ) { |
| 930 |
wfDeprecated( __METHOD__, '1.36' ); |
| 931 |
$services = MediaWikiServices::getInstance(); |
| 932 |
return self::processFormInternal( |
| 933 |
$data, |
| 934 |
$context->getAuthority(), |
| 935 |
$services->getBlockUserFactory(), |
| 936 |
$services->getBlockUtils() |
| 937 |
); |
| 938 |
} |
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
private static function processFormInternal( |
| 951 |
array $data, |
| 952 |
Authority $performer, |
| 953 |
BlockUserFactory $blockUserFactory, |
| 954 |
BlockUtils $blockUtils |
| 955 |
) { |
| 956 |
|
| 957 |
$enablePartialActionBlocks = MediaWikiServices::getInstance() |
| 958 |
->getMainConfig()->get( MainConfigNames::EnablePartialActionBlocks ); |
| 959 |
|
| 960 |
$isPartialBlock = isset( $data['EditingRestriction'] ) && |
| 961 |
$data['EditingRestriction'] === 'partial'; |
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
$data['Confirm'] = !in_array( $data['Confirm'], [ '', '0', null, false ], true ); |
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
if ( !isset( $data['HideUser'] ) ) { |
| 970 |
$data['HideUser'] = false; |
| 971 |
} |
| 972 |
|
| 973 |
|
| 974 |
[ $target, $type ] = $blockUtils->parseBlockTarget( $data['Target'] ); |
| 975 |
if ( $type == DatabaseBlock::TYPE_USER ) { |
| 976 |
$target = $target->getName(); |
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
if ( $target === $performer->getUser()->getName() && |
| 986 |
( $data['PreviousTarget'] !== $target || !$data['Confirm'] ) |
| 987 |
) { |
| 988 |
return [ 'ipb-blockingself', 'ipb-confirmaction' ]; |
| 989 |
} |
| 990 |
|
| 991 |
if ( $data['HideUser'] && !$data['Confirm'] ) { |
| 992 |
return [ 'ipb-confirmhideuser', 'ipb-confirmaction' ]; |
| 993 |
} |
| 994 |
} elseif ( $type == DatabaseBlock::TYPE_IP ) { |
| 995 |
$target = $target->getName(); |
| 996 |
} elseif ( $type != DatabaseBlock::TYPE_RANGE ) { |
| 997 |
|
| 998 |
return [ 'badipaddress' ]; |
| 999 |
} |
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
$blockReason = $data['Reason'][0] ?? ''; |
| 1004 |
|
| 1005 |
$pageRestrictions = []; |
| 1006 |
$namespaceRestrictions = []; |
| 1007 |
$actionRestrictions = []; |
| 1008 |
if ( $isPartialBlock ) { |
| 1009 |
if ( isset( $data['PageRestrictions'] ) && $data['PageRestrictions'] !== '' ) { |
| 1010 |
$titles = explode( "\n", $data['PageRestrictions'] ); |
| 1011 |
foreach ( $titles as $title ) { |
| 1012 |
$pageRestrictions[] = PageRestriction::newFromTitle( $title ); |
| 1013 |
} |
| 1014 |
} |
| 1015 |
if ( isset( $data['NamespaceRestrictions'] ) && $data['NamespaceRestrictions'] !== '' ) { |
| 1016 |
$namespaceRestrictions = array_map( static function ( $id ) { |
| 1017 |
return new NamespaceRestriction( 0, (int)$id ); |
| 1018 |
}, explode( "\n", $data['NamespaceRestrictions'] ) ); |
| 1019 |
} |
| 1020 |
if ( |
| 1021 |
$enablePartialActionBlocks && |
| 1022 |
isset( $data['ActionRestrictions'] ) && |
| 1023 |
$data['ActionRestrictions'] !== '' |
| 1024 |
) { |
| 1025 |
$actionRestrictions = array_map( static function ( $id ) { |
| 1026 |
return new ActionRestriction( 0, $id ); |
| 1027 |
}, $data['ActionRestrictions'] ); |
| 1028 |
} |
| 1029 |
} |
| 1030 |
$restrictions = array_merge( $pageRestrictions, $namespaceRestrictions, $actionRestrictions ); |
| 1031 |
|
| 1032 |
if ( !isset( $data['Tags'] ) ) { |
| 1033 |
$data['Tags'] = []; |
| 1034 |
} |
| 1035 |
|
| 1036 |
$blockOptions = [ |
| 1037 |
'isCreateAccountBlocked' => $data['CreateAccount'], |
| 1038 |
'isHardBlock' => $data['HardBlock'], |
| 1039 |
'isAutoblocking' => $data['AutoBlock'], |
| 1040 |
'isHideUser' => $data['HideUser'], |
| 1041 |
'isPartial' => $isPartialBlock, |
| 1042 |
]; |
| 1043 |
|
| 1044 |
if ( isset( $data['DisableUTEdit'] ) ) { |
| 1045 |
$blockOptions['isUserTalkEditBlocked'] = $data['DisableUTEdit']; |
| 1046 |
} |
| 1047 |
if ( isset( $data['DisableEmail'] ) ) { |
| 1048 |
$blockOptions['isEmailBlocked'] = $data['DisableEmail']; |
| 1049 |
} |
| 1050 |
|
| 1051 |
$blockUser = $blockUserFactory->newBlockUser( |
| 1052 |
$target, |
| 1053 |
$performer, |
| 1054 |
$data['Expiry'], |
| 1055 |
$blockReason, |
| 1056 |
$blockOptions, |
| 1057 |
$restrictions, |
| 1058 |
$data['Tags'] |
| 1059 |
); |
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
$blockNotConfirmed = !$data['Confirm'] || ( array_key_exists( 'PreviousTarget', $data ) |
| 1064 |
&& $data['PreviousTarget'] !== $target ); |
| 1065 |
|
| 1066 |
|
| 1067 |
$reblockNotAllowed = ( array_key_exists( 'Reblock', $data ) && !$data['Reblock'] ); |
| 1068 |
|
| 1069 |
$doReblock = !$blockNotConfirmed && !$reblockNotAllowed; |
| 1070 |
|
| 1071 |
$status = $blockUser->placeBlock( $doReblock ); |
| 1072 |
if ( !$status->isOK() ) { |
| 1073 |
return $status; |
| 1074 |
} |
| 1075 |
|
| 1076 |
if ( |
| 1077 |
|
| 1078 |
$type != DatabaseBlock::TYPE_RANGE |
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
&& array_key_exists( 'Watch', $data ) |
| 1084 |
&& $data['Watch'] |
| 1085 |
) { |
| 1086 |
MediaWikiServices::getInstance()->getWatchlistManager()->addWatchIgnoringRights( |
| 1087 |
$performer->getUser(), |
| 1088 |
Title::makeTitle( NS_USER, $target ) |
| 1089 |
); |
| 1090 |
} |
| 1091 |
|
| 1092 |
return true; |
| 1093 |
} |
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
public static function getSuggestedDurations( ?Language $lang = null, $includeOther = true ) { |
| 1108 |
wfDeprecated( __METHOD__, '1.42' ); |
| 1109 |
$lang ??= MediaWikiServices::getInstance()->getContentLanguage(); |
| 1110 |
return $lang->getBlockDurations( $includeOther ); |
| 1111 |
} |
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
public static function parseExpiryInput( $expiry ) { |
| 1124 |
wfDeprecated( __METHOD__, '1.36' ); |
| 1125 |
return BlockUser::parseExpiryInput( $expiry ); |
| 1126 |
} |
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
public static function canBlockEmail( UserIdentity $user ) { |
| 1137 |
wfDeprecated( __METHOD__, '1.36' ); |
| 1138 |
return MediaWikiServices::getInstance() |
| 1139 |
->getBlockPermissionCheckerFactory() |
| 1140 |
->newBlockPermissionChecker( null, User::newFromIdentity( $user ) ) |
| 1141 |
->checkEmailPermissions(); |
| 1142 |
} |
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
public function onSubmit( array $data, ?HTMLForm $form = null ) { |
| 1151 |
return self::processFormInternal( |
| 1152 |
$data, |
| 1153 |
$this->getAuthority(), |
| 1154 |
$this->blockUserFactory, |
| 1155 |
$this->blockUtils |
| 1156 |
); |
| 1157 |
} |
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
public function onSuccess() { |
| 1164 |
$out = $this->getOutput(); |
| 1165 |
$out->setPageTitleMsg( $this->msg( 'blockipsuccesssub' ) ); |
| 1166 |
$out->addWikiMsg( 'blockipsuccesstext', wfEscapeWikiText( $this->target ) ); |
| 1167 |
} |
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
public function prefixSearchSubpages( $search, $limit, $offset ) { |
| 1178 |
$search = $this->userNameUtils->getCanonical( $search ); |
| 1179 |
if ( !$search ) { |
| 1180 |
|
| 1181 |
return []; |
| 1182 |
} |
| 1183 |
|
| 1184 |
return $this->userNamePrefixSearch |
| 1185 |
->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset ); |
| 1186 |
} |
| 1187 |
|
| 1188 |
protected function getGroupName() { |
| 1189 |
return 'users'; |
| 1190 |
} |
| 1191 |
} |
| 1192 |
|
| 1193 |
|
| 1194 |
class_alias( SpecialBlock::class, 'SpecialBlock' ); |