Index: trunk/extensions/NewUserNotif/NewUserNotif.class.php |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | UserMailer::send( |
44 | 44 | new MailAddress( $target ), |
45 | 45 | new MailAddress( $this->sender ), |
46 | | - wfMsgForContent( 'newusernotifsubj', $wgSitename ), |
| 46 | + $this->makeSubject( $target, $this->user ), |
47 | 47 | $this->makeMessage( $target, $this->user ) |
48 | 48 | ); |
49 | 49 | } |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | $user = $this->makeUser( $userSpec ); |
59 | 59 | if( $user instanceof User && $user->isEmailConfirmed() ) { |
60 | 60 | $user->sendMail( |
61 | | - wfMsgForContent( 'newusernotifsubj', $wgSitename ), |
| 61 | + $this->makeSubject( $user->getName(), $this->user ), |
62 | 62 | $this->makeMessage( $user->getName(), $this->user ), |
63 | 63 | $this->sender |
64 | 64 | ); |
— | — | @@ -80,22 +80,41 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | | - * Build a notification email |
| 84 | + * Build a notification email subject line |
85 | 85 | * |
86 | 86 | * @param string $recipient Name of the recipient |
87 | 87 | * @param User $user User that was created |
88 | 88 | */ |
| 89 | + private function makeSubject( $recipient, $user ) { |
| 90 | + global $wgSitename; |
| 91 | + $SubjectLine = ""; |
| 92 | + wfRunHooks( 'NewUserNotifSubject', array( &$this, &$SubjectLine, $wgSitename, $recipient, $user ) ); |
| 93 | + if (!strlen($SubjectLine) ) |
| 94 | + return wfMsgForContent( 'newusernotifsubj', $wgSitename ); |
| 95 | + return $SubjectLine; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Build a notification email message body |
| 100 | + * |
| 101 | + * @param string $recipient Name of the recipient |
| 102 | + * @param User $user User that was created |
| 103 | + */ |
89 | 104 | private function makeMessage( $recipient, $user ) { |
90 | 105 | 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 | | - ); |
| 106 | + $MessageBody = ""; |
| 107 | + wfRunHooks( 'NewUserNotifBody', array( &$this, &$MessageBody, $wgSitename, $recipient, $user ) ); |
| 108 | + if (!strlen($MessageBody) ) |
| 109 | + return wfMsgForContent( |
| 110 | + 'newusernotifbody', |
| 111 | + $recipient, |
| 112 | + $user->getName(), |
| 113 | + $wgSitename, |
| 114 | + $wgContLang->timeAndDate( wfTimestampNow() ), |
| 115 | + $wgContLang->date( wfTimestampNow() ), |
| 116 | + $wgContLang->time( wfTimestampNow() ) |
| 117 | + ); |
| 118 | + return $MessageBody; |
100 | 119 | } |
101 | 120 | |
102 | 121 | /** |
Index: trunk/extensions/NewUserNotif/ExtendedParamsExample.php |
— | — | @@ -0,0 +1,85 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Example Extension to provide additional parameters to the subject line and message body for NewUserNotif |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @author Jack D. Pond <jack.pond@psitex.com> |
| 8 | + * @ingroup Extensions |
| 9 | + * @copyright 2011 Jack D. pond |
| 10 | + * @url http://www.mediawiki.org/wiki/Manual:Extensions |
| 11 | + * @licence GNU General Public Licence 2.0 or later |
| 12 | + */ |
| 13 | + |
| 14 | +if (!defined('MEDIAWIKI')) die('Not an entry point.'); |
| 15 | + |
| 16 | +$wgExtensionFunctions[] = 'efNewUserNotifSetupExtension'; |
| 17 | +$wgExtensionCredits['other'][] = array( |
| 18 | + 'path' => __FILE__, |
| 19 | + 'name' => 'AdditionalNewUserNotifParams', |
| 20 | + 'author' => array( 'Jack D. Pond' ), |
| 21 | + 'version' => '1.0', |
| 22 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:NewUserNotif', |
| 23 | +); |
| 24 | + |
| 25 | +/** |
| 26 | + * Set up hooks for Additional NewUserNotif Parameters |
| 27 | + * |
| 28 | +*/ |
| 29 | +function efNewUserNotifSetupExtension() { |
| 30 | + global $wgHooks; |
| 31 | + $wgHooks['NewUserNotifSubject'][] = 'efNewUserNotifSubject'; |
| 32 | + $wgHooks['NewUserNotifBody'][] = 'efNewUserNotifBody'; |
| 33 | + return true; |
| 34 | +} |
| 35 | + |
| 36 | + |
| 37 | +/** |
| 38 | + * This function creates additional parameters which can be used in the email notification Subject Line for new users |
| 39 | + * |
| 40 | + * @param $callobj NewUserNotifier object (this). |
| 41 | + * @param $SubjectLine String: Returns the message subject line |
| 42 | + * @param $SiteName Site Name of the Wiki |
| 43 | + * @param $recipient Email/User Name of the Message Recipient. |
| 44 | + * @param $user User name of the added user |
| 45 | + * @return true |
| 46 | + */ |
| 47 | + |
| 48 | +function efNewUserNotifSubject ( $callobj , $SubjectLine , $SiteName , $recipient , $user ) |
| 49 | +{ |
| 50 | + $SubjectLine = wfMsgForContent( |
| 51 | + 'newusernotifsubj', |
| 52 | + $SiteName, // $1 Site Name |
| 53 | + $user->getName() // $2 User Name |
| 54 | + ); |
| 55 | + return ( true ); |
| 56 | +} |
| 57 | + |
| 58 | +/** |
| 59 | + * This function creates additional parameters which can be used in the email notification message body for new users |
| 60 | + * |
| 61 | + * @param $callobj NewUserNotifier object (this). |
| 62 | + * @param $MessageBody String: Returns the message body. |
| 63 | + * @param $SiteName Site Name of the Wiki |
| 64 | + * @param $recipient Email/User Name of the Message Recipient. |
| 65 | + * @param $user User name of the added user |
| 66 | + * @return true |
| 67 | + */ |
| 68 | + |
| 69 | +function efNewUserNotifBody ( $callobj , $MessageBody , $SiteName , $recipient , $user ) |
| 70 | +{ |
| 71 | + global $wgContLang; |
| 72 | + $MessageBody = wfMsgForContent( |
| 73 | + 'newusernotifbody', |
| 74 | + $recipient, // $1 Recipient (of notification message) |
| 75 | + $user->getName(), // $2 User Name |
| 76 | + $SiteName, // $3 Site Name |
| 77 | + $wgContLang->timeAndDate( wfTimestampNow() ), // $4 Time and date stamp |
| 78 | + $wgContLang->date( wfTimestampNow() ), // $5 Date Stamp |
| 79 | + $wgContLang->time( wfTimestampNow() ), // $6 Time Stamp |
| 80 | + $user->getEmail(), // $7 email |
| 81 | + rawurlencode($SiteName), // $8 Site name encoded for email message link |
| 82 | + wfGetIP(), // $9 Submitter's IP Address |
| 83 | + rawurlencode($user->getName()) // $10 User Name encoded for email message link |
| 84 | + ); |
| 85 | + return ( true ); |
| 86 | +} |
Property changes on: trunk/extensions/NewUserNotif/ExtendedParamsExample.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 87 | + native |
Index: trunk/extensions/NewUserNotif/RELEASE-NOTES |
— | — | @@ -0,0 +1,15 @@ |
| 2 | +NEW USER EMAIL NOTIFICATION EXTENSION |
| 3 | + |
| 4 | + Version 1.5 |
| 5 | + � 2006-2007 Rob Church, maintained by jpond |
| 6 | + |
| 7 | +This is free software licenced under the GNU General Public Licence. Please |
| 8 | +see http://www.gnu.org/copyleft/gpl.html for further details, including the |
| 9 | +full text and terms of the license. |
| 10 | + |
| 11 | +=== Summary of changes in 1.5.1 === |
| 12 | + |
| 13 | +* Added two hooks that allow for the customization of both messages and parameters passed to generate the messages |
| 14 | +* Added an example extension to the distribution, ExtendedParamsExample.php |
| 15 | +* Updated Documentation - http://www.mediawiki.org/w/index.php?title=Extension:New_User_Email_Notification |
| 16 | +* Added RELEASE-NOTES to distribution |
Property changes on: trunk/extensions/NewUserNotif/RELEASE-NOTES |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 17 | + native |
Index: trunk/extensions/NewUserNotif/README |
— | — | @@ -76,4 +76,4 @@ |
77 | 77 | |
78 | 78 | == 6. Feedback == |
79 | 79 | |
80 | | -All feedback, bug reports, etc. welcome via <robchur@gmail.com>. |
\ No newline at end of file |
| 80 | +All feedback, bug reports, etc. welcome via <robchur@gmail.com>. |
Index: trunk/extensions/NewUserNotif/NewUserNotif.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | $wgExtensionCredits['other'][] = array( |
17 | 17 | 'path' => __FILE__, |
18 | 18 | 'name' => 'New User Email Notification', |
19 | | - 'version' => '1.5.1', |
| 19 | + 'version' => '1.5.2', |
20 | 20 | 'author' => 'Rob Church', |
21 | 21 | 'url' => 'http://www.mediawiki.org/wiki/Extension:New_User_Email_Notification', |
22 | 22 | 'descriptionmsg' => 'newusernotif-desc', |