diff options
Diffstat (limited to 'includes/api/ApiPatrol.php')
-rw-r--r-- | includes/api/ApiPatrol.php | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/includes/api/ApiPatrol.php b/includes/api/ApiPatrol.php index a6f25af2..3b2b2046 100644 --- a/includes/api/ApiPatrol.php +++ b/includes/api/ApiPatrol.php @@ -23,8 +23,8 @@ * http://www.gnu.org/copyleft/gpl.html */ -if (!defined('MEDIAWIKI')) { - require_once ('ApiBase.php'); +if ( !defined( 'MEDIAWIKI' ) ) { + require_once ( 'ApiBase.php' ); } /** @@ -33,35 +33,30 @@ if (!defined('MEDIAWIKI')) { */ class ApiPatrol extends ApiBase { - public function __construct($main, $action) { - parent :: __construct($main, $action); + public function __construct( $main, $action ) { + parent :: __construct( $main, $action ); } /** * Patrols the article or provides the reason the patrol failed. */ public function execute() { - global $wgUser, $wgUseRCPatrol, $wgUseNPPatrol; $params = $this->extractRequestParams(); - if(!isset($params['token'])) - $this->dieUsageMsg(array('missingparam', 'token')); - if(!isset($params['rcid'])) - $this->dieUsageMsg(array('missingparam', 'rcid')); - if(!$wgUser->matchEditToken($params['token'])) - $this->dieUsageMsg(array('sessionfailure')); + if ( !isset( $params['rcid'] ) ) + $this->dieUsageMsg( array( 'missingparam', 'rcid' ) ); - $rc = RecentChange::newFromID($params['rcid']); - if(!$rc instanceof RecentChange) - $this->dieUsageMsg(array('nosuchrcid', $params['rcid'])); - $retval = RecentChange::markPatrolled($params['rcid']); + $rc = RecentChange::newFromID( $params['rcid'] ); + if ( !$rc instanceof RecentChange ) + $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) ); + $retval = RecentChange::markPatrolled( $params['rcid'] ); - if($retval) - $this->dieUsageMsg(reset($retval)); + if ( $retval ) + $this->dieUsageMsg( reset( $retval ) ); - $result = array('rcid' => intval($rc->getAttribute('rc_id'))); - ApiQueryBase::addTitleInfo($result, $rc->getTitle()); - $this->getResult()->addValue(null, $this->getModuleName(), $result); + $result = array( 'rcid' => intval( $rc->getAttribute( 'rc_id' ) ) ); + ApiQueryBase::addTitleInfo( $result, $rc->getTitle() ); + $this->getResult()->addValue( null, $this->getModuleName(), $result ); } public function isWriteMode() { @@ -89,6 +84,17 @@ class ApiPatrol extends ApiBase { 'Patrol a page or revision. ' ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'missingparam', 'rcid' ), + array( 'nosuchrcid', 'rcid' ), + ) ); + } + + public function getTokenSalt() { + return ''; + } protected function getExamples() { return array( @@ -97,6 +103,6 @@ class ApiPatrol extends ApiBase { } public function getVersion() { - return __CLASS__ . ': $Id: ApiPatrol.php 69579 2010-07-20 02:49:55Z tstarling $'; + return __CLASS__ . ': $Id: ApiPatrol.php 69578 2010-07-20 02:46:20Z tstarling $'; } -} +}
\ No newline at end of file |