Fix comment
[lhc/web/wiklou.git] / includes / ExternalUser.php
index a5f9322..94349c9 100644 (file)
@@ -105,7 +105,7 @@ abstract class ExternalUser {
 
                $dbr = wfGetDB( DB_SLAVE );
                $id = $dbr->selectField( 'external_user', 'eu_external_id',
-                       array( 'eu_wiki_id' => $user->getId() ), __METHOD__ );
+                       array( 'eu_local_id' => $user->getId() ), __METHOD__ );
                if ( $id === false ) {
                        return false;
                }
@@ -180,8 +180,7 @@ abstract class ExternalUser {
 
        /**
         * Is the given password valid for the external user?  The password is
-        * provided in plaintext, with whitespace stripped but not otherwise
-        * modified.
+        * provided in plaintext.
         *
         * @param $password string
         * @return bool
@@ -242,7 +241,7 @@ abstract class ExternalUser {
         * @param $pref string
         * @return mixed String or false
         */
-       public static function prefMessage( $pref ) {
+       public static function getPrefMessage( $pref ) {
                return false;
        }
 
@@ -277,12 +276,30 @@ abstract class ExternalUser {
         *
         * @param $id int user_id
         */
-       public final function link( $id ) {
+       public final function linkToLocal( $id ) {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->replace( 'external_user',
-                       array( 'eu_wiki_id', 'eu_external_id' ),
-                       array( 'eu_wiki_id' => $id,
-                              'eu_external_id' => $this->getId() ),
-                   __METHOD__ );
+                       array( 'eu_local_id', 'eu_external_id' ),
+                       array( 'eu_local_id' => $id,
+                                  'eu_external_id' => $this->getId() ),
+                       __METHOD__ );
        }
+       
+       /**
+        * Check whether this external user id is already linked with
+        * a local user.
+        * @return Mixed User if the account is linked, Null otherwise.
+        */
+       public final function getLocalUser(){
+               $dbr = wfGetDb( DB_SLAVE );
+               $row = $dbr->selectRow(
+                       'external_user',
+                       '*',
+                       array( 'eu_external_id' => $this->getId() )
+               );
+               return $row
+                       ? User::newFromId( $row->eu_local_id )
+                       : null;
+       }
+       
 }