X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialEmailuser.php;h=7c3d5c1e383e206c0f7578457362942c83c59223;hb=1731f820159cf99865e791e2d40fbad687b1e491;hp=59b105154b103d2f1c619c6895fc670518fb7cb8;hpb=7b229a2047bb04443486f1a8864ced4ae58ff36a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 59b105154b..7c3d5c1e38 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -1,5 +1,6 @@ 'mw-emailuser-recipient', ), 'Target' => array( - 'name' => 'wpTarget', 'type' => 'hidden', 'default' => $this->mTargetObj->getName(), ), @@ -82,6 +85,10 @@ class SpecialEmailUser extends UnlistedSpecialPage { public function execute( $par ) { global $wgRequest, $wgOut, $wgUser; + + $this->setHeaders(); + $this->outputHeader(); + $this->mTarget = is_null( $par ) ? $wgRequest->getVal( 'wpTarget', '' ) : $par; @@ -134,7 +141,7 @@ class SpecialEmailUser extends UnlistedSpecialPage { $wgOut->setPagetitle( wfMsg( 'emailpage' ) ); $result = $form->show(); - if( $result === true ){ + if( $result === true || ( $result instanceof Status && $result->isGood() ) ){ $wgOut->setPagetitle( wfMsg( 'emailsent' ) ); $wgOut->addWikiMsg( 'emailsenttext' ); $wgOut->returnToMain( false, $this->mTargetObj->getUserPage() ); @@ -217,7 +224,7 @@ class SpecialEmailUser extends UnlistedSpecialPage { * @return Mixed: True on success, String on error */ public static function submit( $data ) { - global $wgUser, $wgUserEmailUseReplyTo, $wgSiteName; + global $wgUser, $wgUserEmailUseReplyTo; $target = self::getTarget( $data['Target'] ); if( !$target instanceof User ){ @@ -248,8 +255,8 @@ class SpecialEmailUser extends UnlistedSpecialPage { // This is a bit ugly, but will serve to differentiate // wiki-borne mails from direct mails and protects against // SPF and bounce problems with some mailers (see below). - global $wgPasswordSender; - $mailFrom = new MailAddress( $wgPasswordSender ); + global $wgPasswordSender, $wgPasswordSenderName; + $mailFrom = new MailAddress( $wgPasswordSender, $wgPasswordSenderName ); $replyTo = $from; } else { // Put the sending user's e-mail address in the From: header. @@ -269,10 +276,10 @@ class SpecialEmailUser extends UnlistedSpecialPage { $replyTo = null; } - $mailResult = UserMailer::send( $to, $mailFrom, $subject, $text, $replyTo ); + $status = UserMailer::send( $to, $mailFrom, $subject, $text, $replyTo ); - if( WikiError::isError( $mailResult ) && false ) { - return $mailResult->getMessage(); + if( !$status->isGood() ) { + return $status; } else { // if the user requested a copy of this mail, do this now, // unless they are emailing themselves, in which case one @@ -284,20 +291,12 @@ class SpecialEmailUser extends UnlistedSpecialPage { $subject ); wfRunHooks( 'EmailUserCC', array( &$from, &$from, &$cc_subject, &$text ) ); - $ccResult = UserMailer::send( $from, $from, $cc_subject, $text ); - if( WikiError::isError( $ccResult ) ) { - // At this stage, the user's CC mail has failed, but their - // original mail has succeeded. It's unlikely, but still, - // what to do? We can either show them an error, or we can - // say everything was fine, or we can say we sort of failed - // AND sort of succeeded. Of these options, simply saying - // there was an error is probably best. - return $ccResult->getMessage(); - } + $ccStatus = UserMailer::send( $from, $from, $cc_subject, $text ); + $status->merge( $ccStatus ); } wfRunHooks( 'EmailUserComplete', array( $to, $from, $subject, $text ) ); - return true; + return $status; } } }