unset($params['autocompleteContactReference']);
}
+ // save components to be enabled
+ if (CRM_Utils_Array::value('enableComponents', $params)) {
+ CRM_Core_BAO_Setting::setItem($params['enableComponents'],
+ CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,'enable_components');
+
+ // unset params by emptying the values, so while retrieving we can detect and load from settings table
+ // instead of config-backend for backward compatibility. We could use unset() in later releases.
+ $params['enableComponents'] = $params['enableComponentIDs'] = array();
+ }
+
// save checksum timeout
if (CRM_Utils_Array::value('checksumTimeout', $params)) {
CRM_Core_BAO_Setting::setItem($params['checksumTimeout'],
if (!empty($defaults)) {
// 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());
+
+ $components = CRM_Core_Component::getComponents();
+ $enabledComponentIDs = array();
+ foreach ($defaults['enableComponents'] as $name) {
+ $enabledComponentIDs[] = $components[$name]->componentID;
+ }
+ $defaults['enableComponentIDs'] = $enabledComponentIDs;
+ }
}
}
return FALSE;
}
- // get config_backend value
- $sql = "
-SELECT config_backend
-FROM civicrm_domain
-WHERE id = %1
-";
- $params = array(1 => array(CRM_Core_Config::domainID(), 'Integer'));
- $configBackend = CRM_Core_DAO::singleValueQuery($sql, $params);
+ // get enabled-components from DB and add to the list
+ $enabledComponents =
+ CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
+ $enabledComponents[] = $componentName;
- if (!$configBackend) {
- static $alreadyVisited = FALSE;
- if ($alreadyVisited) {
- CRM_Core_Error::fatal(ts('Returning early due to unexpected error - civicrm_domain.config_backend column value is NULL. Try visiting CiviCRM Home page.'));
- }
-
- $alreadyVisited = TRUE;
-
- // try to recreate the config backend
- $config = CRM_Core_Config::singleton(TRUE, TRUE);
- return self::enableComponent($componentName);
+ $enabledComponentIDs = array();
+ foreach ($enabledComponents as $name) {
+ $enabledComponentIDs[] = $components[$name]->componentID;
}
- $configBackend = unserialize($configBackend);
-
- $configBackend['enableComponents'][] = $componentName;
- $configBackend['enableComponentIDs'][] = $components[$componentName]->componentID;
// fix the config object
- $config->enableComponents = $configBackend['enableComponents'];
- $config->enableComponentIDs = $configBackend['enableComponentIDs'];
+ $config->enableComponents = $enabledComponents;
+ $config->enableComponentIDs = $enabledComponentIDs;
// also force reset of component array
CRM_Core_Component::getEnabledComponents(TRUE);
- // check if component is already there, is so return
- $configBackend = serialize($configBackend);
- $sql = "
-UPDATE civicrm_domain
-SET config_backend = %2
-WHERE id = %1
-";
- $params[2] = array($configBackend, 'String');
- CRM_Core_DAO::executeQuery($sql, $params);
+ // update DB
+ CRM_Core_BAO_Setting::setItem($enabledComponents,
+ CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,'enable_components');
return TRUE;
}