Index: branches/5.1.x/core/units/logs/session_logs/session_log_eh.php =================================================================== diff -u -N -r12127 -r12657 --- branches/5.1.x/core/units/logs/session_logs/session_log_eh.php (.../session_log_eh.php) (revision 12127) +++ branches/5.1.x/core/units/logs/session_logs/session_log_eh.php (.../session_log_eh.php) (revision 12657) @@ -1,6 +1,6 @@ Application->ConfigValue('UseChangeLog')) { - // don't use session log when change log is disabled - return ; - } + class SessionLogEventHandler extends kDBEventHandler { - $object =& $this->Application->recallObject($event->Prefix, null, Array ('skip_autoload' => 1)); - /* @var $object kDBItem */ + /** + * Opens log for new session + * + * @param kEvent $event + */ + function OnStartSession(&$event) + { + if (!$this->Application->ConfigValue('UseChangeLog')) { + // don't use session log when change log is disabled + return ; + } - $fields_hash = Array ( - 'SessionStart' => adodb_mktime(), - 'IP' => $_SERVER['REMOTE_ADDR'], - 'PortalUserId' => $this->Application->RecallVar('user_id'), - 'SessionId' => $this->Application->GetSID(), - 'Status' => 0, - ); + $object =& $this->Application->recallObject($event->Prefix, null, Array ('skip_autoload' => 1)); + /* @var $object kDBItem */ - $object->SetDBFieldsFromHash($fields_hash); + $fields_hash = Array ( + 'SessionStart' => adodb_mktime(), + 'IP' => $_SERVER['REMOTE_ADDR'], + 'PortalUserId' => $this->Application->RecallVar('user_id'), + 'SessionId' => $this->Application->GetSID(), + 'Status' => 0, + ); - $object->UpdateFormattersSubFields(); + $object->SetDBFieldsFromHash($fields_hash); - if ($object->Create()) { - $this->Application->StoreVar('_SessionLogId_', $object->GetID()); + $object->UpdateFormattersSubFields(); + + if ($object->Create()) { + $this->Application->StoreVar('_SessionLogId_', $object->GetID()); + } } - } - /** - * Closes log for current session - * - * @param kEvent $event - */ - function OnEndSession(&$event) - { - $object =& $this->Application->recallObject($event->Prefix, null, Array ('skip_autoload' => 1)); - /* @var $object kDBItem */ + /** + * Closes log for current session + * + * @param kEvent $event + */ + function OnEndSession(&$event) + { + $object =& $this->Application->recallObject($event->Prefix, null, Array ('skip_autoload' => 1)); + /* @var $object kDBItem */ - $object->Load($this->Application->RecallVar('_SessionLogId_')); - if (!$object->isLoaded()) { - return ; - } + $object->Load($this->Application->RecallVar('_SessionLogId_')); + if (!$object->isLoaded()) { + return ; + } - $fields_hash = Array ( - 'SessionEnd' => adodb_mktime(), - 'Status' => 1, - ); + $fields_hash = Array ( + 'SessionEnd' => adodb_mktime(), + 'Status' => 1, + ); - $object->SetDBFieldsFromHash($fields_hash); + $object->SetDBFieldsFromHash($fields_hash); - $object->UpdateFormattersSubFields(); - $object->Update(); - } + $object->UpdateFormattersSubFields(); + $object->Update(); + } -} \ No newline at end of file + } \ No newline at end of file