CRM-19693 - Don't show options for disabled components
[civicrm-core.git] / CRM / Core / OptionGroup.php
index 8fdecdfdb5f91ba4ddeeff7e2d5540b4fd064415..a490208509772b453154e355f54089e2c87c80c2 100644 (file)
@@ -144,6 +144,8 @@ WHERE  v.option_group_id = g.id
 
     if ($onlyActive) {
       $query .= " AND  v.is_active = 1 ";
+      $enabledComponents = '"' . implode('","', CRM_Core_Config::singleton()->enableComponents) . '"';
+      $query .= " AND  (v.component_id IS NULL OR v.component_id IN (SELECT id FROM civicrm_component WHERE name IN ($enabledComponents))) ";
     }
     if (in_array($name, self::$_domainIDGroups)) {
       $query .= " AND v.domain_id = " . CRM_Core_Config::domainID();