/** * Update in session the values related to user login; * @param object tNG transaction object * @return nothing * @access public */ function Trigger_Update_RefreshSession(&$tNG) { if (is_array($GLOBALS['tNG_login_config_session'])) { KT_session_start(); if (isset($_SESSION['kt_login_id'])) { $session_pk_field = $GLOBALS['tNG_login_config_session']['kt_login_id']; $session_pk_value = $_SESSION['kt_login_id']; $pk_field = $tNG->getPrimaryKey(); $pk_value = $tNG->getPrimaryKeyValue(); if ($pk_field != '' && $session_pk_field == $pk_field && $pk_value != '' && $session_pk_value == $pk_value) { $ses_arr = $GLOBALS['tNG_login_config_session']; foreach ($ses_arr as $ses_name => $ses_value) { if (isset($tNG->columns[$ses_value])) { $value = $tNG->getColumnValue($ses_value); $_SESSION[$ses_name] = $value; KT_setSessionVar($ses_name); } } } } } return null; }
/** * Main method of the class. grant the access to the page or make the redirect page setted in control panel * @return mix null or error object * @access public */ function Execute() { tNG_cookieLogin($this->connection); // access denied defaults to "redirect_failed" specified in Login Config $grantAccess = false; $redirect_page = $GLOBALS['tNG_login_config']['redirect_failed']; tNG_clearSessionVars(); if (isset($_SESSION['kt_login_user'])) { if (count($this->levels) > 0) { if (isset($_SESSION['kt_login_level'])) { if (in_array($_SESSION['kt_login_level'], $this->levels)) { $grantAccess = true; } else { // acceess denied. check for level default redirect pages if (is_array($GLOBALS['tNG_login_config_redirect_failed']) && array_key_exists($_SESSION['kt_login_level'], $GLOBALS['tNG_login_config_redirect_failed']) and $GLOBALS['tNG_login_config_redirect_failed'][$_SESSION['kt_login_level']] != "") { $redirect_page = $GLOBALS['tNG_login_config_redirect_failed'][$_SESSION['kt_login_level']]; } else { // the failure page for the current user level is not defined.. so fall back to default $redirect_page = $GLOBALS['tNG_login_config']['redirect_failed']; } } } // if levels are required, and the current user doesn't have one.. access is denied } else { // no levels are required for this page access // the user is logged in, so grant the access $grantAccess = true; } } if (!$grantAccess) { // save the accessed page into a session for later use $_SESSION['KT_denied_pageuri'] = KT_getFullUri(); KT_setSessionVar('KT_denied_pageuri'); $_SESSION['KT_denied_pagelevels'] = $this->levels; KT_setSessionVar('KT_denied_pagelevels'); if (isset($_SESSION['KT_max_tries_error'])) { $redirect_page = KT_addReplaceParam($redirect_page, 'info', 'MAXTRIES'); } else { if (isset($_SESSION['KT_account_expire_error'])) { $redirect_page = KT_addReplaceParam($redirect_page, 'info', 'ACCOUNT_EXPIRE'); } else { $redirect_page = KT_addReplaceParam($redirect_page, 'info', 'DENIED'); } } KT_redir($this->relPath . $redirect_page); } else { // clear the sessions used for redirect ?? } }