}
}
+ if ( !is_null( $params['group'] ) && !is_null( $params['excludegroup'] ) ) {
+ $this->dieUsage( 'group and excludegroup cannot be used together', 'group-excludegroup' );
+ }
+
if ( !is_null( $params['group'] ) && count( $params['group'] ) ) {
$useIndex = false;
// Filter only users that belong to a given group
'ug1.ug_group' => $params['group'] ) ) ) );
}
+ if ( !is_null( $params['excludegroup'] ) && count( $params['excludegroup'] ) ) {
+ $useIndex = false;
+ // Filter only users don't belong to a given group
+ $this->addTables( 'user_groups', 'ug1' );
+
+ if ( count( $params['excludegroup'] ) == 1 ) {
+ $exclude = array( 'ug1.ug_group = ' . $db->addQuotes( $params['excludegroup'][0] ) );
+ } else {
+ $exclude = array( $db->makeList( array( 'ug1.ug_group' => $params['excludegroup'] ), LIST_OR ) );
+ }
+ $this->addJoinConds( array( 'ug1' => array( 'LEFT OUTER JOIN',
+ array_merge( array( 'ug1.ug_user=user_id' ), $exclude )
+ )
+ ) );
+ $this->addWhere( 'ug1.ug_user IS NULL' );
+ }
+
if ( $params['witheditsonly'] ) {
$this->addWhere( 'user_editcount > 0' );
}
}
public function getAllowedParams() {
+ $userGroups = User::getAllGroups();
return array(
'from' => null,
'to' => null,
),
),
'group' => array(
- ApiBase::PARAM_TYPE => User::getAllGroups(),
+ ApiBase::PARAM_TYPE => $userGroups,
+ ApiBase::PARAM_ISMULTI => true,
+ ),
+ 'excludegroup' => array(
+ ApiBase::PARAM_TYPE => $userGroups,
ApiBase::PARAM_ISMULTI => true,
),
'rights' => array(
'prefix' => 'Search for all users that begin with this value',
'dir' => 'Direction to sort in',
'group' => 'Limit users to given group name(s)',
+ 'excludegroup' => 'Exclude users in given group name(s)',
'rights' => 'Limit users to given right(s)',
'prop' => array(
'What pieces of information to include.',
return 'Enumerate all registered users';
}
+ public function getPossibleErrors() {
+ return array_merge( parent::getPossibleErrors(), array(
+ array( 'code' => 'group-excludegroup', 'info' => 'group and excludegroup cannot be used together' ),
+ ) );
+ }
+
protected function getExamples() {
return array(
'api.php?action=query&list=allusers&aufrom=Y',