- $data = array();
- $res = $this->select(__METHOD__);
- while(($r = $db->fetchObject($res))) {
- $data[$r->user_name]['name'] = $r->user_name;
- if(isset($this->prop['editcount']))
- $data[$r->user_name]['editcount'] = $r->user_editcount;
- if(isset($this->prop['registration']))
- $data[$r->user_name]['registration'] = wfTimestamp(TS_ISO_8601, $r->user_registration);
- if(isset($this->prop['groups']))
- // This row contains only one group, others will be added from other rows
- if(!is_null($r->ug_group))
- $data[$r->user_name]['groups'][] = $r->ug_group;
- if(isset($this->prop['blockinfo']))
- if(!is_null($r->blocker_name)) {
- $data[$r->user_name]['blockedby'] = $r->blocker_name;
- $data[$r->user_name]['blockreason'] = $r->ipb_reason;
+ if ( count( $goodNames ) ) {
+ $this->addTables( 'user', 'u1' );
+ $this->addFields( 'u1.*' );
+ $this->addWhereFld( 'u1.user_name', $goodNames );
+
+ if ( isset( $this->prop['groups'] ) ) {
+ $this->addTables( 'user_groups' );
+ $this->addJoinConds( array( 'user_groups' => array( 'LEFT JOIN', 'ug_user=u1.user_id' ) ) );
+ $this->addFields( 'ug_group' );
+ }
+ if ( isset( $this->prop['blockinfo'] ) ) {
+ $this->addTables( 'ipblocks' );
+ $this->addTables( 'user', 'u2' );
+ $u2 = $this->getAliasedName( 'user', 'u2' );
+ $this->addJoinConds( array(
+ 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ),
+ $u2 => array( 'LEFT JOIN', 'ipb_by=u2.user_id' ) ) );
+ $this->addFields( array( 'ipb_reason', 'u2.user_name AS blocker_name' ) );
+ }
+
+ $data = array();
+ $res = $this->select( __METHOD__ );
+ foreach ( $res as $row ) {
+ $user = User::newFromRow( $row );
+ $name = $user->getName();
+ $data[$name]['name'] = $name;
+
+ if ( isset( $this->prop['editcount'] ) ) {
+ $data[$name]['editcount'] = intval( $user->getEditCount() );