r83151 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83150‎ | r83151 | r83152 >
Date:17:51, 3 March 2011
Author:jdpond
Status:deferred (Comments)
Tags:
Comment:
(Bug 27831) Allow Custom Parameters for Subject and Message - Version 1.5.2
Modified paths:
  • /trunk/extensions/NewUserNotif/ExtendedParamsExample.php (added) (history)
  • /trunk/extensions/NewUserNotif/NewUserNotif.class.php (modified) (history)
  • /trunk/extensions/NewUserNotif/NewUserNotif.php (modified) (history)
  • /trunk/extensions/NewUserNotif/README (modified) (history)
  • /trunk/extensions/NewUserNotif/RELEASE-NOTES (added) (history)

Diff [purge]

Index: trunk/extensions/NewUserNotif/NewUserNotif.class.php
@@ -42,7 +42,7 @@
4343 UserMailer::send(
4444 new MailAddress( $target ),
4545 new MailAddress( $this->sender ),
46 - wfMsgForContent( 'newusernotifsubj', $wgSitename ),
 46+ $this->makeSubject( $target, $this->user ),
4747 $this->makeMessage( $target, $this->user )
4848 );
4949 }
@@ -57,7 +57,7 @@
5858 $user = $this->makeUser( $userSpec );
5959 if( $user instanceof User && $user->isEmailConfirmed() ) {
6060 $user->sendMail(
61 - wfMsgForContent( 'newusernotifsubj', $wgSitename ),
 61+ $this->makeSubject( $user->getName(), $this->user ),
6262 $this->makeMessage( $user->getName(), $this->user ),
6363 $this->sender
6464 );
@@ -80,22 +80,41 @@
8181 }
8282
8383 /**
84 - * Build a notification email
 84+ * Build a notification email subject line
8585 *
8686 * @param string $recipient Name of the recipient
8787 * @param User $user User that was created
8888 */
 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+ */
89104 private function makeMessage( $recipient, $user ) {
90105 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;
100119 }
101120
102121 /**
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
187 + 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
117 + native
Index: trunk/extensions/NewUserNotif/README
@@ -76,4 +76,4 @@
7777
7878 == 6. Feedback ==
7979
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 @@
1616 $wgExtensionCredits['other'][] = array(
1717 'path' => __FILE__,
1818 'name' => 'New User Email Notification',
19 - 'version' => '1.5.1',
 19+ 'version' => '1.5.2',
2020 'author' => 'Rob Church',
2121 'url' => 'http://www.mediawiki.org/wiki/Extension:New_User_Email_Notification',
2222 'descriptionmsg' => 'newusernotif-desc',

Follow-up revisions

RevisionCommit summaryAuthorDate
r83166Coding Standards Changes. RELEASE-NOTES and ExtendedParamsExample.php to UTF...jdpond20:01, 3 March 2011

Comments

#Comment by Nikerabbit (talk | contribs)   19:01, 3 March 2011

Release-notes should be encoded in UTF-8, local variables usually start with lower case letter.

#Comment by Jpond (talk | contribs)   20:03, 3 March 2011

r83166 - implemented Coding Standards Changes. RELEASE-NOTES and ExtendedParamsExample.php to UTF-8. Also fixed local variables to start lower case.

Status & tagging log