/** * Actually add a user to the database. * Give it a User object that has been initialised with a name. * * @param $tempUser User object. * @param $autocreate boolean -- true if this is an autocreation via auth plugin * @return User object. * @private */ function initUser( $tempUser, $autocreate = false ) { global $wgAuth; $tempUser->addToDatabase(); if ( $wgAuth->allowPasswordChange() ) { $tempUser->setPassword( $this->mPassword ); } $tempUser->setEmail( $this->mEmail ); $tempUser->setRealName( $this->mRealName ); $tempUser->setToken(); $wgAuth->initUser( $tempUser, $autocreate ); if ( $this->mExtUser ) { $this->mExtUser->linkToLocal( $tempUser->getId() ); $email = $this->mExtUser->getPref( 'emailaddress' ); if ( $email && !$this->mEmail ) { $tempUser->setEmail( $email ); } } $tempUser->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 ); $tempUser->saveSettings(); # Update user count $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); $ssUpdate->doUpdate(); $this->addToSourceTracking( $tempUser ); return $tempUser; }
/** * Actually add a user to the database. * Give it a User object that has been initialised with a name. * * @param $u User object. * @param $autocreate boolean -- true if this is an autocreation via auth plugin * @return Status object, with the User object in the value member on success * @private */ function initUser($u, $autocreate) { global $wgAuth; $status = $u->addToDatabase(); if (!$status->isOK()) { return $status; } if ($wgAuth->allowPasswordChange()) { $u->setPassword($this->mPassword); } $u->setEmail($this->mEmail); $u->setRealName($this->mRealName); $u->setToken(); $wgAuth->initUser($u, $autocreate); if ($this->mExtUser) { $this->mExtUser->linkToLocal($u->getId()); $email = $this->mExtUser->getPref('emailaddress'); if ($email && !$this->mEmail) { $u->setEmail($email); } } $u->setOption('rememberpassword', $this->mRemember ? 1 : 0); $u->saveSettings(); # Update user count DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 0, 0, 0, 1)); return Status::newGood($u); }