Added new "byemail" action to the new users log
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Tue, 22 Jan 2013 20:03:44 +0000 (21:03 +0100)
committerSiebrand Mazeland <s.mazeland@xs4all.nl>
Fri, 25 Jan 2013 15:15:33 +0000 (16:15 +0100)
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

includes/Setup.php
includes/User.php
includes/logging/LogFormatter.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messageTypes.inc
maintenance/language/messages.inc

index f6c8245..2bf2507 100644 (file)
@@ -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';
 }
 
index dbe9a64..ce47110 100644 (file)
@@ -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;
        }
 
index 4f699f1..ce5b053 100644 (file)
@@ -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() ) );
                }
index 80593ea..31c8669 100644 (file)
@@ -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',
index 02af790..425043e 100644 (file)
@@ -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.',
index 87bc1c2..3b2292f 100644 (file)
@@ -214,7 +214,6 @@ $wgIgnoredMessages = array(
        '1movedto2',
        '1movedto2_redir',
        'move-redirect-suppressed',
-       // 'newuserlog-byemail',
        'newuserlog-create-entry',
        'newuserlog-create2-entry',
        'newuserlog-autocreate-entry',
index aa6b858..1ab22e2 100644 (file)
@@ -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',