}
// Extract the keys -- somewhat scary, don't think too hard about it
- $baseParams = $params;
- unset($baseParams['values']);
- unset($baseParams['sequential']);
+ $baseParams = _civicrm_api3_generic_replace_base_params($params);
// Lookup pre-existing records
$preexisting = civicrm_api($entity, 'get', $baseParams, $params);
}
}
+function _civicrm_api3_generic_replace_base_params($params) {
+ $baseParams = $params;
+ unset($baseParams['values']);
+ unset($baseParams['sequential']);
+ unset($baseParams['options']);
+ return $baseParams;
+}
+
/**
* returns fields allowable by api
* @param $entity string Entity to query
$customfields = array();
$entity = _civicrm_api_get_camel_name($entity);
if (strtolower($entity) == 'contact') {
- $entity = CRM_Utils_Array::value('contact_type', $params);
+ // Use sub-type if available, otherwise stick with 'Contact'
+ $entity = CRM_Utils_Array::value('contact_type', $params, $entity);
}
$retrieveOnlyParent = FALSE;
// we could / should probably test for other subtypes here - e.g. activity_type_id