Remove --max-slave-lag options and remnants from maintenance scripts
[lhc/web/wiklou.git] / includes / api / ApiUserrights.php
index c3ceb34..cf8ed5a 100644 (file)
@@ -32,12 +32,28 @@ class ApiUserrights extends ApiBase {
 
        private $mUser = null;
 
+       /**
+        * Get a UserrightsPage object, or subclass.
+        * @return UserrightsPage
+        */
+       protected function getUserRightsPage() {
+               return new UserrightsPage;
+       }
+
+       /**
+        * Get all available groups.
+        * @return array
+        */
+       protected function getAllGroups() {
+               return User::getAllGroups();
+       }
+
        public function execute() {
                $params = $this->extractRequestParams();
 
                $user = $this->getUrUser( $params );
 
-               $form = new UserrightsPage;
+               $form = $this->getUserRightsPage();
                $form->setContext( $this->getContext() );
                $r['user'] = $user->getName();
                $r['userid'] = $user->getId();
@@ -65,7 +81,7 @@ class ApiUserrights extends ApiBase {
 
                $user = isset( $params['user'] ) ? $params['user'] : '#' . $params['userid'];
 
-               $form = new UserrightsPage;
+               $form = $this->getUserRightsPage();
                $form->setContext( $this->getContext() );
                $status = $form->fetchUser( $user );
                if ( !$status->isOK() ) {
@@ -94,37 +110,23 @@ class ApiUserrights extends ApiBase {
                                ApiBase::PARAM_TYPE => 'integer',
                        ),
                        'add' => array(
-                               ApiBase::PARAM_TYPE => User::getAllGroups(),
+                               ApiBase::PARAM_TYPE => $this->getAllGroups(),
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'remove' => array(
-                               ApiBase::PARAM_TYPE => User::getAllGroups(),
+                               ApiBase::PARAM_TYPE => $this->getAllGroups(),
                                ApiBase::PARAM_ISMULTI => true
                        ),
                        'reason' => array(
                                ApiBase::PARAM_DFLT => ''
-                       )
-               );
-       }
-
-       public function getParamDescription() {
-               return array(
-                       'user' => 'User name',
-                       'userid' => 'User id',
-                       'add' => 'Add the user to these groups',
-                       'remove' => 'Remove the user from these groups',
+                       ),
                        'token' => array(
-                               /* Standard description automatically prepended */
-                               'For compatibility, the token used in the web UI is also accepted.'
+                               // Standard definition automatically inserted
+                               ApiBase::PARAM_HELP_MSG_APPEND => array( 'api-help-param-token-webui' ),
                        ),
-                       'reason' => 'Reason for the change',
                );
        }
 
-       public function getDescription() {
-               return 'Add/remove a user to/from groups.';
-       }
-
        public function needsToken() {
                return 'userrights';
        }
@@ -133,10 +135,12 @@ class ApiUserrights extends ApiBase {
                return $this->getUrUser( $params )->getName();
        }
 
-       public function getExamples() {
+       protected function getExamplesMessages() {
                return array(
-                       'api.php?action=userrights&user=FooBot&add=bot&remove=sysop|bureaucrat&token=123ABC',
-                       'api.php?action=userrights&userid=123&add=bot&remove=sysop|bureaucrat&token=123ABC'
+                       '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',
                );
        }