w/s diff. mostly eol w/s and using only tabs of width 4 to indent.
[lhc/web/wiklou.git] / includes / specials / SpecialEmailuser.php
index c512044..098d936 100644 (file)
  */
 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',
@@ -49,15 +49,14 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        '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',
                                'id' => 'mw-emailuser-recipient',
                        ),
                        'Target' => array(
-                               'name' => 'wpTarget',
                                'type' => 'hidden',
                                'default' => $this->mTargetObj->getName(),
                        ),
@@ -83,17 +82,18 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        ),
                );
        }
-       
+
        public function execute( $par ) {
                global $wgRequest, $wgOut, $wgUser;
 
                $this->setHeaders();
                $this->outputHeader();
+               $wgOut->addModuleStyles( 'mediawiki.special' );
 
                $this->mTarget = is_null( $par )
-                       ? $wgRequest->getVal( 'wpTarget', '' )
+                       ? $wgRequest->getVal( 'wpTarget', $wgRequest->getVal( 'target', '' ) )
                        : $par;
-                       
+
                $ret = self::getTarget( $this->mTarget );
                if( $ret instanceof User ){
                        $this->mTargetObj = $ret;
@@ -101,7 +101,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        $wgOut->showErrorPage( "{$ret}title", "{$ret}text" );
                        return false;
                }
-       
+
                $error = self::getPermissionsError( $wgUser, $wgRequest->getVal( 'wpEditToken' ) );
                switch ( $error ) {
                        case null:
@@ -126,7 +126,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                                $wgOut->showErrorPage( $title, $msg, $params );
                                return;
                }
-               
+
                $form = new HTMLForm( $this->getFormFields() );
                $form->addPreText( wfMsgExt( 'emailpagetext', 'parseinline' ) );
                $form->setSubmitText( wfMsg( 'emailsend' ) );
@@ -134,14 +134,14 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                $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' );
@@ -160,7 +160,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        wfDebug( "Target is empty.\n" );
                        return 'notarget';
                }
-               
+
                $nu = User::newFromName( $target );
                if( !$nu instanceof User || !$nu->getId() ) {
                        wfDebug( "Target is invalid user.\n" );
@@ -188,11 +188,11 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                if( !$wgEnableEmail || !$wgEnableUserEmail ){
                        return 'usermaildisabled';
                }
-               
+
                if( !$user->isAllowed( 'sendemail' ) ) {
                        return 'badaccess';
                }
-               
+
                if( !$user->isEmailConfirmed() ){
                        return 'mailnologin';
                }
@@ -219,10 +219,11 @@ class SpecialEmailUser extends UnlistedSpecialPage {
 
        /**
         * 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: True on success, String on error
+        * @return Mixed: Status object, or potentially a String on error
+        * or maybe even true on success if anything uses the EmailUser hook.
         */
        public static function submit( $data ) {
                global $wgUser, $wgUserEmailUseReplyTo;
@@ -238,17 +239,17 @@ class SpecialEmailUser extends UnlistedSpecialPage {
 
                // 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.
@@ -283,12 +284,12 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        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 ) );