X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUnblock.php;h=ace41a4e364c16f5714390d604d9f2761b12da49;hb=ed6a2d5df1b60c15f6b541838aabf946ecbaa1e0;hp=2854a8252923b505ea29096ab9e611f6af6ecc65;hpb=5f8b92578167107e91e2b10b631de0cada0b4854;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index 2854a82529..ace41a4e36 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -53,14 +53,29 @@ class ApiUnblock extends ApiBase { if ( $user->isBlocked() ) { $status = SpecialBlock::checkUnblockSelf( $params['user'], $user ); if ( $status !== true ) { - $this->dieUsageMsg( $status ); + $msg = $this->parseMsg( $status ); + $this->dieUsage( + $msg['info'], + $msg['code'], + 0, + [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ] + ); } } - $data = array( + // Check if user can add tags + if ( !is_null( $params['tags'] ) ) { + $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user ); + if ( !$ableToTag->isOK() ) { + $this->dieStatus( $ableToTag ); + } + } + + $data = [ 'Target' => is_null( $params['id'] ) ? $params['user'] : "#{$params['id']}", - 'Reason' => $params['reason'] - ); + 'Reason' => $params['reason'], + 'Tags' => $params['tags'] + ]; $block = Block::newFromTarget( $data['Target'] ); $retval = SpecialUnblock::processUnblock( $data, $this->getContext() ); if ( $retval !== true ) { @@ -84,40 +99,30 @@ class ApiUnblock extends ApiBase { } public function getAllowedParams() { - return array( - 'id' => array( + return [ + 'id' => [ ApiBase::PARAM_TYPE => 'integer', - ), + ], 'user' => null, 'reason' => '', - ); - } - - public function getParamDescription() { - $p = $this->getModulePrefix(); - - return array( - 'id' => "ID of the block you want to unblock (obtained through list=blocks). " . - "Cannot be used together with {$p}user", - 'user' => "Username, IP address or IP range you want to unblock. " . - "Cannot be used together with {$p}id", - 'reason' => 'Reason for unblock', - ); - } - - public function getDescription() { - return 'Unblock a user.'; + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ], + ]; } public function needsToken() { return 'csrf'; } - public function getExamples() { - return array( - 'api.php?action=unblock&id=105', - 'api.php?action=unblock&user=Bob&reason=Sorry%20Bob' - ); + protected function getExamplesMessages() { + return [ + 'action=unblock&id=105' + => 'apihelp-unblock-example-id', + 'action=unblock&user=Bob&reason=Sorry%20Bob' + => 'apihelp-unblock-example-user', + ]; } public function getHelpUrls() {