Fix hook situation for Skin::doEditSectionLink
[mediawiki.git] / includes / api / ApiManageTags.php
blobb027f33c89c591048068dc42840efd4a5305731f
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 ( !$this->getUser()->isAllowed( 'managechangetags' ) ) {
33 $this->dieUsage( "You don't have permission to manage change tags", 'permissiondenied' );
36 $result = $this->getResult();
37 $funcName = "{$params['operation']}TagWithChecks";
38 $status = ChangeTags::$funcName( $params['tag'], $params['reason'],
39 $this->getUser(), $params['ignorewarnings'] );
41 if ( !$status->isOK() ) {
42 $this->dieStatus( $status );
45 $ret = array(
46 'operation' => $params['operation'],
47 'tag' => $params['tag'],
49 if ( !$status->isGood() ) {
50 $ret['warnings'] = $result->convertStatusToArray( $status, 'warning' );
52 if ( $status->value !== null ) {
53 $ret['success'] = '';
54 $ret['logid'] = $status->value;
56 $result->addValue( null, $this->getModuleName(), $ret );
59 public function mustBePosted() {
60 return true;
63 public function isWriteMode() {
64 return true;
67 public function getAllowedParams() {
68 return array(
69 'operation' => array(
70 ApiBase::PARAM_TYPE => array( 'create', 'delete', 'activate', 'deactivate' ),
71 ApiBase::PARAM_REQUIRED => true,
73 'tag' => array(
74 ApiBase::PARAM_TYPE => 'string',
75 ApiBase::PARAM_REQUIRED => true,
77 'reason' => array(
78 ApiBase::PARAM_TYPE => 'string',
80 'ignorewarnings' => array(
81 ApiBase::PARAM_TYPE => 'boolean',
82 ApiBase::PARAM_DFLT => false,
87 public function needsToken() {
88 return 'csrf';
91 protected function getExamplesMessages() {
92 return array(
93 'action=managetags&operation=create&tag=spam&reason=For+use+in+edit+patrolling&token=123ABC'
94 => 'apihelp-managetags-example-create',
95 'action=managetags&operation=delete&tag=vandlaism&reason=Misspelt&token=123ABC'
96 => 'apihelp-managetags-example-delete',
97 'action=managetags&operation=activate&tag=spam&reason=For+use+in+edit+patrolling&token=123ABC'
98 => 'apihelp-managetags-example-activate',
99 'action=managetags&operation=deactivate&tag=spam&reason=No+longer+required&token=123ABC'
100 => 'apihelp-managetags-example-deactivate',
104 public function getHelpUrls() {
105 return 'https://www.mediawiki.org/wiki/API:Tag_management';