From 0400dfac22eae354519a68e2f174f3c50a3b65dd Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 2 Sep 2013 18:19:37 -0700 Subject: [PATCH] CRM-13027 - Pass api_v3_CustomValueContactTypeTest::testGetFields ---------------------------------------- * CRM-13027: Default getFields returns irrelevant custom-data fields http://issues.civicrm.org/jira/browse/CRM-13027 --- CRM/Core/BAO/CustomField.php | 7 +++++-- api/v3/utils.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index c00cf9125f..00b6a1f9ff 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -363,7 +363,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { /** * Store and return an array of all active custom fields. * - * @param string $customDataType type of Custom Data + * @param string $customDataType type of Custom Data; empty is a synonym for "all contact data types" * @param boolean $showAll If true returns all fields (includes disabled fields) * @param boolean $inline If true returns all inline fields (includes disabled fields) * @param int $customDataSubType Custom Data sub type value @@ -386,6 +386,9 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { $onlySubType = FALSE, $checkPermission = TRUE ) { + if (empty($customDataType)) { + $customDataType = array('Contact', 'Individual', 'Organization', 'Household'); + } if ($customDataType && !is_array($customDataType)) { if (in_array($customDataType, CRM_Contact_BAO_ContactType::subTypes())) { @@ -476,7 +479,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { } if (!empty($customDataType) && empty($extends)) { - // $customDataType did not include any customizable/extendable entities. + // $customDataType specified a filter, but there is no corresponding SQL ($extends) self::$_importFields[$cacheKey] = array(); return self::$_importFields[$cacheKey]; } diff --git a/api/v3/utils.php b/api/v3/utils.php index e13da2483a..d9f011a1e6 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1330,7 +1330,7 @@ function _civicrm_api_get_custom_fields($entity, &$params) { $entity = _civicrm_api_get_camel_name($entity); if (strtolower($entity) == 'contact') { // Use sub-type if available, otherwise stick with 'Contact' - $entity = CRM_Utils_Array::value('contact_type', $params, $entity); + $entity = CRM_Utils_Array::value('contact_type', $params); } $retrieveOnlyParent = FALSE; // we could / should probably test for other subtypes here - e.g. activity_type_id -- 2.25.1