r30116 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30115‎ | r30116 | r30117 >
Date:12:54, 24 January 2008
Author:raymond
Status:old
Tags:
Comment:
* Move special case from core to the Newuserlog extension itself.
Modified paths:
  • /trunk/extensions/Newuserlog/Newuserlog.php (modified) (history)
  • /trunk/phase3/includes/SpecialLog.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialLog.php
@@ -394,17 +394,6 @@
395395 // show change protection link
396396 } elseif ( ( $s->log_action == 'protect' || $s->log_action == 'modify' ) && $wgUser->isAllowed( 'protect' ) ) {
397397 $revert = '(' . $skin->makeKnownLinkObj( $title, wfMsg( 'protect_change' ), 'action=unprotect' ) . ')';
398 - // show user tool links for self created users
399 - // @todo The extension should be handling this, get it out of core! E.g. Use the hook below.
400 - } elseif ( $s->log_action == 'create2' ) {
401 - if( isset( $paramArray[0] ) ) {
402 - $revert = $this->skin->userToolLinks( $paramArray[0], $s->log_title, true );
403 - } else {
404 - # Fall back to a blue contributions link
405 - $revert = $this->skin->userToolLinks( 1, $s->log_title );
406 - }
407 - # Suppress $comment from old entries, not needed and can contain incorrect links
408 - $comment = '';
409398 // Show unmerge link
410399 } elseif ( $s->log_action == 'merge' ) {
411400 $merge = SpecialPage::getTitleFor( 'Mergehistory' );
Index: trunk/extensions/Newuserlog/Newuserlog.php
@@ -13,7 +13,7 @@
1414
1515 $wgExtensionCredits['other'][] = array(
1616 'name' => 'Newuserlog',
17 - 'version' => '2008-01-09',
 17+ 'version' => '2008-01-24',
1818 'description' => 'adds a [[Special:Log/newusers|log of account creations]] to [[Special:Log]]',
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:Newuserlog',
2020 'author' => 'Ævar Arnfjörð Bjarmason'
@@ -35,6 +35,8 @@
3636 # Run this hook on new account creation
3737 global $wgHooks;
3838 $wgHooks['AddNewAccount'][] = 'wfNewuserlogHook';
 39+ # Run this hook on Special:Log
 40+ $wgHooks['LogLine'][] = 'wfNewuserlogLogLine';
3941 }
4042
4143 function wfNewuserlogHook( $user = null ) {
@@ -73,3 +75,29 @@
7476
7577 return true;
7678 }
 79+
 80+/**
 81+ * Create user tool links for self created users
 82+ * @param string $log_type
 83+ * @param string $log_action
 84+ * @param object $title
 85+ * @param array $paramArray
 86+ * @param string $comment
 87+ * @param string $revert user tool links
 88+ * @return bool true
 89+ */
 90+function wfNewuserlogLogLine( $log_type = '', $log_action = '', $title = null, $paramArray = array(), &$comment = '', &$revert = '' ) {
 91+ if ( $log_action == 'create2' ) {
 92+ global $wgUser;
 93+ $skin = $wgUser->getSkin();
 94+ if( isset( $paramArray[0] ) ) {
 95+ $revert = $skin->userToolLinks( $paramArray[0], $title->getDBkey(), true );
 96+ } else {
 97+ # Fall back to a blue contributions link
 98+ $revert = $skin->userToolLinks( 1, $title->getDBkey() );
 99+ }
 100+ # Suppress $comment from old entries, not needed and can contain incorrect links
 101+ $comment = '';
 102+ }
 103+ return true;
 104+}

Status & tagging log