* @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;
$this->maybeAlterFormDefaults( $a );
+ // Allow extensions to add more fields
+ wfRunHooks( 'SpecialBlockModifyFormFields', array( $this, &$a ) );
+
return $a;
}
if ( $this->requestedHideUser ) {
$fields['Confirm']['type'] = 'check';
unset( $fields['Confirm']['default'] );
- $this->preErrors[] = 'ipb-confirmhideuser';
+ $this->preErrors[] = array( 'ipb-confirmhideuser', 'ipb-confirmaction' );
}
# Or if the user is trying to block themselves
if ( (string)$this->target === $this->getUser()->getName() ) {
$fields['Confirm']['type'] = 'check';
unset( $fields['Confirm']['default'] );
- $this->preErrors[] = 'ipb-blockingself';
+ $this->preErrors[] = array( 'ipb-blockingself', 'ipb-confirmaction' );
}
}
* @return Bool|String
*/
public static function processForm( array $data, IContextSource $context ) {
- global $wgBlockAllowsUTEdit;
+ global $wgBlockAllowsUTEdit, $wgHideUserContribLimit;
$performer = $context->getUser();
if ( $target === $performer->getName() &&
( $data['PreviousTarget'] !== $target || !$data['Confirm'] )
) {
- return array( 'ipb-blockingself' );
+ return array( 'ipb-blockingself', 'ipb-confirmaction' );
}
} elseif ( $type == Block::TYPE_RANGE ) {
$userId = 0;
} 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' );
+ 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?