summaryrefslogtreecommitdiff
path: root/includes/api/ApiWatch.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
commitca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch)
treeec04cc15b867bc21eedca904cea9af0254531a11 /includes/api/ApiWatch.php
parenta22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff)
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing
Diffstat (limited to 'includes/api/ApiWatch.php')
-rw-r--r--includes/api/ApiWatch.php33
1 files changed, 25 insertions, 8 deletions
diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php
index e9560a4d..6fc55905 100644
--- a/includes/api/ApiWatch.php
+++ b/includes/api/ApiWatch.php
@@ -1,6 +1,6 @@
<?php
/**
- * API for MediaWiki 1.8+
+ *
*
* Created on Jan 4, 2008
*
@@ -49,40 +49,52 @@ class ApiWatch extends ApiBase {
$params = $this->extractRequestParams();
$title = Title::newFromText( $params['title'] );
- if ( !$title ) {
+ if ( !$title || $title->getNamespace() < 0 ) {
$this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
}
- $article = new Article( $title );
+ $article = new Article( $title, 0 );
$res = array( 'title' => $title->getPrefixedText() );
if ( $params['unwatch'] ) {
$res['unwatched'] = '';
$res['message'] = wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() );
- $success = $article->doUnwatch();
+ $success = WatchAction::doUnwatch( $title, $wgUser );
} else {
$res['watched'] = '';
$res['message'] = wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() );
- $success = $article->doWatch();
+ $success = UnwatchAction::doWatch( $title, $wgUser );
}
if ( !$success ) {
- $this->dieUsageMsg( array( 'hookaborted' ) );
+ $this->dieUsageMsg( 'hookaborted' );
}
$this->getResult()->addValue( null, $this->getModuleName(), $res );
}
+ public function mustBePosted() {
+ return true;
+ }
+
public function isWriteMode() {
return true;
}
+ public function needsToken() {
+ return true;
+ }
+
+ public function getTokenSalt() {
+ return 'watch';
+ }
+
public function getAllowedParams() {
return array(
'title' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true
),
-
'unwatch' => false,
+ 'token' => null,
);
}
@@ -90,6 +102,7 @@ class ApiWatch extends ApiBase {
return array(
'title' => 'The page to (un)watch',
'unwatch' => 'If set the page will be unwatched rather than watched',
+ 'token' => 'A token previously acquired via prop=info',
);
}
@@ -112,7 +125,11 @@ class ApiWatch extends ApiBase {
);
}
+ public function getHelpUrls() {
+ return 'https://www.mediawiki.org/wiki/API:Watch';
+ }
+
public function getVersion() {
- return __CLASS__ . ': $Id: ApiWatch.php 77192 2010-11-23 22:05:27Z btongminh $';
+ return __CLASS__ . ': $Id: ApiWatch.php 104449 2011-11-28 15:52:04Z reedy $';
}
}