You can't add or remove a group that doesn't exist, so don't claim that
it's possible on Special:ListGroupRights or the API.
Change-Id: I02d3f00142ca1cb0cdcbf30e79fecb3c96e96405
$data = array();
$result = $this->getResult();
$data = array();
$result = $this->getResult();
+ $allGroups = User::getAllGroups();
foreach ( $config->get( 'GroupPermissions' ) as $group => $permissions ) {
$arr = array(
'name' => $group,
foreach ( $config->get( 'GroupPermissions' ) as $group => $permissions ) {
$arr = array(
'name' => $group,
foreach ( $groupArr as $type => $rights ) {
if ( isset( $rights[$group] ) ) {
foreach ( $groupArr as $type => $rights ) {
if ( isset( $rights[$group] ) ) {
- $arr[$type] = $rights[$group];
- $result->setIndexedTagName( $arr[$type], 'group' );
+ $groups = array_intersect( $rights[$group], $allGroups );
+ if ( $groups ) {
+ $arr[$type] = $groups;
+ $result->setIndexedTagName( $arr[$type], 'group' );
+ }
sort( $r );
$lang = $this->getLanguage();
sort( $r );
$lang = $this->getLanguage();
+ $allGroups = User::getAllGroups();
if ( $add === true ) {
$r[] = $this->msg( 'listgrouprights-addgroup-all' )->escaped();
if ( $add === true ) {
$r[] = $this->msg( 'listgrouprights-addgroup-all' )->escaped();
- } elseif ( is_array( $add ) && count( $add ) ) {
- $add = array_values( array_unique( $add ) );
- $r[] = $this->msg( 'listgrouprights-addgroup',
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $add ) ),
- count( $add )
- )->parse();
+ } elseif ( is_array( $add ) ) {
+ $add = array_intersect( array_values( array_unique( $add ) ), $allGroups );
+ if ( count( $add ) ) {
+ $r[] = $this->msg( 'listgrouprights-addgroup',
+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $add ) ),
+ count( $add )
+ )->parse();
+ }
}
if ( $remove === true ) {
$r[] = $this->msg( 'listgrouprights-removegroup-all' )->escaped();
}
if ( $remove === true ) {
$r[] = $this->msg( 'listgrouprights-removegroup-all' )->escaped();
- } elseif ( is_array( $remove ) && count( $remove ) ) {
- $remove = array_values( array_unique( $remove ) );
- $r[] = $this->msg( 'listgrouprights-removegroup',
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ),
- count( $remove )
- )->parse();
+ } elseif ( is_array( $remove ) ) {
+ $remove = array_intersect( array_values( array_unique( $remove ) ), $allGroups );
+ if ( count( $remove ) ) {
+ $r[] = $this->msg( 'listgrouprights-removegroup',
+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ),
+ count( $remove )
+ )->parse();
+ }
}
if ( $addSelf === true ) {
$r[] = $this->msg( 'listgrouprights-addgroup-self-all' )->escaped();
}
if ( $addSelf === true ) {
$r[] = $this->msg( 'listgrouprights-addgroup-self-all' )->escaped();
- } elseif ( is_array( $addSelf ) && count( $addSelf ) ) {
- $addSelf = array_values( array_unique( $addSelf ) );
- $r[] = $this->msg( 'listgrouprights-addgroup-self',
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ),
- count( $addSelf )
- )->parse();
+ } elseif ( is_array( $addSelf ) ) {
+ $addSelf = array_intersect( array_values( array_unique( $addSelf ) ), $allGroups );
+ if ( count( $addSelf ) ) {
+ $r[] = $this->msg( 'listgrouprights-addgroup-self',
+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ),
+ count( $addSelf )
+ )->parse();
+ }
}
if ( $removeSelf === true ) {
$r[] = $this->msg( 'listgrouprights-removegroup-self-all' )->parse();
}
if ( $removeSelf === true ) {
$r[] = $this->msg( 'listgrouprights-removegroup-self-all' )->parse();
- } elseif ( is_array( $removeSelf ) && count( $removeSelf ) ) {
- $removeSelf = array_values( array_unique( $removeSelf ) );
- $r[] = $this->msg( 'listgrouprights-removegroup-self',
- $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ),
- count( $removeSelf )
- )->parse();
+ } elseif ( is_array( $removeSelf ) ) {
+ $removeSelf = array_intersect( array_values( array_unique( $removeSelf ) ), $allGroups );
+ if ( count( $removeSelf ) ) {
+ $r[] = $this->msg( 'listgrouprights-removegroup-self',
+ $lang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ),
+ count( $removeSelf )
+ )->parse();
+ }