Sort user groups when shown in drop-downs

This makes searching for them easier and makes their
order less arbitrary, especially when they are localized.
Replace one sort function wrongly chosen by me.

Change-Id: I231f28656333c5bf846bedfedb6ba5040a09f74e
This commit is contained in:
Matěj Suchánek 2019-09-24 13:49:18 +02:00
parent 66eb92b458
commit 75ff49a1ff
4 changed files with 20 additions and 6 deletions

View file

@ -325,9 +325,13 @@ class ApiQueryAllUsers extends ApiQueryBase {
return 'anon-public-user-private';
}
public function getAllowedParams() {
public function getAllowedParams( $flags = 0 ) {
$userGroups = User::getAllGroups();
if ( $flags & ApiBase::GET_VALUES_FOR_HELP ) {
sort( $userGroups );
}
return [
'from' => null,
'to' => null,

View file

@ -223,10 +223,14 @@ class ApiQueryContributors extends ApiQueryBase {
return 'public';
}
public function getAllowedParams() {
public function getAllowedParams( $flags = 0 ) {
$userGroups = User::getAllGroups();
$userRights = $this->getPermissionManager()->getAllPermissions();
if ( $flags & ApiBase::GET_VALUES_FOR_HELP ) {
sort( $userGroups );
}
return [
'group' => [
ApiBase::PARAM_TYPE => $userGroups,

View file

@ -160,7 +160,13 @@ class ApiUserrights extends ApiBase {
return true;
}
public function getAllowedParams() {
public function getAllowedParams( $flags = 0 ) {
$allGroups = $this->getAllGroups();
if ( $flags & ApiBase::GET_VALUES_FOR_HELP ) {
sort( $allGroups );
}
$a = [
'user' => [
ApiBase::PARAM_TYPE => 'user',
@ -169,7 +175,7 @@ class ApiUserrights extends ApiBase {
ApiBase::PARAM_TYPE => 'integer',
],
'add' => [
ApiBase::PARAM_TYPE => $this->getAllGroups(),
ApiBase::PARAM_TYPE => $allGroups,
ApiBase::PARAM_ISMULTI => true
],
'expiry' => [
@ -178,7 +184,7 @@ class ApiUserrights extends ApiBase {
ApiBase::PARAM_DFLT => 'infinite',
],
'remove' => [
ApiBase::PARAM_TYPE => $this->getAllGroups(),
ApiBase::PARAM_TYPE => $allGroups,
ApiBase::PARAM_ISMULTI => true
],
'reason' => [

View file

@ -84,7 +84,7 @@ class SpecialActiveUsers extends SpecialPage {
$msg = htmlspecialchars( UserGroupMembership::getGroupName( $group ) );
$options[$msg] = $group;
}
asort( $options );
ksort( $options );
// Backwards-compatibility with old URLs
$req = $this->getRequest();