Mage_Log_Model_Visitor Class Reference

Inheritance diagram for Mage_Log_Model_Visitor:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 getResource ()
 initServerData ()
 getUrl ()
 getFirstVisitAt ()
 getLastVisitAt ()
 isModuleIgnored ($observer)
 initByRequest ($observer)
 saveByRequest ($observer)
 bindCustomerLogin ($observer)
 bindCustomerLogout ($observer)
 bindQuoteCreate ($observer)
 bindQuoteDestroy ($observer)
 addIpData ($data)
 addCustomerData ($data)
 addQuoteData ($data)

Static Public Member Functions

static getOnlineMinutesInterval ()

Public Attributes

const DEFAULT_ONLINE_MINUTES_INTERVAL = 15
const VISITOR_TYPE_CUSTOMER = 'c'
const VISITOR_TYPE_VISITOR = 'v'

Protected Member Functions

 _construct ()
 _getSession ()


Detailed Description

Definition at line 28 of file Visitor.php.


Member Function Documentation

_construct (  )  [protected]

Enter description here...

Reimplemented from Varien_Object.

Definition at line 34 of file Visitor.php.

00035     {
00036         $this->_init('log/visitor');
00037     }

_getSession (  )  [protected]

Retrieve session object

Returns:
Mage_Core_Model_Session_Abstract

Definition at line 44 of file Visitor.php.

00045     {
00046         return Mage::getSingleton('core/session');
00047     }

addCustomerData ( data  ) 

Definition at line 245 of file Visitor.php.

00246     {
00247         $customerId = $data->getCustomerId();
00248         if( intval($customerId) <= 0 ) {
00249             return $this;
00250         }
00251         $customerData = Mage::getModel('customer/customer')->load($customerId);
00252         $newCustomerData = array();
00253         foreach( $customerData->getData() as $propName => $propValue ) {
00254             $newCustomerData['customer_' . $propName] = $propValue;
00255         }
00256 
00257         $data->addData($newCustomerData);
00258         return $this;
00259     }

addIpData ( data  ) 

Methods for research (depends from customer online admin section)

Definition at line 238 of file Visitor.php.

00239     {
00240         $ipData = array();
00241         $data->setIpData($ipData);
00242         return $this;
00243     }

addQuoteData ( data  ) 

Definition at line 261 of file Visitor.php.

00262     {
00263         $quoteId = $data->getQuoteId();
00264         if( intval($quoteId) <= 0 ) {
00265             return $this;
00266         }
00267         $data->setQuoteData(Mage::getModel('sales/quote')->load($quoteId));
00268         return $this;
00269     }

bindCustomerLogin ( observer  ) 

Bind customer data when customer login

Used in event "customer_login"

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Log_Model_Visitor

Definition at line 191 of file Visitor.php.

00192     {
00193         if (!$this->getCustomerId() && $customer = $observer->getEvent()->getCustomer()) {
00194             $this->setDoCustomerLogin(true);
00195             $this->setCustomerId($customer->getId());
00196         }
00197         return $this;
00198     }

bindCustomerLogout ( observer  ) 

Bind customer data when customer logout

Used in event "customer_logout"

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Log_Model_Visitor

Definition at line 208 of file Visitor.php.

00209     {
00210         if ($this->getCustomerId() && $customer = $observer->getEvent()->getCustomer()) {
00211             $this->setDoCustomerLogout(true);
00212         }
00213         return $this;
00214     }

bindQuoteCreate ( observer  ) 

Definition at line 216 of file Visitor.php.

00217     {
00218         if ($quote = $observer->getEvent()->getQuote()) {
00219             if ($quote->getIsCheckoutCart()) {
00220                 $this->setQuoteId($quote->getId());
00221                 $this->setDoQuoteCreate(true);
00222             }
00223         }
00224         return $this;
00225     }

bindQuoteDestroy ( observer  ) 

Definition at line 227 of file Visitor.php.

00228     {
00229         if ($quote = $observer->getEvent()->getQuote()) {
00230             $this->setDoQuoteDestroy(true);
00231         }
00232         return $this;
00233     }

getFirstVisitAt (  ) 

Definition at line 108 of file Visitor.php.

00109     {
00110         if (!$this->hasData('first_visit_at')) {
00111             $this->setData('first_visit_at', now());
00112         }
00113         return $this->getData('first_visit_at');
00114     }

getLastVisitAt (  ) 

Definition at line 116 of file Visitor.php.

00117     {
00118         if (!$this->hasData('last_visit_at')) {
00119             $this->setData('last_visit_at', now());
00120         }
00121         return $this->getData('last_visit_at');
00122     }

static getOnlineMinutesInterval (  )  [static]

Return Online Minutes Interval

Returns:
int Minutes Interval

Definition at line 88 of file Visitor.php.

00089     {
00090         $configValue = Mage::getStoreConfig('customer/online_customers/online_minutes_interval');
00091         return intval($configValue) > 0
00092             ? intval($configValue)
00093             : self::DEFAULT_ONLINE_MINUTES_INTERVAL;
00094     }

getResource (  ) 

Retrieve visitor resource model

Returns:
mixed

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 54 of file Visitor.php.

00055     {
00056         return Mage::getResourceSingleton('log/visitor');
00057     }

getUrl (  ) 

Retrieve url from model data

Returns:
string

Definition at line 101 of file Visitor.php.

00102     {
00103         $url = 'http' . ($this->getHttpSecure() ? 's' : '') . '://';
00104         $url .= $this->getHttpHost().$this->getRequestUri();
00105         return $url;
00106     }

initByRequest ( observer  ) 

Initialization visitor information by request

Used in event "controller_action_predispatch"

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Log_Model_Visitor

Definition at line 145 of file Visitor.php.

00146     {
00147         if ($this->isModuleIgnored($observer)) {
00148             return $this;
00149         }
00150 
00151         $this->setData($this->_getSession()->getVisitorData());
00152         $this->initServerData();
00153 
00154         if (!$this->getId()) {
00155             $this->setFirstVisitAt(now());
00156             $this->setIsNewVisitor(true);
00157             $this->save();
00158         }
00159         return $this;
00160     }

initServerData (  ) 

Initialize visitor information from server data

Returns:
Mage_Log_Model_Visitor

Definition at line 64 of file Visitor.php.

00065     {
00066         $s = $_SERVER;
00067         $this->addData(array(
00068             'server_addr'       => empty($s['SERVER_ADDR']) ? '' : ip2long($s['SERVER_ADDR']),
00069             'remote_addr'       => empty($s['REMOTE_ADDR']) ? '' : ip2long($s['REMOTE_ADDR']),
00070             'http_secure'       => Mage::app()->getStore()->isCurrentlySecure(),
00071             'http_host'         => empty($s['HTTP_HOST']) ? '' : $s['HTTP_HOST'],
00072             'http_user_agent'   => empty($s['HTTP_USER_AGENT']) ? '' : $s['HTTP_USER_AGENT'],
00073             'http_accept_language'=> empty($s['HTTP_ACCEPT_LANGUAGE']) ? '' : $s['HTTP_ACCEPT_LANGUAGE'],
00074             'http_accept_charset'=> empty($s['HTTP_ACCEPT_CHARSET']) ? '' : $s['HTTP_ACCEPT_CHARSET'],
00075             'request_uri'       => empty($s['REQUEST_URI']) ? '' : $s['REQUEST_URI'],
00076             'session_id'        => $this->_getSession()->getSessionId(),
00077             'http_referer'      => empty($s['HTTP_REFERER']) ? '' : $s['HTTP_REFERER'],
00078         ));
00079 
00080         return $this;
00081     }

isModuleIgnored ( observer  ) 

Definition at line 124 of file Visitor.php.

00125     {
00126         $ignores = Mage::getConfig()->getNode('global/ignoredModules/entities')->asArray();
00127 
00128         if( is_array($ignores) && $observer) {
00129             $curModule = $observer->getEvent()->getControllerAction()->getRequest()->getRouteName();
00130             if (isset($ignores[$curModule])) {
00131                 return true;
00132             }
00133         }
00134         return false;
00135     }

saveByRequest ( observer  ) 

Saving visitor information by request

Used in event "controller_action_postdispatch"

Parameters:
Varien_Event_Observer $observer
Returns:
Mage_Log_Model_Visitor

Definition at line 170 of file Visitor.php.

00171     {
00172         if ($this->isModuleIgnored($observer)) {
00173             return $this;
00174         }
00175 
00176         $this->setLastVisitAt(now());
00177         $this->save();
00178 
00179         $this->_getSession()->setVisitorData($this->getData());
00180         return $this;
00181     }


Member Data Documentation

Definition at line 30 of file Visitor.php.

const VISITOR_TYPE_CUSTOMER = 'c'

Definition at line 31 of file Visitor.php.

const VISITOR_TYPE_VISITOR = 'v'

Definition at line 32 of file Visitor.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:29 2009 for Magento by  doxygen 1.5.8