Fixed spacing in db/debug/diff/externalstore/objectcache folder
[mediawiki.git] / includes / api / ApiPatrol.php
blob4d4fbba9870598e72b39e779ed79ec15788a9ff5
1 <?php
2 /**
3 * API for MediaWiki 1.14+
5 * Created on Sep 2, 2008
7 * Copyright © 2008 Soxred93 soxred93@gmail.com,
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
24 * @file
27 /**
28 * Allows user to patrol pages
29 * @ingroup API
31 class ApiPatrol extends ApiBase {
33 /**
34 * Patrols the article or provides the reason the patrol failed.
36 public function execute() {
37 $params = $this->extractRequestParams();
39 $rc = RecentChange::newFromID( $params['rcid'] );
40 if ( !$rc instanceof RecentChange ) {
41 $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) );
43 $retval = $rc->doMarkPatrolled( $this->getUser() );
45 if ( $retval ) {
46 $this->dieUsageMsg( reset( $retval ) );
49 $result = array( 'rcid' => intval( $rc->getAttribute( 'rc_id' ) ) );
50 ApiQueryBase::addTitleInfo( $result, $rc->getTitle() );
51 $this->getResult()->addValue( null, $this->getModuleName(), $result );
54 public function mustBePosted() {
55 return true;
58 public function isWriteMode() {
59 return true;
62 public function getAllowedParams() {
63 return array(
64 'token' => array(
65 ApiBase::PARAM_TYPE => 'string',
66 ApiBase::PARAM_REQUIRED => true
68 'rcid' => array(
69 ApiBase::PARAM_TYPE => 'integer',
70 ApiBase::PARAM_REQUIRED => true
75 public function getParamDescription() {
76 return array(
77 'token' => 'Patrol token obtained from list=recentchanges',
78 'rcid' => 'Recentchanges ID to patrol',
82 public function getResultProperties() {
83 return array(
84 '' => array(
85 'rcid' => 'integer',
86 'ns' => 'namespace',
87 'title' => 'string'
92 public function getDescription() {
93 return 'Patrol a page or revision';
96 public function getPossibleErrors() {
97 return array_merge( parent::getPossibleErrors(), array(
98 array( 'nosuchrcid', 'rcid' ),
99 ) );
102 public function needsToken() {
103 return true;
106 public function getTokenSalt() {
107 return 'patrol';
110 public function getExamples() {
111 return array(
112 'api.php?action=patrol&token=123abc&rcid=230672766'
116 public function getHelpUrls() {
117 return 'https://www.mediawiki.org/wiki/API:Patrol';