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 global $wgUser, $wgUseRCPatrol, $wgUseNPPatrol;
00045 $params = $this->extractRequestParams();
00046
00047 if(!isset($params['token']))
00048 $this->dieUsageMsg(array('missingparam', 'token'));
00049 if(!isset($params['rcid']))
00050 $this->dieUsageMsg(array('missingparam', 'rcid'));
00051 if(!$wgUser->matchEditToken($params['token']))
00052 $this->dieUsageMsg(array('sessionfailure'));
00053
00054 $rc = RecentChange::newFromID($params['rcid']);
00055 if(!$rc instanceof RecentChange)
00056 $this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
00057 $retval = RecentChange::markPatrolled($params['rcid']);
00058
00059 if($retval)
00060 $this->dieUsageMsg(reset($retval));
00061
00062 $result = array('rcid' => intval($rc->getAttribute('rc_id')));
00063 ApiQueryBase::addTitleInfo($result, $rc->getTitle());
00064 $this->getResult()->addValue(null, $this->getModuleName(), $result);
00065 }
00066
00067 public function isWriteMode() {
00068 return true;
00069 }
00070
00071 public function getAllowedParams() {
00072 return array (
00073 'token' => null,
00074 'rcid' => array(
00075 ApiBase :: PARAM_TYPE => 'integer'
00076 ),
00077 );
00078 }
00079
00080 public function getParamDescription() {
00081 return array (
00082 'token' => 'Patrol token obtained from list=recentchanges',
00083 'rcid' => 'Recentchanges ID to patrol',
00084 );
00085 }
00086
00087 public function getDescription() {
00088 return array (
00089 'Patrol a page or revision. '
00090 );
00091 }
00092
00093 protected function getExamples() {
00094 return array(
00095 'api.php?action=patrol&token=123abc&rcid=230672766'
00096 );
00097 }
00098
00099 public function getVersion() {
00100 return __CLASS__ . ': $Id: ApiPatrol.php 48122 2009-03-07 12:58:41Z catrope $';
00101 }
00102 }