Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/logs/session_logs/session_log_eh.php
Show All 22 Lines | |||||
*/ | */ | ||||
function OnStartSession($event) | function OnStartSession($event) | ||||
{ | { | ||||
if (!$this->Application->ConfigValue('UseChangeLog')) { | if (!$this->Application->ConfigValue('UseChangeLog')) { | ||||
// don't use session log when change log is disabled | // don't use session log when change log is disabled | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->Application->recallObject($event->Prefix, null, Array ('skip_autoload' => 1)); | $object = $this->Application->recallObject($event->Prefix, null, Array ('skip_autoload' => 1)); | ||||
/* @var $object kDBItem */ | |||||
$fields_hash = Array ( | $fields_hash = Array ( | ||||
'SessionStart' => adodb_mktime(), | 'SessionStart' => adodb_mktime(), | ||||
'IP' => $this->Application->getClientIp(), | 'IP' => $this->Application->getClientIp(), | ||||
'PortalUserId' => $this->Application->RecallVar('user_id'), | 'PortalUserId' => $this->Application->RecallVar('user_id'), | ||||
'SessionId' => $this->Application->GetSID(), | 'SessionId' => $this->Application->GetSID(), | ||||
'Status' => SESSION_LOG_ACTIVE, | 'Status' => SESSION_LOG_ACTIVE, | ||||
); | ); | ||||
Show All 9 Lines | |||||
/** | /** | ||||
* Closes log for current session | * Closes log for current session | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnEndSession($event) | function OnEndSession($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->Application->recallObject($event->Prefix, null, Array ('skip_autoload' => 1)); | $object = $this->Application->recallObject($event->Prefix, null, Array ('skip_autoload' => 1)); | ||||
/* @var $object kDBItem */ | |||||
$object->Load($this->Application->RecallVar('_SessionLogId_')); | $object->Load($this->Application->RecallVar('_SessionLogId_')); | ||||
if (!$object->isLoaded()) { | if (!$object->isLoaded()) { | ||||
return ; | return ; | ||||
} | } | ||||
$fields_hash = Array ( | $fields_hash = Array ( | ||||
'SessionEnd' => adodb_mktime(), | 'SessionEnd' => adodb_mktime(), | ||||
Show All 38 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemDelete(kEvent $event) | protected function OnAfterItemDelete(kEvent $event) | ||||
{ | { | ||||
parent::OnAfterItemDelete($event); | parent::OnAfterItemDelete($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$sql = 'SELECT ' . $this->Application->getUnitOption('change-log', 'IDField') . ' | $sql = 'SELECT ' . $this->Application->getUnitOption('change-log', 'IDField') . ' | ||||
FROM ' . $this->Application->getUnitOption('change-log', 'TableName') . ' | FROM ' . $this->Application->getUnitOption('change-log', 'TableName') . ' | ||||
WHERE SessionLogId = ' . $object->GetID(); | WHERE SessionLogId = ' . $object->GetID(); | ||||
$related_ids = $this->Conn->GetCol($sql); | $related_ids = $this->Conn->GetCol($sql); | ||||
if ( $related_ids ) { | if ( $related_ids ) { | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject('change-log_TempHandler', 'kTempTablesHandler'); | $temp_handler = $this->Application->recallObject('change-log_TempHandler', 'kTempTablesHandler'); | ||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->DeleteItems('change-log', '', $related_ids); | $temp_handler->DeleteItems('change-log', '', $related_ids); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |