r13953 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13952‎ | r13953 | r13954 >
Date:01:33, 30 April 2006
Author:robchurch
Status:old
Tags:
Comment:
* Update to work with new hook format in MediaWiki 1.7
* Fix date/time handling
Modified paths:
  • /trunk/extensions/NewUserNotif/NewUserNotif (modified) (history)
  • /trunk/extensions/NewUserNotif/NewUserNotif.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NewUserNotif/NewUserNotif
@@ -1,6 +1,6 @@
22 NEW USER EMAIL NOTIFICATION EXTENSION
33
4 - Version 1.1
 4+ Version 1.2
55 � 2006 Rob Church
66
77 This is free software licensed under the GNU General Public License. Please
@@ -92,4 +92,9 @@
9393
9494 Version 1.1
9595 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 @@
3131 }
3232
3333 /** Send the notifications where possible */
34 - function NewUserNotif_Hook() {
 34+ function NewUserNotif_Hook( $user = NULL ) {
3535 global $wgUser, $wgSitename, $wgNewUserNotifSender, $wgNewUserNotifTargets;
3636
 37+ # Some backwards-compatible fiddling
 38+ if( is_null( $user ) )
 39+ $user =& $wgUser;
 40+
3741 # Do external emails first
38 - NewUserNotif_EmailExternal();
 42+ NewUserNotif_EmailExternal( $user );
3943
4044 foreach( $wgNewUserNotifTargets as $target ) {
4145 $recipient = new User();
@@ -44,31 +48,30 @@
4549 # TODO: The target might not exist
4650 if( $recipient->isEmailConfirmed() ) {
4751 $subject = wfMsg( 'newusernotifsubj', $wgSitename );
48 - $message = NewUserNotif_MakeEmail( $recipient->getName() );
 52+ $message = NewUserNotif_MakeEmail( $user, $recipient->getName() );
4953 $recipient->sendMail( $subject, $message, $wgNewUserNotifSender );
5054 }
5155 }
5256 }
5357
5458 /** Send a notification email to the external addresses */
55 - function NewUserNotif_EmailExternal( ) {
 59+ function NewUserNotif_EmailExternal( &$user ) {
5660 global $wgSitename, $wgNewUserNotifEmailTargets;
5761 $sender = new MailAddress( $wgNewUserNotifSender, $wgSitename );
5862
5963 foreach( $wgNewUserNotifEmailTargets as $target ) {
6064 $recipient = new MailAddress( $target );
6165 $subject = wfMsg( 'newusernotifsubj', $wgSitename );
62 - $message = NewUserNotif_MakeEmail( $target );
 66+ $message = NewUserNotif_MakeEmail( $user, $target );
6367 userMailer( $recipient, $sender, $subject, $message );
6468 }
65 -
6669 }
6770
6871 /** 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 );
7376 return( $message );
7477 }
7578

Status & tagging log