Merge "Added assertArrayEquals method to MediaWikiTestCase to avoid duplicating asort...
[lhc/web/wiklou.git] / includes / api / ApiMove.php
index 6fefc6a..c89f59b 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( "ApiBase.php" );
-}
-
 /**
  * API Module to move pages
  * @ingroup API
@@ -40,7 +35,7 @@ class ApiMove extends ApiBase {
        }
 
        public function execute() {
-               global $wgUser;
+               $user = $this->getUser();
                $params = $this->extractRequestParams();
                if ( is_null( $params['reason'] ) ) {
                        $params['reason'] = '';
@@ -75,9 +70,9 @@ class ApiMove extends ApiBase {
                        && !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle )
                        && wfFindFile( $toTitle ) )
                {
-                       if ( !$params['ignorewarnings'] && $wgUser->isAllowed( 'reupload-shared' ) ) {
+                       if ( !$params['ignorewarnings'] && $user->isAllowed( 'reupload-shared' ) ) {
                                $this->dieUsageMsg( 'sharedfile-exists' );
-                       } elseif ( !$wgUser->isAllowed( 'reupload-shared' ) ) {
+                       } elseif ( !$user->isAllowed( 'reupload-shared' ) ) {
                                $this->dieUsageMsg( 'cantoverwrite-sharedfile' );
                        }
                }
@@ -89,7 +84,7 @@ class ApiMove extends ApiBase {
                }
 
                $r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] );
-               if ( !$params['noredirect'] || !$wgUser->isAllowed( 'suppressredirect' ) ) {
+               if ( !$params['noredirect'] || !$user->isAllowed( 'suppressredirect' ) ) {
                        $r['redirectcreated'] = '';
                }
 
@@ -229,6 +224,33 @@ class ApiMove extends ApiBase {
                );
        }
 
+       public function getResultProperties() {
+               return array(
+                       '' => array(
+                               'from' => 'string',
+                               'to' => 'string',
+                               'reason' => 'string',
+                               'redirectcreated' => 'boolean',
+                               'talkfrom' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'talkto' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'talkmove-error-code' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'talkmove-error-info' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       )
+               );
+       }
+
        public function getDescription() {
                return 'Move a page';
        }
@@ -254,12 +276,16 @@ class ApiMove extends ApiBase {
                return '';
        }
 
-       protected function getExamples() {
+       public function getExamples() {
                return array(
                        'api.php?action=move&from=Exampel&to=Example&token=123ABC&reason=Misspelled%20title&movetalk=&noredirect='
                );
        }
 
+       public function getHelpUrls() {
+               return 'https://www.mediawiki.org/wiki/API:Move';
+       }
+
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }