r43155 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43154‎ | r43155 | r43156 >
Date:21:31, 3 November 2008
Author:siebrand
Status:old (Comments)
Tags:
Comment:
(bug 15068) Added $wgEnotifUseRealName, which allows UserMailer to send out e-mails based on the user's real name if one is set. Defaults to false (use the username). Patch by ^demon (Chad Horohoe). Per suggestion of brion.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/UserMailer.php
@@ -32,18 +32,21 @@
3333 * @param $address Mixed: string with an email address, or a User object
3434 * @param $name String: human-readable name if a string address is given
3535 */
36 - function __construct( $address, $name=null ) {
 36+ function __construct( $address, $name = null, $realName = null ) {
3737 if( is_object( $address ) && $address instanceof User ) {
3838 $this->address = $address->getEmail();
3939 $this->name = $address->getName();
 40+ $this->realName = $address->getRealName();
4041 } else {
4142 $this->address = strval( $address );
4243 $this->name = strval( $name );
 44+ $this->reaName = strval( $realName );
4345 }
4446 }
4547
4648 /**
4749 * Return formatted and quoted address to insert into SMTP headers
 50+ * @param bool $useRealName True will use real name instead of username
4851 * @return string
4952 */
5053 function toString() {
@@ -51,7 +54,9 @@
5255 # can't handle "Joe Bloggs <joe@bloggs.com>" format email addresses,
5356 # so don't bother generating them
5457 if( $this->name != '' && !wfIsWindows() ) {
55 - $quoted = wfQuotedPrintable( $this->name );
 58+ global $wgEnotifUseRealName;
 59+ $name = ( $wgEnotifUseRealName && $this->realName ) ? $this->realName : $this->name;
 60+ $quoted = wfQuotedPrintable( $name );
5661 if( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) {
5762 $quoted = '"' . $quoted . '"';
5863 }
@@ -427,7 +432,7 @@
428433 function composeCommonMailtext() {
429434 global $wgPasswordSender, $wgNoReplyAddress;
430435 global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
431 - global $wgEnotifImpersonal;
 436+ global $wgEnotifImpersonal, $wgEnotifUseRealName;
432437
433438 $this->composed_common = true;
434439
@@ -481,7 +486,7 @@
482487 # the user has not opted-out and the option is enabled at the
483488 # global configuration level.
484489 $editor = $this->editor;
485 - $name = $editor->getName();
 490+ $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
486491 $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
487492 $editorAddress = new MailAddress( $editor );
488493 if( $wgEnotifRevealEditorAddress
@@ -567,7 +572,8 @@
568573 // Note: The to parameter cannot be an address in the form of "Something <someone@example.com>".
569574 // The mail command will not parse this properly while talking with the MTA.
570575 $to = new MailAddress( $watchingUser );
571 - $body = str_replace( '$WATCHINGUSERNAME', $watchingUser->getName() , $this->body );
 576+ $name = $wgEnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName();
 577+ $body = str_replace( '$WATCHINGUSERNAME', $name , $this->body );
572578
573579 $timecorrection = $watchingUser->getOption( 'timecorrection' );
574580
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1500,6 +1500,9 @@
15011501 # Send mails via the job queue.
15021502 $wgEnotifUseJobQ = false;
15031503
 1504+# Use real name instead of username in e-mail "from" field
 1505+$wgEnotifUseRealName = false;
 1506+
15041507 /**
15051508 * Array of usernames who will be sent a notification email for every change which occurs on a wiki
15061509 */
Index: trunk/phase3/RELEASE-NOTES
@@ -56,6 +56,8 @@
5757 * Added $wgAllowUserSkin to let the wiki's owner disable user selectable skins
5858 on the wiki. If it's set to true, then the skin used will *always* be
5959 $wgDefaultSkin.
 60+* Added $wgEnotifUseRealName, which allows UserMailer to send out e-mails based
 61+ on the user's real name if one is set. Defaults to false (use the username)
6062
6163 === Migrated extensions ===
6264 The following extensions are migrated into MediaWiki 1.14:

Follow-up revisions

RevisionCommit summaryAuthorDate
r43161Add missing global $wgEnotifUseRealName. Fix for undefined variable notice in...siebrand22:22, 3 November 2008
r43162Update documentation as pointed out by Aaron. Fix on r43155.siebrand22:26, 3 November 2008
r45880Fix typo in r43155...simetrical18:48, 18 January 2009

Comments

#Comment by Aaron Schulz (talk | contribs)   22:22, 3 November 2008

'* @param bool $useRealName True will use real name instead of username' comment seems incorrect

#Comment by Siebrand (talk | contribs)   22:27, 3 November 2008

Fixed in r43162. Thanks.

#Comment by Aaron Schulz (talk | contribs)   22:34, 3 November 2008

Removed entirely in r43163

#Comment by Siebrand (talk | contribs)   22:24, 3 November 2008

Fix undefined variable notice in r43161

Status & tagging log