diff options
author | Subin Siby <subins2000@gmail.com> | 2016-12-07 22:34:02 +0530 |
---|---|---|
committer | Subin Siby <subins2000@gmail.com> | 2016-12-13 18:16:24 +0530 |
commit | 395fe60176a4df28e309d97be86ff12a3c5bd1e8 (patch) | |
tree | f7ec12669dc557040fa18d400fdfc7364f84725a /includes/api/ApiUnblock.php | |
parent | bf714879c1948cfdc0daab62681e4004226d1734 (diff) | |
download | mediawikicore-395fe60176a4df28e309d97be86ff12a3c5bd1e8.tar.gz mediawikicore-395fe60176a4df28e309d97be86ff12a3c5bd1e8.zip |
Block API: Allow blocking/unblocking by user's ID
Add feature to block/unblock users by their ID. For this,a new
parameter `userid` is added to block & unblock API request.
Bug: T34496
Change-Id: I084a4e275cd937053c505cd388a365b316990ece
Diffstat (limited to 'includes/api/ApiUnblock.php')
-rw-r--r-- | includes/api/ApiUnblock.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index 523a888d1277..3eeb7a490eba 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -39,7 +39,7 @@ class ApiUnblock extends ApiBase { $user = $this->getUser(); $params = $this->extractRequestParams(); - $this->requireOnlyOneParameter( $params, 'id', 'user' ); + $this->requireOnlyOneParameter( $params, 'id', 'user', 'userid' ); if ( !$user->isAllowed( 'block' ) ) { $this->dieWithError( 'apierror-permissiondenied-unblock', 'permissiondenied' ); @@ -64,6 +64,16 @@ class ApiUnblock extends ApiBase { } } + if ( $params['userid'] !== null ) { + $username = User::whoIs( $params['userid'] ); + + if ( $username === false ) { + $this->dieWithError( [ 'apierror-nosuchuserid', $params['userid'] ], 'nosuchuserid' ); + } else { + $params['user'] = $username; + } + } + $data = [ 'Target' => is_null( $params['id'] ) ? $params['user'] : "#{$params['id']}", 'Reason' => $params['reason'], @@ -97,6 +107,9 @@ class ApiUnblock extends ApiBase { ApiBase::PARAM_TYPE => 'integer', ], 'user' => null, + 'userid' => [ + ApiBase::PARAM_TYPE => 'integer' + ], 'reason' => '', 'tags' => [ ApiBase::PARAM_TYPE => 'tags', |