merged master (2012-09-11)
[lhc/web/wiklou.git] / includes / api / ApiMove.php
index acaa8b0..9d73562 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Created on Oct 31, 2007
  *
- * Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@gmail.com
+ * Copyright © 2007 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
  *
  * 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
@@ -75,6 +75,7 @@ class ApiMove extends ApiBase {
                }
 
                // Move the page
+               $toTitleExists = $toTitle->exists();
                $retval = $fromTitle->moveTo( $toTitle, true, $params['reason'], !$params['noredirect'] );
                if ( $retval !== true ) {
                        $this->dieUsageMsg( reset( $retval ) );
@@ -84,13 +85,20 @@ class ApiMove extends ApiBase {
                if ( !$params['noredirect'] || !$user->isAllowed( 'suppressredirect' ) ) {
                        $r['redirectcreated'] = '';
                }
+               if( $toTitleExists ) {
+                       $r['moveoverredirect'] = '';
+               }
 
                // Move the talk page
                if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
+                       $toTalkExists = $toTalk->exists();
                        $retval = $fromTalk->moveTo( $toTalk, true, $params['reason'], !$params['noredirect'] );
                        if ( $retval === true ) {
                                $r['talkfrom'] = $fromTalk->getPrefixedText();
                                $r['talkto'] = $toTalk->getPrefixedText();
+                               if( $toTalkExists ) {
+                                       $r['talkmoveoverredirect'] = '';
+                               }
                        } else {
                                // We're not gonna dieUsage() on failure, since we already changed something
                                $parsed = $this->parseMsg( reset( $retval ) );
@@ -177,7 +185,10 @@ class ApiMove extends ApiBase {
                                ApiBase::PARAM_TYPE => 'string',
                                ApiBase::PARAM_REQUIRED => true
                        ),
-                       'token' => null,
+                       'token' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => true
+                       ),
                        'reason' => '',
                        'movetalk' => false,
                        'movesubpages' => false,
@@ -228,6 +239,7 @@ class ApiMove extends ApiBase {
                                'to' => 'string',
                                'reason' => 'string',
                                'redirectcreated' => 'boolean',
+                               'moveoverredirect' => 'boolean',
                                'talkfrom' => array(
                                        ApiBase::PROP_TYPE => 'string',
                                        ApiBase::PROP_NULLABLE => true
@@ -236,6 +248,7 @@ class ApiMove extends ApiBase {
                                        ApiBase::PROP_TYPE => 'string',
                                        ApiBase::PROP_NULLABLE => true
                                ),
+                               'talkmoveoverredirect' => 'boolean',
                                'talkmove-error-code' => array(
                                        ApiBase::PROP_TYPE => 'string',
                                        ApiBase::PROP_NULLABLE => true