Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/session/session_storage.php
Show All 31 Lines | |||||
var $Expiration; | var $Expiration; | ||||
var $SessionTimeout = 0; | var $SessionTimeout = 0; | ||||
var $DirectVars = Array (); | var $DirectVars = Array (); | ||||
var $ChangedDirectVars = Array (); | var $ChangedDirectVars = Array (); | ||||
var $PersistentVars = Array (); | var $PersistentVars = Array (); | ||||
/** | |||||
* Default persistent vars | |||||
* | |||||
* @var array | |||||
*/ | |||||
protected $defaultPersistentVars = array(); | |||||
var $OriginalData = Array (); | var $OriginalData = Array (); | ||||
var $TimestampField; | var $TimestampField; | ||||
var $SessionDataTable; | var $SessionDataTable; | ||||
var $DataValueField; | var $DataValueField; | ||||
var $DataVarField; | var $DataVarField; | ||||
public function Init($prefix, $special) | public function Init($prefix, $special) | ||||
▲ Show 20 Lines • Show All 284 Lines • ▼ Show 20 Line(s) | |||||
@unlink($debug_file); | @unlink($debug_file); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
function LoadPersistentVars() | function LoadPersistentVars() | ||||
{ | { | ||||
$user_id = $this->Session->RecallVar('user_id'); | $user_id = $this->Session->RecallVar('user_id'); | ||||
if ($user_id != USER_GUEST) { | if ( $user_id != USER_GUEST ) { | ||||
// root & normal users | // Root & normal users. | ||||
$sql = 'SELECT VariableValue, VariableName | $this->PersistentVars = $this->getPersistentVars($user_id); | ||||
FROM '.TABLE_PREFIX.'UserPersistentSessionData | |||||
WHERE PortalUserId = '.$user_id; | |||||
$this->PersistentVars = (array)$this->Conn->GetCol($sql, 'VariableName'); | |||||
} | } | ||||
else { | else { | ||||
$this->PersistentVars = Array (); | $this->PersistentVars = Array (); | ||||
} | } | ||||
$default_user_id = (int)$this->Application->ConfigValue('DefaultSettingsUserId'); | |||||
if ( !$default_user_id ) { | |||||
$default_user_id = USER_ROOT; | |||||
} | |||||
if ( $user_id != $default_user_id ) { | |||||
$this->defaultPersistentVars = $this->getPersistentVars($default_user_id); | |||||
} | |||||
} | |||||
/** | |||||
* Get persistent vars | |||||
* | |||||
* @param integer $user_id User Id. | |||||
* | |||||
* @return array | |||||
*/ | |||||
protected function getPersistentVars($user_id) | |||||
{ | |||||
$sql = 'SELECT VariableValue, VariableName | |||||
FROM ' . TABLE_PREFIX . 'UserPersistentSessionData | |||||
WHERE PortalUserId = ' . $user_id; | |||||
return $this->Conn->GetCol($sql, 'VariableName'); | |||||
} | } | ||||
/** | /** | ||||
* Stores variable to persistent session | * Stores variable to persistent session | ||||
* | * | ||||
* @param string $var_name | * @param string $var_name | ||||
* @param mixed $var_value | * @param mixed $var_value | ||||
* @param bool $optional | * @param bool $optional | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
return $this->Session->RecallVar($var_name, $default); | return $this->Session->RecallVar($var_name, $default); | ||||
} | } | ||||
if ( array_key_exists($var_name, $this->PersistentVars) ) { | if ( array_key_exists($var_name, $this->PersistentVars) ) { | ||||
return $this->PersistentVars[$var_name]; | return $this->PersistentVars[$var_name]; | ||||
} | } | ||||
elseif ( $default == ALLOW_DEFAULT_SETTINGS ) { | elseif ( $default == ALLOW_DEFAULT_SETTINGS ) { | ||||
$default_user_id = $this->Application->ConfigValue('DefaultSettingsUserId'); | if ( isset($this->defaultPersistentVars[$var_name]) ) { | ||||
$value = $this->defaultPersistentVars[$var_name]; | |||||
$this->StorePersistentVar($var_name, $value); | |||||
if ( !$default_user_id ) { | return $value; | ||||
$default_user_id = USER_ROOT; | |||||
} | } | ||||
$sql = 'SELECT VariableValue, VariableName | $this->PersistentVars[$var_name] = false; | ||||
FROM ' . TABLE_PREFIX . 'UserPersistentSessionData | |||||
WHERE VariableName = ' . $this->Conn->qstr($var_name) . ' AND PortalUserId = ' . $default_user_id; | |||||
$value = $this->Conn->GetOne($sql); | |||||
$this->PersistentVars[$var_name] = $value; | |||||
if ( $value !== false ) { | return false; | ||||
$this->StorePersistentVar($var_name, $value); //storing it, so next time we don't load default user setting | |||||
} | |||||
return $value; | |||||
} | } | ||||
return $default; | return $default; | ||||
} | } | ||||
/** | /** | ||||
* Removes variable from persistent session | * Removes variable from persistent session | ||||
* | * | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | |||||
* @access public | * @access public | ||||
* @throws BadMethodCallException Always. | * @throws BadMethodCallException Always. | ||||
*/ | */ | ||||
public function GetCol($field) | public function GetCol($field) | ||||
{ | { | ||||
throw new BadMethodCallException('Unsupported'); | throw new BadMethodCallException('Unsupported'); | ||||
} | } | ||||
} | } | ||||
No newline at end of file |