r39294 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39293‎ | r39294 | r39295 >
Date:16:20, 13 August 2008
Author:tstarling
Status:old
Tags:
Comment:
* Refactored r39262
* Fixed spelling
Modified paths:
  • /trunk/extensions/NewUserMessage/NewUserMessage.class.php (modified) (history)
  • /trunk/extensions/NewUserMessage/NewUserMessage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NewUserMessage/NewUserMessage.php
@@ -14,7 +14,7 @@
1515
1616 define('NEWUSERMESSAGE_VERSION','2.0, 2008-06-04');
1717
18 -$wgNewUserSupressRC = false; // Specify whether or not the new user message creation should show up in recent changes
 18+$wgNewUserSuppressRC = false; // Specify whether or not the new user message creation should show up in recent changes
1919 $wgNewUserMinorEdit = true; // Should the new user message creation be a minor edit?
2020 $wgNewUserMessageOnAutoCreate = false; // Should auto creation (CentralAuth) trigger a new user message?
2121
Index: trunk/extensions/NewUserMessage/NewUserMessage.class.php
@@ -21,7 +21,7 @@
2222 $talk = $user->getTalkPage();
2323
2424 if (!$talk->exists()) {
25 - global $wgUser, $wgNewUserMinorEdit, $wgNewUserSupressRC;
 25+ global $wgUser, $wgNewUserMinorEdit, $wgNewUserSuppressRC;
2626
2727 wfLoadExtensionMessages( 'NewUserMessage' );
2828
@@ -48,25 +48,25 @@
4949 $templateTitleText = $templateTitle->getText();
5050 }
5151 if ($wgNewUserMinorEdit) $flags = $flags | EDIT_MINOR;
52 - if ($wgNewUserSupressRC) $flags = $flags | EDIT_SUPPRESS_RC;
 52+ if ($wgNewUserSuppressRC) $flags = $flags | EDIT_SUPPRESS_RC;
5353
5454 $dbw = wfGetDB( DB_MASTER );
5555 $dbw->begin();
5656 $good = true;
57 -
58 - $signatures = wfMsgForContent('newusermessage-signatures');
59 - if (!wfEmptyMsg('newusermessage-signatures', $signatures)) {
 57+
 58+ $text = "{{{$templateTitleText}|$name}}";
 59+ $signatures = wfMsgForContent( 'newusermessage-signatures' );
 60+ if ( !wfEmptyMsg( 'newusermessage-signatures', $signatures ) ) {
6061 $pattern = '/^\* ?(.*?)$/m';
61 - preg_match_all($pattern, $signatures, $signaturesList, PREG_SET_ORDER);
62 - $rand = rand(0, count($signaturesList)-1);
63 - $signature = $signaturesList[$rand][1];
 62+ preg_match_all( $pattern, $signatures, $signatureList, PREG_SET_ORDER );
 63+ if ( count( $signatureList ) > 0 ) {
 64+ $rand = rand( 0, count( $signatureList ) - 1 );
 65+ $signature = $signatureList[$rand][1];
 66+ $text .= "\n-- {$signature} ~~~~~";
 67+ }
6468 }
6569 try {
66 - if (!wfEmptyMsg('newusermessage-signatures', $signatures)) {
67 - $article->doEdit("{{{$templateTitleText}|$name}}\n--" . $signature . "~~~~~" , wfMsgForContent( 'newuseredit-summary' ), $flags);
68 - } else {
69 - $article->doEdit("{{{$templateTitleText}|$name}}", wfMsgForContent( 'newuseredit-summary' ), $flags);
70 - }
 70+ $article->doEdit( $text, wfMsgForContent( 'newuseredit-summary' ), $flags );
7171 } catch ( DBQueryError $e ) {
7272 $good = false;
7373 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r39262Add optional feature. now if mediawiki:newusermessage-signs exists and contai...alnokta01:23, 13 August 2008

Status & tagging log