Remove spaces between parentheses in function calls
[lhc/web/wiklou.git] / includes / specials / SpecialEmailuser.php
index 2ab02cb..b5ad589 100644 (file)
@@ -33,6 +33,15 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                parent::__construct( 'Emailuser' );
        }
 
+       public function getDescription() {
+               $target = self::getTarget( $this->mTarget );
+               if( !$target instanceof User ) {
+                       return $this->msg( 'emailuser-title-notarget' )->text();
+               }
+
+               return $this->msg( 'emailuser-title-target', $target->getName() )->text();
+       }
+
        protected function getFormFields() {
                return array(
                        'From' => array(
@@ -66,14 +75,14 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                                'label-message' => 'emailsubject',
                                'maxlength' => 200,
                                'size' => 60,
-                               'required' => 1,
+                               'required' => true,
                        ),
                        'Text' => array(
                                'type' => 'textarea',
                                'rows' => 20,
                                'cols' => 80,
                                'label-message' => 'emailmessage',
-                               'required' => 1,
+                               'required' => true,
                        ),
                        'CCMe' => array(
                                'type' => 'check',
@@ -84,13 +93,18 @@ class SpecialEmailUser extends UnlistedSpecialPage {
        }
 
        public function execute( $par ) {
-               $this->setHeaders();
-               $this->outputHeader();
                $out = $this->getOutput();
                $out->addModuleStyles( 'mediawiki.special' );
+
                $this->mTarget = is_null( $par )
                        ? $this->getRequest()->getVal( 'wpTarget', $this->getRequest()->getVal( 'target', '' ) )
                        : $par;
+
+               // This needs to be below assignment of $this->mTarget because
+               // getDescription() needs it to determine the correct page title.
+               $this->setHeaders();
+               $this->outputHeader();
+
                // error out if sending user cannot do this
                $error = self::getPermissionsError( $this->getUser(), $this->getRequest()->getVal( 'wpEditToken' ) );
                switch ( $error ) {
@@ -125,7 +139,8 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                $this->mTargetObj = $ret;
 
                $form = new HTMLForm( $this->getFormFields(), $this->getContext() );
-               $form->addPreText( $this->msg( 'emailpagetext' )->parse() );
+               // By now we are supposed to be sure that $this->mTarget is a user name
+               $form->addPreText( $this->msg( 'emailpagetext', $this->mTarget )->parse() );
                $form->setSubmitTextMsg( 'emailsend' );
                $form->setTitle( $this->getTitle() );
                $form->setSubmitCallback( array( __CLASS__, 'uiSubmit' ) );
@@ -136,7 +151,6 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        return false;
                }
 
-               $out->setPageTitle( $this->msg( 'emailpage' ) );
                $result = $form->show();
 
                if( $result === true || ( $result instanceof Status && $result->isGood() ) ) {
@@ -149,7 +163,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
        /**
         * Validate target User
         *
-        * @param $target String: target user name
+        * @param string $target target user name
         * @return User object on success or a string on error
         */
        public static function getTarget( $target ) {
@@ -177,7 +191,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
         * Check whether a user is allowed to send email
         *
         * @param $user User object
-        * @param $editToken String: edit token
+        * @param string $editToken edit token
         * @return null on success or string on error
         */
        public static function getPermissionsError( $user, $editToken ) {
@@ -217,7 +231,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
        /**
         * Form to ask for target user name.
         *
-        * @param $name String: user name submitted.
+        * @param string $name user name submitted.
         * @return String: form asking for user name.
         */
        protected function userForm( $name ) {
@@ -323,4 +337,8 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        return $status;
                }
        }
+
+       protected function getGroupName() {
+               return 'users';
+       }
 }