Index: branches/REL1_18/phase3/includes/UserMailer.php |
— | — | @@ -119,22 +119,14 @@ |
120 | 120 | * @return Status object |
121 | 121 | */ |
122 | 122 | public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8') { |
123 | | - global $wgSMTP, $wgEnotifImpersonal; |
124 | | - global $wgEnotifMaxRecips, $wgAdditionalMailParams; |
| 123 | + global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams; |
125 | 124 | |
126 | | - if ( is_array( $to ) ) { |
127 | | - $emails = ''; |
128 | | - // This wouldn't be necessary if implode() worked on arrays of |
129 | | - // objects using __toString(). http://bugs.php.net/bug.php?id=36612 |
130 | | - foreach ( $to as $t ) { |
131 | | - $emails .= $t->toString() . ","; |
132 | | - } |
133 | | - $emails = rtrim( $emails, ',' ); |
134 | | - wfDebug( __METHOD__ . ': sending mail to ' . $emails . "\n" ); |
135 | | - } else { |
136 | | - wfDebug( __METHOD__ . ': sending mail to ' . implode( ',', array( $to->toString() ) ) . "\n" ); |
| 125 | + if ( !is_array( $to ) ) { |
| 126 | + $to = array( $to ); |
137 | 127 | } |
138 | 128 | |
| 129 | + wfDebug( __METHOD__ . ': sending mail to ' . implode( ', ', $to ) . "\n" ); |
| 130 | + |
139 | 131 | if ( is_array( $wgSMTP ) ) { |
140 | 132 | if ( function_exists( 'stream_resolve_include_path' ) ) { |
141 | 133 | $found = stream_resolve_include_path( 'Mail.php' ); |
— | — | @@ -161,13 +153,13 @@ |
162 | 154 | } |
163 | 155 | |
164 | 156 | $headers['From'] = $from->toString(); |
165 | | - $headers['Return-Path'] = $from->toString(); |
| 157 | + $headers['Return-Path'] = $from->address; |
166 | 158 | |
167 | | - if ( $wgEnotifImpersonal ) { |
| 159 | + if ( count( $to ) > 1 ) { |
168 | 160 | $headers['To'] = 'undisclosed-recipients:;'; |
169 | 161 | } |
170 | 162 | else { |
171 | | - $headers['To'] = implode( ", ", (array )$dest ); |
| 163 | + $headers['To'] = $to[0]->toString(); |
172 | 164 | } |
173 | 165 | |
174 | 166 | if ( $replyto ) { |
— | — | @@ -177,7 +169,7 @@ |
178 | 170 | $headers['Date'] = date( 'r' ); |
179 | 171 | $headers['MIME-Version'] = '1.0'; |
180 | 172 | $headers['Content-type'] = ( is_null( $contentType ) ? |
181 | | - 'text/plain; charset=UTF-8' : $contentType ); |
| 173 | + 'text/plain; charset=UTF-8' : $contentType ); |
182 | 174 | $headers['Content-transfer-encoding'] = '8bit'; |
183 | 175 | // @todo FIXME |
184 | 176 | $headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>'; |
— | — | @@ -495,18 +487,11 @@ |
496 | 488 | |
497 | 489 | $this->composed_common = true; |
498 | 490 | |
499 | | - $summary = ( $this->summary == '' ) ? ' - ' : $this->summary; |
500 | | - $medit = ( $this->minorEdit ) ? wfMsgForContent( 'minoredit' ) : ''; |
501 | | - |
502 | 491 | # You as the WikiAdmin and Sysops can make use of plenty of |
503 | 492 | # named variables when composing your notification emails while |
504 | 493 | # simply editing the Meta pages |
505 | 494 | |
506 | | - $subject = wfMsgForContent( 'enotif_subject' ); |
507 | | - $body = wfMsgForContent( 'enotif_body' ); |
508 | | - $from = ''; /* fail safe */ |
509 | | - $replyto = ''; /* fail safe */ |
510 | | - $keys = array(); |
| 495 | + $keys = array(); |
511 | 496 | |
512 | 497 | if ( $this->oldid ) { |
513 | 498 | $difflink = $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid ); |
— | — | @@ -520,69 +505,54 @@ |
521 | 506 | $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' ); |
522 | 507 | } |
523 | 508 | |
524 | | - if ( $wgEnotifImpersonal && $this->oldid ) { |
525 | | - /** |
526 | | - * For impersonal mail, show a diff link to the last |
527 | | - * revision. |
528 | | - */ |
529 | | - $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff', |
530 | | - $this->title->getCanonicalUrl( "oldid={$this->oldid}&diff=next" ) ); |
| 509 | + $keys['$PAGETITLE'] = $this->title->getPrefixedText(); |
| 510 | + $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl(); |
| 511 | + $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMsgForContent( 'minoredit' ) : ''; |
| 512 | + $keys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary; |
| 513 | + $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' ); |
| 514 | + |
| 515 | + if ( $this->editor->isAnon() ) { |
| 516 | + # real anon (user:xxx.xxx.xxx.xxx) |
| 517 | + $keys['$PAGEEDITOR'] = wfMsgForContent( 'enotif_anon_editor', $this->editor->getName() ); |
| 518 | + $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' ); |
| 519 | + } else { |
| 520 | + $keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName(); |
| 521 | + $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() ); |
| 522 | + $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl(); |
531 | 523 | } |
532 | 524 | |
533 | | - $body = strtr( $body, $keys ); |
534 | | - $pagetitle = $this->title->getPrefixedText(); |
535 | | - $keys['$PAGETITLE'] = $pagetitle; |
536 | | - $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl(); |
| 525 | + $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalUrl(); |
537 | 526 | |
538 | | - $keys['$PAGEMINOREDIT'] = $medit; |
539 | | - $keys['$PAGESUMMARY'] = $summary; |
540 | | - $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' ); |
| 527 | + # Now build message's subject and body |
541 | 528 | |
| 529 | + $subject = wfMsgExt( 'enotif_subject', 'content' ); |
542 | 530 | $subject = strtr( $subject, $keys ); |
| 531 | + $this->subject = MessageCache::singleton()->transform( $subject, false, null, $this->title ); |
543 | 532 | |
| 533 | + $body = wfMsgExt( 'enotif_body', 'content' ); |
| 534 | + $body = strtr( $body, $keys ); |
| 535 | + $body = MessageCache::singleton()->transform( $body, false, null, $this->title ); |
| 536 | + $this->body = wordwrap( $body, 72 ); |
| 537 | + |
544 | 538 | # Reveal the page editor's address as REPLY-TO address only if |
545 | 539 | # the user has not opted-out and the option is enabled at the |
546 | 540 | # global configuration level. |
547 | | - $editor = $this->editor; |
548 | | - $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName(); |
549 | 541 | $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName ); |
550 | | - $editorAddress = new MailAddress( $editor ); |
551 | 542 | if ( $wgEnotifRevealEditorAddress |
552 | | - && ( $editor->getEmail() != '' ) |
553 | | - && $editor->getOption( 'enotifrevealaddr' ) ) { |
| 543 | + && ( $this->editor->getEmail() != '' ) |
| 544 | + && $this->editor->getOption( 'enotifrevealaddr' ) ) |
| 545 | + { |
| 546 | + $editorAddress = new MailAddress( $this->editor ); |
554 | 547 | if ( $wgEnotifFromEditor ) { |
555 | | - $from = $editorAddress; |
| 548 | + $this->from = $editorAddress; |
556 | 549 | } else { |
557 | | - $from = $adminAddress; |
558 | | - $replyto = $editorAddress; |
| 550 | + $this->from = $adminAddress; |
| 551 | + $this->replyto = $editorAddress; |
559 | 552 | } |
560 | 553 | } else { |
561 | | - $from = $adminAddress; |
562 | | - $replyto = new MailAddress( $wgNoReplyAddress ); |
| 554 | + $this->from = $adminAddress; |
| 555 | + $this->replyto = new MailAddress( $wgNoReplyAddress ); |
563 | 556 | } |
564 | | - |
565 | | - if ( $editor->isAnon() ) { |
566 | | - # real anon (user:xxx.xxx.xxx.xxx) |
567 | | - $utext = wfMsgForContent( 'enotif_anon_editor', $name ); |
568 | | - $subject = str_replace( '$PAGEEDITOR', $utext, $subject ); |
569 | | - $keys['$PAGEEDITOR'] = $utext; |
570 | | - $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' ); |
571 | | - } else { |
572 | | - $subject = str_replace( '$PAGEEDITOR', $name, $subject ); |
573 | | - $keys['$PAGEEDITOR'] = $name; |
574 | | - $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name ); |
575 | | - $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl(); |
576 | | - } |
577 | | - $userPage = $editor->getUserPage(); |
578 | | - $keys['$PAGEEDITOR_WIKI'] = $userPage->getCanonicalUrl(); |
579 | | - $body = strtr( $body, $keys ); |
580 | | - $body = wordwrap( $body, 72 ); |
581 | | - |
582 | | - # now save this as the constant user-independent part of the message |
583 | | - $this->from = $from; |
584 | | - $this->replyto = $replyto; |
585 | | - $this->subject = $subject; |
586 | | - $this->body = $body; |
587 | 557 | } |
588 | 558 | |
589 | 559 | /** |