- function getSQL() {
- global $wgDBtype;
- $dbr =& wfGetDB( DB_SLAVE );
- $user = $dbr->tableName( 'user' );
- $user_groups = $dbr->tableName( 'user_groups' );
-
- // We need to get an 'atomic' list of users, so that we
- // don't break the list half-way through a user's group set
- // and so that lists by group will show all group memberships.
- //
- // On MySQL 4.1 we could use GROUP_CONCAT to grab group
- // assignments together with users pretty easily. On other
- // versions, it's not so easy to do it consistently.
- // For now we'll just grab the number of memberships, so
- // we can then do targetted checks on those who are in
- // non-default groups as we go down the list.
-
- $userspace = NS_USER;
- $sql = "SELECT 'Listusers' as type, $userspace AS namespace, user_name AS title, " .
- "user_name as value, user_id, COUNT(ug_group) as numgroups " .
- "FROM $user ".
- "LEFT JOIN $user_groups ON user_id=ug_user " .
- $this->userQueryWhere( $dbr ) .
- " GROUP BY user_name";
- if ( $wgDBtype != 'mysql' ) {
- $sql .= ",user_id";
- }
- return $sql;
- }
-
- function userQueryWhere( &$dbr ) {
- $conds = $this->userQueryConditions( $dbr );
- return empty( $conds )
- ? ""
- : "WHERE " . $dbr->makeList( $conds, LIST_AND );
- }
-
- function userQueryConditions( $dbr ) {
- $conds = array();
- if( $this->requestedGroup != '' ) {
- $conds['ug_group'] = $this->requestedGroup;
- }
- if( $this->requestedUser != '' ) {
- $conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser );
- }
- return $conds;
+ /**
+ * Preserve group and username offset parameters when paging
+ * @return array
+ */
+ function getDefaultQuery() {
+ $query = parent::getDefaultQuery();
+ if( $this->requestedGroup != '' )
+ $query['group'] = $this->requestedGroup;
+ if( $this->requestedUser != '' )
+ $query['username'] = $this->requestedUser;
+ return $query;