summaryrefslogtreecommitdiff
path: root/includes/api/ApiMove.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
committerPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
commit370e83bb0dfd0c70de268c93bf07ad5ee0897192 (patch)
tree491674f4c242e4d6ba0d04eafa305174c35a3391 /includes/api/ApiMove.php
parentf4debf0f12d0524d2b2427c55ea3f16b680fad97 (diff)
Update auf 1.13.0
Diffstat (limited to 'includes/api/ApiMove.php')
-rw-r--r--includes/api/ApiMove.php50
1 files changed, 34 insertions, 16 deletions
diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php
index a8c39c9a..8687bdcd 100644
--- a/includes/api/ApiMove.php
+++ b/includes/api/ApiMove.php
@@ -29,21 +29,21 @@ if (!defined('MEDIAWIKI')) {
/**
- * @addtogroup API
+ * @ingroup API
*/
class ApiMove extends ApiBase {
public function __construct($main, $action) {
parent :: __construct($main, $action);
}
-
+
public function execute() {
global $wgUser;
$this->getMain()->requestWriteMode();
$params = $this->extractRequestParams();
if(is_null($params['reason']))
$params['reason'] = '';
-
+
$titleObj = NULL;
if(!isset($params['from']))
$this->dieUsageMsg(array('missingparam', 'from'));
@@ -69,7 +69,7 @@ class ApiMove extends ApiBase {
// Run getUserPermissionsErrors() here so we get message arguments too,
// rather than just a message key. The latter is troublesome for messages
// that use arguments.
- // FIXME: moveTo() should really return an array, requires some
+ // FIXME: moveTo() should really return an array, requires some
// refactoring of other code, though (mainly SpecialMovepage.php)
$errors = array_merge($fromTitle->getUserPermissionsErrors('move', $wgUser),
$fromTitle->getUserPermissionsErrors('edit', $wgUser),
@@ -79,16 +79,19 @@ class ApiMove extends ApiBase {
// We don't care about multiple errors, just report one of them
$this->dieUsageMsg(current($errors));
- $dbw = wfGetDB(DB_MASTER);
- $dbw->begin();
+ $hookErr = null;
+
$retval = $fromTitle->moveTo($toTitle, true, $params['reason'], !$params['noredirect']);
if($retval !== true)
- $this->dieUsageMsg(array($retval));
+ {
+ # FIXME: Title::moveTo() sometimes returns a string
+ $this->dieUsageMsg(reset($retval));
+ }
$r = array('from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason']);
- if(!$params['noredirect'])
+ if(!$params['noredirect'] || !$wgUser->isAllowed('suppressredirect'))
$r['redirectcreated'] = '';
-
+
if($params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage())
{
// We need to move the talk page as well
@@ -104,14 +107,25 @@ class ApiMove extends ApiBase {
{
$r['talkmove-error-code'] = ApiBase::$messageMap[$retval]['code'];
$r['talkmove-error-info'] = ApiBase::$messageMap[$retval]['info'];
- }
+ }
+ }
+
+ # Watch pages
+ if($params['watch'] || $wgUser->getOption('watchmoves'))
+ {
+ $wgUser->addWatch($fromTitle);
+ $wgUser->addWatch($toTitle);
+ }
+ else if($params['unwatch'])
+ {
+ $wgUser->removeWatch($fromTitle);
+ $wgUser->removeWatch($toTitle);
}
- $dbw->commit(); // Make sure all changes are really written to the DB
$this->getResult()->addValue(null, $this->getModuleName(), $r);
}
-
+
public function mustBePosted() { return true; }
-
+
public function getAllowedParams() {
return array (
'from' => null,
@@ -119,7 +133,9 @@ class ApiMove extends ApiBase {
'token' => null,
'reason' => null,
'movetalk' => false,
- 'noredirect' => false
+ 'noredirect' => false,
+ 'watch' => false,
+ 'unwatch' => false
);
}
@@ -130,7 +146,9 @@ class ApiMove extends ApiBase {
'token' => 'A move token previously retrieved through prop=info',
'reason' => 'Reason for the move (optional).',
'movetalk' => 'Move the talk page, if it exists.',
- 'noredirect' => 'Don\'t create a redirect'
+ 'noredirect' => 'Don\'t create a redirect',
+ 'watch' => 'Add the page and the redirect to your watchlist',
+ 'unwatch' => 'Remove the page and the redirect from your watchlist'
);
}
@@ -147,6 +165,6 @@ class ApiMove extends ApiBase {
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiMove.php 30222 2008-01-28 19:05:26Z catrope $';
+ return __CLASS__ . ': $Id: ApiMove.php 35619 2008-05-30 19:59:47Z btongminh $';
}
}