/** * Set components as enabled or disabled. Leave any other * components unmodified. * * Note: This API has only been tested with CiviCRM 4.4. * * @param array $components keys are component names (e.g. "CiviMail"); values are booleans */ public function setComponentStatuses($components) { $getResult = civicrm_api3('setting', 'getsingle', array('domain_id' => CRM_Core_Config::domainID(), 'return' => array('enable_components'))); if (!is_array($getResult['enable_components'])) { throw new CRM_Core_Exception("Failed to determine component statuses"); } // Merge $components with existing list $enableComponents = $getResult['enable_components']; foreach ($components as $component => $status) { if ($status) { $enableComponents = array_merge($enableComponents, array($component)); } else { $enableComponents = array_diff($enableComponents, array($component)); } } civicrm_api3('setting', 'create', array('domain_id' => CRM_Core_Config::domainID(), 'enable_components' => array_unique($enableComponents))); CRM_Core_Component::flushEnabledComponents(); }