Index: trunk/phase3/includes/User.php |
— | — | @@ -3194,4 +3194,41 @@ |
3195 | 3195 | return self::oldCrypt( $password, $userId ) === $hash; |
3196 | 3196 | } |
3197 | 3197 | } |
| 3198 | + |
| 3199 | + /** |
| 3200 | + * Add a newuser log entry for this user |
| 3201 | + * @param bool $byEmail, account made by email? |
| 3202 | + */ |
| 3203 | + public function addNewUserLogEntry( $byEmail = false ) { |
| 3204 | + global $wgUser, $wgContLang, $wgNewUserLog; |
| 3205 | + if( empty($wgNewUserLog) ) { |
| 3206 | + return true; // disabled |
| 3207 | + } |
| 3208 | + $talk = $wgContLang->getFormattedNsText( NS_TALK ); |
| 3209 | + if( $this->getName() == $wgUser->getName() ) { |
| 3210 | + $action = 'create'; |
| 3211 | + $message = ''; |
| 3212 | + } else { |
| 3213 | + $action = 'create2'; |
| 3214 | + $message = $byEmail ? wfMsgForContent( 'newuserlog-byemail' ) : ''; |
| 3215 | + } |
| 3216 | + $log = new LogPage( 'newusers' ); |
| 3217 | + $log->addEntry( $action, $this->getUserPage(), $message, array( $this->getId() ) ); |
| 3218 | + return true; |
| 3219 | + } |
| 3220 | + |
| 3221 | + /** |
| 3222 | + * Add an autocreate newuser log entry for this user |
| 3223 | + * Used by things like CentralAuth and perhaps other authplugins. |
| 3224 | + */ |
| 3225 | + public static function addNewUserLogEntryAutoCreate() { |
| 3226 | + global $wgNewUserLog; |
| 3227 | + if( empty($wgNewUserLog) ) { |
| 3228 | + return true; // disabled |
| 3229 | + } |
| 3230 | + $log = new LogPage( 'newusers', false ); |
| 3231 | + $log->addEntry( 'autocreate', $this->getUserPage(), '', array( $this->getId() ) ); |
| 3232 | + return true; |
| 3233 | + } |
| 3234 | + |
3198 | 3235 | } |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -315,6 +315,16 @@ |
316 | 316 | wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) ); |
317 | 317 | wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) ); |
318 | 318 | |
| 319 | +if( !empty($wgNewUserLog) ) { |
| 320 | + # Add a new log type |
| 321 | + $wgLogTypes[] = 'newusers'; |
| 322 | + $wgLogNames['newusers'] = 'newuserlogpage'; |
| 323 | + $wgLogHeaders['newusers'] = 'newuserlogpagetext'; |
| 324 | + $wgLogActions['newusers/newusers'] = 'newuserlogentry'; // For compatibility with older log entries |
| 325 | + $wgLogActions['newusers/create'] = 'newuserlog-create-entry'; |
| 326 | + $wgLogActions['newusers/create2'] = 'newuserlog-create2-entry'; |
| 327 | + $wgLogActions['newusers/autocreate'] = 'newuserlog-autocreate-entry'; |
| 328 | +} |
319 | 329 | |
320 | 330 | wfDebug( "Fully initialised\n" ); |
321 | 331 | $wgFullyInitialised = true; |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -279,10 +279,22 @@ |
280 | 280 | $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'], |
281 | 281 | 'target=' . $title->getPrefixedUrl() . $logParams ) . ')'; |
282 | 282 | } |
| 283 | + // Self-created users |
| 284 | + } else if( self::typeAction($row,'newusers','create2') ) { |
| 285 | + if( isset( $paramArray[0] ) ) { |
| 286 | + $revert = $this->skin->userToolLinks( $paramArray[0], $title->getDBkey(), true ); |
| 287 | + } else { |
| 288 | + # Fall back to a blue contributions link |
| 289 | + $revert = $this->skin->userToolLinks( 1, $title->getDBkey() ); |
| 290 | + } |
| 291 | + if( $time < '20080129000000' ) { |
| 292 | + # Suppress $comment from old entries (before 2008-01-29), not needed and can contain incorrect links |
| 293 | + $comment = ''; |
| 294 | + } |
| 295 | + // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters. |
283 | 296 | } else { |
284 | 297 | wfRunHooks( 'LogLine', array( $row->log_type, $row->log_action, $title, $paramArray, |
285 | 298 | &$comment, &$revert, $row->log_timestamp ) ); |
286 | | - // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters. |
287 | 299 | } |
288 | 300 | // Event description |
289 | 301 | if( self::isDeleted($row,LogPage::DELETED_ACTION) ) { |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2748,6 +2748,11 @@ |
2749 | 2749 | $wgLogActionsHandlers = array(); |
2750 | 2750 | |
2751 | 2751 | /** |
| 2752 | + * Maintain a log of newusers at Log/newusers? |
| 2753 | + */ |
| 2754 | +$wgNewUserLog = true; |
| 2755 | + |
| 2756 | +/** |
2752 | 2757 | * List of special pages, followed by what subtitle they should go under |
2753 | 2758 | * at Special:SpecialPages |
2754 | 2759 | */ |
Index: trunk/phase3/includes/specials/SpecialUserlogin.php |
— | — | @@ -129,6 +129,7 @@ |
130 | 130 | $result = $this->mailPasswordInternal( $u, false, 'createaccount-title', 'createaccount-text' ); |
131 | 131 | |
132 | 132 | wfRunHooks( 'AddNewAccount', array( $u, true ) ); |
| 133 | + $u->addNewUserLogEntry(); |
133 | 134 | |
134 | 135 | $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) ); |
135 | 136 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
— | — | @@ -182,6 +183,7 @@ |
183 | 184 | $wgUser = $u; |
184 | 185 | $wgUser->setCookies(); |
185 | 186 | wfRunHooks( 'AddNewAccount', array( $wgUser ) ); |
| 187 | + $wgUser->addNewUserLogEntry(); |
186 | 188 | if( $this->hasSessionCookie() ) { |
187 | 189 | return $this->successfulCreation(); |
188 | 190 | } else { |
— | — | @@ -197,6 +199,7 @@ |
198 | 200 | $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) ); |
199 | 201 | $wgOut->returnToMain( false, $self ); |
200 | 202 | wfRunHooks( 'AddNewAccount', array( $u ) ); |
| 203 | + $u->addNewUserLogEntry(); |
201 | 204 | return true; |
202 | 205 | } |
203 | 206 | } |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2107,6 +2107,16 @@ |
2108 | 2108 | 'listusers-submit' => 'Show', |
2109 | 2109 | 'listusers-noresult' => 'No user found.', |
2110 | 2110 | |
| 2111 | +# New user log |
| 2112 | +'newuserlogpage' => 'User creation log', |
| 2113 | +'newuserlogpagetext' => 'This is a log of user creations.', |
| 2114 | +'newuserlog-desc' => 'Adds a [[Special:Log/newusers|log of account creations]]', |
| 2115 | +'newuserlogentry' => '', # For compatibility, do not translate this |
| 2116 | +'newuserlog-byemail' => 'password sent by e-mail', |
| 2117 | +'newuserlog-create-entry' => 'New user', |
| 2118 | +'newuserlog-create2-entry' => 'created account for $1', |
| 2119 | +'newuserlog-autocreate-entry' => 'Account created automatically', |
| 2120 | + |
2111 | 2121 | # Special:ListGroupRights |
2112 | 2122 | 'listgrouprights' => 'User group rights', |
2113 | 2123 | 'listgrouprights-summary' => 'The following is a list of user groups defined on this wiki, with their associated access rights. |
Index: trunk/extensions/Newuserlog/Newuserlog.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if( !defined('MEDIAWIKI') ) die(); |
4 | 4 | /** |
5 | 5 | * Add a new log to Special:Log that displays account creations in reverse |
6 | 6 | * chronological order using the AddNewAccount hook |
— | — | @@ -21,22 +21,26 @@ |
22 | 22 | 'author' => 'Ævar Arnfjörð Bjarmason' |
23 | 23 | ); |
24 | 24 | |
25 | | -$wgExtensionMessagesFiles['Newuserlog'] = dirname(__FILE__) . '/Newuserlog.i18n.php'; |
| 25 | +if( isset($wgNewUserLog) ) { |
| 26 | + echo( "You must remove the newuserlog extension, as it is now in the core software!\n" ); |
| 27 | +} else { |
| 28 | + # Run this hook on new account creation |
| 29 | + $wgHooks['AddNewAccount'][] = 'wfNewuserlogHook'; |
| 30 | + $wgHooks['AuthPluginAutoCreate'][] = 'wfNewuserlogAutoCreate'; |
| 31 | + # Run this hook on Special:Log |
| 32 | + $wgHooks['LogLine'][] = 'wfNewuserlogLogLine'; |
| 33 | + # Set message file |
| 34 | + $wgExtensionMessagesFiles['Newuserlog'] = dirname(__FILE__) . '/Newuserlog.i18n.php'; |
| 35 | + # Add a new log type |
| 36 | + $wgLogTypes[] = 'newusers'; |
| 37 | + $wgLogNames['newusers'] = 'newuserlogpage'; |
| 38 | + $wgLogHeaders['newusers'] = 'newuserlogpagetext'; |
| 39 | + $wgLogActions['newusers/newusers'] = 'newuserlogentry'; // For compatibility with older log entries |
| 40 | + $wgLogActions['newusers/create'] = 'newuserlog-create-entry'; |
| 41 | + $wgLogActions['newusers/create2'] = 'newuserlog-create2-entry'; |
| 42 | + $wgLogActions['newusers/autocreate'] = 'newuserlog-autocreate-entry'; |
| 43 | +} |
26 | 44 | |
27 | | -# Add a new log type |
28 | | -$wgLogTypes[] = 'newusers'; |
29 | | -$wgLogNames['newusers'] = 'newuserlogpage'; |
30 | | -$wgLogHeaders['newusers'] = 'newuserlogpagetext'; |
31 | | -$wgLogActions['newusers/newusers'] = 'newuserlogentry'; // For compatibility with older log entries |
32 | | -$wgLogActions['newusers/create'] = 'newuserlog-create-entry'; |
33 | | -$wgLogActions['newusers/create2'] = 'newuserlog-create2-entry'; |
34 | | -$wgLogActions['newusers/autocreate'] = 'newuserlog-autocreate-entry'; |
35 | | -# Run this hook on new account creation |
36 | | -$wgHooks['AddNewAccount'][] = 'wfNewuserlogHook'; |
37 | | -$wgHooks['AuthPluginAutoCreate'][] = 'wfNewuserlogAutoCreate'; |
38 | | -# Run this hook on Special:Log |
39 | | -$wgHooks['LogLine'][] = 'wfNewuserlogLogLine'; |
40 | | - |
41 | 45 | function wfNewuserlogHook( $user = null, $byEmail = false ) { |
42 | 46 | global $wgUser, $wgContLang; |
43 | 47 | |
— | — | @@ -80,7 +84,9 @@ |
81 | 85 | * @param string $time timestamp of the log entry |
82 | 86 | * @return bool true |
83 | 87 | */ |
84 | | -function wfNewuserlogLogLine( $log_type = '', $log_action = '', $title = null, $paramArray = array(), &$comment = '', &$revert = '', $time = '' ) { |
| 88 | +function wfNewuserlogLogLine( $log_type = '', $log_action = '', $title = null, $paramArray = array(), |
| 89 | + &$comment = '', &$revert = '', $time = '' ) |
| 90 | +{ |
85 | 91 | if ( $log_action == 'create2' ) { |
86 | 92 | global $wgUser; |
87 | 93 | $skin = $wgUser->getSkin(); |
Index: trunk/extensions/CentralAuth/CentralAuthHooks.php |
— | — | @@ -393,6 +393,7 @@ |
394 | 394 | |
395 | 395 | # Notify hooks (e.g. Newuserlog) |
396 | 396 | wfRunHooks( 'AuthPluginAutoCreate', array( $user ) ); |
| 397 | + $user->addNewUserLogEntryAutoCreate(); |
397 | 398 | return true; |
398 | 399 | } |
399 | 400 | |
Index: trunk/extensions/ConfirmAccount/ConfirmAccount_body.php |
— | — | @@ -558,6 +558,7 @@ |
559 | 559 | |
560 | 560 | # Safe to hook/log now... |
561 | 561 | wfRunHooks( 'AddNewAccount', array( $user ) ); |
| 562 | + $user->addNewUserLogEntry(); |
562 | 563 | # OK, now remove the request from the queue |
563 | 564 | $dbw->delete( 'account_requests', array('acr_id' => $this->acrID), __METHOD__ ); |
564 | 565 | # Clear cache for notice of how many account requests there are |