*
* @see newFromId()
* @see newFromName()
- * @param $db DatabaseBase: db connection
- * @param string $database database name
- * @param string $name user name
- * @param $id Integer: user ID
+ * @param DatabaseBase $db Db connection
+ * @param string $database Database name
+ * @param string $name User name
+ * @param int $id User ID
*/
private function __construct( $db, $database, $name, $id ) {
$this->db = $db;
/**
* Accessor for $this->database
*
- * @return String: database name
+ * @return string Database name
*/
public function getDBName() {
return $this->database;
/**
* Confirm the selected database name is a valid local interwiki database name.
*
- * @param string $database database name
- * @return Boolean
+ * @param string $database Database name
+ * @return bool
*/
public static function validDatabase( $database ) {
global $wgLocalDatabases;
/**
* Same as User::whoIs()
*
- * @param string $database database name
- * @param $id Integer: user ID
- * @param $ignoreInvalidDB Boolean: if true, don't check if $database is in $wgLocalDatabases
- * @return String: user name or false if the user doesn't exist
+ * @param string $database Database name
+ * @param int $id User ID
+ * @param bool $ignoreInvalidDB If true, don't check if $database is in $wgLocalDatabases
+ * @return string User name or false if the user doesn't exist
*/
public static function whoIs( $database, $id, $ignoreInvalidDB = false ) {
$user = self::newFromId( $database, $id, $ignoreInvalidDB );
- if( $user ) {
+ if ( $user ) {
return $user->name;
} else {
return false;
/**
* Factory function; get a remote user entry by ID number.
*
- * @param string $database database name
- * @param $id Integer: user ID
- * @param $ignoreInvalidDB Boolean: if true, don't check if $database is in $wgLocalDatabases
- * @return UserRightsProxy or null if doesn't exist
+ * @param string $database Database name
+ * @param int $id User ID
+ * @param bool $ignoreInvalidDB If true, don't check if $database is in $wgLocalDatabases
+ * @return UserRightsProxy|null If doesn't exist
*/
public static function newFromId( $database, $id, $ignoreInvalidDB = false ) {
return self::newFromLookup( $database, 'user_id', intval( $id ), $ignoreInvalidDB );
/**
* Factory function; get a remote user entry by name.
*
- * @param string $database database name
- * @param string $name user name
- * @param $ignoreInvalidDB Boolean: if true, don't check if $database is in $wgLocalDatabases
- * @return UserRightsProxy or null if doesn't exist
+ * @param string $database Database name
+ * @param string $name User name
+ * @param bool $ignoreInvalidDB If true, don't check if $database is in $wgLocalDatabases
+ * @return UserRightsProxy|null If doesn't exist
*/
public static function newFromName( $database, $name, $ignoreInvalidDB = false ) {
return self::newFromLookup( $database, 'user_name', $name, $ignoreInvalidDB );
}
/**
- * @param $database
- * @param $field
- * @param $value
- * @param $ignoreInvalidDB bool
+ * @param string $database
+ * @param string $field
+ * @param string $value
+ * @param bool $ignoreInvalidDB
* @return null|UserRightsProxy
*/
private static function newFromLookup( $database, $field, $value, $ignoreInvalidDB = false ) {
$db = self::getDB( $database, $ignoreInvalidDB );
- if( $db ) {
+ if ( $db ) {
$row = $db->selectRow( 'user',
array( 'user_id', 'user_name' ),
array( $field => $value ),
__METHOD__ );
- if( $row !== false ) {
+ if ( $row !== false ) {
return new UserRightsProxy( $db, $database,
$row->user_name,
intval( $row->user_id ) );
* Open a database connection to work on for the requested user.
* This may be a new connection to another database for remote users.
*
- * @param $database String
- * @param $ignoreInvalidDB Boolean: if true, don't check if $database is in $wgLocalDatabases
- * @return DatabaseBase or null if invalid selection
+ * @param string $database
+ * @param bool $ignoreInvalidDB If true, don't check if $database is in $wgLocalDatabases
+ * @return DatabaseBase|null If invalid selection
*/
public static function getDB( $database, $ignoreInvalidDB = false ) {
global $wgDBname;
- if( self::validDatabase( $database ) ) {
- if( $database == $wgDBname ) {
+ if ( $ignoreInvalidDB || self::validDatabase( $database ) ) {
+ if ( $database == $wgDBname ) {
// Hmm... this shouldn't happen though. :)
return wfGetDB( DB_MASTER );
} else {
/**
* Same as User::getName()
*
- * @return String
+ * @return string
*/
public function getName() {
return $this->name . '@' . $this->database;
/**
* Same as User::getUserPage()
*
- * @return Title object
+ * @return Title
*/
public function getUserPage() {
return Title::makeTitle( NS_USER, $this->getName() );
/**
* Replaces User::addUserGroup()
+ * @param string $group
*/
function addGroup( $group ) {
$this->db->insert( 'user_groups',
/**
* Replaces User::removeUserGroup()
+ * @param string $group
*/
function removeGroup( $group ) {
$this->db->delete( 'user_groups',
/**
* Replaces User::setOption()
+ * @param string $option
+ * @param mixed $value
*/
public function setOption( $option, $value ) {
$this->newOptions[$option] = $value;