Index: trunk/extensions/NewUserMessage/NewUserMessage.php |
— | — | @@ -12,70 +12,35 @@ |
13 | 13 | if (!defined('MEDIAWIKI')) |
14 | 14 | die('Not an entry point.'); |
15 | 15 | |
16 | | -define('NEWUSERMESSAGE_VERSION','1.1.2, 2008-05-13'); |
| 16 | +define('NEWUSERMESSAGE_VERSION','1.2, 2008-06-04'); |
17 | 17 | |
18 | 18 | // Specify a template to wrap the new user message within |
19 | 19 | $wgNewUserMessageTemplate = 'MediaWiki:NewUserMessage'; |
20 | 20 | |
| 21 | +// Should the new user message creation be a minor edit? |
| 22 | +$wgNewUserMinorEdit = true; |
| 23 | + |
21 | 24 | // Set the username of the user that makes the edit on user talk pages. If |
22 | 25 | // this user does not exist, the new user will show up as editing user. |
23 | | -$wgNewUserMessageEditor = 'Admin'; |
| 26 | +// default: $wgNewUserMessageEditor = 'Admin'; |
24 | 27 | |
25 | 28 | // Edit summary for the recent changes entry of a new users message |
26 | | -$wgNewUserEditSummary = "Adding [[$wgNewUserMessageTemplate|welcome message]] to new user's talk page"; |
| 29 | +// default: $wgNewUserEditSummary = "Adding [[$wgNewUserMessageTemplate|welcome message]] to new user's talk page"; |
27 | 30 | |
28 | 31 | // Specify whether or not the new user message creation should show up in recent changes |
29 | | -$wgNewUserSupressRC = false; |
| 32 | +// default: $wgNewUserSupressRC = false; |
30 | 33 | |
31 | | -// Should the new user message creation be a minor edit? |
32 | | -$wgNewUserMinorEdit = true; |
| 34 | +$dir = dirname(__FILE__) . '/'; |
| 35 | +$wgExtensionMessagesFiles['NewUserMessage'] = $dir . 'NewUserMessage.i18n.php'; |
| 36 | +$wgAutoloadClasses['NewUserMessage'] = $dir . 'NewUserMessage.class.php'; |
33 | 37 | |
| 38 | +$wgHooks['AddNewAccount'][] = 'NewUserMessage::createNewUserMessage'; |
34 | 39 | |
35 | | - |
36 | | -$wgExtensionMessagesFiles['NewUserMessage'] = dirname(__FILE__) . '/NewUserMessage.i18n.php'; |
37 | | -$wgHooks['AddNewAccount'][] = 'wfCreateNewUserMessage'; |
38 | | - |
39 | 40 | $wgExtensionCredits['other'][] = array( |
40 | 41 | 'name' => 'NewUserMessage', |
41 | 42 | 'version' => NEWUSERMESSAGE_VERSION, |
42 | 43 | 'author' => "[http://www.organicdesign.co.nz/User:Nad Nad]", |
43 | | - 'description' => "Add a [[$wgNewUserMessageTemplate|message]] to newly created user's talk pages", |
| 44 | + 'description' => "Add a [[MediaWiki:NewUserMessage|message]] to newly created user's talk pages", |
44 | 45 | 'descriptionmsg' => 'newusermessage-desc', |
45 | 46 | 'url' => 'http://www.mediawiki.org/wiki/Extension:NewUserMessage', |
46 | 47 | ); |
47 | | - |
48 | | -/* |
49 | | - * Add the template message if the users talk page doesn't already exist |
50 | | - */ |
51 | | -function wfCreateNewUserMessage($user) { |
52 | | - global $wgNewUserMessageTemplate, $wgNewUserMinorEdit, $wgNewUserSupressRC, $wgNewUserEditSummary; |
53 | | - |
54 | | - $name = $user->getName(); |
55 | | - $talk = $user->getTalkPage(); |
56 | | - |
57 | | - if (!$talk->exists()) { |
58 | | - global $wgUser, $wgNewUserMessageEditor; |
59 | | - |
60 | | - $article = new Article($talk); |
61 | | - |
62 | | - // Need to make the edit on the user talk page in another |
63 | | - // user's context. Park the current user object and create |
64 | | - // a user object for $wgNewUserMessageEditor. If that user |
65 | | - // does not exist, make the edit with as the new user |
66 | | - // anyway. |
67 | | - $parkedWgUser = $wgUser; |
68 | | - $wgUser = User::newFromName( $wgNewUserMessageEditor ); |
69 | | - if ( !$wgUser->idForName() ) { |
70 | | - $wgUser = $parkedWgUser; |
71 | | - } |
72 | | - |
73 | | - $flags = 0; |
74 | | - if ($wgNewUserMinorEdit) $flags = $flags | EDIT_MINOR; |
75 | | - if ($wgNewUserSupressRC) $flags = $flags | EDIT_SUPPRESS_RC; |
76 | | - |
77 | | - $article->doEdit('{'.'{'."$wgNewUserMessageTemplate|$name}}", $wgNewUserEditSummary, $flags); |
78 | | - $wgUser = $parkedWgUser; |
79 | | - } |
80 | | - |
81 | | - return true; |
82 | | -} |
Index: trunk/extensions/NewUserMessage/NewUserMessage.class.php |
— | — | @@ -0,0 +1,52 @@ |
| 2 | +<?php |
| 3 | +/** Extension:NewUserMessage |
| 4 | + * |
| 5 | + * @package MediaWiki |
| 6 | + * @subpackage Extensions |
| 7 | + * |
| 8 | + * @author [http://www.organicdesign.co.nz/nad User:Nad] |
| 9 | + * @license LGPL (http://www.gnu.org/copyleft/lesser.html) |
| 10 | + * @copyright 2007-10-15 [http://www.organicdesign.co.nz/nad User:Nad] |
| 11 | + */ |
| 12 | + |
| 13 | +if (!defined('MEDIAWIKI')) |
| 14 | + die('Not an entry point.'); |
| 15 | + |
| 16 | +class NewUserMessage { |
| 17 | + /* |
| 18 | + * Add the template message if the users talk page doesn't already exist |
| 19 | + */ |
| 20 | + static function createNewUserMessage($user) { |
| 21 | + $name = $user->getName(); |
| 22 | + $talk = $user->getTalkPage(); |
| 23 | + |
| 24 | + if (!$talk->exists()) { |
| 25 | + global $wgUser, $wgNewUserMessageEditor, $wgNewUserMessageTemplate, |
| 26 | + $wgNewUserMinorEdit, $wgNewUserSupressRC, $wgNewUserEditSummary; |
| 27 | + |
| 28 | + $article = new Article($talk); |
| 29 | + |
| 30 | + // Need to make the edit on the user talk page in another |
| 31 | + // 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 with as the new user |
| 34 | + // anyway. |
| 35 | + $parkedWgUser = $wgUser; |
| 36 | + $wgUser = User::newFromName( $wgNewUserMessageEditor ); |
| 37 | + if ( !$wgUser->idForName() ) { |
| 38 | + $wgUser = $parkedWgUser; |
| 39 | + } |
| 40 | + |
| 41 | + $flags = 0; |
| 42 | + if ($wgNewUserMinorEdit) $flags = $flags | EDIT_MINOR; |
| 43 | + if ($wgNewUserSupressRC) $flags = $flags | EDIT_SUPPRESS_RC; |
| 44 | + if (!$wgNewUserMessageEditor) $wgNewUserMessageEditor = 'Admin'; |
| 45 | + if (!$wgNewUserMessageTemplate) $wgNewUserMessageTemplate = 'MediaWiki:NewUserMessage'; |
| 46 | + if (!$wgNewUserEditSummary) $wgNewUserEditSummary = "Adding [[$wgNewUserMessageTemplate|welcome message]] to new user's talk page"; |
| 47 | + |
| 48 | + $article->doEdit('{'.'{'."$wgNewUserMessageTemplate|$name}}", $wgNewUserEditSummary, $flags); |
| 49 | + $wgUser = $parkedWgUser; |
| 50 | + } |
| 51 | + return true; |
| 52 | + } |
| 53 | +} |
Property changes on: trunk/extensions/NewUserMessage/NewUserMessage.class.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 54 | + native |