<?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
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 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;
'id' => 'mw-emailuser-recipient',
),
'Target' => array(
- 'name' => 'wpTarget',
'type' => 'hidden',
'default' => $this->mTargetObj->getName(),
),
public function execute( $par ) {
global $wgRequest, $wgOut, $wgUser;
+
+ $this->setHeaders();
+ $this->outputHeader();
+
$this->mTarget = is_null( $par )
? $wgRequest->getVal( 'wpTarget', '' )
: $par;
$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() );
* @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 ){
// 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.
$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
$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;
}
}
}