Merge "Revert "Use display name in category page subheadings if provided""
[lhc/web/wiklou.git] / includes / specials / SpecialEmailuser.php
index 80ef4b1..06be7bc 100644 (file)
@@ -154,6 +154,10 @@ class SpecialEmailUser extends UnlistedSpecialPage {
 
                $this->mTargetObj = $ret;
 
+               // Set the 'relevant user' in the skin, so it displays links like Contributions,
+               // User logs, UserRights, etc.
+               $this->getSkin()->setRelevantUser( $this->mTargetObj );
+
                $context = new DerivativeContext( $this->getContext() );
                $context->setTitle( $this->getPageTitle() ); // Remove subpage
                $form = new HTMLForm( $this->getFormFields(), $context );
@@ -265,28 +269,32 @@ class SpecialEmailUser extends UnlistedSpecialPage {
         */
        protected function userForm( $name ) {
                $this->getOutput()->addModules( 'mediawiki.userSuggest' );
-               $string = Xml::openElement(
-                       'form',
-                       [ 'method' => 'get', 'action' => wfScript(), 'id' => 'askusername' ]
-               ) .
+               $string = Html::openElement(
+                               'form',
+                               [ 'method' => 'get', 'action' => wfScript(), 'id' => 'askusername' ]
+                       ) .
                        Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
-                       Xml::openElement( 'fieldset' ) .
+                       Html::openElement( 'fieldset' ) .
                        Html::rawElement( 'legend', null, $this->msg( 'emailtarget' )->parse() ) .
-                       Xml::inputLabel(
+                       Html::label(
                                $this->msg( 'emailusername' )->text(),
+                               'emailusertarget'
+                       ) . ' ' .
+                       Html::input(
                                'target',
-                               'emailusertarget',
-                               30,
                                $name,
+                               'text',
                                [
+                                       'id' => 'emailusertarget',
                                        'class' => 'mw-autocomplete-user',  // used by mediawiki.userSuggest
-                                       'autofocus' => '',
+                                       'autofocus' => true,
+                                       'size' => 30,
                                ]
                        ) .
                        ' ' .
-                       Xml::submitButton( $this->msg( 'emailusernamesubmit' )->text() ) .
-                       Xml::closeElement( 'fieldset' ) .
-                       Xml::closeElement( 'form' ) . "\n";
+                       Html::submitButton( $this->msg( 'emailusernamesubmit' )->text(), [] ) .
+                       Html::closeElement( 'fieldset' ) .
+                       Html::closeElement( 'form' ) . "\n";
 
                return $string;
        }
@@ -380,13 +388,29 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        // unless they are emailing themselves, in which case one
                        // copy of the message is sufficient.
                        if ( $data['CCMe'] && $to != $from ) {
-                               $cc_subject = $context->msg( 'emailccsubject' )->rawParams(
+                               $ccTo = $from;
+                               $ccFrom = $from;
+                               $ccSubject = $context->msg( 'emailccsubject' )->rawParams(
                                        $target->getName(), $subject )->text();
-
-                               // target and sender are equal, because this is the CC for the sender
-                               Hooks::run( 'EmailUserCC', [ &$from, &$from, &$cc_subject, &$text ] );
-
-                               $ccStatus = UserMailer::send( $from, $from, $cc_subject, $text );
+                               $ccText = $text;
+
+                               Hooks::run( 'EmailUserCC', [ &$ccTo, &$ccFrom, &$ccSubject, &$ccText ] );
+
+                               if ( $config->get( 'UserEmailUseReplyTo' ) ) {
+                                       $mailFrom = new MailAddress(
+                                               $config->get( 'PasswordSender' ),
+                                               wfMessage( 'emailsender' )->inContentLanguage()->text()
+                                       );
+                                       $replyTo = $ccFrom;
+                               } else {
+                                       $mailFrom = $ccFrom;
+                                       $replyTo = null;
+                               }
+
+                               $ccStatus = UserMailer::send(
+                                       $ccTo, $mailFrom, $ccSubject, $ccText, [
+                                               'replyTo' => $replyTo,
+                               ] );
                                $status->merge( $ccStatus );
                        }