Index: trunk/extensions/NewUserNotif/NewUserNotif |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | NEW USER EMAIL NOTIFICATION EXTENSION |
3 | 3 | |
4 | | - Version 1.1 |
| 4 | + Version 1.2 |
5 | 5 | � 2006 Rob Church |
6 | 6 | |
7 | 7 | This is free software licensed under the GNU General Public License. Please |
— | — | @@ -92,4 +92,9 @@ |
93 | 93 | |
94 | 94 | Version 1.1 |
95 | 95 | 17/02/2006 |
96 | | - Added external email addresses feature |
\ No newline at end of file |
| 96 | + Added external email addresses feature |
| 97 | + |
| 98 | +Version 1.2 |
| 99 | +30/04/2006 |
| 100 | + Update to work with new hook format in MediaWiki 1.7 |
| 101 | + Fix date/time handling |
\ No newline at end of file |
Index: trunk/extensions/NewUserNotif/NewUserNotif.php |
— | — | @@ -30,11 +30,15 @@ |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** Send the notifications where possible */ |
34 | | - function NewUserNotif_Hook() { |
| 34 | + function NewUserNotif_Hook( $user = NULL ) { |
35 | 35 | global $wgUser, $wgSitename, $wgNewUserNotifSender, $wgNewUserNotifTargets; |
36 | 36 | |
| 37 | + # Some backwards-compatible fiddling |
| 38 | + if( is_null( $user ) ) |
| 39 | + $user =& $wgUser; |
| 40 | + |
37 | 41 | # Do external emails first |
38 | | - NewUserNotif_EmailExternal(); |
| 42 | + NewUserNotif_EmailExternal( $user ); |
39 | 43 | |
40 | 44 | foreach( $wgNewUserNotifTargets as $target ) { |
41 | 45 | $recipient = new User(); |
— | — | @@ -44,31 +48,30 @@ |
45 | 49 | # TODO: The target might not exist |
46 | 50 | if( $recipient->isEmailConfirmed() ) { |
47 | 51 | $subject = wfMsg( 'newusernotifsubj', $wgSitename ); |
48 | | - $message = NewUserNotif_MakeEmail( $recipient->getName() ); |
| 52 | + $message = NewUserNotif_MakeEmail( $user, $recipient->getName() ); |
49 | 53 | $recipient->sendMail( $subject, $message, $wgNewUserNotifSender ); |
50 | 54 | } |
51 | 55 | } |
52 | 56 | } |
53 | 57 | |
54 | 58 | /** Send a notification email to the external addresses */ |
55 | | - function NewUserNotif_EmailExternal( ) { |
| 59 | + function NewUserNotif_EmailExternal( &$user ) { |
56 | 60 | global $wgSitename, $wgNewUserNotifEmailTargets; |
57 | 61 | $sender = new MailAddress( $wgNewUserNotifSender, $wgSitename ); |
58 | 62 | |
59 | 63 | foreach( $wgNewUserNotifEmailTargets as $target ) { |
60 | 64 | $recipient = new MailAddress( $target ); |
61 | 65 | $subject = wfMsg( 'newusernotifsubj', $wgSitename ); |
62 | | - $message = NewUserNotif_MakeEmail( $target ); |
| 66 | + $message = NewUserNotif_MakeEmail( $user, $target ); |
63 | 67 | userMailer( $recipient, $sender, $subject, $message ); |
64 | 68 | } |
65 | | - |
66 | 69 | } |
67 | 70 | |
68 | 71 | /** Make the notification email */ |
69 | | - function NewUserNotif_MakeEmail( $recipient ) { |
70 | | - global $wgUser, $wgContLang, $wgSitename; |
71 | | - $timestamp = $wgContLang->timeAndDate( date( 'YmdHis' ), false, false ) . ' (' . date( 'T' ) . ')'; |
72 | | - $message = wfMsg( 'newusernotifbody', $recipient, $wgUser->getName(), $wgSitename, $timestamp ); |
| 72 | + function NewUserNotif_MakeEmail( &$user, $recipient ) { |
| 73 | + global $wgContLang, $wgSitename; |
| 74 | + $timestamp = $wgContLang->timeAndDate( wfTimestampNow() ); |
| 75 | + $message = wfMsg( 'newusernotifbody', $recipient, $user->getName(), $wgSitename, $timestamp ); |
73 | 76 | return( $message ); |
74 | 77 | } |
75 | 78 | |