* Db errors etc).
*/
protected function initUser( $autocreate=false, $byEmail=false ) {
- global $wgAuth;
+ global $wgAuth, $wgUser;
$fields = array(
'name' => $this->mName,
- 'password' => $byEmail ? null : $this->mPassword,
+ 'password' => $byEmail ? null : User::crypt( $this->mPassword ),
'email' => $this->mEmail,
'options' => array(
'rememberpassword' => $this->mRemember ? 1 : 0,
$ssUpdate->doUpdate();
if( $autocreate )
$this->mUser->addNewUserLogEntryAutoCreate();
+ elseif( $wgUser->isAnon() )
+ # Avoid spamming IP addresses all over the newuser log
+ $this->mUser->addNewUserLogEntry( $this->mUser, $byEmail );
else
- $this->mUser->addNewUserLogEntry( $byEmail );
+ $this->mUser->addNewUserLogEntry( $wgUser, $byEmail );
# Run hooks
wfRunHooks( 'AddNewAccount', array( $this->mUser ) );
/**
* Add a newuser log entry for this user
+ * @param $creator User who
* @param $byEmail Boolean: account made by email?
*/
- public function addNewUserLogEntry( $byEmail = false ) {
+ public function addNewUserLogEntry( $creator, $byEmail = false ) {
global $wgUser, $wgContLang, $wgNewUserLog;
if( empty($wgNewUserLog) ) {
return true; // disabled
}
$talk = $wgContLang->getFormattedNsText( NS_TALK );
- if( $this->getName() == $wgUser->getName() ) {
+ if( $creator != $wgUser ) {
$action = 'create';
$message = '';
} else {
$action = 'create2';
- $message = $byEmail ? wfMsgForContent( 'newuserlog-byemail' ) : '';
+ $message = $byEmail
+ ? wfMsgForContent( 'newuserlog-byemail' )
+ : '';
}
$log = new LogPage( 'newusers' );
- $log->addEntry( $action, $this->getUserPage(), $message, array( $this->getId() ) );
+ $log->addEntry(
+ $action,
+ $this->getUserPage(),
+ $message,
+ array( $this->getId() ),
+ $creator
+ );
return true;
}