From ddaac11cb40536314d5697df41ee5dd081c1ee83 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 20 Apr 2014 18:14:00 -0700 Subject: [PATCH] API - Pass 'sequential' option from getfields to getoptions --- api/v3/Generic.php | 6 +++--- api/v3/utils.php | 15 ++++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/api/v3/Generic.php b/api/v3/Generic.php index cd92adbec2..850740a494 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -119,7 +119,7 @@ function civicrm_api3_generic_getfields($apiRequest) { $fieldsToResolve = (array) CRM_Utils_Array::value('get_options', $apiOptions, array()); foreach ($metadata as $fieldname => $fieldSpec) { - _civicrm_api3_generic_get_metadata_options($metadata, $apiRequest['entity'], $fieldname, $fieldSpec, $fieldsToResolve); + _civicrm_api3_generic_get_metadata_options($metadata, $apiRequest, $fieldname, $fieldSpec, $fieldsToResolve); } $results[$entity][$action][$sequential] = civicrm_api3_create_success($metadata, $apiRequest['params'], NULL, 'getfields'); @@ -257,7 +257,7 @@ function civicrm_api3_generic_getoptions($apiRequest) { * @param array $fieldSpec metadata for that field * @param array $fieldsToResolve anny field resolutions specifically requested */ -function _civicrm_api3_generic_get_metadata_options(&$metadata, $entity, $fieldname, $fieldSpec, $fieldsToResolve){ +function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fieldname, $fieldSpec, $fieldsToResolve){ if (empty($fieldSpec['pseudoconstant'])) { return; } @@ -266,7 +266,7 @@ function _civicrm_api3_generic_get_metadata_options(&$metadata, $entity, $fieldn return; } - $options = civicrm_api($entity, 'getoptions', array('version' => 3, 'field' => $fieldname)); + $options = civicrm_api($apiRequest['entity'], 'getoptions', array('version' => 3, 'field' => $fieldname, 'sequential' => !empty($apiRequest['params']['sequential']))); if (is_array(CRM_Utils_Array::value('values', $options))) { $metadata[$fieldname]['options'] = $options['values']; } diff --git a/api/v3/utils.php b/api/v3/utils.php index 3fde44b5ae..6a4b449677 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1447,23 +1447,16 @@ function _civicrm_api_get_custom_fields($entity, &$params) { FALSE, FALSE ); - // find out if we have any requests to resolve options - $getoptions = CRM_Utils_Array::value('get_options', CRM_Utils_Array::value('options',$params)); - if(!is_array($getoptions)){ - $getoptions = array($getoptions); - } + + $ret = array(); foreach ($customfields as $key => $value) { // Regular fields have a 'name' property $value['name'] = 'custom_' . $key; $value['type'] = _getStandardTypeFromCustomDataType($value['data_type']); - $customfields['custom_' . $key] = $value; - if (in_array('custom_' . $key, $getoptions)) { - $customfields['custom_' . $key]['options'] = CRM_Core_BAO_CustomOption::valuesByID($key); - } - unset($customfields[$key]); + $ret['custom_' . $key] = $value; } - return $customfields; + return $ret; } /** * Translate the custom field data_type attribute into a std 'type' -- 2.25.1