Followup r68129: rename UndeleteForm to SpecialUndelete per CR. Not used in any exten...
[lhc/web/wiklou.git] / includes / specials / SpecialEmailuser.php
index 0e4a55d..7c3d5c1 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 /**
+ * Implements Special:Emailuser
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
  */
 
 /**
- * @file
+ * A special page that allows users to send e-mails to other users
+ *
  * @ingroup SpecialPage
  */
-
 class SpecialEmailUser extends UnlistedSpecialPage {
        protected $mTarget;
        
@@ -53,7 +57,6 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                                'id' => '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() );
@@ -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;
                }
        }
 }