MediaWiki  REL1_20
ApiPatrol.php
Go to the documentation of this file.
00001 <?php
00031 class ApiPatrol extends ApiBase {
00032 
00033         public function __construct( $main, $action ) {
00034                 parent::__construct( $main, $action );
00035         }
00036 
00040         public function execute() {
00041                 $params = $this->extractRequestParams();
00042 
00043                 $rc = RecentChange::newFromID( $params['rcid'] );
00044                 if ( !$rc instanceof RecentChange ) {
00045                         $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) );
00046                 }
00047                 $retval = $rc->doMarkPatrolled( $this->getUser() );
00048 
00049                 if ( $retval ) {
00050                         $this->dieUsageMsg( reset( $retval ) );
00051                 }
00052 
00053                 $result = array( 'rcid' => intval( $rc->getAttribute( 'rc_id' ) ) );
00054                 ApiQueryBase::addTitleInfo( $result, $rc->getTitle() );
00055                 $this->getResult()->addValue( null, $this->getModuleName(), $result );
00056         }
00057 
00058         public function mustBePosted() {
00059                 return true;
00060         }
00061 
00062         public function isWriteMode() {
00063                 return true;
00064         }
00065 
00066         public function getAllowedParams() {
00067                 return array(
00068                         'token' => array(
00069                                 ApiBase::PARAM_TYPE => 'string',
00070                                 ApiBase::PARAM_REQUIRED => true
00071                         ),
00072                         'rcid' => array(
00073                                 ApiBase::PARAM_TYPE => 'integer',
00074                                 ApiBase::PARAM_REQUIRED => true
00075                         ),
00076                 );
00077         }
00078 
00079         public function getParamDescription() {
00080                 return array(
00081                         'token' => 'Patrol token obtained from list=recentchanges',
00082                         'rcid' => 'Recentchanges ID to patrol',
00083                 );
00084         }
00085 
00086         public function getResultProperties() {
00087                 return array(
00088                         '' => array(
00089                                 'rcid' => 'integer',
00090                                 'ns' => 'namespace',
00091                                 'title' => 'string'
00092                         )
00093                 );
00094         }
00095 
00096         public function getDescription() {
00097                 return 'Patrol a page or revision';
00098         }
00099 
00100         public function getPossibleErrors() {
00101                 return array_merge( parent::getPossibleErrors(), array(
00102                         array( 'nosuchrcid', 'rcid' ),
00103                 ) );
00104         }
00105 
00106         public function needsToken() {
00107                 return true;
00108         }
00109 
00110         public function getTokenSalt() {
00111                 return 'patrol';
00112         }
00113 
00114         public function getExamples() {
00115                 return array(
00116                         'api.php?action=patrol&token=123abc&rcid=230672766'
00117                 );
00118         }
00119 
00120         public function getHelpUrls() {
00121                 return 'https://www.mediawiki.org/wiki/API:Patrol';
00122         }
00123 
00124         public function getVersion() {
00125                 return __CLASS__ . ': $Id$';
00126         }
00127 }