Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Thu, Jul 10, 8:33 PM

in-portal

Index: trunk/kernel/units/visits/visits_event_handler.php
===================================================================
--- trunk/kernel/units/visits/visits_event_handler.php (revision 2436)
+++ trunk/kernel/units/visits/visits_event_handler.php (revision 2437)
@@ -1,94 +1,94 @@
<?php
class VisitsEventHandler extends InpDBEventHandler {
/**
* Registers user visit to site
*
* @param kEvent $event
*/
function OnRegisterVisit(&$event)
{
$object =& $event->getObject( Array('skip_autoload'=>true) );
$object->SetDBField('VisitDate_date', time() );
$object->SetDBField('VisitDate_time', time() );
$object->SetDBField('Referer', getArrayValue($_SERVER, 'HTTP_REFERER') );
$object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR'] );
if( $object->Create() )
{
$this->Application->StoreVar('visit_id', $object->GetID() );
$this->Application->SetVar('visits_id', $object->GetID() );
}
}
/**
* Search
*
* @param kEvent $event
*/
function OnSearch(&$event){
parent::OnSearch($event);
}
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
$types = $event->getEventParam('types');
if ($types=='myvisitors'){
$user_id = $this->Application->GetVar('u_id');
$object->addFilter('myitems_user1','au.PortalUserId = '.$user_id);
$object->addFilter('myitems_user2','au.PortalUserId >0');
//$object->AddGroupByField('VisitDate');
$object->AddGroupByField('%1$s.VisitId');
}
if ($types=='myvisitororders'){
$user_id = $this->Application->GetVar('u_id');
$object->addFilter('myitems_orders','ord.OrderId IS NOT NULL');
$object->addFilter('myitems_user1','au.PortalUserId = '.$user_id);
$object->addFilter('myitems_user2','au.PortalUserId >0');
}
}
/**
* Apply some special processing to
* object beeing recalled before using
* it in other events that call prepareObject
*
* @param kBase $object
* @param kEvent $event
* @access protected
*/
function prepareObject(&$object, &$event)
{
$types = $event->getEventParam('types');
if ($types=='myvisitors' || !$types){
$object->addCalculatedField('OrderTotalAmountSum', 'SUM(ord.SubTotal+ord.ShippingCost+ord.VAT-ord.CouponDiscount)');
$object->addCalculatedField('OrderAffiliateCommissionSum', 'SUM(ord.AffiliateCommission)');
$object->addCalculatedField('OrderCountByVisit', 'COUNT(OrderId)');
}
- if (!$types){
+ if (method_exists($object, 'AddGroupByField') && !$types){
$object->AddGroupByField('%1$s.VisitId');
}
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/visits/visits_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6
\ No newline at end of property
+1.7
\ No newline at end of property
Index: trunk/core/units/visits/visits_event_handler.php
===================================================================
--- trunk/core/units/visits/visits_event_handler.php (revision 2436)
+++ trunk/core/units/visits/visits_event_handler.php (revision 2437)
@@ -1,94 +1,94 @@
<?php
class VisitsEventHandler extends InpDBEventHandler {
/**
* Registers user visit to site
*
* @param kEvent $event
*/
function OnRegisterVisit(&$event)
{
$object =& $event->getObject( Array('skip_autoload'=>true) );
$object->SetDBField('VisitDate_date', time() );
$object->SetDBField('VisitDate_time', time() );
$object->SetDBField('Referer', getArrayValue($_SERVER, 'HTTP_REFERER') );
$object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR'] );
if( $object->Create() )
{
$this->Application->StoreVar('visit_id', $object->GetID() );
$this->Application->SetVar('visits_id', $object->GetID() );
}
}
/**
* Search
*
* @param kEvent $event
*/
function OnSearch(&$event){
parent::OnSearch($event);
}
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
$types = $event->getEventParam('types');
if ($types=='myvisitors'){
$user_id = $this->Application->GetVar('u_id');
$object->addFilter('myitems_user1','au.PortalUserId = '.$user_id);
$object->addFilter('myitems_user2','au.PortalUserId >0');
//$object->AddGroupByField('VisitDate');
$object->AddGroupByField('%1$s.VisitId');
}
if ($types=='myvisitororders'){
$user_id = $this->Application->GetVar('u_id');
$object->addFilter('myitems_orders','ord.OrderId IS NOT NULL');
$object->addFilter('myitems_user1','au.PortalUserId = '.$user_id);
$object->addFilter('myitems_user2','au.PortalUserId >0');
}
}
/**
* Apply some special processing to
* object beeing recalled before using
* it in other events that call prepareObject
*
* @param kBase $object
* @param kEvent $event
* @access protected
*/
function prepareObject(&$object, &$event)
{
$types = $event->getEventParam('types');
if ($types=='myvisitors' || !$types){
$object->addCalculatedField('OrderTotalAmountSum', 'SUM(ord.SubTotal+ord.ShippingCost+ord.VAT-ord.CouponDiscount)');
$object->addCalculatedField('OrderAffiliateCommissionSum', 'SUM(ord.AffiliateCommission)');
$object->addCalculatedField('OrderCountByVisit', 'COUNT(OrderId)');
}
- if (!$types){
+ if (method_exists($object, 'AddGroupByField') && !$types){
$object->AddGroupByField('%1$s.VisitId');
}
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/visits/visits_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6
\ No newline at end of property
+1.7
\ No newline at end of property

Event Timeline