]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/api/ApiPatrol.php
MediaWiki 1.16.0
[autoinstallsdev/mediawiki.git] / includes / api / ApiPatrol.php
index 2c9d1ecf64a625a8365353f237920289f3bb90b8..3b2b2046e1164efaae2c19a07692f2d177ae59cb 100644 (file)
@@ -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 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