* http://www.gnu.org/copyleft/gpl.html
*/
-if (!defined('MEDIAWIKI')) {
- require_once ('ApiBase.php');
+if ( !defined( 'MEDIAWIKI' ) ) {
+ require_once ( 'ApiBase.php' );
}
/**
*/
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() {
'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(
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiPatrol.php 48122 2009-03-07 12:58:41Z catrope $';
+ return __CLASS__ . ': $Id: ApiPatrol.php 69578 2010-07-20 02:46:20Z tstarling $';
}
-}
+}
\ No newline at end of file