00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 if ( !defined( 'MEDIAWIKI' ) ) {
00027 require_once ( 'ApiBase.php' );
00028 }
00029
00034 class ApiPatrol extends ApiBase {
00035
00036 public function __construct( $main, $action ) {
00037 parent :: __construct( $main, $action );
00038 }
00039
00043 public function execute() {
00044 $params = $this->extractRequestParams();
00045
00046 if ( !isset( $params['rcid'] ) )
00047 $this->dieUsageMsg( array( 'missingparam', 'rcid' ) );
00048
00049 $rc = RecentChange::newFromID( $params['rcid'] );
00050 if ( !$rc instanceof RecentChange )
00051 $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) );
00052 $retval = RecentChange::markPatrolled( $params['rcid'] );
00053
00054 if ( $retval )
00055 $this->dieUsageMsg( reset( $retval ) );
00056
00057 $result = array( 'rcid' => intval( $rc->getAttribute( 'rc_id' ) ) );
00058 ApiQueryBase::addTitleInfo( $result, $rc->getTitle() );
00059 $this->getResult()->addValue( null, $this->getModuleName(), $result );
00060 }
00061
00062 public function isWriteMode() {
00063 return true;
00064 }
00065
00066 public function getAllowedParams() {
00067 return array (
00068 'token' => null,
00069 'rcid' => array(
00070 ApiBase :: PARAM_TYPE => 'integer'
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 getDescription() {
00083 return array (
00084 'Patrol a page or revision. '
00085 );
00086 }
00087
00088 public function getPossibleErrors() {
00089 return array_merge( parent::getPossibleErrors(), array(
00090 array( 'missingparam', 'rcid' ),
00091 array( 'nosuchrcid', 'rcid' ),
00092 ) );
00093 }
00094
00095 public function needsToken() {
00096 return true;
00097 }
00098
00099 public function getTokenSalt() {
00100 return '';
00101 }
00102
00103 protected function getExamples() {
00104 return array(
00105 'api.php?action=patrol&token=123abc&rcid=230672766'
00106 );
00107 }
00108
00109 public function getVersion() {
00110 return __CLASS__ . ': $Id: ApiPatrol.php 74217 2010-10-03 15:53:07Z reedy $';
00111 }
00112 }