r13682 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13681‎ | r13682 | r13683 >
Date:04:08, 17 April 2006
Author:brion
Status:old
Tags:
Comment:
Fix up new log entries to:
* record the user as the target in the logging table
* allow part of the text to be localized on view
* distinguish self-registrations from admin 'by mail' registrations
Added log actions: newusers/create, newusers/create2
Added messages: newuserlog-create-entry, newuserlog-create-text, newuserlog-create2-entry
Modified paths:
  • /trunk/extensions/Newuserlog/Newuserlog.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Newuserlog/Newuserlog.php
@@ -26,8 +26,18 @@
2727 array(
2828 'newuserlogpage' => 'User creation log',
2929 'newuserlogpagetext' => 'This is a log of recent user creations',
 30+
 31+ // Compatibility entries.
 32+ // Old code stored Special:Userlogin as the target, not very helpful.
3033 'newuserlogentry' => '',
31 - 'newuserloglog' => "New user ([[User talk:$1|$2]] | [[Special:Contributions/$1|$3]] | [[Special:Blockip/$1|$4]])"
 34+ 'newuserloglog' => "New user ([[User talk:$1|$2]] | [[Special:Contributions/$1|$3]] | [[Special:Blockip/$1|$4]])",
 35+
 36+ // Self-login
 37+ 'newuserlog-create-entry' => 'New user',
 38+ 'newuserlog-create-text' => "[[User talk:$1|$2]] | [[Special:Contributions/$1|$3]] | [[Special:Blockip/$1|$4]]",
 39+
 40+ // Created account for someone else with 'by mail' button
 41+ 'newuserlog-create2-entry' => 'created account for $1',
3242 )
3343 );
3444
@@ -41,15 +51,28 @@
4252 $wgHooks['AddNewAccount'][] = 'wfNewuserlogHook';
4353 }
4454
45 -function wfNewuserlogHook() {
46 - global $wgUser, $wgTitle, $wgContLang;
47 -
 55+function wfNewuserlogHook( $user ) {
 56+ global $wgUser, $wgContLang;
 57+
 58+ if( is_null( $user ) ) {
 59+ // Compatibility with old versions which didn't pass the parameter
 60+ $user = $wgUser;
 61+ }
 62+
4863 $talk = $wgContLang->getFormattedNsText( NS_TALK );
4964 $contribs = wfMsgForContent( 'contribslink' );
5065 $block = wfMsgForContent( 'blocklink' );
 66+ $message = wfMsgForContent( 'newuserlog-create-text',
 67+ $user->getName(), $talk, $contribs, $block );
5168
 69+ if( $user->getName() == $wgUser->getName() ) {
 70+ $action = 'create';
 71+ } else {
 72+ $action = 'create2';
 73+ }
 74+
5275 $log = new LogPage( 'newusers' );
53 - $log->addEntry( 'newusers', $wgTitle, wfMsgForContent( 'newuserloglog', $wgUser->getName(), $talk, $contribs, $block ) );
 76+ $log->addEntry( $action, $user->getUserPage(), $message );
5477
5578 return true;
5679 }
@@ -72,6 +95,8 @@
7396
7497 function wfNewuserlogAddActionText( &$actions ) {
7598 $actions['newusers/newusers'] = 'newuserlogentry';
 99+ $actions['newusers/create'] = 'newuserlog-create-entry';
 100+ $actions['newusers/create2'] = 'newuserlog-create2-entry';
76101 return true;
77102 }
78103 ?>

Status & tagging log