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() {
|
2017-08-07 23:35:21 +00:00
|
|
|
$this->checkUserRightsAny( 'abusefilter-modify' );
|
2011-08-26 20:12:34 +00:00
|
|
|
|
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 ) {
|
2016-11-03 19:16:55 +00:00
|
|
|
$encParamName = $this->encodeParamName( 'user' );
|
2017-08-07 23:35:21 +00:00
|
|
|
$this->dieWithError(
|
|
|
|
[ 'apierror-baduser', $encParamName, wfEscapeWikiText( $param['user'] ) ],
|
|
|
|
"baduser_{$encParamName}"
|
|
|
|
);
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$key = AbuseFilter::autoPromoteBlockKey( $user );
|
2015-05-21 21:54:30 +00:00
|
|
|
$stash = ObjectCache::getMainStashInstance();
|
|
|
|
if ( !$stash->get( $key ) ) {
|
2017-08-07 23:35:21 +00:00
|
|
|
$this->dieWithError( [ 'abusefilter-reautoconfirm-none', $user->getName() ], 'notsuspended' );
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 21:54:30 +00:00
|
|
|
$stash->delete( $key );
|
2011-08-26 20:12:34 +00:00
|
|
|
|
2017-06-15 14:23:16 +00:00
|
|
|
$res = [ 'user' => $params['user'] ];
|
2011-08-26 20:12:34 +00:00
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $res );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function mustBePosted() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isWriteMode() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAllowedParams() {
|
2017-06-15 14:23:16 +00:00
|
|
|
return [
|
|
|
|
'user' => [
|
2016-11-03 19:16:55 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'user',
|
2011-08-26 20:12:34 +00:00
|
|
|
ApiBase::PARAM_REQUIRED => true
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
2011-08-26 20:12:34 +00:00
|
|
|
'token' => null,
|
2017-06-15 14:23:16 +00:00
|
|
|
];
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function needsToken() {
|
2014-08-09 12:56:14 +00:00
|
|
|
return 'csrf';
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
|
|
|
|
2014-10-28 16:25:22 +00:00
|
|
|
/**
|
|
|
|
* @see ApiBase::getExamplesMessages()
|
2017-10-06 18:52:31 +00:00
|
|
|
* @return array
|
2014-10-28 16:25:22 +00:00
|
|
|
*/
|
|
|
|
protected function getExamplesMessages() {
|
2017-06-15 14:23:16 +00:00
|
|
|
return [
|
2014-10-28 16:25:22 +00:00
|
|
|
'action=abusefilterunblockautopromote&user=Example&token=123ABC'
|
|
|
|
=> 'apihelp-abusefilterunblockautopromote-example-1',
|
2017-06-15 14:23:16 +00:00
|
|
|
];
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
|
|
|
}
|