$getFieldsResult = civicrm_api3($entity, 'getfields', array('action' => 'get'));
$getFieldsResult = $getFieldsResult['values'];
foreach ($getFieldsResult as $getFieldKey => $getFieldSpec) {
- $uniqueAliases[$getFieldKey] = $getFieldSpec['name'];
- $uniqueAliases[$getFieldSpec['name']] = $getFieldSpec['name'];
+ if (in_array($getFieldSpec['name'], $entity_field_names)) {
+ $uniqueAliases[$getFieldKey] = $getFieldSpec['name'];
+ $uniqueAliases[$getFieldSpec['name']] = $getFieldSpec['name'];
+ foreach (CRM_Utils_Array::value('api.aliases', $getFieldSpec, array()) as $alias) {
+ $uniqueAliases[$alias] = $getFieldSpec['name'];
+ }
+ }
}
// $select_fields maps column names to the field names of the result
$return = $return_all_fields ? array_fill_keys($entity_field_names, 1) : $options['return'];
// default fields
- foreach (array_keys($return) as $field_name) {
- if (!empty($uniqueAliases[$field_name]) && (CRM_Core_BAO_CustomField::getKeyID($field_name) == FALSE)) {
+ foreach ($return as $field_name => $include) {
+ if ($include && !empty($uniqueAliases[$field_name])) {
// 'a.' is an alias for the entity table.
$select_fields["a.{$uniqueAliases[$field_name]}"] = $uniqueAliases[$field_name];
}
*
* @return array
*/
-function _civicrm_api3_basic_get($bao_name, &$params, $returnAsSuccess = TRUE, $entity = "", $sql = NULL, $uniqueFields = FALSE) {
-
+function _civicrm_api3_basic_get($bao_name, $params, $returnAsSuccess = TRUE, $entity = "", $sql = NULL, $uniqueFields = FALSE) {
+ $result = _civicrm_api3_get_using_utils_sql($bao_name, $params, $uniqueFields, $sql);
if ($returnAsSuccess) {
- return civicrm_api3_create_success(_civicrm_api3_get_using_utils_sql($bao_name, $params, $uniqueFields, $sql), $params, $entity, 'get');
- }
- else {
- return _civicrm_api3_get_using_utils_sql($bao_name, $params, $uniqueFields, $sql);
+ return civicrm_api3_create_success($result, $params, $entity, 'get');
}
+ return $result;
}
/**