* @ingroup SpecialPage
*/
class SpecialBlock extends FormSpecialPage {
- /** The maximum number of edits a user can have and still be hidden
- * TODO: config setting? */
- const HIDEUSER_CONTRIBLIMIT = 1000;
-
/** @var User user to be blocked, as passed either by parameter (url?wpTarget=Foo)
* or as subpage (Special:Block/Foo) */
protected $target;
- /// @var Block::TYPE_ constant
+ /** @var Integer Block::TYPE_ constant */
protected $type;
- /// @var User|String the previous block target
+ /** @var User|String the previous block target */
protected $previousTarget;
- /// @var Bool whether the previous submission of the form asked for HideUser
+ /** @var Bool whether the previous submission of the form asked for HideUser */
protected $requestedHideUser;
- /// @var Bool
+ /** @var Bool */
protected $alreadyBlocked;
- /// @var Array
+ /** @var Array */
protected $preErrors = array();
public function __construct() {
/**
* Given the form data, actually implement a block
- * @param $data Array
- * @param $context IContextSource
+ * @param $data Array
+ * @param $context IContextSource
* @return Bool|String
*/
public static function processForm( array $data, IContextSource $context ) {
- global $wgBlockAllowsUTEdit;
+ global $wgBlockAllowsUTEdit, $wgHideUserContribLimit;
$performer = $context->getUser();
} elseif ( !in_array( $data['Expiry'], array( 'infinite', 'infinity', 'indefinite' ) ) ) {
# Bad expiry.
return array( 'ipb_expiry_temp' );
- } elseif ( $user->getEditCount() > self::HIDEUSER_CONTRIBLIMIT ) {
+ } elseif ( $wgHideUserContribLimit !== false
+ && $user->getEditCount() > $wgHideUserContribLimit
+ ) {
# Typically, the user should have a handful of edits.
# Disallow hiding users with many edits for performance.
- return array( 'ipb_hide_invalid' );
+ return array( array( 'ipb_hide_invalid',
+ Message::numParam( $wgHideUserContribLimit ) ) );
} elseif ( !$data['Confirm'] ) {
return array( 'ipb-confirmhideuser', 'ipb-confirmaction' );
}
$block->isAutoblocking( $data['AutoBlock'] );
$block->mHideName = $data['HideUser'];
- if ( !wfRunHooks( 'BlockIp', array( &$block, &$performer ) ) ) {
- return array( 'hookaborted' );
+ $reason = array( 'hookaborted' );
+ if ( !wfRunHooks( 'BlockIp', array( &$block, &$performer, &$reason ) ) ) {
+ return $reason;
}
# Try to insert block. Is there a conflicting block?
return array( 'cant-see-hidden-user' );
}
- $currentBlock->delete();
- $status = $block->insert();
+ $currentBlock->isHardblock( $block->isHardblock() );
+ $currentBlock->prevents( 'createaccount', $block->prevents( 'createaccount' ) );
+ $currentBlock->mExpiry = $block->mExpiry;
+ $currentBlock->isAutoblocking( $block->isAutoblocking() );
+ $currentBlock->mHideName = $block->mHideName;
+ $currentBlock->prevents( 'sendemail', $block->prevents( 'sendemail' ) );
+ $currentBlock->prevents( 'editownusertalk', $block->prevents( 'editownusertalk' ) );
+ $currentBlock->mReason = $block->mReason;
+
+ $status = $currentBlock->update();
+
$logaction = 'reblock';
# Unset _deleted fields if requested
/**
* Process the form on POST submission.
- * @param $data Array
+ * @param $data Array
* @return Bool|Array true for success, false for didn't-try, array of errors on failure
*/
public function onSubmit( array $data ) {