From 7db738a09e4b3f4c2395fbd913889bc5f514a0f3 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Sun, 20 Sep 2009 18:53:17 +0000 Subject: [PATCH] New function for ExternalUser to get the local User corresponding to the external one. --- includes/ExternalUser.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/includes/ExternalUser.php b/includes/ExternalUser.php index a5f932232e..ecb00971ec 100644 --- a/includes/ExternalUser.php +++ b/includes/ExternalUser.php @@ -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; + } + } -- 2.20.1