Index: trunk/phase3/includes/specials/SpecialBlock.php |
— | — | @@ -29,18 +29,18 @@ |
30 | 30 | */ |
31 | 31 | class SpecialBlock extends SpecialPage { |
32 | 32 | |
33 | | - # The maximum number of edits a user can have and still be hidden |
34 | | - # TODO: config setting? |
| 33 | + /** The maximum number of edits a user can have and still be hidden |
| 34 | + * TODO: config setting? */ |
35 | 35 | const HIDEUSER_CONTRIBLIMIT = 1000; |
36 | 36 | |
37 | | - # @var User user to be blocked, as passed either by parameter (url?wpTarget=Foo) |
38 | | - # or as subpage (Special:Block/Foo) |
| 37 | + /** @var User user to be blocked, as passed either by parameter (url?wpTarget=Foo) |
| 38 | + * or as subpage (Special:Block/Foo) */ |
39 | 39 | protected $target; |
40 | 40 | |
41 | | - # @var Block::TYPE_ constant |
| 41 | + /// @var Block::TYPE_ constant |
42 | 42 | protected $type; |
43 | 43 | |
44 | | - # @var Bool |
| 44 | + /// @var Bool |
45 | 45 | protected $alreadyBlocked; |
46 | 46 | |
47 | 47 | public function __construct() { |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | |
100 | 100 | if( $form->show() ){ |
101 | 101 | $wgOut->setPageTitle( wfMsg( 'blockipsuccesssub' ) ); |
102 | | - $wgOut->addHTML( wfMsgExt( 'blockipsuccesstext', array( 'parse' ), $this->target ) ); |
| 102 | + $wgOut->addWikiMsg( 'blockipsuccesstext', $this->target ); |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
— | — | @@ -117,6 +117,7 @@ |
118 | 118 | 'id' => 'mw-bi-target', |
119 | 119 | 'size' => '45', |
120 | 120 | 'required' => true, |
| 121 | + 'validation-callback' => array( __CLASS__, 'validateTargetField' ), |
121 | 122 | ), |
122 | 123 | 'Expiry' => array( |
123 | 124 | 'type' => 'selectorother', |
— | — | @@ -448,25 +449,20 @@ |
449 | 450 | } |
450 | 451 | } |
451 | 452 | |
452 | | - /** |
453 | | - * Given the form data, actually implement a block |
454 | | - * @param $data Array |
455 | | - * @return Bool|String |
456 | | - */ |
457 | | - public static function processForm( array $data ){ |
458 | | - global $wgUser, $wgBlockAllowsUTEdit, $wgBlockCIDRLimit; |
| 453 | + public static function validateTargetField( $data, $alldata = null ) { |
| 454 | + global $wgBlockCIDRLimit; |
459 | 455 | |
460 | | - list( $target, $type ) = self::getTargetAndType( $data['Target'] ); |
| 456 | + list( $target, $type ) = self::getTargetAndType( $data ); |
461 | 457 | |
462 | 458 | if( $type == Block::TYPE_USER ){ |
463 | 459 | # TODO: why do we not have a User->exists() method? |
464 | 460 | if( !$target->getId() ){ |
465 | | - return array( array( 'nosuchusershort', $target->getName() ) ); |
| 461 | + return wfMessage( 'nosuchusershort', $target->getName() ); |
466 | 462 | } |
467 | 463 | |
468 | 464 | $status = self::checkUnblockSelf( $target ); |
469 | 465 | if ( $status !== true ) { |
470 | | - return array( array( 'badaccess', $status ) ); |
| 466 | + return wfMessage( 'badaccess', $status ); |
471 | 467 | } |
472 | 468 | |
473 | 469 | $user = $target; |
— | — | @@ -480,22 +476,22 @@ |
481 | 477 | || ( IP::isIPv6( $ip ) && $wgBlockCIDRLimit['IPV6'] == 128 ) ) |
482 | 478 | { |
483 | 479 | # Range block effectively disabled |
484 | | - return array( 'range_block_disabled' ); |
| 480 | + return wfMessage( 'range_block_disabled' ); |
485 | 481 | } |
486 | 482 | |
487 | 483 | if( ( IP::isIPv4( $ip ) && $range > 32 ) |
488 | 484 | || ( IP::isIPv6( $ip ) && $range > 128 ) ) |
489 | 485 | { |
490 | 486 | # Dodgy range |
491 | | - return array( 'ip_range_invalid' ); |
| 487 | + return wfMessage( 'ip_range_invalid' ); |
492 | 488 | } |
493 | 489 | |
494 | 490 | if( IP::isIPv4( $ip ) && $range < $wgBlockCIDRLimit['IPv4'] ) { |
495 | | - return array( array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] ) ); |
| 491 | + return wfMessage( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] ); |
496 | 492 | } |
497 | 493 | |
498 | 494 | if( IP::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) { |
499 | | - return array( array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] ) ); |
| 495 | + return wfMessage( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] ); |
500 | 496 | } |
501 | 497 | |
502 | 498 | $userId = 0; |
— | — | @@ -506,9 +502,21 @@ |
507 | 503 | $userId = 0; |
508 | 504 | |
509 | 505 | } else { |
510 | | - return array( 'badipaddress' ); |
| 506 | + return wfMessage( 'badipaddress' ); |
511 | 507 | } |
| 508 | + } |
512 | 509 | |
| 510 | + /** |
| 511 | + * Given the form data, actually implement a block |
| 512 | + * @param $data Array |
| 513 | + * @return Bool|String |
| 514 | + */ |
| 515 | + public static function processForm( array $data ){ |
| 516 | + global $wgUser, $wgBlockAllowsUTEdit; |
| 517 | + |
| 518 | + // Handled by field validator callback |
| 519 | + // self::validateTargetField( $data['Target'] ); |
| 520 | + |
513 | 521 | if( ( strlen( $data['Expiry'] ) == 0) || ( strlen( $data['Expiry'] ) > 50 ) |
514 | 522 | || !Block::parseExpiryInput( $data['Expiry'] ) ) |
515 | 523 | { |