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 () |
Definition at line 28 of file Visitor.php.
_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
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.
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"
Varien_Event_Observer | $observer |
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"
Varien_Event_Observer | $observer |
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 | ( | ) |
getLastVisitAt | ( | ) |
static getOnlineMinutesInterval | ( | ) | [static] |
Return Online 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
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
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"
Varien_Event_Observer | $observer |
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
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"
Varien_Event_Observer | $observer |
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 }
const DEFAULT_ONLINE_MINUTES_INTERVAL = 15 |
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.