protected $alreadyBlocked;
/** @var array */
- protected $preErrors = array();
+ protected $preErrors = [];
public function __construct() {
parent::__construct( 'Block', 'block' );
if ( $s ) {
$form->addHeaderText( Html::rawElement(
'div',
- array( 'class' => 'error' ),
+ [ 'class' => 'error' ],
$s
) );
}
$suggestedDurations = self::getSuggestedDurations();
- $a = array(
- 'Target' => array(
+ $a = [
+ 'Target' => [
'type' => 'text',
'label-message' => 'ipaddressorusername',
'id' => 'mw-bi-target',
'size' => '45',
'autofocus' => true,
'required' => true,
- 'validation-callback' => array( __CLASS__, 'validateTargetField' ),
+ 'validation-callback' => [ __CLASS__, 'validateTargetField' ],
'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
- ),
- 'Expiry' => array(
+ ],
+ 'Expiry' => [
'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother',
'label-message' => 'ipbexpiry',
'required' => true,
'options' => $suggestedDurations,
'other' => $this->msg( 'ipbother' )->text(),
'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(),
- ),
- 'Reason' => array(
+ ],
+ 'Reason' => [
'type' => 'selectandother',
'maxlength' => 255,
'label-message' => 'ipbreason',
'options-message' => 'ipbreason-dropdown',
- ),
- 'CreateAccount' => array(
+ ],
+ 'CreateAccount' => [
'type' => 'check',
'label-message' => 'ipbcreateaccount',
'default' => true,
- ),
- );
+ ],
+ ];
if ( self::canBlockEmail( $user ) ) {
- $a['DisableEmail'] = array(
+ $a['DisableEmail'] = [
'type' => 'check',
'label-message' => 'ipbemailban',
- );
+ ];
}
if ( $wgBlockAllowsUTEdit ) {
- $a['DisableUTEdit'] = array(
+ $a['DisableUTEdit'] = [
'type' => 'check',
'label-message' => 'ipb-disableusertalk',
'default' => false,
- );
+ ];
}
- $a['AutoBlock'] = array(
+ $a['AutoBlock'] = [
'type' => 'check',
'label-message' => 'ipbenableautoblock',
'default' => true,
- );
+ ];
# Allow some users to hide name from block log, blocklist and listusers
if ( $user->isAllowed( 'hideuser' ) ) {
- $a['HideUser'] = array(
+ $a['HideUser'] = [
'type' => 'check',
'label-message' => 'ipbhidename',
'cssclass' => 'mw-block-hideuser',
- );
+ ];
}
# Watchlist their user page? (Only if user is logged in)
if ( $user->isLoggedIn() ) {
- $a['Watch'] = array(
+ $a['Watch'] = [
'type' => 'check',
'label-message' => 'ipbwatchuser',
- );
+ ];
}
- $a['HardBlock'] = array(
+ $a['HardBlock'] = [
'type' => 'check',
'label-message' => 'ipb-hardblock',
'default' => false,
- );
+ ];
# This is basically a copy of the Target field, but the user can't change it, so we
# can see if the warnings we maybe showed to the user before still apply
- $a['PreviousTarget'] = array(
+ $a['PreviousTarget'] = [
'type' => 'hidden',
'default' => false,
- );
+ ];
# We'll turn this into a checkbox if we need to
- $a['Confirm'] = array(
+ $a['Confirm'] = [
'type' => 'hidden',
'default' => '',
'label-message' => 'ipb-confirm',
- );
+ ];
$this->maybeAlterFormDefaults( $a );
// Allow extensions to add more fields
- Hooks::run( 'SpecialBlockModifyFormFields', array( $this, &$a ) );
+ Hooks::run( 'SpecialBlockModifyFormFields', [ $this, &$a ] );
return $a;
}
}
$this->alreadyBlocked = true;
- $this->preErrors[] = array( 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) );
+ $this->preErrors[] = [ 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) ];
}
# We always need confirmation to do HideUser
if ( $this->requestedHideUser ) {
$fields['Confirm']['type'] = 'check';
unset( $fields['Confirm']['default'] );
- $this->preErrors[] = array( 'ipb-confirmhideuser', 'ipb-confirmaction' );
+ $this->preErrors[] = [ '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[] = array( 'ipb-blockingself', 'ipb-confirmaction' );
+ $this->preErrors[] = [ 'ipb-blockingself', 'ipb-confirmaction' ];
}
}
* @return string
*/
protected function preText() {
- $this->getOutput()->addModules( array( 'mediawiki.special.block', 'mediawiki.userSuggest' ) );
+ $this->getOutput()->addModules( [ 'mediawiki.special.block', 'mediawiki.userSuggest' ] );
$blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' );
$text = $this->msg( 'blockiptext', $blockCIDRLimit['IPv4'], $blockCIDRLimit['IPv6'] )->parse();
- $otherBlockMessages = array();
+ $otherBlockMessages = [];
if ( $this->target !== null ) {
# Get other blocks, i.e. from GlobalBlocking or TorBlock extension
- Hooks::run( 'OtherBlockLogLink', array( &$otherBlockMessages, $this->target ) );
+ Hooks::run( 'OtherBlockLogLink', [ &$otherBlockMessages, $this->target ] );
if ( count( $otherBlockMessages ) ) {
$s = Html::rawElement(
'h2',
- array(),
+ [],
$this->msg( 'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse()
) . "\n";
$list = '';
foreach ( $otherBlockMessages as $link ) {
- $list .= Html::rawElement( 'li', array(), $link ) . "\n";
+ $list .= Html::rawElement( 'li', [], $link ) . "\n";
}
$s .= Html::rawElement(
'ul',
- array( 'class' => 'mw-blockip-alreadyblocked' ),
+ [ 'class' => 'mw-blockip-alreadyblocked' ],
$list
) . "\n";
* @return string
*/
protected function postText() {
- $links = array();
+ $links = [];
$this->getOutput()->addModuleStyles( 'mediawiki.special' );
$message = $this->msg( 'ipb-unblock' )->parse();
$list = SpecialPage::getTitleFor( 'Unblock' );
}
- $links[] = Linker::linkKnown( $list, $message, array() );
+ $links[] = Linker::linkKnown( $list, $message, [] );
# Link to the block list
$links[] = Linker::linkKnown(
$links[] = Linker::linkKnown(
$this->msg( 'ipbreason-dropdown' )->inContentLanguage()->getTitle(),
$this->msg( 'ipb-edit-dropdown' )->escaped(),
- array(),
- array( 'action' => 'edit' )
+ [],
+ [ 'action' => 'edit' ]
);
}
$text = Html::rawElement(
'p',
- array( 'class' => 'mw-ipb-conveniencelinks' ),
+ [ 'class' => 'mw-ipb-conveniencelinks' ],
$this->getLanguage()->pipeList( $links )
);
'block',
$userTitle,
'',
- array(
+ [
'lim' => 10,
- 'msgKey' => array( 'blocklog-showlog', $userTitle->getText() ),
+ 'msgKey' => [ 'blocklog-showlog', $userTitle->getText() ],
'showIfEmpty' => false
- )
+ ]
);
$text .= $out;
'suppress',
$userTitle,
'',
- array(
+ [
'lim' => 10,
- 'conds' => array( 'log_action' => array( 'block', 'reblock', 'unblock' ) ),
- 'msgKey' => array( 'blocklog-showsuppresslog', $userTitle->getText() ),
+ 'conds' => [ 'log_action' => [ 'block', 'reblock', 'unblock' ] ],
+ 'msgKey' => [ 'blocklog-showsuppresslog', $userTitle->getText() ],
'showIfEmpty' => false
- )
+ ]
);
$text .= $out;
list( $target, $type ) = Block::parseTarget( $target );
if ( $type !== null ) {
- return array( $target, $type );
+ return [ $target, $type ];
}
}
- return array( null, null );
+ return [ null, null ];
}
/**
if ( !$status->isOK() ) {
$errors = $status->getErrorsArray();
- return call_user_func_array( array( $form, 'msg' ), $errors[0] );
+ return call_user_func_array( [ $form, 'msg' ], $errors[0] );
} else {
return true;
}
# This might have been a hidden field or a checkbox, so interesting data
# can come from it
- $data['Confirm'] = !in_array( $data['Confirm'], array( '', '0', null, false ), true );
+ $data['Confirm'] = !in_array( $data['Confirm'], [ '', '0', null, false ], true );
/** @var User $target */
list( $target, $type ) = self::getTargetAndType( $data['Target'] );
if ( $target === $performer->getName() &&
( $data['PreviousTarget'] !== $target || !$data['Confirm'] )
) {
- return array( 'ipb-blockingself', 'ipb-confirmaction' );
+ return [ 'ipb-blockingself', 'ipb-confirmaction' ];
}
} elseif ( $type == Block::TYPE_RANGE ) {
$userId = 0;
$userId = 0;
} else {
# This should have been caught in the form field validation
- return array( 'badipaddress' );
+ return [ 'badipaddress' ];
}
$expiryTime = self::parseExpiryInput( $data['Expiry'] );
// check, if the time could be parsed
!$expiryTime
) {
- return array( 'ipb_expiry_invalid' );
+ return [ 'ipb_expiry_invalid' ];
}
// an expiry time should be in the future, not in the
// past (wouldn't make any sense) - bug T123069
if ( $expiryTime < wfTimestampNow() ) {
- return array( 'ipb_expiry_old' );
+ return [ 'ipb_expiry_old' ];
}
if ( !isset( $data['DisableEmail'] ) ) {
# or by race conditions (user has hideuser and block rights, loads block form,
# and loses hideuser rights before submission); so need to fail completely
# rather than just silently disable hiding
- return array( 'badaccess-group0' );
+ return [ 'badaccess-group0' ];
}
# Recheck params here...
$data['HideUser'] = false; # IP users should not be hidden
} elseif ( !wfIsInfinity( $data['Expiry'] ) ) {
# Bad expiry.
- return array( 'ipb_expiry_temp' );
+ return [ 'ipb_expiry_temp' ];
} 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( array( 'ipb_hide_invalid',
- Message::numParam( $wgHideUserContribLimit ) ) );
+ return [ [ 'ipb_hide_invalid',
+ Message::numParam( $wgHideUserContribLimit ) ] ];
} elseif ( !$data['Confirm'] ) {
- return array( 'ipb-confirmhideuser', 'ipb-confirmaction' );
+ return [ 'ipb-confirmhideuser', 'ipb-confirmaction' ];
}
}
$block->isAutoblocking( $data['AutoBlock'] );
$block->mHideName = $data['HideUser'];
- $reason = array( 'hookaborted' );
- if ( !Hooks::run( 'BlockIp', array( &$block, &$performer, &$reason ) ) ) {
+ $reason = [ 'hookaborted' ];
+ if ( !Hooks::run( 'BlockIp', [ &$block, &$performer, &$reason ] ) ) {
return $reason;
}
# Show form unless the user is already aware of this...
if ( $blockNotConfirmed || $reblockNotAllowed ) {
- return array( array( 'ipb_already_blocked', $block->getTarget() ) );
+ return [ [ 'ipb_already_blocked', $block->getTarget() ] ];
# Otherwise, try to update the block...
} else {
# This returns direct blocks before autoblocks/rangeblocks, since we should
$currentBlock = Block::newFromTarget( $target );
if ( $block->equals( $currentBlock ) ) {
- return array( array( 'ipb_already_blocked', $block->getTarget() ) );
+ return [ [ 'ipb_already_blocked', $block->getTarget() ] ];
}
# If the name was hidden and the blocking user cannot hide
# names, then don't allow any block changes...
if ( $currentBlock->mHideName && !$performer->isAllowed( 'hideuser' ) ) {
- return array( 'cant-see-hidden-user' );
+ return [ 'cant-see-hidden-user' ];
}
$currentBlock->isHardblock( $block->isHardblock() );
$logaction = 'block';
}
- Hooks::run( 'BlockIpComplete', array( $block, $performer ) );
+ Hooks::run( 'BlockIpComplete', [ $block, $performer ] );
# Set *_deleted fields if requested
if ( $data['HideUser'] ) {
$data['AutoBlock'] = $block->isAutoblocking();
# Prepare log parameters
- $logParams = array();
+ $logParams = [];
$logParams['5::duration'] = $data['Expiry'];
$logParams['6::flags'] = self::blockLogFlags( $data, $type );
$logEntry->setPerformer( $performer );
$logEntry->setParameters( $logParams );
# Relate log ID to block IDs (bug 25763)
- $blockIds = array_merge( array( $status['id'] ), $status['autoIds'] );
- $logEntry->setRelations( array( 'ipb_id' => $blockIds ) );
+ $blockIds = array_merge( [ $status['id'] ], $status['autoIds'] );
+ $logEntry->setRelations( [ 'ipb_id' => $blockIds ] );
$logId = $logEntry->insert();
$logEntry->publish( $logId );
* @return array
*/
public static function getSuggestedDurations( $lang = null ) {
- $a = array();
+ $a = [];
$msg = $lang === null
? wfMessage( 'ipboptions' )->inContentLanguage()->text()
: wfMessage( 'ipboptions' )->inLanguage( $lang )->text();
if ( $msg == '-' ) {
- return array();
+ return [];
}
foreach ( explode( ',', $msg ) as $option ) {
*/
protected static function blockLogFlags( array $data, $type ) {
global $wgBlockAllowsUTEdit;
- $flags = array();
+ $flags = [];
# when blocking a user the option 'anononly' is not available/has no effect
# -> do not write this into log
$user = User::newFromName( $search );
if ( !$user ) {
// No prefix suggestion for invalid user
- return array();
+ return [];
}
// Autocomplete subpage as user list - public to allow caching
return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );