Merge fixes to ?preload= from /branches/conrad/ (cf. bug 5210, r62864, r62035)
[lhc/web/wiklou.git] / includes / specials / SpecialResetpass.php
index f585612..967d211 100644 (file)
@@ -37,6 +37,11 @@ class SpecialResetpass extends SpecialPage {
                        return;
                }
 
+               if( $wgRequest->wasPosted() && $wgRequest->getBool( 'wpCancel' ) ) {
+                       $this->doReturnTo();
+                       return;
+               }
+
                if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('token') ) ) {
                        try {
                                $this->attemptReset( $this->mNewpass, $this->mRetype );
@@ -54,17 +59,22 @@ class SpecialResetpass extends SpecialPage {
                                        $login = new LoginForm( new FauxRequest( $data, true ) );
                                        $login->execute();
                                }
-                               $titleObj = Title::newFromText( $wgRequest->getVal( 'returnto' ) );
-                               if ( !$titleObj instanceof Title ) {
-                                       $titleObj = Title::newMainPage();
-                               }
-                               $wgOut->redirect( $titleObj->getFullURL() );
+                               $this->doReturnTo();
                        } catch( PasswordError $e ) {
                                $this->error( $e->getMessage() );
                        }
                }
                $this->showForm();
        }
+       
+       function doReturnTo() {
+               global $wgRequest, $wgOut;
+               $titleObj = Title::newFromText( $wgRequest->getVal( 'returnto' ) );
+               if ( !$titleObj instanceof Title ) {
+                       $titleObj = Title::newMainPage();
+               }
+               $wgOut->redirect( $titleObj->getFullURL() );
+       }
 
        function error( $msg ) {
                global $wgOut;
@@ -119,6 +129,7 @@ class SpecialResetpass extends SpecialPage {
                                "<td></td>\n" .
                                '<td class="mw-input">' .
                                        Xml::submitButton( wfMsg( $submitMsg ) ) .
+                                       Xml::submitButton( wfMsg( 'resetpass-submit-cancel' ), array( 'name' => 'wpCancel' ) ) .
                                "</td>\n" .
                        "</tr>\n" .
                        Xml::closeElement( 'table' ) .
@@ -128,8 +139,6 @@ class SpecialResetpass extends SpecialPage {
        }
 
        function pretty( $fields ) {
-               global $wgMinimalPasswordLength;
-
                $out = '';
                foreach ( $fields as $list ) {
                        list( $name, $label, $type, $value ) = $list;
@@ -137,14 +146,9 @@ class SpecialResetpass extends SpecialPage {
                                $field = htmlspecialchars( $value );
                        } else {
                                $attribs = array( 'id' => $name );
-                               # The current password field is never required; it's possible
-                               # that existing users might have empty passwords on any wiki.
-                               # The two other password fields are required if
-                               # $wgMinimalPasswordLength > 0 (not allowed to set an empty
-                               # password).
-                               if ( ( $name == 'wpNewPassword' || $name == 'wpRetype' )
-                               && $wgMinimalPasswordLength > 0 ) {
-                                       $attribs[] = 'required';
+                               if ( $name == 'wpNewPassword' || $name == 'wpRetype' ) {
+                                       $attribs = array_merge( $attribs,
+                                               User::passwordChangeInputAttribs() );
                                }
                                if ( $name == 'wpPassword' ) {
                                        $attribs[] = 'autofocus';