*/ class Mage_Log_Model_Visitor_Online extends Mage_Core_Model_Abstract { const XML_PATH_ONLINE_INTERVAL = 'customer/online_customers/online_minutes_interval'; const XML_PATH_UPDATE_FREQUENCY = 'log/visitor/online_update_frequency'; /** * Initialize resource model * */ protected function _construct() { $this->_init('log/visitor_online'); } /** * Retrieve resource instance wrapper * * @return Mage_Log_Model_Mysql4_Visitor_Online */ protected function _getResource() { return parent::_getResource(); } /** * Prepare Online visitors collection * * @return Mage_Log_Model_Visitor_Online */ public function prepare() { $this->_getResource()->prepare($this); return $this; } /** * Retrieve last prepare at timestamp * * @return int */ public function getPrepareAt() { return Mage::app()->loadCache('log_visitor_online_prepare_at'); } /** * Set Prepare at timestamp (if time is null, set current timestamp) * * @param int $time * @return Mage_Log_Model_Mysql4_Visitor_Online */ public function setPrepareAt($time = null) { if (is_null($time)) { $time = time(); } Mage::app()->saveCache($time, 'log_visitor_online_prepare_at'); return $this; } /** * Retrieve data update Frequency in second * * @return int */ public function getUpdateFrequency() { return Mage::getStoreConfig(self::XML_PATH_UPDATE_FREQUENCY); } /** * Retrieve Online Interval (in minutes) * * @return int */ public function getOnlineInterval() { $value = intval(Mage::getStoreConfig(self::XML_PATH_ONLINE_INTERVAL)); if (!$value) { $value = Mage_Log_Model_Visitor::DEFAULT_ONLINE_MINUTES_INTERVAL; } return $value; } }