Index: branches/wmf/1.18wmf1/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'] . '>'; |
— | — | @@ -532,18 +524,11 @@ |
533 | 525 | |
534 | 526 | $this->composed_common = true; |
535 | 527 | |
536 | | - $summary = ( $this->summary == '' ) ? ' - ' : $this->summary; |
537 | | - $medit = ( $this->minorEdit ) ? wfMsgForContent( 'minoredit' ) : ''; |
538 | | - |
539 | 528 | # You as the WikiAdmin and Sysops can make use of plenty of |
540 | 529 | # named variables when composing your notification emails while |
541 | 530 | # simply editing the Meta pages |
542 | 531 | |
543 | | - $subject = wfMsgForContent( 'enotif_subject' ); |
544 | | - $body = wfMsgForContent( 'enotif_body' ); |
545 | | - $from = ''; /* fail safe */ |
546 | | - $replyto = ''; /* fail safe */ |
547 | | - $keys = array(); |
| 532 | + $keys = array(); |
548 | 533 | |
549 | 534 | if ( $this->oldid ) { |
550 | 535 | $difflink = $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid ); |
— | — | @@ -557,69 +542,54 @@ |
558 | 543 | $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' ); |
559 | 544 | } |
560 | 545 | |
561 | | - if ( $wgEnotifImpersonal && $this->oldid ) { |
562 | | - /** |
563 | | - * For impersonal mail, show a diff link to the last |
564 | | - * revision. |
565 | | - */ |
566 | | - $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff', |
567 | | - $this->title->getCanonicalUrl( "oldid={$this->oldid}&diff=next" ) ); |
| 546 | + $keys['$PAGETITLE'] = $this->title->getPrefixedText(); |
| 547 | + $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl(); |
| 548 | + $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMsgForContent( 'minoredit' ) : ''; |
| 549 | + $keys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary; |
| 550 | + $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' ); |
| 551 | + |
| 552 | + if ( $this->editor->isAnon() ) { |
| 553 | + # real anon (user:xxx.xxx.xxx.xxx) |
| 554 | + $keys['$PAGEEDITOR'] = wfMsgForContent( 'enotif_anon_editor', $this->editor->getName() ); |
| 555 | + $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' ); |
| 556 | + } else { |
| 557 | + $keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName(); |
| 558 | + $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() ); |
| 559 | + $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl(); |
568 | 560 | } |
569 | 561 | |
570 | | - $body = strtr( $body, $keys ); |
571 | | - $pagetitle = $this->title->getPrefixedText(); |
572 | | - $keys['$PAGETITLE'] = $pagetitle; |
573 | | - $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl(); |
| 562 | + $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalUrl(); |
574 | 563 | |
575 | | - $keys['$PAGEMINOREDIT'] = $medit; |
576 | | - $keys['$PAGESUMMARY'] = $summary; |
577 | | - $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' ); |
| 564 | + # Now build message's subject and body |
578 | 565 | |
| 566 | + $subject = wfMsgExt( 'enotif_subject', 'content' ); |
579 | 567 | $subject = strtr( $subject, $keys ); |
| 568 | + $this->subject = MessageCache::singleton()->transform( $subject, false, null, $this->title ); |
580 | 569 | |
| 570 | + $body = wfMsgExt( 'enotif_body', 'content' ); |
| 571 | + $body = strtr( $body, $keys ); |
| 572 | + $body = MessageCache::singleton()->transform( $body, false, null, $this->title ); |
| 573 | + $this->body = wordwrap( $body, 72 ); |
| 574 | + |
581 | 575 | # Reveal the page editor's address as REPLY-TO address only if |
582 | 576 | # the user has not opted-out and the option is enabled at the |
583 | 577 | # global configuration level. |
584 | | - $editor = $this->editor; |
585 | | - $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName(); |
586 | 578 | $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName ); |
587 | | - $editorAddress = new MailAddress( $editor ); |
588 | 579 | if ( $wgEnotifRevealEditorAddress |
589 | | - && ( $editor->getEmail() != '' ) |
590 | | - && $editor->getOption( 'enotifrevealaddr' ) ) { |
| 580 | + && ( $this->editor->getEmail() != '' ) |
| 581 | + && $this->editor->getOption( 'enotifrevealaddr' ) ) |
| 582 | + { |
| 583 | + $editorAddress = new MailAddress( $this->editor ); |
591 | 584 | if ( $wgEnotifFromEditor ) { |
592 | | - $from = $editorAddress; |
| 585 | + $this->from = $editorAddress; |
593 | 586 | } else { |
594 | | - $from = $adminAddress; |
595 | | - $replyto = $editorAddress; |
| 587 | + $this->from = $adminAddress; |
| 588 | + $this->replyto = $editorAddress; |
596 | 589 | } |
597 | 590 | } else { |
598 | | - $from = $adminAddress; |
599 | | - $replyto = new MailAddress( $wgNoReplyAddress ); |
| 591 | + $this->from = $adminAddress; |
| 592 | + $this->replyto = new MailAddress( $wgNoReplyAddress ); |
600 | 593 | } |
601 | | - |
602 | | - if ( $editor->isAnon() ) { |
603 | | - # real anon (user:xxx.xxx.xxx.xxx) |
604 | | - $utext = wfMsgForContent( 'enotif_anon_editor', $name ); |
605 | | - $subject = str_replace( '$PAGEEDITOR', $utext, $subject ); |
606 | | - $keys['$PAGEEDITOR'] = $utext; |
607 | | - $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' ); |
608 | | - } else { |
609 | | - $subject = str_replace( '$PAGEEDITOR', $name, $subject ); |
610 | | - $keys['$PAGEEDITOR'] = $name; |
611 | | - $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name ); |
612 | | - $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl(); |
613 | | - } |
614 | | - $userPage = $editor->getUserPage(); |
615 | | - $keys['$PAGEEDITOR_WIKI'] = $userPage->getCanonicalUrl(); |
616 | | - $body = strtr( $body, $keys ); |
617 | | - $body = wordwrap( $body, 72 ); |
618 | | - |
619 | | - # now save this as the constant user-independent part of the message |
620 | | - $this->from = $from; |
621 | | - $this->replyto = $replyto; |
622 | | - $this->subject = $subject; |
623 | | - $this->body = $body; |
624 | 594 | } |
625 | 595 | |
626 | 596 | /** |
Property changes on: branches/wmf/1.18wmf1/includes |
___________________________________________________________________ |
Modified: svn:mergeinfo |
627 | 597 | Merged /branches/REL1_18/phase3/includes:r107920 |
Property changes on: branches/wmf/1.18wmf1 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
628 | 598 | Merged /branches/REL1_18/phase3:r107920 |