X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUserrights.php;h=66af4c574cefa7f4c2892a74c416273ebb79b2ea;hb=71a8bf7b82621a974ab2bdf8ce517e8bd0878d44;hp=c3ceb3457bfb19764cd4d16c98f7dda727524e31;hpb=04d7d46b1d39340121698ba76fd8e433f60929c9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index c3ceb3457b..66af4c574c 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(); @@ -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,11 +110,11 @@ 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(