mediawiki-extensions-AbuseF.../api/ApiAbuseFilterUnblockAutopromote.php
addshore f3a829329e Remove use of deprecated getPossibleErrors (since 1.24)
Change-Id: If43d20687b5aaf78880c7d91e7487da5cb5f7e17
2014-08-29 11:56:02 +01:00

79 lines
1.8 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' );
}
global $wgMemc;
$key = AbuseFilter::autoPromoteBlockKey( $user );
if ( !$wgMemc->get( $key ) ) {
// Same as above :(
$msg = wfMessage( 'abusefilter-reautoconfirm-none', $params['user'] )->text();
$this->dieUsage( $msg, 'notsuspended' );
}
$wgMemc->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 getParamDescription() {
return array(
'user' => 'Username of the user you want to unblock',
'token' => 'An edit token',
);
}
public function getDescription() {
return 'Unblocks a user from receiving autopromotions due to an abusefilter consequence';
}
public function needsToken() {
return 'csrf';
}
public function getTokenSalt() {
return '';
}
public function getExamples() {
return array(
"api.php?action=abusefilterunblockautopromote&user=Bob&token=%2B\\"
);
}
public function getVersion() {
return __CLASS__ . ': $Id$';
}
}