$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;
}
/**
* 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
* @param $pref string
* @return mixed String or false
*/
- public static function prefMessage( $pref ) {
+ public static function getPrefMessage( $pref ) {
return false;
}
*
* @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;
+ }
+
}