MediaWiki
REL1_19
|
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' => null, 00069 'rcid' => array( 00070 ApiBase::PARAM_TYPE => 'integer', 00071 ApiBase::PARAM_REQUIRED => true 00072 ), 00073 ); 00074 } 00075 00076 public function getParamDescription() { 00077 return array( 00078 'token' => 'Patrol token obtained from list=recentchanges', 00079 'rcid' => 'Recentchanges ID to patrol', 00080 ); 00081 } 00082 00083 public function getDescription() { 00084 return 'Patrol a page or revision'; 00085 } 00086 00087 public function getPossibleErrors() { 00088 return array_merge( parent::getPossibleErrors(), array( 00089 array( 'nosuchrcid', 'rcid' ), 00090 ) ); 00091 } 00092 00093 public function needsToken() { 00094 return true; 00095 } 00096 00097 public function getTokenSalt() { 00098 return 'patrol'; 00099 } 00100 00101 public function getExamples() { 00102 return array( 00103 'api.php?action=patrol&token=123abc&rcid=230672766' 00104 ); 00105 } 00106 00107 public function getHelpUrls() { 00108 return 'https://www.mediawiki.org/wiki/API:Patrol'; 00109 } 00110 00111 public function getVersion() { 00112 return __CLASS__ . ': $Id$'; 00113 } 00114 }