SpecialChangeEmail: error if old email was entered in new email field
[lhc/web/wiklou.git] / includes / specials / SpecialChangeEmail.php
index 674cbc8..22df04e 100644 (file)
@@ -92,14 +92,14 @@ class SpecialChangeEmail extends FormSpecialPage {
                        'NewEmail' => array(
                                'type' => 'email',
                                'label-message' => 'changeemail-newemail',
+                               'autofocus' => true
                        ),
                );
 
                if ( $this->getConfig()->get( 'RequirePasswordforEmailChange' ) ) {
                        $fields['Password'] = array(
                                'type' => 'password',
-                               'label-message' => 'changeemail-password',
-                               'autofocus' => true,
+                               'label-message' => 'changeemail-password'
                        );
                }
 
@@ -107,7 +107,7 @@ class SpecialChangeEmail extends FormSpecialPage {
        }
 
        protected function getDisplayFormat() {
-               return 'vform';
+               return 'ooui';
        }
 
        protected function alterForm( HTMLForm $form ) {
@@ -129,7 +129,8 @@ class SpecialChangeEmail extends FormSpecialPage {
        public function onSuccess() {
                $request = $this->getRequest();
 
-               $titleObj = Title::newFromText( $request->getVal( 'returnto' ) );
+               $returnto = $request->getVal( 'returnto' );
+               $titleObj = $returnto !== null ? Title::newFromText( $returnto ) : null;
                if ( !$titleObj instanceof Title ) {
                        $titleObj = Title::newMainPage();
                }
@@ -141,7 +142,8 @@ class SpecialChangeEmail extends FormSpecialPage {
                        # Notify user that a confirmation email has been sent...
                        $this->getOutput()->wrapWikiMsg( "<div class='error' style='clear: both;'>\n$1\n</div>",
                                'eauthentsent', $this->getUser()->getName() );
-                       $this->getOutput()->addReturnTo( $titleObj, wfCgiToArray( $query ) ); // just show the link to go back
+                       // just show the link to go back
+                       $this->getOutput()->addReturnTo( $titleObj, wfCgiToArray( $query ) );
                }
        }
 
@@ -158,6 +160,10 @@ class SpecialChangeEmail extends FormSpecialPage {
                        return Status::newFatal( 'invalidemailaddress' );
                }
 
+               if ( $newaddr === $user->getEmail() ) {
+                       return Status::newFatal( 'changeemail-nochange' );
+               }
+
                $throttleCount = LoginForm::incLoginThrottle( $user->getName() );
                if ( $throttleCount === true ) {
                        $lang = $this->getLanguage();