2007-12-06 16:06:22 +00:00
|
|
|
<?php
|
2010-02-21 12:32:46 +00:00
|
|
|
/**
|
2012-07-15 20:13:02 +00:00
|
|
|
* Copyright © 2007 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
|
2007-12-06 16:06:22 +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.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-12-06 16:06:22 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-04-22 19:45:13 +00:00
|
|
|
use MediaWiki\Block\AbstractBlock;
|
2021-04-29 16:21:50 +00:00
|
|
|
use MediaWiki\Block\BlockActionInfo;
|
2020-09-19 18:06:27 +00:00
|
|
|
use MediaWiki\Block\BlockPermissionCheckerFactory;
|
2020-04-23 19:33:56 +00:00
|
|
|
use MediaWiki\Block\BlockUserFactory;
|
2021-03-17 17:48:43 +00:00
|
|
|
use MediaWiki\Block\BlockUtils;
|
2019-05-13 14:18:07 +00:00
|
|
|
use MediaWiki\Block\DatabaseBlock;
|
2021-04-29 16:21:50 +00:00
|
|
|
use MediaWiki\Block\Restriction\ActionRestriction;
|
2020-04-23 19:33:56 +00:00
|
|
|
use MediaWiki\Block\Restriction\NamespaceRestriction;
|
|
|
|
|
use MediaWiki\Block\Restriction\PageRestriction;
|
2021-07-26 11:39:51 +00:00
|
|
|
use MediaWiki\ParamValidator\TypeDef\TitleDef;
|
2019-08-21 19:53:53 +00:00
|
|
|
use MediaWiki\ParamValidator\TypeDef\UserDef;
|
2020-04-23 19:33:56 +00:00
|
|
|
use MediaWiki\User\UserIdentity;
|
2021-06-28 19:16:31 +00:00
|
|
|
use MediaWiki\User\UserIdentityLookup;
|
2021-07-04 12:47:21 +00:00
|
|
|
use MediaWiki\User\UserOptionsLookup;
|
|
|
|
|
use MediaWiki\Watchlist\WatchlistManager;
|
2020-10-01 12:17:06 +00:00
|
|
|
use Wikimedia\ParamValidator\TypeDef\ExpiryDef;
|
2019-05-13 14:18:07 +00:00
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
/**
|
2013-03-07 16:27:38 +00:00
|
|
|
* API module that facilitates the blocking of users. Requires API write mode
|
|
|
|
|
* to be enabled.
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
class ApiBlock extends ApiBase {
|
|
|
|
|
|
2019-04-29 07:47:31 +00:00
|
|
|
use ApiBlockInfoTrait;
|
2020-10-01 12:17:06 +00:00
|
|
|
use ApiWatchlistTrait;
|
2019-04-29 07:47:31 +00:00
|
|
|
|
2020-09-19 18:06:27 +00:00
|
|
|
/** @var BlockPermissionCheckerFactory */
|
|
|
|
|
private $blockPermissionCheckerFactory;
|
|
|
|
|
|
2020-04-23 19:33:56 +00:00
|
|
|
/** @var BlockUserFactory */
|
|
|
|
|
private $blockUserFactory;
|
|
|
|
|
|
|
|
|
|
/** @var TitleFactory */
|
|
|
|
|
private $titleFactory;
|
|
|
|
|
|
2021-06-28 19:16:31 +00:00
|
|
|
/** @var UserIdentityLookup */
|
|
|
|
|
private $userIdentityLookup;
|
2020-04-23 19:33:56 +00:00
|
|
|
|
2020-10-01 12:17:06 +00:00
|
|
|
/** @var WatchedItemStoreInterface */
|
|
|
|
|
private $watchedItemStore;
|
|
|
|
|
|
2021-03-17 17:48:43 +00:00
|
|
|
/** @var BlockUtils */
|
|
|
|
|
private $blockUtils;
|
|
|
|
|
|
2021-04-29 16:21:50 +00:00
|
|
|
/** @var BlockActionInfo */
|
|
|
|
|
private $blockActionInfo;
|
|
|
|
|
|
2020-09-19 18:06:27 +00:00
|
|
|
/**
|
|
|
|
|
* @param ApiMain $main
|
|
|
|
|
* @param string $action
|
|
|
|
|
* @param BlockPermissionCheckerFactory $blockPermissionCheckerFactory
|
2020-04-23 19:33:56 +00:00
|
|
|
* @param BlockUserFactory $blockUserFactory
|
|
|
|
|
* @param TitleFactory $titleFactory
|
2021-06-28 19:16:31 +00:00
|
|
|
* @param UserIdentityLookup $userIdentityLookup
|
2020-10-01 12:17:06 +00:00
|
|
|
* @param WatchedItemStoreInterface $watchedItemStore
|
2021-03-17 17:48:43 +00:00
|
|
|
* @param BlockUtils $blockUtils
|
2021-04-29 16:21:50 +00:00
|
|
|
* @param BlockActionInfo $blockActionInfo
|
2021-07-04 12:47:21 +00:00
|
|
|
* @param WatchlistManager $watchlistManager
|
|
|
|
|
* @param UserOptionsLookup $userOptionsLookup
|
2020-09-19 18:06:27 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct(
|
|
|
|
|
ApiMain $main,
|
|
|
|
|
$action,
|
2020-04-23 19:33:56 +00:00
|
|
|
BlockPermissionCheckerFactory $blockPermissionCheckerFactory,
|
|
|
|
|
BlockUserFactory $blockUserFactory,
|
|
|
|
|
TitleFactory $titleFactory,
|
2021-06-28 19:16:31 +00:00
|
|
|
UserIdentityLookup $userIdentityLookup,
|
2021-03-17 17:48:43 +00:00
|
|
|
WatchedItemStoreInterface $watchedItemStore,
|
2021-04-29 16:21:50 +00:00
|
|
|
BlockUtils $blockUtils,
|
2021-07-04 12:47:21 +00:00
|
|
|
BlockActionInfo $blockActionInfo,
|
|
|
|
|
WatchlistManager $watchlistManager,
|
|
|
|
|
UserOptionsLookup $userOptionsLookup
|
2020-09-19 18:06:27 +00:00
|
|
|
) {
|
|
|
|
|
parent::__construct( $main, $action );
|
|
|
|
|
|
|
|
|
|
$this->blockPermissionCheckerFactory = $blockPermissionCheckerFactory;
|
2020-04-23 19:33:56 +00:00
|
|
|
$this->blockUserFactory = $blockUserFactory;
|
|
|
|
|
$this->titleFactory = $titleFactory;
|
2021-06-28 19:16:31 +00:00
|
|
|
$this->userIdentityLookup = $userIdentityLookup;
|
2020-10-01 12:17:06 +00:00
|
|
|
$this->watchedItemStore = $watchedItemStore;
|
2021-03-17 17:48:43 +00:00
|
|
|
$this->blockUtils = $blockUtils;
|
2021-04-29 16:21:50 +00:00
|
|
|
$this->blockActionInfo = $blockActionInfo;
|
2021-07-04 12:47:21 +00:00
|
|
|
|
|
|
|
|
// Variables needed in ApiWatchlistTrait trait
|
|
|
|
|
$this->watchlistExpiryEnabled = $this->getConfig()->get( 'WatchlistExpiry' );
|
|
|
|
|
$this->watchlistMaxDuration = $this->getConfig()->get( 'WatchlistExpiryMaxDuration' );
|
|
|
|
|
$this->watchlistManager = $watchlistManager;
|
|
|
|
|
$this->userOptionsLookup = $userOptionsLookup;
|
2020-09-19 18:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-12 07:08:17 +00:00
|
|
|
/**
|
|
|
|
|
* Blocks the user specified in the parameters for the given expiry, with the
|
|
|
|
|
* given reason, and with all other settings provided in the params. If the block
|
|
|
|
|
* succeeds, produces a result containing the details of the block and notice
|
|
|
|
|
* of success. If it fails, the result will specify the nature of the error.
|
|
|
|
|
*/
|
2007-12-06 16:06:22 +00:00
|
|
|
public function execute() {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->checkUserRightsAny( 'block' );
|
2007-12-06 16:06:22 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2016-12-07 17:04:02 +00:00
|
|
|
$this->requireOnlyOneParameter( $params, 'user', 'userid' );
|
|
|
|
|
|
2020-04-23 19:33:56 +00:00
|
|
|
// Make sure $target contains a parsed target
|
|
|
|
|
if ( $params['user'] !== null ) {
|
|
|
|
|
$target = $params['user'];
|
2016-12-07 17:04:02 +00:00
|
|
|
} else {
|
2021-06-28 19:16:31 +00:00
|
|
|
$target = $this->userIdentityLookup->getUserIdentityByUserId( $params['userid'] );
|
|
|
|
|
if ( !$target ) {
|
2020-04-23 19:33:56 +00:00
|
|
|
$this->dieWithError( [ 'apierror-nosuchuserid', $params['userid'] ], 'nosuchuserid' );
|
2016-12-07 17:04:02 +00:00
|
|
|
}
|
2017-01-12 07:14:55 +00:00
|
|
|
}
|
2021-03-17 17:48:43 +00:00
|
|
|
list( $target, $targetType ) = $this->blockUtils->parseBlockTarget( $target );
|
2017-01-12 07:14:55 +00:00
|
|
|
|
2020-09-19 18:06:27 +00:00
|
|
|
if (
|
|
|
|
|
$params['noemail'] &&
|
|
|
|
|
!$this->blockPermissionCheckerFactory
|
|
|
|
|
->newBlockPermissionChecker(
|
2020-04-23 19:33:56 +00:00
|
|
|
$target,
|
2020-09-19 18:06:27 +00:00
|
|
|
$this->getUser()
|
|
|
|
|
)
|
|
|
|
|
->checkEmailPermissions()
|
|
|
|
|
) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->dieWithError( 'apierror-cantblock-email' );
|
2010-02-21 12:32:46 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2020-09-28 16:23:43 +00:00
|
|
|
$restrictions = [];
|
|
|
|
|
if ( $params['partial'] ) {
|
2021-07-26 11:39:51 +00:00
|
|
|
$pageRestrictions = array_map( static function ( $title ) {
|
|
|
|
|
return PageRestriction::newFromTitle( $title );
|
|
|
|
|
}, (array)$params['pagerestrictions'] );
|
2020-12-04 07:30:22 +00:00
|
|
|
|
2021-02-10 22:31:02 +00:00
|
|
|
$namespaceRestrictions = array_map( static function ( $id ) {
|
2020-09-28 16:23:43 +00:00
|
|
|
return new NamespaceRestriction( 0, $id );
|
|
|
|
|
}, (array)$params['namespacerestrictions'] );
|
|
|
|
|
$restrictions = array_merge( $pageRestrictions, $namespaceRestrictions );
|
2021-04-29 16:21:50 +00:00
|
|
|
|
|
|
|
|
if ( $this->getConfig()->get( 'EnablePartialActionBlocks' ) ) {
|
|
|
|
|
$actionRestrictions = array_map( function ( $action ) {
|
|
|
|
|
return new ActionRestriction( 0, $this->blockActionInfo->getIdFromAction( $action ) );
|
|
|
|
|
}, (array)$params['actionrestrictions'] );
|
|
|
|
|
$restrictions = array_merge( $restrictions, $actionRestrictions );
|
|
|
|
|
}
|
2020-04-23 19:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$status = $this->blockUserFactory->newBlockUser(
|
|
|
|
|
$target,
|
2021-03-16 01:37:57 +00:00
|
|
|
$this->getAuthority(),
|
2020-04-23 19:33:56 +00:00
|
|
|
$params['expiry'],
|
|
|
|
|
$params['reason'],
|
|
|
|
|
[
|
|
|
|
|
'isCreateAccountBlocked' => $params['nocreate'],
|
|
|
|
|
'isEmailBlocked' => $params['noemail'],
|
|
|
|
|
'isHardBlock' => !$params['anononly'],
|
|
|
|
|
'isAutoblocking' => $params['autoblock'],
|
|
|
|
|
'isUserTalkEditBlocked' => !$params['allowusertalk'],
|
2020-09-23 13:39:32 +00:00
|
|
|
'isHideUser' => $params['hidename'],
|
|
|
|
|
'isPartial' => $params['partial'],
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2020-04-23 19:33:56 +00:00
|
|
|
$restrictions,
|
|
|
|
|
$params['tags']
|
|
|
|
|
)->placeBlock( $params['reblock'] );
|
|
|
|
|
|
2020-10-02 10:48:54 +00:00
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
$this->dieStatus( $status );
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-15 21:57:52 +00:00
|
|
|
$block = $status->value;
|
|
|
|
|
|
2020-10-01 12:17:06 +00:00
|
|
|
$watchlistExpiry = $this->getExpiryFromParams( $params );
|
2021-07-15 21:57:52 +00:00
|
|
|
$userPage = Title::makeTitle( NS_USER, $block->getTargetName() );
|
2020-10-01 12:17:06 +00:00
|
|
|
|
2020-04-23 19:33:56 +00:00
|
|
|
if ( $params['watchuser'] && $targetType !== AbstractBlock::TYPE_RANGE ) {
|
2020-10-01 12:17:06 +00:00
|
|
|
$this->setWatch( 'watch', $userPage, $this->getUser(), null, $watchlistExpiry );
|
2018-07-13 15:07:51 +00:00
|
|
|
}
|
|
|
|
|
|
2019-08-30 17:56:27 +00:00
|
|
|
$res = [];
|
2019-09-03 17:38:57 +00:00
|
|
|
|
2021-07-15 21:57:52 +00:00
|
|
|
$res['user'] = $block->getTargetName();
|
|
|
|
|
$res['userID'] = $target instanceof UserIdentity ? $target->getId() : 0;
|
2011-03-12 21:54:35 +00:00
|
|
|
|
2019-05-13 14:18:07 +00:00
|
|
|
if ( $block instanceof DatabaseBlock ) {
|
2019-03-22 15:16:40 +00:00
|
|
|
$res['expiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
|
2012-04-22 12:20:46 +00:00
|
|
|
$res['id'] = $block->getId();
|
2011-03-12 21:54:35 +00:00
|
|
|
} else {
|
|
|
|
|
# should be unreachable
|
2018-03-18 18:48:51 +00:00
|
|
|
$res['expiry'] = ''; // @codeCoverageIgnore
|
|
|
|
|
$res['id'] = ''; // @codeCoverageIgnore
|
2011-03-12 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
$res['reason'] = $params['reason'];
|
2015-01-16 19:00:07 +00:00
|
|
|
$res['anononly'] = $params['anononly'];
|
|
|
|
|
$res['nocreate'] = $params['nocreate'];
|
|
|
|
|
$res['autoblock'] = $params['autoblock'];
|
|
|
|
|
$res['noemail'] = $params['noemail'];
|
|
|
|
|
$res['hidename'] = $params['hidename'];
|
|
|
|
|
$res['allowusertalk'] = $params['allowusertalk'];
|
|
|
|
|
$res['watchuser'] = $params['watchuser'];
|
2020-10-01 12:17:06 +00:00
|
|
|
if ( $watchlistExpiry ) {
|
|
|
|
|
$expiry = $this->getWatchlistExpiry(
|
|
|
|
|
$this->watchedItemStore,
|
|
|
|
|
$userPage,
|
|
|
|
|
$this->getUser()
|
|
|
|
|
);
|
|
|
|
|
$res['watchlistexpiry'] = $expiry;
|
|
|
|
|
}
|
2020-03-02 16:18:23 +00:00
|
|
|
$res['partial'] = $params['partial'];
|
|
|
|
|
$res['pagerestrictions'] = $params['pagerestrictions'];
|
|
|
|
|
$res['namespacerestrictions'] = $params['namespacerestrictions'];
|
2021-04-29 16:21:50 +00:00
|
|
|
if ( $this->getConfig()->get( 'EnablePartialActionBlocks' ) ) {
|
|
|
|
|
$res['actionrestrictions'] = $params['actionrestrictions'];
|
|
|
|
|
}
|
2018-08-27 22:19:37 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $res );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-14 21:12:11 +00:00
|
|
|
public function mustBePosted() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2008-01-18 20:43:59 +00:00
|
|
|
|
2009-03-06 13:49:44 +00:00
|
|
|
public function isWriteMode() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2020-10-01 12:17:06 +00:00
|
|
|
$params = [
|
2016-02-17 09:09:32 +00:00
|
|
|
'user' => [
|
2016-01-04 18:55:26 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'user',
|
2019-08-21 19:53:53 +00:00
|
|
|
UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'ip', 'cidr', 'id' ],
|
2016-12-07 17:04:02 +00:00
|
|
|
],
|
|
|
|
|
'userid' => [
|
|
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
2019-08-21 19:53:53 +00:00
|
|
|
ApiBase::PARAM_DEPRECATED => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2007-12-06 16:06:22 +00:00
|
|
|
'expiry' => 'never',
|
2012-07-07 07:12:04 +00:00
|
|
|
'reason' => '',
|
2007-12-06 16:06:22 +00:00
|
|
|
'anononly' => false,
|
|
|
|
|
'nocreate' => false,
|
|
|
|
|
'autoblock' => false,
|
|
|
|
|
'noemail' => false,
|
|
|
|
|
'hidename' => false,
|
2008-10-26 10:47:13 +00:00
|
|
|
'allowusertalk' => false,
|
2008-11-18 15:21:04 +00:00
|
|
|
'reblock' => false,
|
2011-01-02 19:58:27 +00:00
|
|
|
'watchuser' => false,
|
2020-10-01 12:17:06 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Params appear in the docs in the order they are defined,
|
|
|
|
|
// which is why this is here and not at the bottom.
|
|
|
|
|
// @todo Find better way to support insertion at arbitrary position
|
|
|
|
|
if ( $this->watchlistExpiryEnabled ) {
|
|
|
|
|
$params += [
|
|
|
|
|
'watchlistexpiry' => [
|
|
|
|
|
ApiBase::PARAM_TYPE => 'expiry',
|
|
|
|
|
ExpiryDef::PARAM_MAX => $this->watchlistMaxDuration,
|
|
|
|
|
ExpiryDef::PARAM_USE_MAX => true,
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 16:21:50 +00:00
|
|
|
$params += [
|
2017-01-12 07:14:55 +00:00
|
|
|
'tags' => [
|
|
|
|
|
ApiBase::PARAM_TYPE => 'tags',
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
],
|
2020-03-02 16:18:23 +00:00
|
|
|
'partial' => false,
|
|
|
|
|
'pagerestrictions' => [
|
2021-07-26 11:39:51 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'title',
|
|
|
|
|
TitleDef::PARAM_MUST_EXIST => true,
|
|
|
|
|
|
|
|
|
|
// TODO: TitleDef returns instances of TitleValue when PARAM_RETURN_OBJECT is
|
|
|
|
|
// truthy. At the time of writing,
|
|
|
|
|
// MediaWiki\Block\Restriction\PageRestriction::newFromTitle accepts either
|
|
|
|
|
// string or instance of Title.
|
|
|
|
|
//TitleDef::PARAM_RETURN_OBJECT => true,
|
|
|
|
|
|
2018-08-27 22:19:37 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
2018-12-17 17:53:27 +00:00
|
|
|
ApiBase::PARAM_ISMULTI_LIMIT1 => 10,
|
|
|
|
|
ApiBase::PARAM_ISMULTI_LIMIT2 => 10,
|
2020-03-02 16:18:23 +00:00
|
|
|
],
|
|
|
|
|
'namespacerestrictions' => [
|
2018-12-14 21:08:40 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase::PARAM_TYPE => 'namespace',
|
2020-03-02 16:18:23 +00:00
|
|
|
],
|
|
|
|
|
];
|
2021-04-29 16:21:50 +00:00
|
|
|
|
|
|
|
|
if ( $this->getConfig()->get( 'EnablePartialActionBlocks' ) ) {
|
|
|
|
|
$params += [
|
|
|
|
|
'actionrestrictions' => [
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase::PARAM_TYPE => array_keys(
|
|
|
|
|
$this->blockActionInfo->getAllBlockActions()
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $params;
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-01 20:12:50 +00:00
|
|
|
public function needsToken() {
|
2014-08-08 16:56:07 +00:00
|
|
|
return 'csrf';
|
2010-02-14 22:20:27 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2014-10-28 17:17:02 +00:00
|
|
|
protected function getExamplesMessages() {
|
2018-01-01 13:10:16 +00:00
|
|
|
// phpcs:disable Generic.Files.LineLength
|
2016-02-20 20:16:20 +00:00
|
|
|
return [
|
2014-09-18 17:38:23 +00:00
|
|
|
'action=block&user=192.0.2.5&expiry=3%20days&reason=First%20strike&token=123ABC'
|
|
|
|
|
=> 'apihelp-block-example-ip-simple',
|
|
|
|
|
'action=block&user=Vandal&expiry=never&reason=Vandalism&nocreate=&autoblock=&noemail=&token=123ABC'
|
|
|
|
|
=> 'apihelp-block-example-user-complex',
|
2016-02-20 20:16:20 +00:00
|
|
|
];
|
2018-01-01 13:10:16 +00:00
|
|
|
// phpcs:enable
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-17 16:38:24 +00:00
|
|
|
public function getHelpUrls() {
|
2017-04-04 22:52:57 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Block';
|
2011-07-17 16:38:24 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|