mediawiki-extensions-AbuseF.../api/ApiAbuseFilterUnblockAutopromote.php
Brad Jorsch 3aa76b0f5f Remove pre-1.25 API compatibility code
Since this extension uses extension.json, it already requires 1.25+ so
no need to keep the old code around.

Change-Id: I6f968be3b7ef7cbc7193c8e103beb36ecf9c7b60
2016-09-20 15:31:58 -04:00

63 lines
1.5 KiB
PHP

<?php
class ApiAbuseFilterUnblockAutopromote extends ApiBase {
public function execute() {
if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
$this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' );
}
$params = $this->extractRequestParams();
$user = User::newFromName( $params['user'] );
if ( $user === false ) {
// Oh god this is so bad but this message uses GENDER
$msg = wfMessage( 'abusefilter-reautoconfirm-none', $params['user'] )->text();
$this->dieUsage( $msg, 'notsuspended' );
}
$key = AbuseFilter::autoPromoteBlockKey( $user );
$stash = ObjectCache::getMainStashInstance();
if ( !$stash->get( $key ) ) {
// Same as above :(
$msg = wfMessage( 'abusefilter-reautoconfirm-none', $params['user'] )->text();
$this->dieUsage( $msg, 'notsuspended' );
}
$stash->delete( $key );
$res = array( 'user' => $params['user'] );
$this->getResult()->addValue( null, $this->getModuleName(), $res );
}
public function mustBePosted() {
return true;
}
public function isWriteMode() {
return true;
}
public function getAllowedParams() {
return array(
'user' => array(
ApiBase::PARAM_REQUIRED => true
),
'token' => null,
);
}
public function needsToken() {
return 'csrf';
}
/**
* @see ApiBase::getExamplesMessages()
*/
protected function getExamplesMessages() {
return array(
'action=abusefilterunblockautopromote&user=Example&token=123ABC'
=> 'apihelp-abusefilterunblockautopromote-example-1',
);
}
}