GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Main page
  • Get MediaWiki
  • Get extensions
  • Tech blog
  • Contribute
  • User help
  • FAQ
  • Technical manual
  • Support desk
  • Communication
  • Developer portal
  • Code statistics
  • Community portal
  • Recent changes

This view

  • Original page
  • New address

GeezerVison is showing www.mediawiki.org — Wikia code/includes/ExternalUser.php - MediaWiki

< Wikia code | includes
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date.

The information shown below refers to the now unmaintained 1.16 MediaWiki release. The current stable release number is 1.46.2.
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\ExternalUser.php	2011-07-18 22:31:27.998046900 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\ExternalUser.php	2011-08-17 15:28:46.360351600 +0100
@@ -105,13 +105,41 @@
 			return false;
 		}
 
+		if ( method_exists( $wgExternalAuthType, 'initFromUser' ) ) {
+			$obj = new $wgExternalAuthType;
+			if ( !$obj->initFromUser( $user ) ) {
+				return false;
+			}
+		} else {
 		$dbr = wfGetDB( DB_SLAVE );
 		$id = $dbr->selectField( 'external_user', 'eu_external_id',
 			array( 'eu_local_id' => $user->getId() ), __METHOD__ );
 		if ( $id === false ) {
 			return false;
 		}
-		return self::newFromId( $id );
+			$obj = self::newFromId( $id );
+		}
+		
+		return $obj;
+	}
+	
+	/**
+	 * add new User object to database
+	 * 
+	 * @param $user User
+	 * @return mixed User or false
+	 */
+	public static function addUser( &$User, $password, $email, $realname ) {
+		global $wgExternalAuthType;
+		if ( is_null( $wgExternalAuthType ) ) {
+			return false;
+		}
+
+		$obj = new $wgExternalAuthType;
+		if ( !$obj->addToDatabase( $User, $password, $email, $realname ) ) {
+			return false;
+		}
+		return $User;
 	}
 
 	/**
@@ -136,6 +164,15 @@
 	protected abstract function initFromId( $id );
 
 	/**
+	 * Given a User object. Return true if successful, otherwise
+	 * false.
+	 *
+	 * @param $user object
+	 * @return bool Success?
+	 */
+	protected abstract function initFromUser( $User );
+	
+	/**
 	 * Try to magically initialize the user from cookies or similar information
 	 * so he or she can be logged in on just viewing the wiki.  If this is
 	 * impossible to do, just return false.
@@ -149,6 +186,14 @@
 	}
 
 	/**
+	 * Add user to the central database
+	 *
+	 * @param $user object
+	 * @return bool
+	 */
+	protected abstract function addToDatabase( $User, $password, $email, $realname );
+	
+	/**
 	 * This must return some identifier that stably, uniquely identifies the
 	 * user.  In a typical web application, this could be an integer
 	 * representing the "user id".  In other cases, it might be a string.  In
@@ -275,7 +320,7 @@
 	 *
 	 * @param $id int user_id
 	 */
-	public final function linkToLocal( $id ) {
+	protected function linkToLocal( $id ) {
 		$dbw = wfGetDB( DB_MASTER );
 		$dbw->replace( 'external_user',
 			array( 'eu_local_id', 'eu_external_id' ),
@@ -289,7 +334,7 @@
 	 * a local user.
 	 * @return Mixed User if the account is linked, Null otherwise.
 	 */
-	public final function getLocalUser(){
+	protected function getLocalUser(){
 		$dbr = wfGetDb( DB_SLAVE );
 		$row = $dbr->selectRow(
 			'external_user',
@@ -301,4 +346,10 @@
 			: null;
 	}
 	
+	/**
+	 * set global user object in externalUser 
+	 */	
+	public function updateUser() {
+		return false;
+	}
 }
Retrieved from "https://www.mediawiki.org/w/index.php?title=Wikia_code/includes/ExternalUser.php&oldid=4961085"
Categories:
  • Pages kept for historical interest
  • Wikia code diffs
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.