From: eileen Date: Thu, 11 Apr 2013 13:46:54 +0000 (+1200) Subject: multipledomain config get working X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7583c3f35b05fb91a5279bb06f191d4f881e9231;p=civicrm-core.git multipledomain config get working fix setting test to only call create if required --- diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index e925d26d2d..0016252f83 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -114,6 +114,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { static function resetDomain(){ CRM_Core_Config::domainID(null, true); self::getDomain(null, true); + CRM_Core_Config::singleton(TRUE, TRUE); } static function version( $skipUsingCache = false ) { diff --git a/CRM/Core/BAO/Setting.php b/CRM/Core/BAO/Setting.php index 4d75ee43fc..e9d9a819ab 100644 --- a/CRM/Core/BAO/Setting.php +++ b/CRM/Core/BAO/Setting.php @@ -225,13 +225,13 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { $fields = $result = array(); $fieldsToGet = self::validateSettingsInput(array_flip($settingsToReturn), $fields, FALSE); - foreach ($domains as $domain) { - CRM_Core_BAO_Domain::setDomain($domain); - if($domain != $originalDomain){ + foreach ($domains as $domainID) { + if($domainID != CRM_Core_Config::domainID()){ $reloadConfig = TRUE; + CRM_Core_BAO_Domain::setDomain($domainID); } $config = CRM_Core_Config::singleton($reloadConfig, $reloadConfig); - $result[$domain] = array(); + $result[$domainID] = array(); foreach ($fieldsToGet as $name => $value) { if(!empty($fields['values'][$name]['prefetch'])){ $configKey = CRM_Utils_Array::value('config_key', $fields['values'][$name], $name); @@ -247,16 +247,16 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { CRM_Utils_Array::value('component_id', $params), CRM_Utils_Array::value('default_value', $params), CRM_Utils_Array::value('contact_id', $params), - $domain + $domainID ); } if (!is_null($setting)) { // we won't return if not set - helps in return all scenario - otherwise we can't indentify the missing ones // e.g for revert of fill actions - $result[$domain][$name] = $setting; + $result[$domainID][$name] = $setting; } - CRM_Core_BAO_Domain::resetDomain(); } + CRM_Core_BAO_Domain::resetDomain(); } return $result; } @@ -346,9 +346,11 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { * @access public */ static function setItems(&$params, $domains = null) { + $originalDomain = CRM_Core_Config::domainID(); if (empty($domains)) { - $domains[] = CRM_Core_Config::domainID(); + $domains[] = $originalDomain; } + $reloadConfig = FALSE; $fields = $config_keys = array(); $fieldsToSet = self::validateSettingsInput($params, $fields); @@ -356,8 +358,12 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { self::validateSetting($settingValue, $fields['values'][$settingField]); } - foreach ($domains as $domain) { - $result[$domain] = array(); + foreach ($domains as $domainID) { + if($domainID != CRM_Core_Config::domainID()){ + $reloadConfig = TRUE; + CRM_Core_BAO_Domain::setDomain($domainID); + } + $result[$domainID] = array(); foreach ($fieldsToSet as $name => $value) { if(empty($fields['values'][$name]['config_only'])){ CRM_Core_BAO_Setting::setItem( @@ -367,7 +373,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { CRM_Utils_Array::value('component_id', $params), CRM_Utils_Array::value('contact_id', $params), CRM_Utils_Array::value('created_id', $params), - $domain + $domainID ); } if(!empty($fields['values'][$name]['prefetch'])){ @@ -376,9 +382,18 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { } $config_keys[$name] = $value; } - $result[$domain][$name] = $value; + $result[$domainID][$name] = $value; + } + if($reloadConfig){ + CRM_Core_Config::singleton($reloadConfig, $reloadConfig); + } + + if(!empty($config_keys)){ + CRM_Core_BAO_ConfigSetting::create($config_keys); + } + if($reloadConfig){ + CRM_Core_BAO_Domain::resetDomain(); } - CRM_Core_BAO_ConfigSetting::create($config_keys); } return $result;