Merge "Follow-up I087c2729 (750936f): factorise common code"
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index f80e7da..dda159c 100644 (file)
@@ -559,7 +559,7 @@ class LoginForm extends SpecialPage {
                }
 
                $isAutoCreated = false;
-               if ( 0 == $u->getID() ) {
+               if ( $u->getID() == 0 ) {
                        $status = $this->attemptAutoCreate( $u );
                        if ( $status !== self::SUCCESS ) {
                                return $status;
@@ -569,8 +569,9 @@ class LoginForm extends SpecialPage {
                } else {
                        global $wgExternalAuthType, $wgAutocreatePolicy;
                        if ( $wgExternalAuthType && $wgAutocreatePolicy != 'never'
-                       && is_object( $this->mExtUser )
-                       && $this->mExtUser->authenticate( $this->mPassword ) ) {
+                               && is_object( $this->mExtUser )
+                               && $this->mExtUser->authenticate( $this->mPassword )
+                       ) {
                                # The external user and local user have the same name and
                                # password, so we assume they're the same.
                                $this->mExtUser->linkToLocal( $u->getID() );
@@ -855,7 +856,7 @@ class LoginForm extends SpecialPage {
         * @return Status object
         */
        function mailPasswordInternal( $u, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) {
-               global $wgServer, $wgScript, $wgNewPasswordExpiry;
+               global $wgCanonicalServer, $wgScript, $wgNewPasswordExpiry;
 
                if ( $u->getEmail() == '' ) {
                        return Status::newFatal( 'noemail', $u->getName() );
@@ -872,7 +873,7 @@ class LoginForm extends SpecialPage {
                $u->setNewpassword( $np, $throttle );
                $u->saveSettings();
                $userLanguage = $u->getOption( 'language' );
-               $m = $this->msg( $emailText, $ip, $u->getName(), $np, '<' . $wgServer . $wgScript . '>',
+               $m = $this->msg( $emailText, $ip, $u->getName(), $np, '<' . $wgCanonicalServer . $wgScript . '>',
                        round( $wgNewPasswordExpiry / 86400 ) )->inLanguage( $userLanguage )->text();
                $result = $u->sendMail( $this->msg( $emailTitle )->inLanguage( $userLanguage )->text(), $m );
 
@@ -897,7 +898,8 @@ class LoginForm extends SpecialPage {
                wfRunHooks( 'UserLoginComplete', array( &$currentUser, &$injected_html ) );
 
                if( $injected_html !== '' ) {
-                       $this->displaySuccessfulLogin( 'loginsuccess', $injected_html );
+                       $this->displaySuccessfulAction( $this->msg( 'loginsuccesstitle' ),
+                               'loginsuccess', $injected_html );
                } else {
                        $this->executeReturnTo( 'successredirect' );
                }
@@ -924,18 +926,21 @@ class LoginForm extends SpecialPage {
                 */
                wfRunHooks( 'BeforeWelcomeCreation', array( &$welcome_creation_msg, &$injected_html ) );
 
-               $this->displaySuccessfulLogin( $welcome_creation_msg, $injected_html );
+               $this->displaySuccessfulAction( $this->msg( 'welcomeuser', $this->getUser()->getName() ),
+                       $welcome_creation_msg, $injected_html );
        }
 
        /**
-        * Display a "login successful" page.
+        * Display an "successful action" page.
+        *
+        * @param $title string|Message page's title
         * @param $msgname string
         * @param $injected_html string
         */
-       private function displaySuccessfulLogin( $msgname, $injected_html ) {
+       private function displaySuccessfulAction( $title, $msgname, $injected_html ) {
                $out = $this->getOutput();
-               $out->setPageTitle( $this->msg( 'loginsuccesstitle' ) );
-               if( $msgname ){
+               $out->setPageTitle( $title );
+               if ( $msgname ) {
                        $out->addWikiMsg( $msgname, wfEscapeWikiText( $this->getUser()->getName() ) );
                }