*/
class SpecialEmailUser extends UnlistedSpecialPage {
protected $mTarget;
-
+
public function __construct(){
parent::__construct( 'Emailuser' );
}
-
+
protected function getFormFields(){
global $wgUser;
return array(
'From' => array(
'type' => 'info',
'raw' => 1,
- 'default' => $wgUser->getSkin()->link(
- $wgUser->getUserPage(),
- htmlspecialchars( $wgUser->getName() )
+ 'default' => $wgUser->getSkin()->link(
+ $wgUser->getUserPage(),
+ htmlspecialchars( $wgUser->getName() )
),
'label-message' => 'emailfrom',
'id' => 'mw-emailuser-sender',
'To' => array(
'type' => 'info',
'raw' => 1,
- 'default' => $wgUser->getSkin()->link(
- $this->mTargetObj->getUserPage(),
+ 'default' => $wgUser->getSkin()->link(
+ $this->mTargetObj->getUserPage(),
htmlspecialchars( $this->mTargetObj->getName() )
),
'label-message' => 'emailto',
),
);
}
-
+
public function execute( $par ) {
global $wgRequest, $wgOut, $wgUser;
$this->mTarget = is_null( $par )
? $wgRequest->getVal( 'wpTarget', $wgRequest->getVal( 'target', '' ) )
: $par;
-
+
$ret = self::getTarget( $this->mTarget );
if( $ret instanceof User ){
$this->mTargetObj = $ret;
$wgOut->showErrorPage( "{$ret}title", "{$ret}text" );
return false;
}
-
+
$error = self::getPermissionsError( $wgUser, $wgRequest->getVal( 'wpEditToken' ) );
switch ( $error ) {
case null:
$wgOut->showErrorPage( $title, $msg, $params );
return;
}
-
+
$form = new HTMLForm( $this->getFormFields() );
$form->addPreText( wfMsgExt( 'emailpagetext', 'parseinline' ) );
$form->setSubmitText( wfMsg( 'emailsend' ) );
$form->setSubmitCallback( array( __CLASS__, 'submit' ) );
$form->setWrapperLegend( wfMsgExt( 'email-legend', 'parsemag' ) );
$form->loadData();
-
+
if( !wfRunHooks( 'EmailUserForm', array( &$form ) ) ){
return false;
}
-
+
$wgOut->setPagetitle( wfMsg( 'emailpage' ) );
$result = $form->show();
-
+
if( $result === true || ( $result instanceof Status && $result->isGood() ) ){
$wgOut->setPagetitle( wfMsg( 'emailsent' ) );
$wgOut->addWikiMsg( 'emailsenttext' );
wfDebug( "Target is empty.\n" );
return 'notarget';
}
-
+
$nu = User::newFromName( $target );
if( !$nu instanceof User || !$nu->getId() ) {
wfDebug( "Target is invalid user.\n" );
if( !$wgEnableEmail || !$wgEnableUserEmail ){
return 'usermaildisabled';
}
-
+
if( !$user->isAllowed( 'sendemail' ) ) {
return 'badaccess';
}
-
+
if( !$user->isEmailConfirmed() ){
return 'mailnologin';
}
/**
* Really send a mail. Permissions should have been checked using
- * getPermissionsError(). It is probably also a good
+ * getPermissionsError(). It is probably also a good
* idea to check the edit token and ping limiter in advance.
*
* @return Mixed: Status object, or potentially a String on error
// Add a standard footer and trim up trailing newlines
$text = rtrim( $text ) . "\n\n-- \n";
- $text .= wfMsgExt(
+ $text .= wfMsgExt(
'emailuserfooter',
- array( 'content', 'parsemag' ),
- array( $from->name, $to->name )
+ array( 'content', 'parsemag' ),
+ array( $from->name, $to->name )
);
$error = '';
if( !wfRunHooks( 'EmailUser', array( &$to, &$from, &$subject, &$text, &$error ) ) ) {
return $error;
}
-
+
if( $wgUserEmailUseReplyTo ) {
// Put the generic wiki autogenerated address in the From:
// header and reserve the user for Reply-To.
return $status;
} else {
// if the user requested a copy of this mail, do this now,
- // unless they are emailing themselves, in which case one
+ // unless they are emailing themselves, in which case one
// copy of the message is sufficient.
if ( $data['CCMe'] && $to != $from ) {
$cc_subject = wfMsg(
- 'emailccsubject',
- $target->getName(),
+ 'emailccsubject',
+ $target->getName(),
$subject
);
wfRunHooks( 'EmailUserCC', array( &$from, &$from, &$cc_subject, &$text ) );