00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Log 00023 * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 00028 /** 00029 * Prepare Log Online Visitors Model 00030 * 00031 * @category Mage 00032 * @package Mage_Log 00033 * @author Magento Core Team <core@magentocommerce.com> 00034 */ 00035 class Mage_Log_Model_Visitor_Online extends Mage_Core_Model_Abstract 00036 { 00037 const XML_PATH_ONLINE_INTERVAL = 'customer/online_customers/online_minutes_interval'; 00038 const XML_PATH_UPDATE_FREQUENCY = 'log/visitor/online_update_frequency'; 00039 00040 /** 00041 * Initialize resource model 00042 * 00043 */ 00044 protected function _construct() 00045 { 00046 $this->_init('log/visitor_online'); 00047 } 00048 00049 /** 00050 * Retrieve resource instance wrapper 00051 * 00052 * @return Mage_Log_Model_Mysql4_Visitor_Online 00053 */ 00054 protected function _getResource() 00055 { 00056 return parent::_getResource(); 00057 } 00058 00059 /** 00060 * Prepare Online visitors collection 00061 * 00062 * @return Mage_Log_Model_Visitor_Online 00063 */ 00064 public function prepare() 00065 { 00066 $this->_getResource()->prepare($this); 00067 return $this; 00068 } 00069 00070 /** 00071 * Retrieve last prepare at timestamp 00072 * 00073 * @return int 00074 */ 00075 public function getPrepareAt() 00076 { 00077 return Mage::app()->loadCache('log_visitor_online_prepare_at'); 00078 } 00079 00080 /** 00081 * Set Prepare at timestamp (if time is null, set current timestamp) 00082 * 00083 * @param int $time 00084 * @return Mage_Log_Model_Mysql4_Visitor_Online 00085 */ 00086 public function setPrepareAt($time = null) 00087 { 00088 if (is_null($time)) { 00089 $time = time(); 00090 } 00091 Mage::app()->saveCache($time, 'log_visitor_online_prepare_at'); 00092 return $this; 00093 } 00094 00095 /** 00096 * Retrieve data update Frequency in second 00097 * 00098 * @return int 00099 */ 00100 public function getUpdateFrequency() 00101 { 00102 return Mage::getStoreConfig(self::XML_PATH_UPDATE_FREQUENCY); 00103 } 00104 00105 /** 00106 * Retrieve Online Interval (in minutes) 00107 * 00108 * @return int 00109 */ 00110 public function getOnlineInterval() 00111 { 00112 $value = intval(Mage::getStoreConfig(self::XML_PATH_ONLINE_INTERVAL)); 00113 if (!$value) { 00114 $value = Mage_Log_Model_Visitor::DEFAULT_ONLINE_MINUTES_INTERVAL; 00115 } 00116 return $value; 00117 } 00118 }