Expose $wgMaxArticleSize in siteinfo query api
[mediawiki.git] / includes / api / ApiManageTags.php
blob617db227df7a48d13b1cae12f5baedb316c225ad
1 <?php
3 /**
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
19 * @file
22 /**
23 * @ingroup API
24 * @since 1.25
26 class ApiManageTags extends ApiBase {
28 public function execute() {
29 $params = $this->extractRequestParams();
31 // make sure the user is allowed
32 if ( $params['operation'] !== 'delete'
33 && !$this->getUser()->isAllowed( 'managechangetags' )
34 ) {
35 $this->dieUsage( "You don't have permission to manage change tags",
36 'permissiondenied' );
37 } elseif ( !$this->getUser()->isAllowed( 'deletechangetags' ) ) {
38 $this->dieUsage( "You don't have permission to delete change tags",
39 'permissiondenied' );
42 $result = $this->getResult();
43 $funcName = "{$params['operation']}TagWithChecks";
44 $status = ChangeTags::$funcName( $params['tag'], $params['reason'],
45 $this->getUser(), $params['ignorewarnings'] );
47 if ( !$status->isOK() ) {
48 $this->dieStatus( $status );
51 $ret = [
52 'operation' => $params['operation'],
53 'tag' => $params['tag'],
55 if ( !$status->isGood() ) {
56 $ret['warnings'] = $this->getErrorFormatter()->arrayFromStatus( $status, 'warning' );
58 $ret['success'] = $status->value !== null;
59 if ( $ret['success'] ) {
60 $ret['logid'] = $status->value;
62 $result->addValue( null, $this->getModuleName(), $ret );
65 public function mustBePosted() {
66 return true;
69 public function isWriteMode() {
70 return true;
73 public function getAllowedParams() {
74 return [
75 'operation' => [
76 ApiBase::PARAM_TYPE => [ 'create', 'delete', 'activate', 'deactivate' ],
77 ApiBase::PARAM_REQUIRED => true,
79 'tag' => [
80 ApiBase::PARAM_TYPE => 'string',
81 ApiBase::PARAM_REQUIRED => true,
83 'reason' => [
84 ApiBase::PARAM_TYPE => 'string',
86 'ignorewarnings' => [
87 ApiBase::PARAM_TYPE => 'boolean',
88 ApiBase::PARAM_DFLT => false,
93 public function needsToken() {
94 return 'csrf';
97 protected function getExamplesMessages() {
98 return [
99 'action=managetags&operation=create&tag=spam&reason=For+use+in+edit+patrolling&token=123ABC'
100 => 'apihelp-managetags-example-create',
101 'action=managetags&operation=delete&tag=vandlaism&reason=Misspelt&token=123ABC'
102 => 'apihelp-managetags-example-delete',
103 'action=managetags&operation=activate&tag=spam&reason=For+use+in+edit+patrolling&token=123ABC'
104 => 'apihelp-managetags-example-activate',
105 'action=managetags&operation=deactivate&tag=spam&reason=No+longer+required&token=123ABC'
106 => 'apihelp-managetags-example-deactivate',
110 public function getHelpUrls() {
111 return 'https://www.mediawiki.org/wiki/API:Tag_management';