Index: trunk/extensions/NewUserNotif/NewUserNotif.class.php |
— | — | @@ -37,13 +37,13 @@ |
38 | 38 | * Send email to external addresses |
39 | 39 | */ |
40 | 40 | private function sendExternalMails() { |
41 | | - global $wgNewUserNotifEmailTargets, $wgNewUserNotifSenderParam, $wgNewUserNotifSenderSubjParam; |
| 41 | + global $wgNewUserNotifEmailTargets, $wgSitename; |
42 | 42 | foreach( $wgNewUserNotifEmailTargets as $target ) { |
43 | | - UserMailer::send( |
| 43 | + userMailer( |
44 | 44 | new MailAddress( $target ), |
45 | 45 | new MailAddress( $this->sender ), |
46 | | - $this->makeMessage( $target, $this->user, 'newusernotifsubj', $wgNewUserNotifSenderSubjParam), |
47 | | - $this->makeMessage( $target, $this->user, 'newusernotifbody', $wgNewUserNotifSenderParam) |
| 46 | + wfMsgForContent( 'newusernotifsubj', $wgSitename ), |
| 47 | + $this->makeMessage( $target, $this->user ) |
48 | 48 | ); |
49 | 49 | } |
50 | 50 | } |
— | — | @@ -52,13 +52,13 @@ |
53 | 53 | * Send email to users |
54 | 54 | */ |
55 | 55 | private function sendInternalMails() { |
56 | | - global $wgNewUserNotifTargets, $wgNewUserNotifSenderParam, $wgNewUserNotifSenderSubjParam; |
| 56 | + global $wgNewUserNotifTargets, $wgSitename; |
57 | 57 | foreach( $wgNewUserNotifTargets as $userSpec ) { |
58 | 58 | $user = $this->makeUser( $userSpec ); |
59 | 59 | if( $user instanceof User && $user->isEmailConfirmed() ) { |
60 | 60 | $user->sendMail( |
61 | | - $this->makeMessage( $user->getName(), $this->user, 'newusernotifsubj', $wgNewUserNotifSenderSubjParam ), |
62 | | - $this->makeMessage( $user->getName(), $this->user, 'newusernotifbody', $wgNewUserNotifSenderParam ), |
| 61 | + wfMsgForContent( 'newusernotifsubj', $wgSitename ), |
| 62 | + $this->makeMessage( $user->getName(), $this->user ), |
63 | 63 | $this->sender |
64 | 64 | ); |
65 | 65 | } |
— | — | @@ -80,18 +80,22 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | | - * Build a notification email message (body and subject) |
| 84 | + * Build a notification email |
85 | 85 | * |
86 | | - * @param string $recipient Name of the new user notification email recipient |
87 | | - * @param User $user User (object) created for new user |
88 | | - * @param string $msgId Localised Message Identifier |
89 | | - * @param string $parmArr Array of Strings eval'd to pass parameters to message |
90 | | - * @return string |
| 86 | + * @param string $recipient Name of the recipient |
| 87 | + * @param User $user User that was created |
91 | 88 | */ |
92 | | - private function makeMessage( $recipient, $user, $msgId, $parmArr) { |
93 | | - global $wgSitename,$wgContLang; |
94 | | - eval( "\$retval = wfMsgForContent('".$msgId."',".implode(",",$parmArr).");" ); |
95 | | - return ($retval); |
| 89 | + private function makeMessage( $recipient, $user ) { |
| 90 | + global $wgSitename, $wgContLang; |
| 91 | + return wfMsgForContent( |
| 92 | + 'newusernotifbody', |
| 93 | + $recipient, |
| 94 | + $user->getName(), |
| 95 | + $wgSitename, |
| 96 | + $wgContLang->timeAndDate( wfTimestampNow() ), |
| 97 | + $wgContLang->date( wfTimestampNow() ), |
| 98 | + $wgContLang->time( wfTimestampNow() ) |
| 99 | + ); |
96 | 100 | } |
97 | 101 | |
98 | 102 | /** |
Index: trunk/extensions/NewUserNotif/README |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | NEW USER EMAIL NOTIFICATION EXTENSION |
3 | | -(http://www.mediawiki.org/wiki/Extension:New_User_Email_Notification) |
4 | 3 | |
5 | 4 | Version 1.5 |
6 | 5 | © 2006-2007 Rob Church |
— | — | @@ -14,9 +13,8 @@ |
15 | 14 | 2. Installation requirements |
16 | 15 | 3. Installing the extension |
17 | 16 | 4. Editing the notification email |
18 | | - 5. Configuration |
19 | | - 6. Advanced Configuration |
20 | | - 7. Feedback |
| 17 | + 5. Further configuration |
| 18 | + 6. Feedback |
21 | 19 | |
22 | 20 | == 1. Introduction == |
23 | 21 | |
— | — | @@ -53,12 +51,9 @@ |
54 | 52 | $2 is replaced with the username of the new user account; |
55 | 53 | $3 is replaced with the wiki site name from $wgSitename; |
56 | 54 | $4 is replaced with the time and date of the account's creation. |
57 | | - $5 is replaced with the date of the account's creation. |
58 | | - $6 is replaced with the time of the account's creation. |
59 | 55 | |
| 56 | +== 5. Further configuration == |
60 | 57 | |
61 | | -== 5. Configuration == |
62 | | - |
63 | 58 | The behaviour of the extension can be tweaked using three configuration |
64 | 59 | variables. To override the defaults for these, set them in LocalSettings.php |
65 | 60 | underneath the call to the extension file. |
— | — | @@ -78,76 +73,7 @@ |
79 | 74 | $wgNewUserNotifEmailTargets |
80 | 75 | Array containing email addresses to which a notification should also be sent |
81 | 76 | Defaults to no additional addresses |
82 | | - |
83 | | -== 6. Advanced Configuration == |
84 | 77 | |
85 | | -As of version 1.5.2 of this extension, you can customize and add parameters passed to both the subject and body messages in your localsettings.php without modifying the extension code. |
| 78 | +== 6. Feedback == |
86 | 79 | |
87 | | -You can do this by adding (or changing) parameter values and/or functions that return the desired parameter values to the parameter definition arrays underneath the call to the extension file. In both cases you can use references to $this, $user (created user object), $recipient (target), or from globals $wfContLang, $wgSitename. (For advanced techniques and using other globals, see below). |
88 | | - |
89 | | -$wgNewUserNotifSenderSubjParam |
90 | | - The list of evaluated parameters passed to the message subject(MediaWiki:Newusernotifsubj). Default is: |
91 | | - '$wgSitename', // $1 Site Name |
92 | | - |
93 | | -$wgNewUserNotifSenderParam |
94 | | - The list of evaluated parameters passed to the message body(MediaWiki:Newusernotifbody). Defaults are: |
95 | | - '$recipient', // $1 Recipient (of notification message) |
96 | | - '$user->getname()', // $2 User Name |
97 | | - '$wgSitename', // $3 Site Name |
98 | | - '$wgContLang->timeAndDate( wfTimestampNow() )', // $4 Time and date stamp |
99 | | - '$wgContLang->date( wfTimestampNow() )', // $5 Date Stamp |
100 | | - '$wgContLang->time( wfTimestampNow() )', // $6 Time Stamp |
101 | | - |
102 | | -You can then either edit MediaWiki:Newusernotifbody to make use of the new parameters (e.g. add "\n\nThe request came from $7."). |
103 | | - |
104 | | -=== 6.1 Upgrading from 1.5.1 === |
105 | | - |
106 | | -If you did not customize the passed parameters, this extension works exactly as before and no action need to be taken. |
107 | | - |
108 | | -If you added to or changed the default passed parameters, you will need to correspondingly add to or change the corresponding arrays. You should be able to take the exact same code and add to or replace it in the arrays. |
109 | | - |
110 | | -For example, if you added a 7th parameter (in his case, the email address of the new user), you would just add it (in localsettings.php, below the extension reference) like this: |
111 | | - |
112 | | -<source lang="php"> |
113 | | -$wgNewUserNotifSenderParam[] = '$user->getEmail()'; // $7 new user email address |
114 | | -</source> |
115 | | - |
116 | | -The code for the parameter to be passed should be exactly the same (except enclosed in quotes) as it is in your modified wfMsgForContent function call found in private function makeMessage. |
117 | | - |
118 | | -=== 6.2 Examples For Adding Additional Parameters === |
119 | | - |
120 | | -Here are some commonly used additional parameter you could add to further customize your notification message subject and body: |
121 | | -<source lang="php"> |
122 | | -$wgNewUserNotifSenderParam[] = '$user->getEmail()'; // $7 email |
123 | | -$wgNewUserNotifSenderParam[] = 'rawurlencode($wgSitename)'; // $8 Escaped for email message |
124 | | -$wgNewUserNotifSenderParam[] = 'wfGetIP()'; // $9 Submitter's IP Address |
125 | | -</source> |
126 | | - |
127 | | -Of course if you wanted to pass these parameter(s) to the subject message, you would add them to the $wgNewUserNotifSenderSubjParam array instead of the $wgNewUserNotifSenderParam array. |
128 | | - |
129 | | -=== 6.4 Some Technique/Tricks for Adding Additional Parameters === |
130 | | - |
131 | | -Let's say you wanted to use a global variable or reference other than $this, $user (created user object), $recipient (target), $wfContLang, or $wgSitename. |
132 | | - |
133 | | -You could do so by directly referencing a previously assigned global. Example: |
134 | | - |
135 | | -<source lang="php"> |
136 | | -$wgNewUserNotifSenderParam[] = '$GLOBALS["wgUser"]->getEmail()'; // $10 email |
137 | | -</source> |
138 | | - |
139 | | -Note: This isn't the best example, because it would be easier to use the $user object ('$user->getEmail()'), but it gives you an idea how you could reference the global variable (in this case objec) $wgUser directly. |
140 | | - |
141 | | -=== 6.5 Advanced Customization Prior to 1.5.2 === |
142 | | - |
143 | | -If you want to change the parameters passed in a version prior to 1.5.2, you would need to modify the extension code directly in wfMsgForContent function call found in private function makeMessage of NewUserNotif.class.php. |
144 | | - |
145 | | -== 7. Feedback == |
146 | | - |
147 | | -Bugs and enhancement requests should be submitted through bugzilla for the MediaWiki Extensions at: |
148 | | - |
149 | | -https://bugzilla.wikimedia.org/enter_bug.cgi?product=MediaWiki%20extensions |
150 | | - |
151 | | -For comments and discussion, see: |
152 | | - |
153 | | -http://www.mediawiki.org/wiki/Extension_talk:New_User_Email_Notification |
154 | | - |
| 80 | +All feedback, bug reports, etc. welcome via <robchur@gmail.com>. |
\ No newline at end of file |
Index: trunk/extensions/NewUserNotif/NewUserNotif.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | if ( ! defined( 'MEDIAWIKI' ) ) |
4 | | - die(); |
| 4 | + die(); |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Extension to provide customisable email notification of new user creation |
— | — | @@ -13,9 +13,9 @@ |
14 | 14 | */ |
15 | 15 | |
16 | 16 | $wgExtensionCredits['other'][] = array( |
17 | | - 'path' => __FILE__, |
| 17 | + 'path' => __FILE__, |
18 | 18 | 'name' => 'New User Email Notification', |
19 | | - 'version' => '1.5.2', |
| 19 | + 'version' => '1.5.1', |
20 | 20 | 'author' => 'Rob Church', |
21 | 21 | 'url' => 'http://www.mediawiki.org/wiki/Extension:New_User_Email_Notification', |
22 | 22 | 'descriptionmsg' => 'newusernotif-desc', |
— | — | @@ -40,26 +40,6 @@ |
41 | 41 | * Additional email addresses to send mails to |
42 | 42 | */ |
43 | 43 | $wgNewUserNotifEmailTargets = array(); |
44 | | -/** |
45 | | - * These are the parameters that will be passed into MediaWiki:newusernotifbody |
46 | | - * Can use anthing available as part of $this, $user (created user object), $recipient (target), |
47 | | - * or from globals $wgContLang, $wgSitename |
48 | | - */ |
49 | | -$wgNewUserNotifSenderParam = array( |
50 | | - '$recipient', // $1 Recipient (of notification message) |
51 | | - '$user->getname()', // $2 User Name |
52 | | - '$wgSitename', // $3 Site Name |
53 | | - '$wgContLang->timeAndDate( wfTimestampNow() )', // $4 Time and date stamp |
54 | | - '$wgContLang->date( wfTimestampNow() )', // $5 Date Stamp |
55 | | - '$wgContLang->time( wfTimestampNow() )', // $6 Time Stamp |
56 | | -); |
57 | | -/** |
58 | | - * These are the parameters that will be passed into MediaWiki:Newusernotifsubj (for use in the "subject:" line) |
59 | | - * parameters defs have same options as $wgNewUserNotifSenderParam |
60 | | - */ |
61 | | -$wgNewUserNotifSenderSubjParam = array( |
62 | | - '$wgSitename', // $1 Site Name |
63 | | -); |
64 | 44 | |
65 | 45 | /** |
66 | 46 | * Extension setup |