Index: branches/5.2.x/core/kernel/session/session_storage.php =================================================================== diff -u -N -r14811 -r14995 --- branches/5.2.x/core/kernel/session/session_storage.php (.../session_storage.php) (revision 14811) +++ branches/5.2.x/core/kernel/session/session_storage.php (.../session_storage.php) (revision 14995) @@ -1,7 +1,7 @@ Session->RecallVar('user_id'); - if ($user_id == USER_GUEST || $user_id === false) { + if ( $user_id == USER_GUEST || $user_id === false ) { // -2 (when not logged in), false (when after u:OnLogout event) $this->Session->StoreVar($var_name, $var_value, $optional); - return ; + return; } $this->PersistentVars[$var_name] = $var_value; - $key_clause = 'PortalUserId = '.$user_id.' AND VariableName = '.$this->Conn->qstr($var_name); + $key_clause = 'PortalUserId = ' . $user_id . ' AND VariableName = ' . $this->Conn->qstr($var_name); $sql = 'SELECT VariableName - FROM '.TABLE_PREFIX.'PersistantSessionData - WHERE '.$key_clause; + FROM ' . TABLE_PREFIX . 'PersistantSessionData + WHERE ' . $key_clause; $record_found = $this->Conn->GetOne($sql); $fields_hash = Array ( @@ -380,11 +382,11 @@ 'VariableValue' => $var_value, ); - if ($record_found) { - $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'PersistantSessionData', $key_clause); + if ( $record_found ) { + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'PersistantSessionData', $key_clause); } else { - $this->Conn->doInsert($fields_hash, TABLE_PREFIX.'PersistantSessionData'); + $this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'PersistantSessionData'); } } @@ -394,46 +396,58 @@ * @param string $var_name * @param mixed $default * @return mixed + * @access public */ - function RecallPersistentVar($var_name, $default = false) + public function RecallPersistentVar($var_name, $default = false) { - if ($this->Session->RecallVar('user_id') == USER_GUEST) { - if ($default == ALLOW_DEFAULT_SETTINGS) { + if ( $this->Session->RecallVar('user_id') == USER_GUEST ) { + if ( $default == ALLOW_DEFAULT_SETTINGS ) { $default = null; } + 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]; } - elseif ($default == ALLOW_DEFAULT_SETTINGS) { + elseif ( $default == ALLOW_DEFAULT_SETTINGS ) { $default_user_id = $this->Application->ConfigValue('DefaultSettingsUserId'); - if (!$default_user_id) { + + if ( !$default_user_id ) { $default_user_id = USER_ROOT; } + $sql = 'SELECT VariableValue, VariableName - FROM '.TABLE_PREFIX.'PersistantSessionData - WHERE VariableName = '.$this->Conn->qstr($var_name).' AND PortalUserId = '.$default_user_id; + FROM ' . TABLE_PREFIX . 'PersistantSessionData + 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) { + + if ( $value !== false ) { $this->StorePersistentVar($var_name, $value); //storing it, so next time we don't load default user setting } + return $value; } - else { - return $default; - } + + return $default; } + /** + * Removes variable from persistent session + * + * @param string $var_name + * @return void + * @access public + */ function RemovePersistentVar($var_name) { unset($this->PersistentVars[$var_name]); $user_id = $this->Session->RecallVar('user_id'); - if ($user_id == USER_GUEST || $user_id === false) { + if ( $user_id == USER_GUEST || $user_id === false ) { // -2 (when not logged in), false (when after u:OnLogout event) $this->Session->RemoveVar($var_name); }