Index: trunk/phase3/includes/UserMailer.php |
— | — | @@ -32,18 +32,21 @@ |
33 | 33 | * @param $address Mixed: string with an email address, or a User object |
34 | 34 | * @param $name String: human-readable name if a string address is given |
35 | 35 | */ |
36 | | - function __construct( $address, $name=null ) { |
| 36 | + function __construct( $address, $name = null, $realName = null ) { |
37 | 37 | if( is_object( $address ) && $address instanceof User ) { |
38 | 38 | $this->address = $address->getEmail(); |
39 | 39 | $this->name = $address->getName(); |
| 40 | + $this->realName = $address->getRealName(); |
40 | 41 | } else { |
41 | 42 | $this->address = strval( $address ); |
42 | 43 | $this->name = strval( $name ); |
| 44 | + $this->reaName = strval( $realName ); |
43 | 45 | } |
44 | 46 | } |
45 | 47 | |
46 | 48 | /** |
47 | 49 | * Return formatted and quoted address to insert into SMTP headers |
| 50 | + * @param bool $useRealName True will use real name instead of username |
48 | 51 | * @return string |
49 | 52 | */ |
50 | 53 | function toString() { |
— | — | @@ -51,7 +54,9 @@ |
52 | 55 | # can't handle "Joe Bloggs <joe@bloggs.com>" format email addresses, |
53 | 56 | # so don't bother generating them |
54 | 57 | 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 ); |
56 | 61 | if( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) { |
57 | 62 | $quoted = '"' . $quoted . '"'; |
58 | 63 | } |
— | — | @@ -427,7 +432,7 @@ |
428 | 433 | function composeCommonMailtext() { |
429 | 434 | global $wgPasswordSender, $wgNoReplyAddress; |
430 | 435 | global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress; |
431 | | - global $wgEnotifImpersonal; |
| 436 | + global $wgEnotifImpersonal, $wgEnotifUseRealName; |
432 | 437 | |
433 | 438 | $this->composed_common = true; |
434 | 439 | |
— | — | @@ -481,7 +486,7 @@ |
482 | 487 | # the user has not opted-out and the option is enabled at the |
483 | 488 | # global configuration level. |
484 | 489 | $editor = $this->editor; |
485 | | - $name = $editor->getName(); |
| 490 | + $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName(); |
486 | 491 | $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' ); |
487 | 492 | $editorAddress = new MailAddress( $editor ); |
488 | 493 | if( $wgEnotifRevealEditorAddress |
— | — | @@ -567,7 +572,8 @@ |
568 | 573 | // Note: The to parameter cannot be an address in the form of "Something <someone@example.com>". |
569 | 574 | // The mail command will not parse this properly while talking with the MTA. |
570 | 575 | $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 ); |
572 | 578 | |
573 | 579 | $timecorrection = $watchingUser->getOption( 'timecorrection' ); |
574 | 580 | |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1500,6 +1500,9 @@ |
1501 | 1501 | # Send mails via the job queue. |
1502 | 1502 | $wgEnotifUseJobQ = false; |
1503 | 1503 | |
| 1504 | +# Use real name instead of username in e-mail "from" field |
| 1505 | +$wgEnotifUseRealName = false; |
| 1506 | + |
1504 | 1507 | /** |
1505 | 1508 | * Array of usernames who will be sent a notification email for every change which occurs on a wiki |
1506 | 1509 | */ |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -56,6 +56,8 @@ |
57 | 57 | * Added $wgAllowUserSkin to let the wiki's owner disable user selectable skins |
58 | 58 | on the wiki. If it's set to true, then the skin used will *always* be |
59 | 59 | $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) |
60 | 62 | |
61 | 63 | === Migrated extensions === |
62 | 64 | The following extensions are migrated into MediaWiki 1.14: |