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