This allows to display the "password sent by e-mail." string in the user's language
since it's now in the action text rather than always in content language due to the
fact it was hardcoded in the log's comment.
Insertion of log entries for the new users log is now acomplished using the
ManualLogEntry class rather than the old LogPage one.
Removed 'newuserlog-byemail' message since it's no longer used (also checked
extensions in Wikimedia's Git repo).
IRC notifications will use the same message for 'create2' and 'byemail' for backward
compatibility. The only difference is that 'byemail' entries will no longer have
"password sent by email." in the comment.
Change-Id: Icdf1d714259d054cf8c256faf894c533be0dc73c
$wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
$wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
$wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
+ $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
$wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
}
return true; // disabled
}
- if ( $action === true || $action === 'byemail' ) {
- $action = 'create2';
- if ( $reason === '' ) {
- $reason = wfMessage( 'newuserlog-byemail' )->inContentLanguage()->text();
- } else {
- $reason = $wgContLang->commaList( array(
- $reason, wfMessage( 'newuserlog-byemail' )->inContentLanguage()->text() ) );
- }
+ if ( $action === true ) {
+ $action = 'byemail';
} elseif ( $action === false ) {
if ( $this->getName() == $wgUser->getName() ) {
$action = 'create';
}
}
- if ( $action === 'create' ) {
+ if ( $action === 'create' || $action === 'autocreate' ) {
$performer = $this;
} else {
$performer = $wgUser;
}
- $log = new LogPage( 'newusers' );
- return (int)$log->addEntry(
- $action,
- $this->getUserPage(),
- $reason,
- array( $this->getId() ),
- $performer
- );
+ $logEntry = new ManualLogEntry( 'newusers', $action );
+ $logEntry->setPerformer( $performer );
+ $logEntry->setTarget( $this->getUserPage() );
+ $logEntry->setComment( $reason );
+ $logEntry->setParameters( array(
+ '4::userid' => $this->getId(),
+ ) );
+ $logid = $logEntry->insert();
+
+ if ( $action !== 'autocreate' ) {
+ $logEntry->publish( $logid );
+ }
+
+ return (int)$logid;
}
/**
* Add an autocreate newuser log entry for this user
* Used by things like CentralAuth and perhaps other authplugins.
+ * Consider calling addNewUserLogEntry() directly instead.
*
* @return bool
*/
public function addNewUserLogEntryAutoCreate() {
- global $wgNewUserLog;
- if( !$wgNewUserLog ) {
- return true; // disabled
- }
- $log = new LogPage( 'newusers', false );
- $log->addEntry( 'autocreate', $this->getUserPage(), '', array( $this->getId() ), $this );
+ $this->addNewUserLogEntry( 'autocreate' );
+
return true;
}
->inContentLanguage()->escaped();
break;
case 'create2':
+ case 'byemail':
$text = wfMessage( 'newuserlog-create2-entry' )
->rawParams( $target )->inContentLanguage()->escaped();
break;
class NewUsersLogFormatter extends LogFormatter {
protected function getMessageParameters() {
$params = parent::getMessageParameters();
- if ( $this->entry->getSubtype() === 'create2' ) {
+ $subtype = $this->entry->getSubtype();
+ if ( $subtype === 'create2' || $subtype === 'byemail' ) {
if ( isset( $params[3] ) ) {
$target = User::newFromId( $params[3] );
} else {
}
public function getPreloadTitles() {
- if ( $this->entry->getSubtype() === 'create2' ) {
+ $subtype = $this->entry->getSubtype();
+ if ( $subtype === 'create2' || $subtype === 'byemail' ) {
//add the user talk to LinkBatch for the userLink
return array( Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) );
}
'logentry-newusers-newusers' => 'User account $1 was created',
'logentry-newusers-create' => 'User account $1 was created',
'logentry-newusers-create2' => 'User account $3 was created by $1',
+'logentry-newusers-byemail' => 'User account $3 was created by $1 and password was sent by e-mail',
'logentry-newusers-autocreate' => 'User account $1 was created automatically',
-'newuserlog-byemail' => 'password sent by e-mail',
'logentry-rights-rights' => '$1 changed group membership for $3 from $4 to $5',
'logentry-rights-rights-legacy' => '$1 changed group membership for $3',
'logentry-rights-autopromote' => '$1 was automatically promoted from $4 to $5',
$4 is the gender of the target user.',
'logentry-newusers-create2' => '{{Logentry}}
-$4 is the name of the target user.',
+$4 is the name of the user that was created.',
+'logentry-newusers-byemail' => '{{Logentry}}
+
+$4 is the name of the user that was created.',
'logentry-newusers-autocreate' => '{{Logentry}}
$4 is the gender of the target user.',
'1movedto2',
'1movedto2_redir',
'move-redirect-suppressed',
- // 'newuserlog-byemail',
'newuserlog-create-entry',
'newuserlog-create2-entry',
'newuserlog-autocreate-entry',
'logentry-newusers-newusers',
'logentry-newusers-create',
'logentry-newusers-create2',
+ 'logentry-newusers-byemail',
'logentry-newusers-autocreate',
- 'newuserlog-byemail',
'logentry-rights-rights',
'logentry-rights-rights-legacy',
'logentry-rights-autopromote',
'1movedto2',
'1movedto2_redir',
'move-redirect-suppressed',
- // 'newuserlog-byemail',
'newuserlog-create-entry',
'newuserlog-create2-entry',
'newuserlog-autocreate-entry',