X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiPatrol.php;h=c33542f1c7aa2ea87bf5f7623a9924bbbbb69130;hb=2326d420c78ab71c1f13542973a695a80e6202f7;hp=1230babb9b80997324ad2f11f6c15c891b2aa385;hpb=2a1fcd27c19913394c179cbe8be1a9e981d7f81b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiPatrol.php b/includes/api/ApiPatrol.php index 1230babb9b..c33542f1c7 100644 --- a/includes/api/ApiPatrol.php +++ b/includes/api/ApiPatrol.php @@ -40,26 +40,34 @@ class ApiPatrol extends ApiBase { if ( isset( $params['rcid'] ) ) { $rc = RecentChange::newFromId( $params['rcid'] ); if ( !$rc ) { - $this->dieUsageMsg( [ 'nosuchrcid', $params['rcid'] ] ); + $this->dieWithError( [ 'apierror-nosuchrcid', $params['rcid'] ] ); } } else { $rev = Revision::newFromId( $params['revid'] ); if ( !$rev ) { - $this->dieUsageMsg( [ 'nosuchrevid', $params['revid'] ] ); + $this->dieWithError( [ 'apierror-nosuchrevid', $params['revid'] ] ); } $rc = $rev->getRecentChange(); if ( !$rc ) { - $this->dieUsage( - 'The revision ' . $params['revid'] . " can't be patrolled as it's too old", - 'notpatrollable' - ); + $this->dieWithError( [ 'apierror-notpatrollable', $params['revid'] ] ); } } - $retval = $rc->doMarkPatrolled( $this->getUser() ); + $user = $this->getUser(); + $tags = $params['tags']; + + // Check if user can add tags + if ( !is_null( $tags ) ) { + $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $tags, $user ); + if ( !$ableToTag->isOK() ) { + $this->dieStatus( $ableToTag ); + } + } + + $retval = $rc->doMarkPatrolled( $user, false, $tags ); if ( $retval ) { - $this->dieUsageMsg( reset( $retval ) ); + $this->dieStatus( $this->errorArrayToStatus( $retval, $user ) ); } $result = [ 'rcid' => intval( $rc->getAttribute( 'rc_id' ) ) ]; @@ -83,6 +91,10 @@ class ApiPatrol extends ApiBase { 'revid' => [ ApiBase::PARAM_TYPE => 'integer' ], + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ], ]; }