Added new "byemail" action to the new users log
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
This commit is contained in:
parent
05902444ef
commit
b65893755f
7 changed files with 32 additions and 30 deletions
|
|
@ -359,6 +359,7 @@ if ( $wgNewUserLog ) {
|
|||
$wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
|
||||
$wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
|
||||
$wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
|
||||
$wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
|
||||
$wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4242,14 +4242,8 @@ class User {
|
|||
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';
|
||||
|
|
@ -4258,35 +4252,38 @@ class User {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ class LogFormatter {
|
|||
->inContentLanguage()->escaped();
|
||||
break;
|
||||
case 'create2':
|
||||
case 'byemail':
|
||||
$text = wfMessage( 'newuserlog-create2-entry' )
|
||||
->rawParams( $target )->inContentLanguage()->escaped();
|
||||
break;
|
||||
|
|
@ -1085,7 +1086,8 @@ class PatrolLogFormatter extends LogFormatter {
|
|||
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 {
|
||||
|
|
@ -1108,7 +1110,8 @@ class NewUsersLogFormatter extends LogFormatter {
|
|||
}
|
||||
|
||||
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() ) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4886,8 +4886,8 @@ This site is experiencing technical difficulties.',
|
|||
'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',
|
||||
|
|
|
|||
|
|
@ -8526,7 +8526,10 @@ Parameter $4, the target page, is also not visible to parser functions.',
|
|||
$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.',
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ $wgIgnoredMessages = array(
|
|||
'1movedto2',
|
||||
'1movedto2_redir',
|
||||
'move-redirect-suppressed',
|
||||
// 'newuserlog-byemail',
|
||||
'newuserlog-create-entry',
|
||||
'newuserlog-create2-entry',
|
||||
'newuserlog-autocreate-entry',
|
||||
|
|
|
|||
|
|
@ -3735,8 +3735,8 @@ $wgMessageStructure = array(
|
|||
'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',
|
||||
|
|
@ -3761,7 +3761,6 @@ $wgMessageStructure = array(
|
|||
'1movedto2',
|
||||
'1movedto2_redir',
|
||||
'move-redirect-suppressed',
|
||||
// 'newuserlog-byemail',
|
||||
'newuserlog-create-entry',
|
||||
'newuserlog-create2-entry',
|
||||
'newuserlog-autocreate-entry',
|
||||
|
|
|
|||
Loading…
Reference in a new issue