Merge "Align fieldset borders with WikimediaUI color palette"
[lhc/web/wiklou.git] / includes / api / ApiUserrights.php
index 815ef0b..4ef974c 100644 (file)
@@ -61,13 +61,23 @@ class ApiUserrights extends ApiBase {
 
                $user = $this->getUrUser( $params );
 
+               $tags = $params['tags'];
+
+               // Check if user can add tags
+               if ( !is_null( $tags ) ) {
+                       $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $tags, $pUser );
+                       if ( !$ableToTag->isOK() ) {
+                               $this->dieStatus( $ableToTag );
+                       }
+               }
+
                $form = $this->getUserRightsPage();
                $form->setContext( $this->getContext() );
                $r['user'] = $user->getName();
                $r['userid'] = $user->getId();
                list( $r['added'], $r['removed'] ) = $form->doSaveUserGroups(
                        $user, (array)$params['add'],
-                       (array)$params['remove'], $params['reason']
+                       (array)$params['remove'], $params['reason'], $tags
                );
 
                $result = $this->getResult();
@@ -110,29 +120,33 @@ class ApiUserrights extends ApiBase {
        }
 
        public function getAllowedParams() {
-               return array(
-                       'user' => array(
+               return [
+                       'user' => [
                                ApiBase::PARAM_TYPE => 'user',
-                       ),
-                       'userid' => array(
+                       ],
+                       'userid' => [
                                ApiBase::PARAM_TYPE => 'integer',
-                       ),
-                       'add' => array(
+                       ],
+                       'add' => [
                                ApiBase::PARAM_TYPE => $this->getAllGroups(),
                                ApiBase::PARAM_ISMULTI => true
-                       ),
-                       'remove' => array(
+                       ],
+                       'remove' => [
                                ApiBase::PARAM_TYPE => $this->getAllGroups(),
                                ApiBase::PARAM_ISMULTI => true
-                       ),
-                       'reason' => array(
+                       ],
+                       'reason' => [
                                ApiBase::PARAM_DFLT => ''
-                       ),
-                       'token' => array(
+                       ],
+                       'token' => [
                                // Standard definition automatically inserted
-                               ApiBase::PARAM_HELP_MSG_APPEND => array( 'api-help-param-token-webui' ),
-                       ),
-               );
+                               ApiBase::PARAM_HELP_MSG_APPEND => [ 'api-help-param-token-webui' ],
+                       ],
+                       'tags' => [
+                               ApiBase::PARAM_TYPE => 'tags',
+                               ApiBase::PARAM_ISMULTI => true
+                       ],
+               ];
        }
 
        public function needsToken() {
@@ -144,12 +158,12 @@ class ApiUserrights extends ApiBase {
        }
 
        protected function getExamplesMessages() {
-               return array(
+               return [
                        'action=userrights&user=FooBot&add=bot&remove=sysop|bureaucrat&token=123ABC'
                                => 'apihelp-userrights-example-user',
                        'action=userrights&userid=123&add=bot&remove=sysop|bureaucrat&token=123ABC'
                                => 'apihelp-userrights-example-userid',
-               );
+               ];
        }
 
        public function getHelpUrls() {