r38759 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38758‎ | r38759 | r38760 >
Date:09:42, 7 August 2008
Author:siebrand
Status:old
Tags:
Comment:
Updates adressing requirements of Tim Starling in bug 14311#c2.
* All the text ($wgNewUserMessageTemplate, $wgNewUserMessageEditor and
$wgNewUserEditSummary) can be customised with messages, not configuration
* The default editing user is reserved. A configured non-existing user falls back to the reserved user.
* Bump version, add myself to extension authors for NewUserMessage
* ignore 2 messages in Translate
Modified paths:
  • /trunk/extensions/NewUserMessage/NewUserMessage.class.php (modified) (history)
  • /trunk/extensions/NewUserMessage/NewUserMessage.i18n.php (modified) (history)
  • /trunk/extensions/NewUserMessage/NewUserMessage.php (modified) (history)
  • /trunk/extensions/Translate/groups/mediawiki-defines.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/NewUserMessage/NewUserMessage.i18n.php
@@ -12,6 +12,11 @@
1313 */
1414 $messages['en'] = array(
1515 'newusermessage-desc' => "Adds a [[MediaWiki:NewUserMessage|message]] to newly created user's talk pages",
 16+ 'newuseredit-summary' => 'Adding [[{{MediaWiki:Newusermessage-template}}|welcome message]] to new user\'s talk page',
 17+
 18+ // Configuration (should not be translated)
 19+ 'newusermessage-template' => 'MediaWiki:NewUserMessage', # do not translate this message to other languages
 20+ 'newusermessage-editor' => 'MediaWiki default', # do not translate this message to other languages
1621 );
1722
1823 /** Afrikaans (Afrikaans)
Index: trunk/extensions/NewUserMessage/NewUserMessage.php
@@ -12,24 +12,11 @@
1313 if (!defined('MEDIAWIKI'))
1414 die('Not an entry point.');
1515
16 -define('NEWUSERMESSAGE_VERSION','1.2.1, 2008-06-04');
 16+define('NEWUSERMESSAGE_VERSION','2.0, 2008-06-04');
1717
18 -// Specify a template to wrap the new user message within
19 -$wgNewUserMessageTemplate = 'MediaWiki:NewUserMessage';
 18+$wgNewUserSupressRC = false; // Specify whether or not the new user message creation should show up in recent changes
 19+$wgNewUserMinorEdit = true; // Should the new user message creation be a minor edit?
2020
21 -// Set the username of the user that makes the edit on user talk pages. If
22 -// this user does not exist, the new user will show up as editing user.
23 -$wgNewUserMessageEditor = 'Admin';
24 -
25 -// Edit summary for the recent changes entry of a new users message
26 -$wgNewUserEditSummary = "Adding [[$wgNewUserMessageTemplate|welcome message]] to new user's talk page";
27 -
28 -// Specify whether or not the new user message creation should show up in recent changes
29 -$wgNewUserSupressRC = false;
30 -
31 -// Should the new user message creation be a minor edit?
32 -$wgNewUserMinorEdit = true;
33 -
3421 $dir = dirname(__FILE__) . '/';
3522 $wgExtensionMessagesFiles['NewUserMessage'] = $dir . 'NewUserMessage.i18n.php';
3623 $wgAutoloadClasses['NewUserMessage'] = $dir . 'NewUserMessage.class.php';
@@ -39,7 +26,7 @@
4027 $wgExtensionCredits['other'][] = array(
4128 'name' => 'NewUserMessage',
4229 'version' => NEWUSERMESSAGE_VERSION,
43 - 'author' => "[http://www.organicdesign.co.nz/User:Nad Nad]",
 30+ 'author' => array( "[http://www.organicdesign.co.nz/User:Nad Nad]", 'Siebrand Mazeland' ),
4431 'description' => "Add a [[MediaWiki:NewUserMessage|message]] to newly created user's talk pages",
4532 'descriptionmsg' => 'newusermessage-desc',
4633 'url' => 'http://www.mediawiki.org/wiki/Extension:NewUserMessage',
Index: trunk/extensions/NewUserMessage/NewUserMessage.class.php
@@ -21,26 +21,31 @@
2222 $talk = $user->getTalkPage();
2323
2424 if (!$talk->exists()) {
25 - global $wgUser, $wgNewUserMessageEditor, $wgNewUserMessageTemplate,
26 - $wgNewUserMinorEdit, $wgNewUserSupressRC, $wgNewUserEditSummary;
 25+ global $wgUser, $wgNewUserMinorEdit, $wgNewUserSupressRC;
2726
 27+ wfLoadExtensionMessages( 'NewUserMessage' );
 28+
2829 $article = new Article($talk);
2930
3031 // Need to make the edit on the user talk page in another
3132 // user's context. Park the current user object and create
32 - // a user object for $wgNewUserMessageEditor. If that user
33 - // does not exist, make the edit as the new user anyway.
 33+ // a user object for $editingUser. If that user does not
 34+ // exist, make the edit as reserved user
 35+ // "MediaWiki default".
3436 $parkedWgUser = $wgUser;
35 - $wgUser = User::newFromName( $wgNewUserMessageEditor );
36 - if ( !$wgUser->idForName() ) {
37 - $wgUser = $parkedWgUser;
 37+ $editingUser = wfMsg( 'newusermessage-editor' );
 38+ if( User::idFromName( $editingUser ) ) {
 39+ $wgUser = User::newFromName( $editingUser );
3840 }
 41+ else
 42+ $wgUser = User::newFromName( "MediaWiki default" );
3943
4044 $flags = 0;
 45+ $messageTemplate = wfMsg( 'newusermessage-template' );
4146 if ($wgNewUserMinorEdit) $flags = $flags | EDIT_MINOR;
4247 if ($wgNewUserSupressRC) $flags = $flags | EDIT_SUPPRESS_RC;
4348
44 - $article->doEdit('{'.'{'."$wgNewUserMessageTemplate|$name}}", $wgNewUserEditSummary, $flags);
 49+ $article->doEdit('{'.'{'."$messageTemplate|$name}}", wfMsg( 'newuseredit-summary' ), $flags);
4550 $wgUser = $parkedWgUser;
4651 }
4752 return true;
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt
@@ -422,6 +422,7 @@
423423 ignored = newuserlogentry
424424
425425 New User Message
 426+ignored = newusermessage-template, newusermessage-editor
426427
427428 New User Notification
428429 file = NewUserNotif/NewUserNotif.i18n.php

Status & tagging log