<?php
-
/**
- * Created on July 30, 2007
- *
* API for MediaWiki 1.8+
*
+ * Created on July 30, 2007
+ *
* Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
*
* This program is free software; you can redistribute it and/or modify
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
*/
if ( !defined( 'MEDIAWIKI' ) ) {
public function execute() {
$params = $this->extractRequestParams();
$result = $this->getResult();
- $r = array();
if ( !is_null( $params['prop'] ) ) {
$this->prop = array_flip( $params['prop'] );
}
if ( count( $goodNames ) ) {
- $db = $this->getDb();
$this->addTables( 'user', 'u1' );
$this->addFields( 'u1.*' );
$this->addWhereFld( 'u1.user_name', $goodNames );
$data = array();
$res = $this->select( __METHOD__ );
- while ( ( $r = $db->fetchObject( $res ) ) ) {
- $user = User::newFromRow( $r );
+ foreach ( $res as $row ) {
+ $user = User::newFromRow( $row );
$name = $user->getName();
$data[$name]['name'] = $name;
$data[$name]['registration'] = wfTimestampOrNull( TS_ISO_8601, $user->getRegistration() );
}
- if ( isset( $this->prop['groups'] ) && !is_null( $r->ug_group ) ) {
+ if ( isset( $this->prop['groups'] ) && !is_null( $row->ug_group ) ) {
// This row contains only one group, others will be added from other rows
- $data[$name]['groups'][] = $r->ug_group;
+ $data[$name]['groups'][] = $row->ug_group;
}
- if ( isset( $this->prop['blockinfo'] ) && !is_null( $r->blocker_name ) ) {
- $data[$name]['blockedby'] = $r->blocker_name;
- $data[$name]['blockreason'] = $r->ipb_reason;
+ if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->blocker_name ) ) {
+ $data[$name]['blockedby'] = $row->blocker_name;
+ $data[$name]['blockreason'] = $row->ipb_reason;
}
if ( isset( $this->prop['emailable'] ) && $user->canReceiveEmail() ) {
} else {
if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
$autolist = ApiQueryUsers::getAutoGroups( User::newFromName( $u ) );
-
+
$data[$u]['groups'] = array_merge( $autolist, $data[$u]['groups'] );
-
+
$this->getResult()->setIndexedTagName( $data[$u]['groups'], 'g' );
}
}
}
return $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' );
}
-
+
+ /**
+ * Gets all the groups that a user is automatically a member of
+ * @return array
+ */
public static function getAutoGroups( $user ) {
- $autolist = array();
- $autolist[] = "*";
- $autolist[] = "user";
+ $groups = array( '*' );
+
+ if ( !$user->isAnon() ) {
+ $groups[] = 'user';
+ }
- foreach( Autopromote::getAutopromoteGroups( $user ) as $group ) {
- $autolist[] = $group;
+ return array_merge( $groups, Autopromote::getAutopromoteGroups( $user ) );
+ }
+
+ public function getCacheMode( $params ) {
+ if ( isset( $params['token'] ) ) {
+ return 'private';
+ } else {
+ return 'public';
}
-
- return $autolist;
}
public function getAllowedParams() {