summaryrefslogtreecommitdiff
path: root/includes/api/ApiUserrights.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiUserrights.php')
-rw-r--r--includes/api/ApiUserrights.php56
1 files changed, 30 insertions, 26 deletions
diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php
index c3ceb345..3ccdde25 100644
--- a/includes/api/ApiUserrights.php
+++ b/includes/api/ApiUserrights.php
@@ -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();
@@ -47,8 +63,8 @@ class ApiUserrights extends ApiBase {
);
$result = $this->getResult();
- $result->setIndexedTagName( $r['added'], 'group' );
- $result->setIndexedTagName( $r['removed'], 'group' );
+ ApiResult::setIndexedTagName( $r['added'], 'group' );
+ ApiResult::setIndexedTagName( $r['removed'], 'group' );
$result->addValue( null, $this->getModuleName(), $r );
}
@@ -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',
);
}