فهرست منبع

Ticket #2808 - Allow to call service methods for Inactive modules when it's really needed.

AntonLV 6 سال پیش
والد
کامیت
d78b6f8e5e
3فایلهای تغییر یافته به همراه42 افزوده شده و 26 حذف شده
  1. 2 2
      inc/classes/BxDolService.php
  2. 18 2
      inc/utils.inc.php
  3. 22 22
      studio/classes/BxDolStudioInstaller.php

+ 2 - 2
inc/classes/BxDolService.php

@@ -39,10 +39,10 @@ class BxDolService extends BxDol
      * @param $sClass class to search for service method, by default it is main module class
      * @return service call result
      */
-    public static function call($mixed, $sMethod, $aParams = array(), $sClass = 'Module', $bIgnoreCache = false)
+    public static function call($mixed, $sMethod, $aParams = array(), $sClass = 'Module', $bIgnoreCache = false, $bIgnoreInactive = false)
     {
         $aModule = self::getModule($mixed);
-        if (empty($aModule) || (int)$aModule['enabled'] == 0)
+        if (empty($aModule) || ((int)$aModule['enabled'] == 0 && !$bIgnoreInactive))
             return '';
 
         $sKey = md5($mixed . $sMethod . print_r($aParams, true) . $sClass . bx_get_logged_profile_id());

+ 18 - 2
inc/utils.inc.php

@@ -1519,9 +1519,25 @@ function bx_alert($sUnit, $sAction, $iObjectId, $iSender = false, $aExtras = arr
  * @param $sClass class to search for service method, by default it is main module class
  * @return service call result
  */
-function bx_srv($mixed, $sMethod, $aParams = array(), $sClass = 'Module', $bIgnoreCache = false)
+function bx_srv($mixed, $sMethod, $aParams = array(), $sClass = 'Module', $bIgnoreCache = false, $bIgnoreInactive = false)
 {
-    return BxDolService::call($mixed, $sMethod, $aParams, $sClass, $bIgnoreCache);
+    return BxDolService::call($mixed, $sMethod, $aParams, $sClass, $bIgnoreCache, $bIgnoreInactive);
+}
+
+/**
+ * Perform serice call in 'Ignore Inactive' mode.
+ */
+function bx_srv_ii($mixed, $sMethod, $aParams = array(), $sClass = 'Module', $bIgnoreCache = false)
+{
+    return BxDolService::call($mixed, $sMethod, $aParams, $sClass, $bIgnoreCache, true);
+}
+
+/**
+ * Perform serice call in 'Ignore Cache' mode.
+ */
+function bx_srv_ic($mixed, $sMethod, $aParams = array(), $sClass = 'Module', $bIgnoreInactive = false)
+{
+    return BxDolService::call($mixed, $sMethod, $aParams, $sClass, true, $bIgnoreInactive);
 }
 
 function bx_replace_markers($mixed, $aMarkers)

+ 22 - 22
studio/classes/BxDolStudioInstaller.php

@@ -668,19 +668,19 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         if(!in_array($sOperation, array('install', 'uninstall', 'enable', 'disable'))) 
         	return BX_DOL_STUDIO_INSTALLER_FAILED;
 
-		if(empty($this->_aConfig['relations']) || !is_array($this->_aConfig['relations']))
+        if(empty($this->_aConfig['relations']) || !is_array($this->_aConfig['relations']))
             return BX_DOL_STUDIO_INSTALLER_SUCCESS;
 
-		foreach($this->_aConfig['relations'] as $sModule) {
-			if(!$this->oDb->isModuleByName($sModule))
-				continue;
+        foreach($this->_aConfig['relations'] as $sModule) {
+            if(!$this->oDb->isModuleByName($sModule))
+                continue;
 
-			$aRelation = $this->oDb->getRelationsBy(array('type' => 'module', 'value' => $sModule));
-			if(empty($aRelation) || empty($aRelation['on_' . $sOperation]) || !BxDolRequest::serviceExists($aRelation['module'], $aRelation['on_' . $sOperation]))
-				continue;
+            $aRelation = $this->oDb->getRelationsBy(array('type' => 'module', 'value' => $sModule));
+            if(empty($aRelation) || empty($aRelation['on_' . $sOperation]) || !BxDolRequest::serviceExists($aRelation['module'], $aRelation['on_' . $sOperation]))
+                continue;
 
-			BxDolService::call($aRelation['module'], $aRelation['on_' . $sOperation], array($this->_aConfig['home_uri']));
-		}
+            bx_srv_ii($aRelation['module'], $aRelation['on_' . $sOperation], array($this->_aConfig['home_uri']));
+        }
 
         return BX_DOL_STUDIO_INSTALLER_SUCCESS;
     }
@@ -692,26 +692,26 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
     protected function actionUpdateRelationsForAll($sOperation)
     {
     	if(!in_array($sOperation, array('enable', 'disable'))) 
-        	return BX_DOL_STUDIO_INSTALLER_FAILED;
+            return BX_DOL_STUDIO_INSTALLER_FAILED;
 
         if($sOperation == 'enable')
-        	$this->oDb->insertRelation($this->_aConfig['name'], $this->_aConfig['relation_handlers']);
+            $this->oDb->insertRelation($this->_aConfig['name'], $this->_aConfig['relation_handlers']);
 
-		$aRelation = $this->oDb->getRelationsBy(array('type' => 'module', 'value' => $this->_aConfig['name']));
-		if(empty($aRelation) || empty($aRelation['on_' . $sOperation]))
-			return BX_DOL_STUDIO_INSTALLER_SUCCESS;
+        $aRelation = $this->oDb->getRelationsBy(array('type' => 'module', 'value' => $this->_aConfig['name']));
+        if(empty($aRelation) || empty($aRelation['on_' . $sOperation]))
+                return BX_DOL_STUDIO_INSTALLER_SUCCESS;
 
     	$aModules = $this->oDb->getModulesBy(array('type' => 'all', 'active' => 1));
-	    foreach($aModules as $aModule) {
-	    	$aConfig = self::getModuleConfig($aModule);
-			if(!empty($aConfig['relations']) && is_array($aConfig['relations']) && in_array($this->_aConfig['name'], $aConfig['relations']))
-				BxDolService::call($this->_aConfig['name'], $aRelation['on_' . $sOperation], array($aModule['uri']));
-		}
+        foreach($aModules as $aModule) {
+            $aConfig = self::getModuleConfig($aModule);
+                if(!empty($aConfig['relations']) && is_array($aConfig['relations']) && in_array($this->_aConfig['name'], $aConfig['relations']))
+                    bx_srv_ii($this->_aConfig['name'], $aRelation['on_' . $sOperation], array($aModule['uri']));
+            }
 
-		if($sOperation == 'disable')
-        	$this->oDb->deleteRelation($this->_aConfig['name']);
+        if($sOperation == 'disable')
+            $this->oDb->deleteRelation($this->_aConfig['name']);
 
-		return BX_DOL_STUDIO_INSTALLER_SUCCESS;
+        return BX_DOL_STUDIO_INSTALLER_SUCCESS;
     }
 
 	/**