X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiManageTags.php;h=42de16101856a7aca837ef692c7b446eb67961a5;hb=4d4264f59ea77b91fc8047d5284f424f214882b6;hp=3299f73b5b0e58b2dc214a548c733ae86dc83896;hpb=4e6810e4a2c1d821d8d108c7974ac16917561764;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiManageTags.php b/includes/api/ApiManageTags.php index 3299f73b5b..42de161018 100644 --- a/includes/api/ApiManageTags.php +++ b/includes/api/ApiManageTags.php @@ -27,6 +27,7 @@ class ApiManageTags extends ApiBase { public function execute() { $params = $this->extractRequestParams(); + $user = $this->getUser(); // make sure the user is allowed if ( $params['operation'] !== 'delete' @@ -37,10 +38,23 @@ class ApiManageTags extends ApiBase { $this->dieWithError( 'tags-delete-no-permission', 'permissiondenied' ); } + // Check if user can add the log entry tags which were requested + if ( $params['tags'] ) { + $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user ); + if ( !$ableToTag->isOK() ) { + $this->dieStatus( $ableToTag ); + } + } + $result = $this->getResult(); $funcName = "{$params['operation']}TagWithChecks"; - $status = ChangeTags::$funcName( $params['tag'], $params['reason'], - $this->getUser(), $params['ignorewarnings'] ); + $status = ChangeTags::$funcName( + $params['tag'], + $params['reason'], + $user, + $params['ignorewarnings'], + $params['tags'] ?: [] + ); if ( !$status->isOK() ) { $this->dieStatus( $status ); @@ -57,6 +71,7 @@ class ApiManageTags extends ApiBase { if ( $ret['success'] ) { $ret['logid'] = $status->value; } + $result->addValue( null, $this->getModuleName(), $ret ); } @@ -85,6 +100,10 @@ class ApiManageTags extends ApiBase { ApiBase::PARAM_TYPE => 'boolean', ApiBase::PARAM_DFLT => false, ], + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ], ]; } @@ -106,6 +125,6 @@ class ApiManageTags extends ApiBase { } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Tag_management'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tag_management'; } }