$fld_blockinfo = isset( $prop['blockinfo'] );
$fld_editcount = isset( $prop['editcount'] );
$fld_groups = isset( $prop['groups'] );
+ $fld_rights = isset( $prop['rights'] );
$fld_registration = isset( $prop['registration'] );
} else {
$fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration = false;
$this->addWhere( 'u1.user_editcount > 0' );
}
- if ( $fld_groups ) {
+ if ( $fld_groups || $fld_rights ) {
// Show the groups the given users belong to
// request more than needed to avoid not getting all rows that belong to one user
$groupCount = count( User::getAllGroups() );
$lastUserData['groups'][] = $row->ug_group2;
$result->setIndexedTagName( $lastUserData['groups'], 'g' );
}
+
+ if ( $fld_rights && !is_null( $row->ug_group2 ) ) {
+ if ( !isset( $lastUserData['rights'] ) ) {
+ $lastUserData['rights'] = User::getGroupPermissions( User::getImplicitGroups() );
+ }
+
+ $lastUserData['rights'] = array_merge( $lastUserData['rights'], User::getGroupPermissions( array( $row->ug_group2 ) ) );
+ $result->setIndexedTagName( $lastUserData['rights'], 'r' );
+ }
}
if ( is_array( $lastUserData ) ) {
'What pieces of information to include.',
' blockinfo - Adds the information about a current block on the user',
' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit',
+ ' rights - Lists groups that the user has',
' editcount - Adds the edit count of the user',
' registration - Adds the timestamp of when the user registered',
),
$data[$name]['groups'][] = $row->ug_group;
}
+ if ( isset( $this->prop['rights'] ) && !isset( $data[$name]['rights'] ) ) {
+ // User::getRights() may return duplicate values, strip them
+ $data[$name]['rights'] = array_values( array_unique( $user->getRights() ) );
+ $result->setIndexedTagName( $data[$name]['rights'], 'r' ); // even if empty
+ }
+
if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->blocker_name ) ) {
$data[$name]['blockedby'] = $row->blocker_name;
$data[$name]['blockreason'] = $row->ipb_reason;
ApiBase::PARAM_TYPE => array(
'blockinfo',
'groups',
+ 'rights',
'editcount',
'registration',
'emailable',
'What pieces of information to include',
' blockinfo - Tags if the user is blocked, by whom, and for what reason',
' groups - Lists all the groups the user(s) belongs to',
- //' rights - Lists all the rights the user(s) has',
+ ' rights - Lists all the rights the user(s) has',
' editcount - Adds the user\'s edit count',
' registration - Adds the user\'s registration timestamp',
' emailable - Tags if the user can and wants to receive e-mail through [[Special:Emailuser]]',