Merge "mw.Feedback: If the message is posted remotely, link the title correctly"
[lhc/web/wiklou.git] / includes / api / ApiImageRotate.php
index 72fb16d..21e2694 100644 (file)
@@ -1,8 +1,5 @@
 <?php
 /**
- *
- * Created on January 3rd, 2013
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -42,6 +39,14 @@ class ApiImageRotate extends ApiBase {
                        'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'interwikiTitles',
                ] );
 
+               // Check if user can add tags
+               if ( $params['tags'] ) {
+                       $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $this->getUser() );
+                       if ( !$ableToTag->isOK() ) {
+                               $this->dieStatus( $ableToTag );
+                       }
+               }
+
                foreach ( $pageSet->getTitles() as $title ) {
                        $r = [];
                        $r['id'] = $title->getArticleID();
@@ -104,8 +109,16 @@ class ApiImageRotate extends ApiBase {
                                $comment = wfMessage(
                                        'rotate-comment'
                                )->numParams( $rotation )->inContentLanguage()->text();
-                               $status = $file->upload( $dstPath,
-                                       $comment, $comment, 0, false, false, $this->getUser() );
+                               $status = $file->upload(
+                                       $dstPath,
+                                       $comment,
+                                       $comment,
+                                       0,
+                                       false,
+                                       false,
+                                       $this->getUser(),
+                                       $params['tags'] ?: []
+                               );
                                if ( $status->isGood() ) {
                                        $r['result'] = 'Success';
                                } else {
@@ -157,6 +170,10 @@ class ApiImageRotate extends ApiBase {
                        'continue' => [
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
                        ],
+                       'tags' => [
+                               ApiBase::PARAM_TYPE => 'tags',
+                               ApiBase::PARAM_ISMULTI => true,
+                       ],
                ];
                if ( $flags ) {
                        $result += $this->getPageSet()->getFinalParams( $flags );