Merge "User rights API: Abstract out some stuff about core's form into separate methods"

This commit is contained in:
jenkins-bot 2014-10-01 13:33:10 +00:00 committed by Gerrit Code Review
commit e6444a462a

View 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,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(