Просмотр исходного кода

Ticket #3002 - Related changes in Live Updates.

AntonLV 5 лет назад
Родитель
Сommit
e703e8ad90

+ 3 - 2
inc/classes/BxDolLiveUpdates.php

@@ -259,10 +259,11 @@ class BxDolLiveUpdates extends BxDolFactory implements iBxDolSingleton
 
     protected function _getRequestedData($iIndex = 0, $bIndexCheck = false, $aCachedData = array())
     {
-        $aResult = array();
+        $bInit = !$bIndexCheck && empty($aCachedData);
 
+        $aResult = array();
         foreach($this->_aSystems as $sName => $aSystem) {
-            if(empty($aSystem) || !is_array($aSystem) || (int)$aSystem['active'] != 1)
+            if(empty($aSystem) || !is_array($aSystem) || (int)$aSystem['active'] != 1 || ($bInit && (int)$aSystem['init'] == 0))
                 continue;
 
             if($bIndexCheck && $iIndex % (int)$aSystem['frequency'] != 0)

+ 2 - 9
inc/classes/BxDolLiveUpdatesQuery.php

@@ -17,19 +17,12 @@ class BxDolLiveUpdatesQuery extends BxDolDb
         parent::__construct();
     }
 
-	public function getSystems()
+    public function getSystems()
     {
         $sKey = 'bx_dol_cache_memory_live_updates_systems';
 
         if(!isset($GLOBALS[$sKey]))
-            $GLOBALS[$sKey] = BxDolDb::getInstance()->fromCache('sys_objects_live_updates', 'getAllWithKey', '
-                SELECT
-                    `id` as `id`,
-                    `name` AS `name`,
-                    `frequency` AS `frequency`,
-                    `service_call` AS `service_call`,
-                    `active` AS `active`
-                FROM `sys_objects_live_updates`', 'name');
+            $GLOBALS[$sKey] = BxDolDb::getInstance()->fromCache('sys_objects_live_updates', 'getAllWithKey', 'SELECT * FROM `sys_objects_live_updates`', 'name');
 
         return $GLOBALS[$sKey];
     }

+ 17 - 17
inc/js/classes/BxDolLiveUpdates.js

@@ -8,32 +8,32 @@
 
 function BxDolLiveUpdates(oOptions)
 {
-	this._sActionsUrl = oOptions.sActionsUrl == undefined ? sUrlRoot + 'live_updates.php' : oOptions.sActionsUrl;
-	this._sObjName = oOptions.sObjName == undefined ? 'oLiveUpdates' : oOptions.sObjName;
-	this._iInterval = oOptions.iInterval == undefined ? 3000 : oOptions.iInterval;
-	this._aSystemsActive = oOptions.aSystemsActive == undefined ? {} : oOptions.aSystemsActive;
-	this._aSystemsTransient = oOptions.aSystemsTransient == undefined ? {} : oOptions.aSystemsTransient;
-	this._bServerRequesting = oOptions.bServerRequesting == undefined ? false : oOptions.bServerRequesting;
-	this._sHash = oOptions.sHash == undefined ? '' : oOptions.sHash;
-
-	this._iIndex = 0;
-	this._iHandler = 0;
-	this._bBusy = false;
-
-	this.init();
+    this._sActionsUrl = oOptions.sActionsUrl == undefined ? sUrlRoot + 'live_updates.php' : oOptions.sActionsUrl;
+    this._sObjName = oOptions.sObjName == undefined ? 'oLiveUpdates' : oOptions.sObjName;
+    this._iInterval = oOptions.iInterval == undefined ? 3000 : oOptions.iInterval;
+    this._aSystemsActive = oOptions.aSystemsActive == undefined ? {} : oOptions.aSystemsActive;
+    this._aSystemsTransient = oOptions.aSystemsTransient == undefined ? {} : oOptions.aSystemsTransient;
+    this._bServerRequesting = oOptions.bServerRequesting == undefined ? false : oOptions.bServerRequesting;
+    this._sHash = oOptions.sHash == undefined ? '' : oOptions.sHash;
+
+    this._iIndex = 0;
+    this._iHandler = 0;
+    this._bBusy = false;
+
+    this.init();
 }
 
 BxDolLiveUpdates.prototype.init = function() {
-	var $this = this;
+    var $this = this;
 
-	if(this._iHandler)
-		this.destroy();
+    if(this._iHandler)
+        this.destroy();
 
     $(document).ready(function() {
         $this.perform(); // make first call straight away to load addons for menus
 
     	$this._iHandler = setInterval(function() {
-    		$this.perform();
+            $this.perform();
     	}, $this._iInterval);
     });
 };

+ 4 - 3
install/sql/system.sql

@@ -5172,6 +5172,7 @@ CREATE TABLE IF NOT EXISTS `sys_categories2objects` (
 CREATE TABLE `sys_objects_live_updates` (
   `id` int(11) unsigned NOT NULL auto_increment,
   `name` varchar(50) NOT NULL default '',
+  `init` tinyint(4) NOT NULL DEFAULT '0',
   `frequency` tinyint(4) NOT NULL DEFAULT '1',
   `service_call` text NOT NULL default '', 
   `active` tinyint(4) NOT NULL DEFAULT '1',
@@ -5179,9 +5180,9 @@ CREATE TABLE `sys_objects_live_updates` (
   UNIQUE KEY `name` (`name`)
 );
 
-INSERT INTO `sys_objects_live_updates`(`name`, `frequency`, `service_call`, `active`) VALUES
-('sys_payments_cart', 1, 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:21:"get_live_updates_cart";s:6:"params";a:3:{i:0;a:2:{s:11:"menu_object";s:18:"sys_toolbar_member";s:9:"menu_item";s:7:"account";}i:1;a:2:{s:11:"menu_object";s:25:"sys_account_notifications";s:9:"menu_item";s:4:"cart";}i:2;s:7:"{count}";}s:5:"class";s:21:"TemplPaymentsServices";}', 1),
-('sys_payments_orders', 1, 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:23:"get_live_updates_orders";s:6:"params";a:3:{i:0;a:2:{s:11:"menu_object";s:18:"sys_toolbar_member";s:9:"menu_item";s:7:"account";}i:1;a:2:{s:11:"menu_object";s:25:"sys_account_notifications";s:9:"menu_item";s:6:"orders";}i:2;s:7:"{count}";}s:5:"class";s:21:"TemplPaymentsServices";}', 1);
+INSERT INTO `sys_objects_live_updates`(`name`, `init`, `frequency`, `service_call`, `active`) VALUES
+('sys_payments_cart', 0, 1, 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:21:"get_live_updates_cart";s:6:"params";a:3:{i:0;a:2:{s:11:"menu_object";s:18:"sys_toolbar_member";s:9:"menu_item";s:7:"account";}i:1;a:2:{s:11:"menu_object";s:25:"sys_account_notifications";s:9:"menu_item";s:4:"cart";}i:2;s:7:"{count}";}s:5:"class";s:21:"TemplPaymentsServices";}', 1),
+('sys_payments_orders', 0, 1, 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:23:"get_live_updates_orders";s:6:"params";a:3:{i:0;a:2:{s:11:"menu_object";s:18:"sys_toolbar_member";s:9:"menu_item";s:7:"account";}i:1;a:2:{s:11:"menu_object";s:25:"sys_account_notifications";s:9:"menu_item";s:6:"orders";}i:2;s:7:"{count}";}s:5:"class";s:21:"TemplPaymentsServices";}', 1);
 
 -- --------------------------------------------------------
 

+ 0 - 5
template/scripts/BxBaseLiveUpdates.php

@@ -34,11 +34,6 @@ class BxBaseLiveUpdates extends BxDolLiveUpdates
          */ 
         $aCached = $this->_getCachedData();
 
-        /* tmp fix for #3002 */
-        foreach ($aCached as $sName => $a)
-            if (!in_array($sName, $this->_aSystemsTransient))
-                $aCached[$sName] = 0;
-
         $aParams = array_merge(array(
             'sActionsUrl' => BX_DOL_URL_ROOT . 'live_updates.php',
             'sObjName' => $this->_sJsObject,