2011-08-26 20:12:34 +00:00
|
|
|
<?php
|
|
|
|
|
2011-09-29 23:30:42 +00:00
|
|
|
class ApiAbuseFilterUnblockAutopromote extends ApiBase {
|
2011-08-26 20:12:34 +00:00
|
|
|
public function execute() {
|
2011-11-16 05:34:24 +00:00
|
|
|
if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
|
2011-08-26 20:12:34 +00:00
|
|
|
$this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' );
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:52:46 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2011-08-26 20:12:34 +00:00
|
|
|
$user = User::newFromName( $params['user'] );
|
|
|
|
|
|
|
|
if ( $user === false ) {
|
2011-09-30 00:48:00 +00:00
|
|
|
// Oh god this is so bad but this message uses GENDER
|
2012-09-02 11:07:02 +00:00
|
|
|
$msg = wfMessage( 'abusefilter-reautoconfirm-none', $params['user'] )->text();
|
2011-08-26 20:12:34 +00:00
|
|
|
$this->dieUsage( $msg, 'notsuspended' );
|
|
|
|
}
|
|
|
|
|
|
|
|
global $wgMemc;
|
|
|
|
$key = AbuseFilter::autoPromoteBlockKey( $user );
|
|
|
|
|
|
|
|
if ( !$wgMemc->get( $key ) ) {
|
2011-09-30 00:48:00 +00:00
|
|
|
// Same as above :(
|
2012-09-02 11:07:02 +00:00
|
|
|
$msg = wfMessage( 'abusefilter-reautoconfirm-none', $params['user'] )->text();
|
2011-08-26 20:12:34 +00:00
|
|
|
$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,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-10-28 16:25:22 +00:00
|
|
|
/**
|
|
|
|
* @deprecated since MediaWiki core 1.25
|
|
|
|
*/
|
2011-08-26 20:12:34 +00:00
|
|
|
public function getParamDescription() {
|
|
|
|
return array(
|
|
|
|
'user' => 'Username of the user you want to unblock',
|
|
|
|
'token' => 'An edit token',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-10-28 16:25:22 +00:00
|
|
|
/**
|
|
|
|
* @deprecated since MediaWiki core 1.25
|
|
|
|
*/
|
2011-08-26 20:12:34 +00:00
|
|
|
public function getDescription() {
|
|
|
|
return 'Unblocks a user from receiving autopromotions due to an abusefilter consequence';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function needsToken() {
|
2014-08-09 12:56:14 +00:00
|
|
|
return 'csrf';
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getTokenSalt() {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2014-10-28 16:25:22 +00:00
|
|
|
/**
|
|
|
|
* @deprecated since MediaWiki core 1.25
|
|
|
|
*/
|
2011-08-26 20:12:34 +00:00
|
|
|
public function getExamples() {
|
|
|
|
return array(
|
2012-05-19 06:41:06 +00:00
|
|
|
"api.php?action=abusefilterunblockautopromote&user=Bob&token=%2B\\"
|
2011-08-26 20:12:34 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-10-28 16:25:22 +00:00
|
|
|
/**
|
|
|
|
* @see ApiBase::getExamplesMessages()
|
|
|
|
*/
|
|
|
|
protected function getExamplesMessages() {
|
|
|
|
return array(
|
|
|
|
'action=abusefilterunblockautopromote&user=Example&token=123ABC'
|
|
|
|
=> 'apihelp-abusefilterunblockautopromote-example-1',
|
|
|
|
);
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
|
|
|
}
|