CRM-19693 - Don't show options for disabled components
[civicrm-core.git] / CRM / Core / OptionGroup.php
index f4be86c75d36fcd657a5cb414e6d034a5cba7596..a490208509772b453154e355f54089e2c87c80c2 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016                                |
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  */
 class CRM_Core_OptionGroup {
   static $_values = array();
@@ -108,10 +108,10 @@ class CRM_Core_OptionGroup {
    *   ignore cache entries and go back to DB.
    * @param string $keyColumnName
    *   the column to use for 'key'.
+   * @param string $orderBy
    *
    * @return array
-   *   the values as specified by the above params
-   * @void
+   *   The values as specified by the params
    */
   public static function &values(
     $name, $flip = FALSE, $grouping = FALSE,
@@ -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();