From: Alex Monk Date: Wed, 1 Oct 2014 12:06:10 +0000 (+0100) Subject: User rights API: Abstract out some stuff about core's form into separate methods X-Git-Tag: 1.31.0-rc.0~13738^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=7ac4fec0ba987775786bca104991644050f71373 User rights API: Abstract out some stuff about core's form into separate methods To we can make a CentralAuth API module for global user rights. Bug: 71495 Change-Id: I139c43e5eaa1fb63b75baddbafb7caa3c964d6b5 --- 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(