GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing www.mediawiki.org — Wikia code/includes/ExternalUser.php - MediaWiki < Wikia code | includes
--- 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; + } } | ||
| 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. |