mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
176227e721
* Replace deprecated methods. * Remove no longer needed function fnmatch(). * Remove superfluous newlines. * Remove unused and redundant local variables and globals. * Deglobalization. * Update documentation. * Fix incorrect return values or add FIXMEs when in doubt. * Escape output in a few places where needed. * Remove unneeded MEDIAWIKI constant checks. * Fix various JSHint/JSLint issues. Patch Set 11: Merged https://gerrit.wikimedia.org/r/24701 into this one per Siebrand's request Change-Id: I02ba4ce31b6aca5b7324114093f8ece143abc295
86 lines
2.1 KiB
PHP
86 lines
2.1 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 getPossibleErrors() {
|
|
return array_merge( parent::getPossibleErrors(), array(
|
|
array( 'code' => 'notsuspended', 'info' => 'That user has not had their autoconfirmed status suspended'),
|
|
array( 'code' => 'permissiondenied', 'info' => 'You do not have permissions to unblock autopromotion' ),
|
|
) );
|
|
}
|
|
|
|
public function needsToken() {
|
|
return true;
|
|
}
|
|
|
|
public function getTokenSalt() {
|
|
return '';
|
|
}
|
|
|
|
public function getExamples() {
|
|
return array(
|
|
"api.php?action=abusefilterunblockautopromote&user=Bob&token=%2B\\"
|
|
);
|
|
}
|
|
|
|
public function getVersion() {
|
|
return __CLASS__ . ': $Id$';
|
|
}
|
|
}
|