Index: trunk/phase3/includes/specials/SpecialBlock.php |
— | — | @@ -28,7 +28,6 @@ |
29 | 29 | * @ingroup SpecialPage |
30 | 30 | */ |
31 | 31 | class SpecialBlock extends SpecialPage { |
32 | | - |
33 | 32 | /** The maximum number of edits a user can have and still be hidden |
34 | 33 | * TODO: config setting? */ |
35 | 34 | const HIDEUSER_CONTRIBLIMIT = 1000; |
— | — | @@ -238,15 +237,19 @@ |
239 | 238 | $fields['HardBlock']['default'] = $block->isHardblock(); |
240 | 239 | $fields['CreateAccount']['default'] = $block->prevents( 'createaccount' ); |
241 | 240 | $fields['AutoBlock']['default'] = $block->isAutoblocking(); |
| 241 | + |
242 | 242 | if( isset( $fields['DisableEmail'] ) ){ |
243 | 243 | $fields['DisableEmail']['default'] = $block->prevents( 'sendemail' ); |
244 | 244 | } |
| 245 | + |
245 | 246 | if( isset( $fields['HideUser'] ) ){ |
246 | 247 | $fields['HideUser']['default'] = $block->mHideName; |
247 | 248 | } |
| 249 | + |
248 | 250 | if( isset( $fields['DisableUTEdit'] ) ){ |
249 | 251 | $fields['DisableUTEdit']['default'] = $block->prevents( 'editownusertalk' ); |
250 | 252 | } |
| 253 | + |
251 | 254 | $fields['Reason']['default'] = $block->mReason; |
252 | 255 | |
253 | 256 | if( $wgRequest->wasPosted() ){ |
— | — | @@ -304,15 +307,19 @@ |
305 | 308 | array(), |
306 | 309 | wfMsgExt( 'ipb-otherblocks-header', 'parseinline', count( $otherBlockMessages ) ) |
307 | 310 | ) . "\n"; |
| 311 | + |
308 | 312 | $list = ''; |
| 313 | + |
309 | 314 | foreach( $otherBlockMessages as $link ) { |
310 | 315 | $list .= Html::rawElement( 'li', array(), $link ) . "\n"; |
311 | 316 | } |
| 317 | + |
312 | 318 | $s .= Html::rawElement( |
313 | 319 | 'ul', |
314 | 320 | array( 'class' => 'mw-blockip-alreadyblocked' ), |
315 | 321 | $list |
316 | 322 | ) . "\n"; |
| 323 | + |
317 | 324 | $form->addPreText( $s ); |
318 | 325 | } |
319 | 326 | } |
— | — | @@ -325,6 +332,7 @@ |
326 | 333 | */ |
327 | 334 | protected function doHeaderText( HTMLForm &$form ){ |
328 | 335 | global $wgRequest; |
| 336 | + |
329 | 337 | # Don't need to do anything if the form has been posted |
330 | 338 | if( !$wgRequest->wasPosted() && $this->preErrors ){ |
331 | 339 | $s = HTMLForm::formatErrors( $this->preErrors ); |
— | — | @@ -419,6 +427,7 @@ |
420 | 428 | 'showIfEmpty' => false |
421 | 429 | ) |
422 | 430 | ); |
| 431 | + |
423 | 432 | $form->addPostText( $out ); |
424 | 433 | } |
425 | 434 | } |
— | — | @@ -435,6 +444,7 @@ |
436 | 445 | public static function getTargetAndType( $par, WebRequest $request = null ){ |
437 | 446 | $i = 0; |
438 | 447 | $target = null; |
| 448 | + |
439 | 449 | while( true ){ |
440 | 450 | switch( $i++ ){ |
441 | 451 | case 0: |
— | — | @@ -463,11 +473,14 @@ |
464 | 474 | case 4: |
465 | 475 | break 2; |
466 | 476 | } |
| 477 | + |
467 | 478 | list( $target, $type ) = Block::parseTarget( $target ); |
| 479 | + |
468 | 480 | if( $type !== null ){ |
469 | 481 | return array( $target, $type ); |
470 | 482 | } |
471 | 483 | } |
| 484 | + |
472 | 485 | return array( null, null ); |
473 | 486 | } |
474 | 487 | |
— | — | @@ -519,10 +532,8 @@ |
520 | 533 | if( IP::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) { |
521 | 534 | return wfMessage( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] ); |
522 | 535 | } |
523 | | - |
524 | 536 | } elseif( $type == Block::TYPE_IP ){ |
525 | 537 | # All is well |
526 | | - |
527 | 538 | } else { |
528 | 539 | return wfMessage( 'badipaddress' ); |
529 | 540 | } |
— | — | @@ -559,14 +570,11 @@ |
560 | 571 | { |
561 | 572 | return array( 'ipb-blockingself' ); |
562 | 573 | } |
563 | | - |
564 | 574 | } elseif( $type == Block::TYPE_RANGE ){ |
565 | 575 | $userId = 0; |
566 | | - |
567 | 576 | } elseif( $type == Block::TYPE_IP ){ |
568 | 577 | $target = $target->getName(); |
569 | 578 | $userId = 0; |
570 | | - |
571 | 579 | } else { |
572 | 580 | # This should have been caught in the form field validation |
573 | 581 | return array( 'badipaddress' ); |
— | — | @@ -587,6 +595,7 @@ |
588 | 596 | if( !isset( $data['HideUser'] ) ){ |
589 | 597 | $data['HideUser'] = false; |
590 | 598 | } |
| 599 | + |
591 | 600 | if( $data['HideUser'] ) { |
592 | 601 | if( !$wgUser->isAllowed('hideuser') ){ |
593 | 602 | # this codepath is unreachable except by a malicious user spoofing forms, |
— | — | @@ -599,16 +608,13 @@ |
600 | 609 | # Recheck params here... |
601 | 610 | if( $type != Block::TYPE_USER ) { |
602 | 611 | $data['HideUser'] = false; # IP users should not be hidden |
603 | | - |
604 | 612 | } elseif( !in_array( $data['Expiry'], array( 'infinite', 'infinity', 'indefinite' ) ) ) { |
605 | 613 | # Bad expiry. |
606 | 614 | return array( 'ipb_expiry_temp' ); |
607 | | - |
608 | 615 | } elseif( $user->getEditCount() > self::HIDEUSER_CONTRIBLIMIT ) { |
609 | 616 | # Typically, the user should have a handful of edits. |
610 | 617 | # Disallow hiding users with many edits for performance. |
611 | 618 | return array( 'ipb_hide_invalid' ); |
612 | | - |
613 | 619 | } elseif( !$data['Confirm'] ){ |
614 | 620 | return array( 'ipb-confirmhideuser' ); |
615 | 621 | } |
— | — | @@ -733,9 +739,11 @@ |
734 | 740 | if( strpos( $option, ':' ) === false ){ |
735 | 741 | $option = "$option:$option"; |
736 | 742 | } |
| 743 | + |
737 | 744 | list( $show, $value ) = explode( ':', $option ); |
738 | 745 | $a[htmlspecialchars( $show )] = htmlspecialchars( $value ); |
739 | 746 | } |
| 747 | + |
740 | 748 | return $a; |
741 | 749 | } |
742 | 750 | |
— | — | @@ -750,15 +758,19 @@ |
751 | 759 | if( $infinity == null ){ |
752 | 760 | $infinity = wfGetDB( DB_SLAVE )->getInfinity(); |
753 | 761 | } |
| 762 | + |
754 | 763 | if ( $expiry == 'infinite' || $expiry == 'indefinite' ) { |
755 | 764 | $expiry = $infinity; |
756 | 765 | } else { |
757 | 766 | $expiry = strtotime( $expiry ); |
| 767 | + |
758 | 768 | if ( $expiry < 0 || $expiry === false ) { |
759 | 769 | return false; |
760 | 770 | } |
| 771 | + |
761 | 772 | $expiry = wfTimestamp( TS_MW, $expiry ); |
762 | 773 | } |
| 774 | + |
763 | 775 | return $expiry; |
764 | 776 | } |
765 | 777 | |
— | — | @@ -769,6 +781,7 @@ |
770 | 782 | */ |
771 | 783 | public static function canBlockEmail( $user ) { |
772 | 784 | global $wgEnableUserEmail, $wgSysopEmailBans; |
| 785 | + |
773 | 786 | return ( $wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ) ); |
774 | 787 | } |
775 | 788 | |
— | — | @@ -781,11 +794,13 @@ |
782 | 795 | */ |
783 | 796 | public static function checkUnblockSelf( $user ) { |
784 | 797 | global $wgUser; |
| 798 | + |
785 | 799 | if ( is_int( $user ) ) { |
786 | 800 | $user = User::newFromId( $user ); |
787 | 801 | } elseif ( is_string( $user ) ) { |
788 | 802 | $user = User::newFromName( $user ); |
789 | 803 | } |
| 804 | + |
790 | 805 | if( $wgUser->isBlocked() ){ |
791 | 806 | if( $user instanceof User && $user->getId() == $wgUser->getId() ) { |
792 | 807 | # User is trying to unblock themselves |