Commit b086633a authored by totten's avatar totten

CRM_Core_BAO_ConfigSetting -- Add disableComponent($componentName)

parent 1c9437c3
......@@ -626,10 +626,9 @@ WHERE option_group_id = (
// component is already enabled
return TRUE;
}
$components = CRM_Core_Component::getComponents();
// return if component does not exist
if (!array_key_exists($componentName, $components)) {
if (!array_key_exists($componentName, CRM_Core_Component::getComponents())) {
return FALSE;
}
......@@ -638,6 +637,32 @@ WHERE option_group_id = (
CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
$enabledComponents[] = $componentName;
self::setEnabledComponents($enabledComponents);
return TRUE;
}
static function disableComponent($componentName) {
$config = CRM_Core_Config::singleton();
if (!in_array($componentName, $config->enableComponents) || !array_key_exists($componentName, CRM_Core_Component::getComponents())) {
// post-condition satisified
return TRUE;
}
// 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 = array_diff($enabledComponents, array($componentName));
self::setEnabledComponents($enabledComponents);
return TRUE;
}
public static function setEnabledComponents($enabledComponents) {
$config = CRM_Core_Config::singleton();
$components = CRM_Core_Component::getComponents();
$enabledComponentIDs = array();
foreach ($enabledComponents as $name) {
$enabledComponentIDs[] = $components[$name]->componentID;
......@@ -652,9 +677,7 @@ WHERE option_group_id = (
// update DB
CRM_Core_BAO_Setting::setItem($enabledComponents,
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,'enable_components');
return TRUE;
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components');
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment