New function for ExternalUser to get the local User corresponding to the external...
authorHappy-melon <happy-melon@users.mediawiki.org>
Sun, 20 Sep 2009 18:53:17 +0000 (18:53 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sun, 20 Sep 2009 18:53:17 +0000 (18:53 +0000)
includes/ExternalUser.php

index a5f9322..ecb0097 100644 (file)
@@ -285,4 +285,22 @@ abstract class ExternalUser {
                               '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->fetchObject()->eu_wiki_id )
+                       : null;
+       }
+       
 }