33fbe636d155a465c7d45729e2c3661c674b8b65
4 * Created on Sep 2, 2008
6 * API for MediaWiki 1.14+
8 * Copyright © 2008 Soxred93 soxred93@gmail.com,
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
26 if ( !defined( 'MEDIAWIKI' ) ) {
27 require_once ( 'ApiBase.php' );
31 * Allows user to patrol pages
34 class ApiPatrol
extends ApiBase
{
36 public function __construct( $main, $action ) {
37 parent
::__construct( $main, $action );
41 * Patrols the article or provides the reason the patrol failed.
43 public function execute() {
44 $params = $this->extractRequestParams();
46 $rc = RecentChange
::newFromID( $params['rcid'] );
47 if ( !$rc instanceof RecentChange
) {
48 $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) );
50 $retval = RecentChange
::markPatrolled( $params['rcid'] );
53 $this->dieUsageMsg( reset( $retval ) );
56 $result = array( 'rcid' => intval( $rc->getAttribute( 'rc_id' ) ) );
57 ApiQueryBase
::addTitleInfo( $result, $rc->getTitle() );
58 $this->getResult()->addValue( null, $this->getModuleName(), $result );
61 public function isWriteMode() {
65 public function getAllowedParams() {
69 ApiBase
::PARAM_TYPE
=> 'integer',
70 ApiBase
::PARAM_REQUIRED
=> 1
75 public function getParamDescription() {
77 'token' => 'Patrol token obtained from list=recentchanges',
78 'rcid' => 'Recentchanges ID to patrol',
82 public function getDescription() {
83 return 'Patrol a page or revision';
86 public function getPossibleErrors() {
87 return array_merge( parent
::getPossibleErrors(), array(
88 array( 'missingparam', 'rcid' ),
89 array( 'nosuchrcid', 'rcid' ),
93 public function getTokenSalt() {
97 protected function getExamples() {
99 'api.php?action=patrol&token=123abc&rcid=230672766'
103 public function getVersion() {
104 return __CLASS__
. ': $Id$';