Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/visits/visits_event_handler.php
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
*/ | */ | ||||
protected function OnRegisterVisit($event) | protected function OnRegisterVisit($event) | ||||
{ | { | ||||
if ( $this->Application->isAdmin || !$this->Application->ConfigValue('UseVisitorTracking') || $this->Application->RecallVar('visit_id') ) { | if ( $this->Application->isAdmin || !$this->Application->ConfigValue('UseVisitorTracking') || $this->Application->RecallVar('visit_id') ) { | ||||
// admin logins are not registered in visits list | // admin logins are not registered in visits list | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(Array ('skip_autoload' => true)); | $object = $event->getObject(Array ('skip_autoload' => true)); | ||||
/* @var $object kDBItem */ | |||||
$object->SetDBField('VisitDate_date', adodb_mktime()); | $object->SetDBField('VisitDate_date', adodb_mktime()); | ||||
$object->SetDBField('VisitDate_time', adodb_mktime()); | $object->SetDBField('VisitDate_time', adodb_mktime()); | ||||
$object->SetDBField('Referer', getArrayValue($_SERVER, 'HTTP_REFERER')); | $object->SetDBField('Referer', getArrayValue($_SERVER, 'HTTP_REFERER')); | ||||
$object->SetDBField('IPAddress', $this->Application->getClientIp()); | $object->SetDBField('IPAddress', $this->Application->getClientIp()); | ||||
if ( $object->Create() ) { | if ( $object->Create() ) { | ||||
$this->Application->StoreVar('visit_id', $object->GetID()); | $this->Application->StoreVar('visit_id', $object->GetID()); | ||||
$this->Application->SetVar('visits_id', $object->GetID()); | $this->Application->SetVar('visits_id', $object->GetID()); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Apply any custom changes to list's sql query | * Apply any custom changes to list's sql query | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
* @see kDBEventHandler::OnListBuild() | * @see kDBEventHandler::OnListBuild() | ||||
*/ | */ | ||||
protected function SetCustomQuery(kEvent $event) | protected function SetCustomQuery(kEvent $event) | ||||
{ | { | ||||
parent::SetCustomQuery($event); | parent::SetCustomQuery($event); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$types = $event->getEventParam('types'); | $types = $event->getEventParam('types'); | ||||
if ( $types == 'myvisitors' ) { | if ( $types == 'myvisitors' ) { | ||||
$user_id = $this->Application->RecallVar('user_id'); | $user_id = $this->Application->RecallVar('user_id'); | ||||
$object->addFilter('myitems_user1', 'au.PortalUserId = ' . $user_id); | $object->addFilter('myitems_user1', 'au.PortalUserId = ' . $user_id); | ||||
$object->addFilter('myitems_user2', 'au.PortalUserId >0'); | $object->addFilter('myitems_user2', 'au.PortalUserId >0'); | ||||
//$object->AddGroupByField('VisitDate'); | //$object->AddGroupByField('VisitDate'); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
if ($user_id > 0) { | if ($user_id > 0) { | ||||
// for real users only, not root,guest | // for real users only, not root,guest | ||||
$this->Application->setVisitField('PortalUserId', $user_id); | $this->Application->setVisitField('PortalUserId', $user_id); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |