- if (!is_null($params['from']))
- $this->addWhere('u1.user_name >= ' . $db->addQuotes($this->keyToTitle($params['from'])));
+ $this->addTables( 'user' );
+ $useIndex = true;
+
+ $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
+ $from = is_null( $params['from'] ) ? null : $this->keyToTitle( $params['from'] );
+ $to = is_null( $params['to'] ) ? null : $this->keyToTitle( $params['to'] );
+
+ $this->addWhereRange( 'user_name', $dir, $from, $to );
+
+ if ( !is_null( $params['prefix'] ) ) {
+ $this->addWhere( 'user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) );
+ }
+
+ if ( !is_null( $params['rights'] ) ) {
+ $groups = array();
+ foreach( $params['rights'] as $r ) {
+ $groups = array_merge( $groups, User::getGroupsWithPermission( $r ) );
+ }
+
+ $groups = array_diff( array_unique( $groups ), User::getImplicitGroups() );