Remove a bunch of trailing spaces and unneeded newlines
[lhc/web/wiklou.git] / includes / extauth / MediaWiki.php
index 9df4ea1..c7f6a20 100644 (file)
  *       'DBprefix' => '',
  *   );
  *
- * All fields must be present.  These mean the same things as $wgDBtype, 
- * $wgDBserver, etc.  This implementation is quite crude; it could easily 
- * support multiple database servers, for instance, and memcached, and it 
- * probably has bugs.  Kind of hard to reuse code when things might rely on who 
+ * All fields must be present.  These mean the same things as $wgDBtype,
+ * $wgDBserver, etc.  This implementation is quite crude; it could easily
+ * support multiple database servers, for instance, and memcached, and it
+ * probably has bugs.  Kind of hard to reuse code when things might rely on who
  * knows what configuration globals.
  *
- * If either wiki uses the UserComparePasswords hook, password authentication 
- * might fail unexpectedly unless they both do the exact same validation.  
- * There may be other corner cases like this where this will fail, but it 
+ * If either wiki uses the UserComparePasswords hook, password authentication
+ * might fail unexpectedly unless they both do the exact same validation.
+ * There may be other corner cases like this where this will fail, but it
  * should be unlikely.
  *
  * @ingroup ExternalUser
  */
 class ExternalUser_MediaWiki extends ExternalUser {
-       private $mRow, $mDb;
+       private $mRow;
 
+       /**
+        * @var DatabaseBase
+        */
+       private $mDb;
+
+       /**
+        * @param $name string
+        * @return bool
+        */
        protected function initFromName( $name ) {
-               # We might not need the 'usable' bit, but let's be safe.  Theoretically 
-               # this might return wrong results for old versions, but it's probably 
+               # We might not need the 'usable' bit, but let's be safe.  Theoretically
+               # this might return wrong results for old versions, but it's probably
                # good enough.
                $name = User::getCanonicalName( $name, 'usable' );
 
@@ -65,20 +74,28 @@ class ExternalUser_MediaWiki extends ExternalUser {
                return $this->initFromCond( array( 'user_name' => $name ) );
        }
 
+       /**
+        * @param $id int
+        * @return bool
+        */
        protected function initFromId( $id ) {
                return $this->initFromCond( array( 'user_id' => $id ) );
        }
 
+       /**
+        * @param $cond array
+        * @return bool
+        */
        private function initFromCond( $cond ) {
                global $wgExternalAuthConf;
 
-               $this->mDb = DatabaseBase::newFromType( $wgExternalAuthConf['DBtype'],
+               $this->mDb = DatabaseBase::factory( $wgExternalAuthConf['DBtype'],
                        array(
-                               'server'      => $wgExternalAuthConf['DBserver'],
+                               'host'        => $wgExternalAuthConf['DBserver'],
                                'user'        => $wgExternalAuthConf['DBuser'],
                                'password'    => $wgExternalAuthConf['DBpassword'],
                                'dbname'      => $wgExternalAuthConf['DBname'],
-                               'tableprefix' => $wgExternalAuthConf['DBprefix'],
+                               'tablePrefix' => $wgExternalAuthConf['DBprefix'],
                        )
                );
 
@@ -105,19 +122,22 @@ class ExternalUser_MediaWiki extends ExternalUser {
                return $this->mRow->user_id;
        }
 
+       /**
+        * @return string
+        */
        public function getName() {
                return $this->mRow->user_name;
        }
 
        public function authenticate( $password ) {
-               # This might be wrong if anyone actually uses the UserComparePasswords hook 
+               # This might be wrong if anyone actually uses the UserComparePasswords hook
                # (on either end), so don't use this if you those are incompatible.
                return User::comparePasswords( $this->mRow->user_password, $password,
-                       $this->mRow->user_id ); 
+                       $this->mRow->user_id );
        }
 
        public function getPref( $pref ) {
-               # FIXME: Return other prefs too.  Lots of global-riddled code that does 
+               # @todo FIXME: Return other prefs too.  Lots of global-riddled code that does
                # this normally.
                if ( $pref === 'emailaddress'
                && $this->row->user_email_authenticated !== null ) {
@@ -126,8 +146,11 @@ class ExternalUser_MediaWiki extends ExternalUser {
                return null;
        }
 
+       /**
+        * @return array
+        */
        public function getGroups() {
-               # FIXME: Untested.
+               # @todo FIXME: Untested.
                $groups = array();
                $res = $this->mDb->select(
                        'user_groups',