Temporarily revert 14847; makes incompatible changes to message strings.
[lhc/web/wiklou.git] / includes / SpecialUserlogin.php
index caedffb..6a549e2 100644 (file)
@@ -135,27 +135,40 @@ class LoginForm {
         */
        function addNewAccount() {
                global $wgUser, $wgEmailAuthentication;
-
+               
+               # Create the account and abort if there's a problem doing so
                $u = $this->addNewAccountInternal();
-
-               if ($u == NULL) {
+               if( $u == NULL )
                        return;
-               }
-
-               $wgUser = $u;
-               $wgUser->setCookies();
-
-               $wgUser->saveSettings();
-               if( $wgEmailAuthentication && $wgUser->isValidEmailAddr( $wgUser->getEmail() ) ) {
-                       $wgUser->sendConfirmationMail();
-               }
-
-               wfRunHooks( 'AddNewAccount', array( $u ) );
-
-               if( $this->hasSessionCookie() ) {
-                       return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
+                       
+               # Save user settings and send out an email authentication message if needed
+               $u->saveSettings();
+               if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) )
+                       $u->sendConfirmationMail();
+                       
+               # If not logged in, assume the new account as the current one and set session cookies
+               # then show a "welcome" message or a "need cookies" message as needed
+               if( $wgUser->isAnon() ) {
+                       $wgUser = $u;
+                       $wgUser->setCookies();
+                       wfRunHooks( 'AddNewAccount', array( $wgUser ) );
+                       if( $this->hasSessionCookie() ) {
+                               return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
+                       } else {
+                               return $this->cookieRedirectCheck( 'new' );
+                       }
                } else {
-                       return $this->cookieRedirectCheck( 'new' );
+                       # Confirm that the account was created
+                       global $wgOut;
+                       $skin = $wgUser->getSkin();
+                       $self = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
+                       $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
+                       $wgOut->setArticleRelated( false );
+                       $wgOut->setRobotPolicy( 'noindex,nofollow' );
+                       $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
+                       $wgOut->returnToMain( $self->getPrefixedText() );
+                       wfRunHooks( 'AddNewAccount', array( $u ) );
+                       return true;
                }
        }
 
@@ -351,6 +364,14 @@ class LoginForm {
         * @private
         */
        function mailPassword() {
+               global $wgUser, $wgOut;
+               
+               # Check against the rate limiter
+               if( $wgUser->pingLimiter( 'mailpassword' ) ) {
+                       $wgOut->rateLimited();
+                       return;
+               }
+       
                if ( '' == $this->mName ) {
                        $this->mainLoginForm( wfMsg( 'noname' ) );
                        return;
@@ -382,6 +403,7 @@ class LoginForm {
         */
        function mailPasswordInternal( $u ) {
                global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure;
+               global $wgServer, $wgScript;
 
                if ( '' == $u->getEmail() ) {
                        return wfMsg( 'noemail', $u->getName() );
@@ -397,7 +419,7 @@ class LoginForm {
                $ip = wfGetIP();
                if ( '' == $ip ) { $ip = '(Unknown)'; }
 
-               $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np );
+               $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np, $wgServer . $wgScript );
 
                $result = $u->sendMail( wfMsg( 'passwordremindertitle' ), $m );
                return $result;
@@ -450,6 +472,11 @@ class LoginForm {
                global $wgCookiePrefix;
                global $wgAuth;
 
+               if ( $this->mType == 'signup' && !$wgUser->isAllowedToCreateAccount() ) {
+                       $this->userNotPrivilegedMessage();
+                       return;
+               }
+
                if ( '' == $this->mName ) {
                        if ( $wgUser->isLoggedIn() ) {
                                $this->mName = $wgUser->getName();
@@ -502,7 +529,6 @@ class LoginForm {
                $template->set( 'action', $titleObj->getLocalUrl( $q ) );
                $template->set( 'message', $msg );
                $template->set( 'messagetype', $msgtype );
-               $template->set( 'create', $wgUser->isAllowedToCreateAccount() );
                $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
                $template->set( 'userealname', $wgAllowRealName );
                $template->set( 'useemail', $wgEnableEmail );