Removed unused var
[lhc/web/wiklou.git] / includes / UserRightsProxy.php
index 9096744..0d6b815 100644 (file)
@@ -1,27 +1,55 @@
 <?php
 
-
 /**
  * Cut-down copy of User interface for local-interwiki-database
  * user rights manipulation.
  */
 class UserRightsProxy {
+
+       /**
+        * Constructor.
+        *
+        * @see newFromId()
+        * @see newFromName()
+        * @param $db DatabaseBase: db connection
+        * @param $database String: database name
+        * @param $name String: user name
+        * @param $id Integer: user ID
+        */
        private function __construct( $db, $database, $name, $id ) {
                $this->db = $db;
                $this->database = $database;
                $this->name = $name;
                $this->id = intval( $id );
        }
-       
+
+       /**
+        * Accessor for $this->database
+        *
+        * @return String: database name
+        */
+       public function getDBName() {
+               return $this->database;
+       }
+
        /**
         * Confirm the selected database name is a valid local interwiki database name.
-        * @return bool
+        *
+        * @param $database String: database name
+        * @return Boolean
         */
        public static function validDatabase( $database ) {
                global $wgLocalDatabases;
                return in_array( $database, $wgLocalDatabases );
        }
-       
+
+       /**
+        * Same as User::whoIs()
+        *
+        * @param $database String: database name
+        * @param $id Integer: user ID
+        * @return String: user name or false if the user doesn't exist
+        */
        public static function whoIs( $database, $id ) {
                $user = self::newFromId( $database, $id );
                if( $user ) {
@@ -30,19 +58,29 @@ class UserRightsProxy {
                        return false;
                }
        }
-       
+
        /**
         * Factory function; get a remote user entry by ID number.
+        *
+        * @param $database String: database name
+        * @param $id Integer: user ID
         * @return UserRightsProxy or null if doesn't exist
         */
        public static function newFromId( $database, $id ) {
                return self::newFromLookup( $database, 'user_id', intval( $id ) );
        }
 
+       /**
+        * Factory function; get a remote user entry by name.
+        *
+        * @param $database String: database name
+        * @param $name String: user name
+        * @return UserRightsProxy or null if doesn't exist
+        */
        public static function newFromName( $database, $name ) {
                return self::newFromLookup( $database, 'user_name', $name );
        }
-       
+
        private static function newFromLookup( $database, $field, $value ) {
                $db = self::getDB( $database );
                if( $db ) {
@@ -62,8 +100,9 @@ class UserRightsProxy {
        /**
         * Open a database connection to work on for the requested user.
         * This may be a new connection to another database for remote users.
-        * @param string $database
-        * @return Database or null if invalid selection
+        *
+        * @param $database String
+        * @return DatabaseBase or null if invalid selection
         */
        public static function getDB( $database ) {
                global $wgLocalDatabases, $wgDBname;
@@ -77,24 +116,36 @@ class UserRightsProxy {
                }
                return null;
        }
-       
+
        public function getId() {
                return $this->id;
        }
-       
+
        public function isAnon() {
                return $this->getId() == 0;
        }
-       
+
+       /**
+        * Same as User::getName()
+        *
+        * @return String
+        */
        public function getName() {
                return $this->name . '@' . $this->database;
        }
-       
+
+       /**
+        * Same as User::getUserPage()
+        *
+        * @return Title object
+        */
        public function getUserPage() {
                return Title::makeTitle( NS_USER, $this->getName() );
        }
-       
-       // Replaces getUserGroups()
+
+       /**
+        * Replaces User::getUserGroups()
+        */
        function getGroups() {
                $res = $this->db->select( 'user_groups',
                        array( 'ug_group' ),
@@ -106,8 +157,10 @@ class UserRightsProxy {
                }
                return $groups;
        }
-       
-       // replaces addUserGroup
+
+       /**
+        * Replaces User::addUserGroup()
+        */
        function addGroup( $group ) {
                $this->db->insert( 'user_groups',
                        array(
@@ -117,8 +170,10 @@ class UserRightsProxy {
                        __METHOD__,
                        array( 'IGNORE' ) );
        }
-       
-       // replaces removeUserGroup
+
+       /**
+        * Replaces User::removeUserGroup()
+        */
        function removeGroup( $group ) {
                $this->db->delete( 'user_groups',
                        array(
@@ -127,8 +182,10 @@ class UserRightsProxy {
                        ),
                        __METHOD__ );
        }
-       
-       // replaces touchUser
+
+       /**
+        * Replaces User::touchUser()
+        */
        function invalidateCache() {
                $this->db->update( 'user',
                        array( 'user_touched' => $this->db->timestamp() ),
@@ -144,5 +201,3 @@ class UserRightsProxy {
                $wgMemc->delete( $key );
        }
 }
-
-?>