2011-03-12 21:54:35 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2011-03-12 22:53:15 +00:00
|
|
|
* Implements Special:Block
|
2011-03-12 21:54:35 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A special page that allows users with 'block' right to block users from
|
|
|
|
|
* editing pages and other actions
|
|
|
|
|
*
|
|
|
|
|
* @ingroup SpecialPage
|
|
|
|
|
*/
|
2011-11-15 02:25:36 +00:00
|
|
|
class SpecialBlock extends FormSpecialPage {
|
2014-07-24 17:43:44 +00:00
|
|
|
/** @var User User to be blocked, as passed either by parameter (url?wpTarget=Foo)
|
2011-03-13 09:57:02 +00:00
|
|
|
* or as subpage (Special:Block/Foo) */
|
2011-03-12 22:53:15 +00:00
|
|
|
protected $target;
|
|
|
|
|
|
2014-04-19 08:16:52 +00:00
|
|
|
/** @var int Block::TYPE_ constant */
|
2011-03-12 22:53:15 +00:00
|
|
|
protected $type;
|
|
|
|
|
|
2014-04-19 08:16:52 +00:00
|
|
|
/** @var User|string The previous block target */
|
2011-04-01 23:13:15 +00:00
|
|
|
protected $previousTarget;
|
|
|
|
|
|
2014-04-19 08:16:52 +00:00
|
|
|
/** @var bool Whether the previous submission of the form asked for HideUser */
|
2011-04-01 23:13:15 +00:00
|
|
|
protected $requestedHideUser;
|
|
|
|
|
|
2014-04-19 08:16:52 +00:00
|
|
|
/** @var bool */
|
2011-03-12 22:53:15 +00:00
|
|
|
protected $alreadyBlocked;
|
2011-06-02 19:32:45 +00:00
|
|
|
|
2014-04-19 08:16:52 +00:00
|
|
|
/** @var array */
|
2011-04-01 23:13:15 +00:00
|
|
|
protected $preErrors = array();
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2011-03-12 21:54:35 +00:00
|
|
|
public function __construct() {
|
2011-03-12 22:53:15 +00:00
|
|
|
parent::__construct( 'Block', 'block' );
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
/**
|
|
|
|
|
* Checks that the user can unblock themselves if they are trying to do so
|
|
|
|
|
*
|
|
|
|
|
* @param User $user
|
|
|
|
|
* @throws ErrorPageError
|
|
|
|
|
*/
|
|
|
|
|
protected function checkExecutePermissions( User $user ) {
|
2013-02-03 19:28:43 +00:00
|
|
|
parent::checkExecutePermissions( $user );
|
2011-07-16 19:31:18 +00:00
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
# bug 15810: blocked admins should have limited access here
|
|
|
|
|
$status = self::checkUnblockSelf( $this->target, $user );
|
|
|
|
|
if ( $status !== true ) {
|
|
|
|
|
throw new ErrorPageError( 'badaccess', $status );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle some magic here
|
|
|
|
|
*
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param string $par
|
2011-11-15 02:25:36 +00:00
|
|
|
*/
|
|
|
|
|
protected function setParameter( $par ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
# Extract variables from the request. Try not to get into a situation where we
|
|
|
|
|
# need to extract *every* variable from the form just for processing here, but
|
|
|
|
|
# there are legitimate uses for some variables
|
2011-09-12 08:49:14 +00:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
list( $this->target, $this->type ) = self::getTargetAndType( $par, $request );
|
2011-03-12 22:53:15 +00:00
|
|
|
if ( $this->target instanceof User ) {
|
|
|
|
|
# Set the 'relevant user' in the skin, so it displays links like Contributions,
|
|
|
|
|
# User logs, UserRights, etc.
|
2011-07-01 02:25:19 +00:00
|
|
|
$this->getSkin()->setRelevantUser( $this->target );
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
2011-03-18 20:37:11 +00:00
|
|
|
|
2014-05-09 19:33:58 +00:00
|
|
|
list( $this->previousTarget, /*...*/ ) =
|
|
|
|
|
Block::parseTarget( $request->getVal( 'wpPreviousTarget' ) );
|
2011-09-12 08:49:14 +00:00
|
|
|
$this->requestedHideUser = $request->getBool( 'wpHideUser' );
|
2011-11-15 02:25:36 +00:00
|
|
|
}
|
2011-04-01 23:13:15 +00:00
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
/**
|
|
|
|
|
* Customizes the HTMLForm a bit
|
|
|
|
|
*
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param HTMLForm $form
|
2011-11-15 02:25:36 +00:00
|
|
|
*/
|
|
|
|
|
protected function alterForm( HTMLForm $form ) {
|
|
|
|
|
$form->setWrapperLegendMsg( 'blockip-legend' );
|
|
|
|
|
$form->setHeaderText( '' );
|
2014-10-07 23:07:58 +00:00
|
|
|
$form->setSubmitDestructive();
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
$msg = $this->alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit';
|
|
|
|
|
$form->setSubmitTextMsg( $msg );
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2015-05-02 11:37:19 +00:00
|
|
|
$this->addHelpLink( 'Help:Blocking users' );
|
2014-08-31 10:25:18 +00:00
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
# Don't need to do anything if the form has been posted
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( !$this->getRequest()->wasPosted() && $this->preErrors ) {
|
2014-12-13 11:08:45 +00:00
|
|
|
$s = $form->formatErrors( $this->preErrors );
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $s ) {
|
2011-11-15 02:25:36 +00:00
|
|
|
$form->addHeaderText( Html::rawElement(
|
2013-03-25 22:52:41 +00:00
|
|
|
'div',
|
|
|
|
|
array( 'class' => 'error' ),
|
|
|
|
|
$s
|
|
|
|
|
) );
|
2011-11-15 02:25:36 +00:00
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
/**
|
|
|
|
|
* Get the HTMLForm descriptor array for the block form
|
2014-04-19 08:16:52 +00:00
|
|
|
* @return array
|
2011-03-12 22:53:15 +00:00
|
|
|
*/
|
2012-08-29 02:34:00 +00:00
|
|
|
protected function getFormFields() {
|
2011-09-12 08:49:14 +00:00
|
|
|
global $wgBlockAllowsUTEdit;
|
|
|
|
|
|
|
|
|
|
$user = $this->getUser();
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2013-04-29 13:48:57 +00:00
|
|
|
$suggestedDurations = self::getSuggestedDurations();
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
$a = array(
|
|
|
|
|
'Target' => array(
|
|
|
|
|
'type' => 'text',
|
2014-04-27 21:11:07 +00:00
|
|
|
'label-message' => 'ipaddressorusername',
|
2011-03-12 22:53:15 +00:00
|
|
|
'id' => 'mw-bi-target',
|
|
|
|
|
'size' => '45',
|
2013-01-01 13:25:50 +00:00
|
|
|
'autofocus' => true,
|
2011-03-12 22:53:15 +00:00
|
|
|
'required' => true,
|
2011-03-13 09:57:02 +00:00
|
|
|
'validation-callback' => array( __CLASS__, 'validateTargetField' ),
|
2014-10-10 14:36:33 +00:00
|
|
|
'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
|
2011-03-12 22:53:15 +00:00
|
|
|
),
|
|
|
|
|
'Expiry' => array(
|
2013-04-29 13:48:57 +00:00
|
|
|
'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother',
|
2011-03-12 22:53:15 +00:00
|
|
|
'label-message' => 'ipbexpiry',
|
|
|
|
|
'required' => true,
|
2013-04-29 13:48:57 +00:00
|
|
|
'options' => $suggestedDurations,
|
2011-12-28 19:15:10 +00:00
|
|
|
'other' => $this->msg( 'ipbother' )->text(),
|
2012-06-06 19:50:19 +00:00
|
|
|
'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(),
|
2011-03-12 22:53:15 +00:00
|
|
|
),
|
|
|
|
|
'Reason' => array(
|
|
|
|
|
'type' => 'selectandother',
|
2014-07-26 21:56:37 +00:00
|
|
|
'maxlength' => 255,
|
2011-03-12 22:53:15 +00:00
|
|
|
'label-message' => 'ipbreason',
|
|
|
|
|
'options-message' => 'ipbreason-dropdown',
|
|
|
|
|
),
|
|
|
|
|
'CreateAccount' => array(
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'label-message' => 'ipbcreateaccount',
|
|
|
|
|
'default' => true,
|
|
|
|
|
),
|
2011-03-12 22:51:48 +00:00
|
|
|
);
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( self::canBlockEmail( $user ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$a['DisableEmail'] = array(
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'label-message' => 'ipbemailban',
|
2011-03-12 21:54:35 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $wgBlockAllowsUTEdit ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$a['DisableUTEdit'] = array(
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'label-message' => 'ipb-disableusertalk',
|
|
|
|
|
'default' => false,
|
2011-03-12 21:54:35 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
$a['AutoBlock'] = array(
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'label-message' => 'ipbenableautoblock',
|
|
|
|
|
'default' => true,
|
2011-03-12 21:54:35 +00:00
|
|
|
);
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Allow some users to hide name from block log, blocklist and listusers
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $user->isAllowed( 'hideuser' ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$a['HideUser'] = array(
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'label-message' => 'ipbhidename',
|
|
|
|
|
'cssclass' => 'mw-block-hideuser',
|
2011-03-12 21:54:35 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Watchlist their user page? (Only if user is logged in)
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $user->isLoggedIn() ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$a['Watch'] = array(
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'label-message' => 'ipbwatchuser',
|
2011-03-12 21:54:35 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
$a['HardBlock'] = array(
|
|
|
|
|
'type' => 'check',
|
|
|
|
|
'label-message' => 'ipb-hardblock',
|
|
|
|
|
'default' => false,
|
2011-03-12 21:54:35 +00:00
|
|
|
);
|
|
|
|
|
|
2011-04-01 23:13:15 +00:00
|
|
|
# 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(
|
2011-03-12 22:53:15 +00:00
|
|
|
'type' => 'hidden',
|
|
|
|
|
'default' => false,
|
|
|
|
|
);
|
|
|
|
|
|
2011-04-01 23:13:15 +00:00
|
|
|
# We'll turn this into a checkbox if we need to
|
|
|
|
|
$a['Confirm'] = array(
|
|
|
|
|
'type' => 'hidden',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'label-message' => 'ipb-confirm',
|
|
|
|
|
);
|
|
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
$this->maybeAlterFormDefaults( $a );
|
|
|
|
|
|
2013-12-12 20:18:05 +00:00
|
|
|
// Allow extensions to add more fields
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'SpecialBlockModifyFormFields', array( $this, &$a ) );
|
2013-12-12 20:18:05 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
return $a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If the user has already been blocked with similar settings, load that block
|
|
|
|
|
* and change the defaults for the form fields to match the existing settings.
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param array $fields HTMLForm descriptor array
|
2014-04-19 08:16:52 +00:00
|
|
|
* @return bool Whether fields were altered (that is, whether the target is
|
2011-03-12 22:53:15 +00:00
|
|
|
* already blocked)
|
|
|
|
|
*/
|
2012-08-29 02:34:00 +00:00
|
|
|
protected function maybeAlterFormDefaults( &$fields ) {
|
2011-04-01 23:13:15 +00:00
|
|
|
# This will be overwritten by request data
|
2011-03-13 14:41:57 +00:00
|
|
|
$fields['Target']['default'] = (string)$this->target;
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2014-05-30 09:14:54 +00:00
|
|
|
if ( $this->target ) {
|
|
|
|
|
$status = self::validateTarget( $this->target, $this->getUser() );
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
$errors = $status->getErrorsArray();
|
|
|
|
|
$this->preErrors = array_merge( $this->preErrors, $errors );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-01 23:13:15 +00:00
|
|
|
# This won't be
|
|
|
|
|
$fields['PreviousTarget']['default'] = (string)$this->target;
|
|
|
|
|
|
2011-03-21 19:12:41 +00:00
|
|
|
$block = Block::newFromTarget( $this->target );
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $block instanceof Block && !$block->mAuto # The block exists and isn't an autoblock
|
2011-03-12 22:53:15 +00:00
|
|
|
&& ( $this->type != Block::TYPE_RANGE # The block isn't a rangeblock
|
2013-02-03 19:28:43 +00:00
|
|
|
|| $block->getTarget() == $this->target ) # or if it is, the range is what we're about to block
|
2013-03-25 22:52:41 +00:00
|
|
|
) {
|
2011-03-19 23:47:08 +00:00
|
|
|
$fields['HardBlock']['default'] = $block->isHardblock();
|
|
|
|
|
$fields['CreateAccount']['default'] = $block->prevents( 'createaccount' );
|
2011-03-21 19:12:41 +00:00
|
|
|
$fields['AutoBlock']['default'] = $block->isAutoblocking();
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( isset( $fields['DisableEmail'] ) ) {
|
2011-03-19 23:47:08 +00:00
|
|
|
$fields['DisableEmail']['default'] = $block->prevents( 'sendemail' );
|
2011-03-15 11:20:15 +00:00
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( isset( $fields['HideUser'] ) ) {
|
2011-03-15 11:20:15 +00:00
|
|
|
$fields['HideUser']['default'] = $block->mHideName;
|
|
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( isset( $fields['DisableUTEdit'] ) ) {
|
2011-03-20 17:43:17 +00:00
|
|
|
$fields['DisableUTEdit']['default'] = $block->prevents( 'editownusertalk' );
|
2011-03-15 11:20:15 +00:00
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2012-08-08 17:04:10 +00:00
|
|
|
// If the username was hidden (ipb_deleted == 1), don't show the reason
|
|
|
|
|
// unless this user also has rights to hideuser: Bug 35839
|
|
|
|
|
if ( !$block->mHideName || $this->getUser()->isAllowed( 'hideuser' ) ) {
|
|
|
|
|
$fields['Reason']['default'] = $block->mReason;
|
|
|
|
|
} else {
|
|
|
|
|
$fields['Reason']['default'] = '';
|
|
|
|
|
}
|
2011-04-01 23:13:15 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $this->getRequest()->wasPosted() ) {
|
2011-04-01 23:13:15 +00:00
|
|
|
# Ok, so we got a POST submission asking us to reblock a user. So show the
|
|
|
|
|
# confirm checkbox; the user will only see it if they haven't previously
|
|
|
|
|
$fields['Confirm']['type'] = 'check';
|
|
|
|
|
} else {
|
|
|
|
|
# We got a target, but it wasn't a POST request, so the user must have gone
|
|
|
|
|
# to a link like [[Special:Block/User]]. We don't need to show the checkbox
|
|
|
|
|
# as long as they go ahead and block *that* user
|
|
|
|
|
$fields['Confirm']['default'] = 1;
|
|
|
|
|
}
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $block->mExpiry == 'infinity' ) {
|
2012-06-06 19:50:19 +00:00
|
|
|
$fields['Expiry']['default'] = 'infinite';
|
2011-03-12 22:53:15 +00:00
|
|
|
} else {
|
|
|
|
|
$fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->mExpiry );
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-01 23:13:15 +00:00
|
|
|
$this->alreadyBlocked = true;
|
2012-04-21 13:12:08 +00:00
|
|
|
$this->preErrors[] = array( 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) );
|
2011-04-01 23:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# We always need confirmation to do HideUser
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $this->requestedHideUser ) {
|
2011-04-01 23:13:15 +00:00
|
|
|
$fields['Confirm']['type'] = 'check';
|
|
|
|
|
unset( $fields['Confirm']['default'] );
|
2013-12-23 11:37:03 +00:00
|
|
|
$this->preErrors[] = array( 'ipb-confirmhideuser', 'ipb-confirmaction' );
|
2011-04-01 23:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Or if the user is trying to block themselves
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( (string)$this->target === $this->getUser()->getName() ) {
|
2011-04-01 23:13:15 +00:00
|
|
|
$fields['Confirm']['type'] = 'check';
|
|
|
|
|
unset( $fields['Confirm']['default'] );
|
2013-12-23 11:37:03 +00:00
|
|
|
$this->preErrors[] = array( 'ipb-blockingself', 'ipb-confirmaction' );
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2011-03-12 22:53:15 +00:00
|
|
|
* Add header elements like block log entries, etc.
|
2014-04-19 08:16:52 +00:00
|
|
|
* @return string
|
2011-03-12 21:54:35 +00:00
|
|
|
*/
|
2012-08-29 02:34:00 +00:00
|
|
|
protected function preText() {
|
2014-10-10 14:36:33 +00:00
|
|
|
$this->getOutput()->addModules( array( 'mediawiki.special.block', 'mediawiki.userSuggest' ) );
|
2012-07-24 20:59:42 +00:00
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
$text = $this->msg( 'blockiptext' )->parse();
|
2011-03-12 22:53:15 +00:00
|
|
|
|
|
|
|
|
$otherBlockMessages = array();
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $this->target !== null ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
# Get other blocks, i.e. from GlobalBlocking or TorBlock extension
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'OtherBlockLogLink', array( &$otherBlockMessages, $this->target ) );
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( count( $otherBlockMessages ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$s = Html::rawElement(
|
|
|
|
|
'h2',
|
|
|
|
|
array(),
|
2011-12-28 19:15:10 +00:00
|
|
|
$this->msg( 'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse()
|
2011-03-12 22:53:15 +00:00
|
|
|
) . "\n";
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
$list = '';
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
foreach ( $otherBlockMessages as $link ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$list .= Html::rawElement( 'li', array(), $link ) . "\n";
|
|
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
$s .= Html::rawElement(
|
|
|
|
|
'ul',
|
|
|
|
|
array( 'class' => 'mw-blockip-alreadyblocked' ),
|
|
|
|
|
$list
|
|
|
|
|
) . "\n";
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
$text .= $s;
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
return $text;
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2011-03-12 21:54:35 +00:00
|
|
|
/**
|
2011-03-12 22:53:15 +00:00
|
|
|
* Add footer elements to the form
|
2012-01-03 15:36:46 +00:00
|
|
|
* @return string
|
2011-03-12 21:54:35 +00:00
|
|
|
*/
|
2012-08-29 02:34:00 +00:00
|
|
|
protected function postText() {
|
2012-06-26 09:09:53 +00:00
|
|
|
$links = array();
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Link to the user's contributions, if applicable
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $this->target instanceof User ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->target->getName() );
|
2011-07-26 19:04:48 +00:00
|
|
|
$links[] = Linker::link(
|
2011-03-12 22:53:15 +00:00
|
|
|
$contribsPage,
|
2011-12-28 19:15:10 +00:00
|
|
|
$this->msg( 'ipb-blocklist-contribs', $this->target->getName() )->escaped()
|
2011-03-12 22:53:15 +00:00
|
|
|
);
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
2011-03-12 22:53:15 +00:00
|
|
|
|
|
|
|
|
# Link to unblock the specified user, or to a blank unblock form
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $this->target instanceof User ) {
|
2014-05-09 19:33:58 +00:00
|
|
|
$message = $this->msg(
|
|
|
|
|
'ipb-unblock-addr',
|
|
|
|
|
wfEscapeWikiText( $this->target->getName() )
|
|
|
|
|
)->parse();
|
2011-03-13 21:33:52 +00:00
|
|
|
$list = SpecialPage::getTitleFor( 'Unblock', $this->target->getName() );
|
2011-03-12 21:54:35 +00:00
|
|
|
} else {
|
2011-12-28 19:15:10 +00:00
|
|
|
$message = $this->msg( 'ipb-unblock' )->parse();
|
2011-03-13 21:33:52 +00:00
|
|
|
$list = SpecialPage::getTitleFor( 'Unblock' );
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
2011-07-26 19:04:48 +00:00
|
|
|
$links[] = Linker::linkKnown( $list, $message, array() );
|
2011-03-12 22:53:15 +00:00
|
|
|
|
|
|
|
|
# Link to the block list
|
2011-07-26 19:04:48 +00:00
|
|
|
$links[] = Linker::linkKnown(
|
2011-03-14 16:09:44 +00:00
|
|
|
SpecialPage::getTitleFor( 'BlockList' ),
|
2011-12-28 19:15:10 +00:00
|
|
|
$this->msg( 'ipb-blocklist' )->escaped()
|
2011-03-12 22:53:15 +00:00
|
|
|
);
|
|
|
|
|
|
2011-09-12 08:49:14 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Link to edit the block dropdown reasons, if applicable
|
2011-09-12 08:49:14 +00:00
|
|
|
if ( $user->isAllowed( 'editinterface' ) ) {
|
2015-06-19 16:55:30 +00:00
|
|
|
$links[] = Linker::linkKnown(
|
2014-12-13 19:55:13 +00:00
|
|
|
$this->msg( 'ipbreason-dropdown' )->inContentLanguage()->getTitle(),
|
2011-12-28 19:15:10 +00:00
|
|
|
$this->msg( 'ipb-edit-dropdown' )->escaped(),
|
2011-03-12 22:53:15 +00:00
|
|
|
array(),
|
|
|
|
|
array( 'action' => 'edit' )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-28 21:11:10 +00:00
|
|
|
$text = Html::rawElement(
|
2011-03-12 22:53:15 +00:00
|
|
|
'p',
|
|
|
|
|
array( 'class' => 'mw-ipb-conveniencelinks' ),
|
2011-11-21 16:13:21 +00:00
|
|
|
$this->getLanguage()->pipeList( $links )
|
2011-11-15 02:25:36 +00:00
|
|
|
);
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2012-03-14 01:42:14 +00:00
|
|
|
$userTitle = self::getTargetUserTitle( $this->target );
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $userTitle ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
# Get relevant extracts from the block and suppression logs, if possible
|
|
|
|
|
$out = '';
|
|
|
|
|
|
|
|
|
|
LogEventsList::showLogExtract(
|
|
|
|
|
$out,
|
|
|
|
|
'block',
|
2012-03-14 01:42:14 +00:00
|
|
|
$userTitle,
|
2011-03-12 22:53:15 +00:00
|
|
|
'',
|
|
|
|
|
array(
|
|
|
|
|
'lim' => 10,
|
2012-03-14 01:42:14 +00:00
|
|
|
'msgKey' => array( 'blocklog-showlog', $userTitle->getText() ),
|
2011-03-12 22:53:15 +00:00
|
|
|
'showIfEmpty' => false
|
|
|
|
|
)
|
|
|
|
|
);
|
2011-11-15 02:25:36 +00:00
|
|
|
$text .= $out;
|
2011-03-12 22:53:15 +00:00
|
|
|
|
|
|
|
|
# Add suppression block entries if allowed
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $user->isAllowed( 'suppressionlog' ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
LogEventsList::showLogExtract(
|
|
|
|
|
$out,
|
|
|
|
|
'suppress',
|
2012-03-14 01:42:14 +00:00
|
|
|
$userTitle,
|
2011-03-12 22:53:15 +00:00
|
|
|
'',
|
|
|
|
|
array(
|
|
|
|
|
'lim' => 10,
|
|
|
|
|
'conds' => array( 'log_action' => array( 'block', 'reblock', 'unblock' ) ),
|
2012-03-14 01:42:14 +00:00
|
|
|
'msgKey' => array( 'blocklog-showsuppresslog', $userTitle->getText() ),
|
2011-03-12 22:53:15 +00:00
|
|
|
'showIfEmpty' => false
|
|
|
|
|
)
|
|
|
|
|
);
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-11-15 02:25:36 +00:00
|
|
|
$text .= $out;
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
2011-11-15 02:25:36 +00:00
|
|
|
|
|
|
|
|
return $text;
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-14 01:42:14 +00:00
|
|
|
/**
|
|
|
|
|
* Get a user page target for things like logs.
|
|
|
|
|
* This handles account and IP range targets.
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param User|string $target
|
2012-03-14 01:42:14 +00:00
|
|
|
* @return Title|null
|
|
|
|
|
*/
|
|
|
|
|
protected static function getTargetUserTitle( $target ) {
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $target instanceof User ) {
|
2012-03-14 01:42:14 +00:00
|
|
|
return $target->getUserPage();
|
|
|
|
|
} elseif ( IP::isIPAddress( $target ) ) {
|
|
|
|
|
return Title::makeTitleSafe( NS_USER, $target );
|
|
|
|
|
}
|
2013-04-14 17:27:14 +00:00
|
|
|
|
2012-03-14 01:42:14 +00:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-12 21:54:35 +00:00
|
|
|
/**
|
2011-03-12 22:53:15 +00:00
|
|
|
* Determine the target of the block, and the type of target
|
2014-05-09 19:33:58 +00:00
|
|
|
* @todo Should be in Block.php?
|
2014-07-24 17:43:44 +00:00
|
|
|
* @param string $par Subpage parameter passed to setup, or data value from
|
2011-03-12 22:53:15 +00:00
|
|
|
* the HTMLForm
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param WebRequest $request Optionally try and get data from a request too
|
2011-07-20 02:34:17 +00:00
|
|
|
* @return array( User|string|null, Block::TYPE_ constant|null )
|
2011-03-12 21:54:35 +00:00
|
|
|
*/
|
2012-08-29 02:34:00 +00:00
|
|
|
public static function getTargetAndType( $par, WebRequest $request = null ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$i = 0;
|
|
|
|
|
$target = null;
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2013-03-25 22:52:41 +00:00
|
|
|
while ( true ) {
|
|
|
|
|
switch ( $i++ ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
case 0:
|
|
|
|
|
# The HTMLForm will check wpTarget first and only if it doesn't get
|
|
|
|
|
# a value use the default, which will be generated from the options
|
|
|
|
|
# below; so this has to have a higher precedence here than $par, or
|
|
|
|
|
# we could end up with different values in $this->target and the HTMLForm!
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $request instanceof WebRequest ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$target = $request->getText( 'wpTarget', null );
|
2011-03-12 22:51:48 +00:00
|
|
|
}
|
2011-03-18 20:37:11 +00:00
|
|
|
break;
|
2011-03-12 22:53:15 +00:00
|
|
|
case 1:
|
|
|
|
|
$target = $par;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $request instanceof WebRequest ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$target = $request->getText( 'ip', null );
|
2011-03-12 22:51:48 +00:00
|
|
|
}
|
2011-03-18 20:37:11 +00:00
|
|
|
break;
|
2011-03-12 22:53:15 +00:00
|
|
|
case 3:
|
|
|
|
|
# B/C @since 1.18
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $request instanceof WebRequest ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$target = $request->getText( 'wpBlockAddress', null );
|
|
|
|
|
}
|
2011-03-18 20:37:11 +00:00
|
|
|
break;
|
2011-03-12 22:53:15 +00:00
|
|
|
case 4:
|
|
|
|
|
break 2;
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-13 14:47:34 +00:00
|
|
|
list( $target, $type ) = Block::parseTarget( $target );
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $type !== null ) {
|
2011-03-13 14:47:34 +00:00
|
|
|
return array( $target, $type );
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
return array( null, null );
|
|
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2011-03-13 10:02:56 +00:00
|
|
|
/**
|
|
|
|
|
* HTMLForm field validation-callback for Target field.
|
|
|
|
|
* @since 1.18
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param string $value
|
|
|
|
|
* @param array $alldata
|
|
|
|
|
* @param HTMLForm $form
|
2011-03-13 10:02:56 +00:00
|
|
|
* @return Message
|
|
|
|
|
*/
|
2011-11-13 07:25:56 +00:00
|
|
|
public static function validateTargetField( $value, $alldata, $form ) {
|
2012-11-03 04:56:24 +00:00
|
|
|
$status = self::validateTarget( $value, $form->getUser() );
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
$errors = $status->getErrorsArray();
|
2013-04-14 17:27:14 +00:00
|
|
|
|
2012-11-03 04:56:24 +00:00
|
|
|
return call_user_func_array( array( $form, 'msg' ), $errors[0] );
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Validate a block target.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.21
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $value Block target to check
|
2012-11-03 04:56:24 +00:00
|
|
|
* @param User $user Performer of the block
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
public static function validateTarget( $value, User $user ) {
|
2011-03-13 09:57:02 +00:00
|
|
|
global $wgBlockCIDRLimit;
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2013-04-14 19:18:38 +00:00
|
|
|
/** @var User $target */
|
2011-03-13 14:41:57 +00:00
|
|
|
list( $target, $type ) = self::getTargetAndType( $value );
|
2012-11-03 04:56:24 +00:00
|
|
|
$status = Status::newGood( $target );
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $type == Block::TYPE_USER ) {
|
2012-11-03 04:56:24 +00:00
|
|
|
if ( $target->isAnon() ) {
|
|
|
|
|
$status->fatal(
|
|
|
|
|
'nosuchusershort',
|
|
|
|
|
wfEscapeWikiText( $target->getName() )
|
|
|
|
|
);
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-03 04:56:24 +00:00
|
|
|
$unblockStatus = self::checkUnblockSelf( $target, $user );
|
|
|
|
|
if ( $unblockStatus !== true ) {
|
|
|
|
|
$status->fatal( 'badaccess', $unblockStatus );
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
2012-08-29 02:34:00 +00:00
|
|
|
} elseif ( $type == Block::TYPE_RANGE ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
list( $ip, $range ) = explode( '/', $target, 2 );
|
|
|
|
|
|
2012-11-03 04:56:24 +00:00
|
|
|
if (
|
|
|
|
|
( IP::isIPv4( $ip ) && $wgBlockCIDRLimit['IPv4'] == 32 ) ||
|
|
|
|
|
( IP::isIPv6( $ip ) && $wgBlockCIDRLimit['IPv6'] == 128 )
|
|
|
|
|
) {
|
|
|
|
|
// Range block effectively disabled
|
|
|
|
|
$status->fatal( 'range_block_disabled' );
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-03 04:56:24 +00:00
|
|
|
if (
|
|
|
|
|
( IP::isIPv4( $ip ) && $range > 32 ) ||
|
|
|
|
|
( IP::isIPv6( $ip ) && $range > 128 )
|
|
|
|
|
) {
|
|
|
|
|
// Dodgy range
|
|
|
|
|
$status->fatal( 'ip_range_invalid' );
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( IP::isIPv4( $ip ) && $range < $wgBlockCIDRLimit['IPv4'] ) {
|
2012-11-03 04:56:24 +00:00
|
|
|
$status->fatal( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] );
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( IP::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) {
|
2012-11-03 04:56:24 +00:00
|
|
|
$status->fatal( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] );
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
2012-08-29 02:34:00 +00:00
|
|
|
} elseif ( $type == Block::TYPE_IP ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
# All is well
|
|
|
|
|
} else {
|
2012-11-03 04:56:24 +00:00
|
|
|
$status->fatal( 'badipaddress' );
|
2011-03-12 22:51:48 +00:00
|
|
|
}
|
2011-03-13 14:41:57 +00:00
|
|
|
|
2012-11-03 04:56:24 +00:00
|
|
|
return $status;
|
2011-03-13 09:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-13 07:25:56 +00:00
|
|
|
/**
|
2015-07-27 14:23:24 +00:00
|
|
|
* Given the form data, actually implement a block. This is also called from ApiBlock.
|
|
|
|
|
*
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param array $data
|
|
|
|
|
* @param IContextSource $context
|
|
|
|
|
* @return bool|string
|
2011-03-13 09:57:02 +00:00
|
|
|
*/
|
2012-08-29 02:34:00 +00:00
|
|
|
public static function processForm( array $data, IContextSource $context ) {
|
2014-07-28 17:25:49 +00:00
|
|
|
global $wgBlockAllowsUTEdit, $wgHideUserContribLimit, $wgContLang;
|
2011-11-13 07:25:56 +00:00
|
|
|
|
|
|
|
|
$performer = $context->getUser();
|
2011-03-13 09:57:02 +00:00
|
|
|
|
|
|
|
|
// Handled by field validator callback
|
|
|
|
|
// self::validateTargetField( $data['Target'] );
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2011-04-01 23:13:15 +00:00
|
|
|
# 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 );
|
|
|
|
|
|
2013-04-14 19:18:38 +00:00
|
|
|
/** @var User $target */
|
2011-03-13 14:41:57 +00:00
|
|
|
list( $target, $type ) = self::getTargetAndType( $data['Target'] );
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $type == Block::TYPE_USER ) {
|
2011-03-13 14:41:57 +00:00
|
|
|
$user = $target;
|
|
|
|
|
$target = $user->getName();
|
|
|
|
|
$userId = $user->getId();
|
2011-03-30 18:00:11 +00:00
|
|
|
|
|
|
|
|
# Give admins a heads-up before they go and block themselves. Much messier
|
|
|
|
|
# to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
|
2011-12-20 10:15:18 +00:00
|
|
|
# permission anyway, although the code does allow for it.
|
|
|
|
|
# Note: Important to use $target instead of $data['Target']
|
|
|
|
|
# since both $data['PreviousTarget'] and $target are normalized
|
2014-12-12 08:41:27 +00:00
|
|
|
# but $data['target'] gets overridden by (non-normalized) request variable
|
2011-12-20 10:15:18 +00:00
|
|
|
# from previous request.
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $target === $performer->getName() &&
|
2013-03-25 22:52:41 +00:00
|
|
|
( $data['PreviousTarget'] !== $target || !$data['Confirm'] )
|
|
|
|
|
) {
|
2013-12-23 11:37:03 +00:00
|
|
|
return array( 'ipb-blockingself', 'ipb-confirmaction' );
|
2011-03-30 18:00:11 +00:00
|
|
|
}
|
2012-08-29 02:34:00 +00:00
|
|
|
} elseif ( $type == Block::TYPE_RANGE ) {
|
2011-03-13 14:41:57 +00:00
|
|
|
$userId = 0;
|
2012-08-29 02:34:00 +00:00
|
|
|
} elseif ( $type == Block::TYPE_IP ) {
|
2011-03-13 14:41:57 +00:00
|
|
|
$target = $target->getName();
|
|
|
|
|
$userId = 0;
|
|
|
|
|
} else {
|
|
|
|
|
# This should have been caught in the form field validation
|
2011-03-13 21:33:52 +00:00
|
|
|
return array( 'badipaddress' );
|
2011-03-13 14:41:57 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-24 10:01:51 +00:00
|
|
|
if ( ( strlen( $data['Expiry'] ) == 0 ) || ( strlen( $data['Expiry'] ) > 50 )
|
2013-03-25 22:52:41 +00:00
|
|
|
|| !self::parseExpiryInput( $data['Expiry'] )
|
|
|
|
|
) {
|
2011-03-12 22:51:48 +00:00
|
|
|
return array( 'ipb_expiry_invalid' );
|
|
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( !isset( $data['DisableEmail'] ) ) {
|
2011-03-22 11:14:11 +00:00
|
|
|
$data['DisableEmail'] = false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# If the user has done the form 'properly', they won't even have been given the
|
|
|
|
|
# option to suppress-block unless they have the 'hideuser' permission
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( !isset( $data['HideUser'] ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$data['HideUser'] = false;
|
|
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $data['HideUser'] ) {
|
2013-01-28 21:11:10 +00:00
|
|
|
if ( !$performer->isAllowed( 'hideuser' ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
# this codepath is unreachable except by a malicious user spoofing forms,
|
|
|
|
|
# or by race conditions (user has oversight and sysop, loads block form,
|
|
|
|
|
# and is de-oversighted before submission); so need to fail completely
|
|
|
|
|
# rather than just silently disable hiding
|
|
|
|
|
return array( 'badaccess-group0' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Recheck params here...
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $type != Block::TYPE_USER ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$data['HideUser'] = false; # IP users should not be hidden
|
2014-06-18 02:45:32 +00:00
|
|
|
} elseif ( !wfIsInfinity( $data['Expiry'] ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
# Bad expiry.
|
2011-03-12 21:54:35 +00:00
|
|
|
return array( 'ipb_expiry_temp' );
|
2013-12-17 18:56:33 +00:00
|
|
|
} elseif ( $wgHideUserContribLimit !== false
|
|
|
|
|
&& $user->getEditCount() > $wgHideUserContribLimit
|
|
|
|
|
) {
|
2011-03-12 22:53:15 +00:00
|
|
|
# Typically, the user should have a handful of edits.
|
|
|
|
|
# Disallow hiding users with many edits for performance.
|
2013-12-17 18:56:33 +00:00
|
|
|
return array( array( 'ipb_hide_invalid',
|
|
|
|
|
Message::numParam( $wgHideUserContribLimit ) ) );
|
2012-08-29 02:34:00 +00:00
|
|
|
} elseif ( !$data['Confirm'] ) {
|
2013-12-23 11:37:03 +00:00
|
|
|
return array( 'ipb-confirmhideuser', 'ipb-confirmaction' );
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-21 19:12:41 +00:00
|
|
|
# Create block object.
|
|
|
|
|
$block = new Block();
|
|
|
|
|
$block->setTarget( $target );
|
2011-11-13 07:25:56 +00:00
|
|
|
$block->setBlocker( $performer );
|
2014-07-28 17:25:49 +00:00
|
|
|
# Truncate reason for whole multibyte characters
|
|
|
|
|
$block->mReason = $wgContLang->truncate( $data['Reason'][0], 255 );
|
2011-03-21 19:12:41 +00:00
|
|
|
$block->mExpiry = self::parseExpiryInput( $data['Expiry'] );
|
|
|
|
|
$block->prevents( 'createaccount', $data['CreateAccount'] );
|
2011-03-20 17:43:17 +00:00
|
|
|
$block->prevents( 'editownusertalk', ( !$wgBlockAllowsUTEdit || $data['DisableUTEdit'] ) );
|
2011-03-19 23:47:08 +00:00
|
|
|
$block->prevents( 'sendemail', $data['DisableEmail'] );
|
2011-03-21 19:12:41 +00:00
|
|
|
$block->isHardblock( $data['HardBlock'] );
|
|
|
|
|
$block->isAutoblocking( $data['AutoBlock'] );
|
|
|
|
|
$block->mHideName = $data['HideUser'];
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2014-01-18 21:31:47 +00:00
|
|
|
$reason = array( 'hookaborted' );
|
2014-12-09 07:23:30 +00:00
|
|
|
if ( !Hooks::run( 'BlockIp', array( &$block, &$performer, &$reason ) ) ) {
|
2014-01-18 21:31:47 +00:00
|
|
|
return $reason;
|
2011-03-12 22:53:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Try to insert block. Is there a conflicting block?
|
2011-03-22 11:22:15 +00:00
|
|
|
$status = $block->insert();
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( !$status ) {
|
2012-04-14 21:43:49 +00:00
|
|
|
# Indicates whether the user is confirming the block and is aware of
|
|
|
|
|
# the conflict (did not change the block target in the meantime)
|
|
|
|
|
$blockNotConfirmed = !$data['Confirm'] || ( array_key_exists( 'PreviousTarget', $data )
|
|
|
|
|
&& $data['PreviousTarget'] !== $target );
|
|
|
|
|
|
|
|
|
|
# Special case for API - bug 32434
|
|
|
|
|
$reblockNotAllowed = ( array_key_exists( 'Reblock', $data ) && !$data['Reblock'] );
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Show form unless the user is already aware of this...
|
2013-03-25 22:52:41 +00:00
|
|
|
if ( $blockNotConfirmed || $reblockNotAllowed ) {
|
2011-03-22 17:26:32 +00:00
|
|
|
return array( array( 'ipb_already_blocked', $block->getTarget() ) );
|
2013-03-25 22:52:41 +00:00
|
|
|
# Otherwise, try to update the block...
|
2011-03-12 22:53:15 +00:00
|
|
|
} else {
|
|
|
|
|
# This returns direct blocks before autoblocks/rangeblocks, since we should
|
|
|
|
|
# be sure the user is blocked by now it should work for our purposes
|
2011-03-21 19:12:41 +00:00
|
|
|
$currentBlock = Block::newFromTarget( $target );
|
2011-03-12 22:53:15 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $block->equals( $currentBlock ) ) {
|
2011-03-22 17:26:32 +00:00
|
|
|
return array( array( 'ipb_already_blocked', $block->getTarget() ) );
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# If the name was hidden and the blocking user cannot hide
|
|
|
|
|
# names, then don't allow any block changes...
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $currentBlock->mHideName && !$performer->isAllowed( 'hideuser' ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
return array( 'cant-see-hidden-user' );
|
|
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2013-06-02 17:36:30 +00:00
|
|
|
$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();
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
$logaction = 'reblock';
|
|
|
|
|
|
|
|
|
|
# Unset _deleted fields if requested
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $currentBlock->mHideName && !$data['HideUser'] ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
RevisionDeleteUser::unsuppressUserName( $target, $userId );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If hiding/unhiding a name, this should go in the private logs
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( (bool)$currentBlock->mHideName ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$data['HideUser'] = true;
|
|
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
2011-03-12 22:53:15 +00:00
|
|
|
} else {
|
|
|
|
|
$logaction = 'block';
|
|
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'BlockIpComplete', array( $block, $performer ) );
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Set *_deleted fields if requested
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $data['HideUser'] ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
RevisionDeleteUser::suppressUserName( $target, $userId );
|
|
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Can't watch a rangeblock
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $type != Block::TYPE_RANGE && $data['Watch'] ) {
|
2014-05-09 19:33:58 +00:00
|
|
|
WatchAction::doWatch(
|
|
|
|
|
Title::makeTitle( NS_USER, $target ),
|
|
|
|
|
$performer,
|
|
|
|
|
WatchedItem::IGNORE_USER_RIGHTS
|
|
|
|
|
);
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Block constructor sanitizes certain block options on insert
|
2011-03-19 23:47:08 +00:00
|
|
|
$data['BlockEmail'] = $block->prevents( 'sendemail' );
|
2011-03-21 19:12:41 +00:00
|
|
|
$data['AutoBlock'] = $block->isAutoblocking();
|
2011-03-12 22:53:15 +00:00
|
|
|
|
|
|
|
|
# Prepare log parameters
|
|
|
|
|
$logParams = array();
|
2014-08-04 21:12:53 +00:00
|
|
|
$logParams['5::duration'] = $data['Expiry'];
|
|
|
|
|
$logParams['6::flags'] = self::blockLogFlags( $data, $type );
|
2011-03-12 22:53:15 +00:00
|
|
|
|
|
|
|
|
# Make log entry, if the name is hidden, put it in the oversight log
|
|
|
|
|
$log_type = $data['HideUser'] ? 'suppress' : 'block';
|
2014-08-04 21:12:53 +00:00
|
|
|
$logEntry = new ManualLogEntry( $log_type, $logaction );
|
|
|
|
|
$logEntry->setTarget( Title::makeTitle( NS_USER, $target ) );
|
|
|
|
|
$logEntry->setComment( $data['Reason'][0] );
|
|
|
|
|
$logEntry->setPerformer( $performer );
|
|
|
|
|
$logEntry->setParameters( $logParams );
|
2011-03-22 11:22:15 +00:00
|
|
|
# Relate log ID to block IDs (bug 25763)
|
2013-02-03 19:28:43 +00:00
|
|
|
$blockIds = array_merge( array( $status['id'] ), $status['autoIds'] );
|
2014-08-04 21:12:53 +00:00
|
|
|
$logEntry->setRelations( array( 'ipb_id' => $blockIds ) );
|
|
|
|
|
$logId = $logEntry->insert();
|
|
|
|
|
$logEntry->publish( $logId );
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Report to the user
|
|
|
|
|
return true;
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2011-03-12 22:53:15 +00:00
|
|
|
* Get an array of suggested block durations from MediaWiki:Ipboptions
|
2011-05-17 22:03:20 +00:00
|
|
|
* @todo FIXME: This uses a rather odd syntax for the options, should it be converted
|
2011-03-12 22:53:15 +00:00
|
|
|
* to the standard "**<duration>|<displayname>" format?
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param Language|null $lang The language to get the durations in, or null to use
|
2011-07-26 19:04:48 +00:00
|
|
|
* the wiki's content language
|
2014-04-19 08:16:52 +00:00
|
|
|
* @return array
|
2011-03-12 21:54:35 +00:00
|
|
|
*/
|
2012-08-29 02:34:00 +00:00
|
|
|
public static function getSuggestedDurations( $lang = null ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
$a = array();
|
2011-03-18 16:35:22 +00:00
|
|
|
$msg = $lang === null
|
2011-03-21 19:12:41 +00:00
|
|
|
? wfMessage( 'ipboptions' )->inContentLanguage()->text()
|
|
|
|
|
: wfMessage( 'ipboptions' )->inLanguage( $lang )->text();
|
2011-03-18 16:35:22 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $msg == '-' ) {
|
2011-03-18 16:35:22 +00:00
|
|
|
return array();
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
foreach ( explode( ',', $msg ) as $option ) {
|
|
|
|
|
if ( strpos( $option, ':' ) === false ) {
|
2011-03-18 16:35:22 +00:00
|
|
|
$option = "$option:$option";
|
|
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
list( $show, $value ) = explode( ':', $option );
|
2014-12-06 10:47:19 +00:00
|
|
|
$a[$show] = $value;
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
return $a;
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-18 16:35:22 +00:00
|
|
|
/**
|
|
|
|
|
* Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute
|
|
|
|
|
* ("24 May 2034", etc), into an absolute timestamp we can put into the database.
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param string $expiry Whatever was typed into the form
|
Clean up handling of 'infinity'
There's a bunch of stuff that probably only works because the database
representation of infinity is actually 'infinity' on all databases
besides Oracle, and Oracle in general isn't maintained.
Generally, we should probably use 'infinity' everywhere except where
directly dealing with the database.
* Many extension callers of Language::formatExpiry() with $format !==
true are assuming it'll return 'infinity', none are checking for
$db->getInfinity().
* And Language::formatExpiry() would choke if passed 'infinity', despite
callers doing this.
* And Language::formatExpiry() could be more useful for the API if we
can override the string returned for infinity.
* As for core, Title is using Language::formatExpiry() with TS_MW which
is going to be changing anyway. Extension callers mostly don't exist.
* Block already normalizes its mExpiry field (and ->getExpiry()),
but some stuff is comparing it with $db->getInfinity() anyway. A few
external users set mExpiry to $db->getInfinity(), but this is mostly
because SpecialBlock::parseExpiryInput() returns $db->getInfinity()
while most callers (including all extensions) are assuming 'infinity'.
* And for that matter, Block should use $db->decodeExpiry() instead of
manually doing it, once we make that safe to call with 'infinity' for
all the extensions passing $db->getInfinity() to Block's contructor.
* WikiPage::doUpdateRestrictions() and some of its callers are using
$db->getInfinity(), when all the inserts using that value are using
$db->encodeExpiry() which will convert 'infinity'.
This also cleans up a slave-lag issue I noticed in ApiBlock while
testing.
Bug: T92550
Change-Id: I5eb68c1fb6029da8289276ecf7c81330575029ef
2015-03-12 16:37:04 +00:00
|
|
|
* @return string Timestamp or 'infinity'
|
2011-03-18 16:35:22 +00:00
|
|
|
*/
|
|
|
|
|
public static function parseExpiryInput( $expiry ) {
|
2014-06-18 02:45:32 +00:00
|
|
|
if ( wfIsInfinity( $expiry ) ) {
|
Clean up handling of 'infinity'
There's a bunch of stuff that probably only works because the database
representation of infinity is actually 'infinity' on all databases
besides Oracle, and Oracle in general isn't maintained.
Generally, we should probably use 'infinity' everywhere except where
directly dealing with the database.
* Many extension callers of Language::formatExpiry() with $format !==
true are assuming it'll return 'infinity', none are checking for
$db->getInfinity().
* And Language::formatExpiry() would choke if passed 'infinity', despite
callers doing this.
* And Language::formatExpiry() could be more useful for the API if we
can override the string returned for infinity.
* As for core, Title is using Language::formatExpiry() with TS_MW which
is going to be changing anyway. Extension callers mostly don't exist.
* Block already normalizes its mExpiry field (and ->getExpiry()),
but some stuff is comparing it with $db->getInfinity() anyway. A few
external users set mExpiry to $db->getInfinity(), but this is mostly
because SpecialBlock::parseExpiryInput() returns $db->getInfinity()
while most callers (including all extensions) are assuming 'infinity'.
* And for that matter, Block should use $db->decodeExpiry() instead of
manually doing it, once we make that safe to call with 'infinity' for
all the extensions passing $db->getInfinity() to Block's contructor.
* WikiPage::doUpdateRestrictions() and some of its callers are using
$db->getInfinity(), when all the inserts using that value are using
$db->encodeExpiry() which will convert 'infinity'.
This also cleans up a slave-lag issue I noticed in ApiBlock while
testing.
Bug: T92550
Change-Id: I5eb68c1fb6029da8289276ecf7c81330575029ef
2015-03-12 16:37:04 +00:00
|
|
|
$expiry = 'infinity';
|
2011-03-18 16:35:22 +00:00
|
|
|
} else {
|
|
|
|
|
$expiry = strtotime( $expiry );
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-18 16:35:22 +00:00
|
|
|
if ( $expiry < 0 || $expiry === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-18 16:35:22 +00:00
|
|
|
$expiry = wfTimestamp( TS_MW, $expiry );
|
|
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-18 16:35:22 +00:00
|
|
|
return $expiry;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
/**
|
|
|
|
|
* Can we do an email block?
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param User $user The sysop wanting to make a block
|
|
|
|
|
* @return bool
|
2011-03-12 22:53:15 +00:00
|
|
|
*/
|
|
|
|
|
public static function canBlockEmail( $user ) {
|
|
|
|
|
global $wgEnableUserEmail, $wgSysopEmailBans;
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
return ( $wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ) );
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
/**
|
|
|
|
|
* bug 15810: blocked admins should not be able to block/unblock
|
|
|
|
|
* others, and probably shouldn't be able to unblock themselves
|
|
|
|
|
* either.
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param User|int|string $user
|
|
|
|
|
* @param User $performer User doing the request
|
|
|
|
|
* @return bool|string True or error message key
|
2011-03-12 22:53:15 +00:00
|
|
|
*/
|
2011-11-13 07:25:56 +00:00
|
|
|
public static function checkUnblockSelf( $user, User $performer ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
if ( is_int( $user ) ) {
|
|
|
|
|
$user = User::newFromId( $user );
|
|
|
|
|
} elseif ( is_string( $user ) ) {
|
|
|
|
|
$user = User::newFromName( $user );
|
|
|
|
|
}
|
2011-09-01 13:59:38 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $performer->isBlocked() ) {
|
|
|
|
|
if ( $user instanceof User && $user->getId() == $performer->getId() ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
# User is trying to unblock themselves
|
2011-11-13 07:25:56 +00:00
|
|
|
if ( $performer->isAllowed( 'unblockself' ) ) {
|
2011-03-12 22:53:15 +00:00
|
|
|
return true;
|
2013-03-25 22:52:41 +00:00
|
|
|
# User blocked themselves and is now trying to reverse it
|
2011-11-13 07:25:56 +00:00
|
|
|
} elseif ( $performer->blockedBy() === $performer->getName() ) {
|
2011-07-26 19:04:48 +00:00
|
|
|
return true;
|
2011-03-12 22:53:15 +00:00
|
|
|
} else {
|
|
|
|
|
return 'ipbnounblockself';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
# User is trying to block/unblock someone else
|
|
|
|
|
return 'ipbblocked';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a comma-delimited list of "flags" to be passed to the log
|
|
|
|
|
* reader for this block, to provide more information in the logs
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param array $data From HTMLForm data
|
|
|
|
|
* @param int $type Block::TYPE_ constant (USER, RANGE, or IP)
|
2012-08-29 02:34:00 +00:00
|
|
|
* @return string
|
2011-03-12 21:54:35 +00:00
|
|
|
*/
|
2011-03-12 22:53:15 +00:00
|
|
|
protected static function blockLogFlags( array $data, $type ) {
|
2011-03-12 21:54:35 +00:00
|
|
|
global $wgBlockAllowsUTEdit;
|
|
|
|
|
$flags = array();
|
2011-03-12 22:51:48 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
# when blocking a user the option 'anononly' is not available/has no effect
|
|
|
|
|
# -> do not write this into log
|
|
|
|
|
if ( !$data['HardBlock'] && $type != Block::TYPE_USER ) {
|
2011-09-01 14:40:56 +00:00
|
|
|
// For grepping: message block-log-flags-anononly
|
2011-03-12 22:53:15 +00:00
|
|
|
$flags[] = 'anononly';
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $data['CreateAccount'] ) {
|
2011-09-01 14:40:56 +00:00
|
|
|
// For grepping: message block-log-flags-nocreate
|
2011-03-12 22:53:15 +00:00
|
|
|
$flags[] = 'nocreate';
|
|
|
|
|
}
|
2011-03-12 22:51:48 +00:00
|
|
|
|
2011-03-12 22:53:15 +00:00
|
|
|
# Same as anononly, this is not displayed when blocking an IP address
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( !$data['AutoBlock'] && $type == Block::TYPE_USER ) {
|
2011-09-01 14:40:56 +00:00
|
|
|
// For grepping: message block-log-flags-noautoblock
|
2011-03-12 22:53:15 +00:00
|
|
|
$flags[] = 'noautoblock';
|
|
|
|
|
}
|
2011-03-12 22:51:48 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $data['DisableEmail'] ) {
|
2011-09-01 14:40:56 +00:00
|
|
|
// For grepping: message block-log-flags-noemail
|
2011-03-12 22:53:15 +00:00
|
|
|
$flags[] = 'noemail';
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $wgBlockAllowsUTEdit && $data['DisableUTEdit'] ) {
|
2011-09-01 14:40:56 +00:00
|
|
|
// For grepping: message block-log-flags-nousertalk
|
2011-03-12 22:53:15 +00:00
|
|
|
$flags[] = 'nousertalk';
|
|
|
|
|
}
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2012-08-29 02:34:00 +00:00
|
|
|
if ( $data['HideUser'] ) {
|
2011-09-01 14:40:56 +00:00
|
|
|
// For grepping: message block-log-flags-hiddenname
|
2011-03-12 22:53:15 +00:00
|
|
|
$flags[] = 'hiddenname';
|
2011-03-12 22:51:48 +00:00
|
|
|
}
|
2011-03-12 22:53:15 +00:00
|
|
|
|
|
|
|
|
return implode( ',', $flags );
|
2011-03-12 22:51:48 +00:00
|
|
|
}
|
2011-11-15 02:25:36 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Process the form on POST submission.
|
2014-04-19 08:16:52 +00:00
|
|
|
* @param array $data
|
2015-07-27 14:23:24 +00:00
|
|
|
* @param HTMLForm $form
|
2014-04-19 08:16:52 +00:00
|
|
|
* @return bool|array True for success, false for didn't-try, array of errors on failure
|
2011-11-15 02:25:36 +00:00
|
|
|
*/
|
2015-07-27 14:23:24 +00:00
|
|
|
public function onSubmit( array $data, HTMLForm $form = null ) {
|
|
|
|
|
return self::processForm( $data, $form->getContext() );
|
2011-11-15 02:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Do something exciting on successful processing of the form, most likely to show a
|
|
|
|
|
* confirmation message
|
|
|
|
|
*/
|
|
|
|
|
public function onSuccess() {
|
|
|
|
|
$out = $this->getOutput();
|
|
|
|
|
$out->setPageTitle( $this->msg( 'blockipsuccesssub' ) );
|
2012-04-21 13:12:08 +00:00
|
|
|
$out->addWikiMsg( 'blockipsuccesstext', wfEscapeWikiText( $this->target ) );
|
2011-11-15 02:25:36 +00:00
|
|
|
}
|
2013-03-07 20:15:54 +00:00
|
|
|
|
|
|
|
|
protected function getGroupName() {
|
|
|
|
|
return 'users';
|
|
|
|
|
}
|
2011-03-12 22:51:48 +00:00
|
|
|
}
|