CRM-12846, give preference to settings table
authorDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Mon, 8 Jul 2013 11:53:26 +0000 (17:23 +0530)
committerDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Mon, 8 Jul 2013 11:53:26 +0000 (17:23 +0530)
----------------------------------------
* CRM-12846: API support for toggling components by storing 'enableComponents' config in settings table
  http://issues.civicrm.org/jira/browse/CRM-12846

CRM/Core/BAO/ConfigSetting.php

index 40a807361aee4c6ba4efdf3aa7b6510372740aab..95933fba60bd942ce278831624f2087eb4254104 100644 (file)
@@ -353,12 +353,11 @@ class CRM_Core_BAO_ConfigSetting {
       // retrieve directory and url preferences also
       CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences($defaults);
 
-      // Pickup enabled-components from settings table. 
-      // For backward compatibility we will have to make sure we not finding the values from config-backend.
-      if (!CRM_Utils_Array::value('enableComponents', $defaults)) {
-        $defaults['enableComponents'] = 
-          CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
-
+      // Pickup enabled-components from settings table if found. 
+      $enableComponents = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
+      if (!empty($enableComponents)) {
+        $defaults['enableComponents'] = $enableComponents;
+        
         $components = CRM_Core_Component::getComponents();
         $enabledComponentIDs = array();
         foreach ($defaults['enableComponents'] as $name) {