Changeset 1200

Show
Ignore:
Timestamp:
08/03/2008 11:44:32 PM (2 years ago)
Author:
DotMG
Message:

refs #245

backporting [248] and [253] to milestone:1.1.6.6

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.1.6.6/actions/usersettings.php

    r868 r1200  
    9999if (!defined('RETRIEVE_PASSWORD_MESSAGE')) define('RETRIEVE_PASSWORD_MESSAGE', "If you need a password reminder, click [[PasswordForgotten here]]. --- You can login here using your password reminder."); 
    100100if (!defined('TEMP_PASSWORD_LABEL')) define('TEMP_PASSWORD_LABEL', "Password reminder:"); 
     101if (!defined('USERSETTINGS_REDIRECT_AFTER_LOGIN_LABEL')) define('USERSETTINGS_REDIRECT_AFTER_LOGIN_LABEL', 'Redirect to %s after login');       // %s page to redirect to 
    101102 
    102103//initialize variables 
     
    133134$params = ($this->config['rewrite_mode'] == 1) ? '?' : '&'; 
    134135 
     136$regex_referrer = '@^'.preg_quote($this->config['base_url'], '@').'([^\/\?&]*)@i'; 
     137if (isset($_SERVER['HTTP_REFERER']) && preg_match($regex_referrer, $_SERVER['HTTP_REFERER'], $match)) 
     138{ 
     139        if (strcasecmp($this->tag, $match[1])) 
     140        { 
     141                $_SESSION['go_back'] = $_SERVER['HTTP_REFERER']; 
     142                //We save the tag of the referring page, this tag is to be shown in label <Go back to ...>. We must use a session here because if the user  
     143                //Refresh the page by hitting <Enter> on the address bar, the value would be lost. 
     144                $_SESSION['go_back_tag'] = $match[1]; 
     145        } 
     146} 
     147 
    135148// BEGIN *** Logout *** 
    136149// is user trying to log out? 
     
    404417                                default: 
    405418                                        $this->SetUser($existingUser); 
    406                                         $this->Redirect($url, ''); 
     419                                        if ((isset($_SESSION['go_back'])) && (isset($_POST['do_redirect']))) 
     420                                        { 
     421                                                $go_back = $_SESSION['go_back']; 
     422                                                unset($_SESSION['go_back']); 
     423                                                unset($_SESSION['go_back_tag']); 
     424                                                $this->Redirect($go_back); 
     425                                        } 
     426                                        else 
     427                                        { 
     428                                                $this->Redirect($url, ''); 
     429                                        } 
    407430                        } 
    408431                } 
     
    487510                                // log in 
    488511                                $this->SetUser($this->LoadUser($name)); 
    489                                 $params .= 'registered=true'; 
    490                                 $this->Redirect($url.$params); 
     512                                if ((isset($_SESSION['go_back'])) && (isset($_POST['do_redirect']))) 
     513                                { 
     514                                        $go_back = $_SESSION['go_back']; 
     515                                        unset($_SESSION['go_back']); 
     516                                        unset($_SESSION['go_back_tag']); 
     517                                        $this->Redirect($go_back); 
     518                                } 
     519                                else 
     520                                { 
     521                                        $params .= 'registered=true'; 
     522                                        $this->Redirect($url.$params); 
     523                                } 
    491524                } 
    492525                // END *** Register *** 
     
    561594                <td><input <?php echo $password_highlight; ?> type="password" name="password" size="40" /></td> 
    562595        </tr> 
     596        <?php 
     597                if (isset($_SESSION['go_back'])) 
     598                { 
     599                ?> 
     600        <tr> 
     601                <td align="right"><?php printf(USERSETTINGS_REDIRECT_AFTER_LOGIN_LABEL, $_SESSION['go_back_tag']); ?></td> 
     602                <td><input type='checkbox' name='do_redirect' id='do_redirect'<?php if(isset($_POST['do_redirect']) || empty($_POST)) echo 'checked="checked"'; ?> /> 
     603        </tr> 
     604        <?php 
     605                } 
     606        ?> 
    563607        <tr> 
    564608                <td>&nbsp;</td>