X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FUserRightsProxy.php;h=a8a22be7334acffc819a27e3d5fa13e7bbb94556;hb=9a3b6e5639d0fae23c721ed803a3feb0a0462c14;hp=6c2a5f1201fdafda63b77715dbe493e595ecf496;hpb=a2589ff8c6718dc170db8eb6c08ce656d38df46b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/UserRightsProxy.php b/includes/UserRightsProxy.php index 6c2a5f1201..a8a22be733 100644 --- a/includes/UserRightsProxy.php +++ b/includes/UserRightsProxy.php @@ -1,4 +1,24 @@ name; } else { return false; @@ -64,7 +84,7 @@ class UserRightsProxy { /** * Factory function; get a remote user entry by ID number. * - * @param $database String: database name + * @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 @@ -76,8 +96,8 @@ class UserRightsProxy { /** * Factory function; get a remote user entry by name. * - * @param $database String: database name - * @param $name String: user 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 */ @@ -85,14 +105,21 @@ class UserRightsProxy { return self::newFromLookup( $database, 'user_name', $name, $ignoreInvalidDB ); } + /** + * @param $database + * @param $field + * @param $value + * @param $ignoreInvalidDB bool + * @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 ) ); @@ -111,8 +138,8 @@ class UserRightsProxy { */ 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 { @@ -122,10 +149,16 @@ class UserRightsProxy { return null; } + /** + * @return int + */ public function getId() { return $this->id; } + /** + * @return bool + */ public function isAnon() { return $this->getId() == 0; } @@ -150,6 +183,7 @@ class UserRightsProxy { /** * Replaces User::getUserGroups() + * @return array */ function getGroups() { $res = $this->db->select( 'user_groups', @@ -187,14 +221,14 @@ class UserRightsProxy { ), __METHOD__ ); } - + /** * Replaces User::setOption() */ public function setOption( $option, $value ) { $this->newOptions[$option] = $value; } - + public function saveSettings() { $rows = array(); foreach ( $this->newOptions as $option => $value ) {