$action = strtolower(CRM_Utils_Array::value('action', $apiRequest['params']));
$sequential = empty($apiRequest['params']) ? 0 : 1;
$apiOptions = CRM_Utils_Array::value('options', $apiRequest['params'], array());
- if ($action == 'getvalue' || $action == 'getvalue' || $action == 'getcount') {
+ if (!$action || $action == 'getvalue' || $action == 'getcount') {
$action = 'get';
}
-
- if (empty($action)) {
- $action='get';
- }
// determines whether to use unique field names - seem comment block above
$unique = TRUE;
if (empty($apiOptions) && isset($results[$entity . $subentity]) && isset($action, $results[$entity . $subentity])
$output[] = array('key' => $key, 'value' => $val);
}
}
- return civicrm_api3_create_success($output);
+ return civicrm_api3_create_success($output, $apiRequest['params'], $apiRequest['entity'], 'getoptions');
}
/**
*
* @return array $result
*/
-function civicrm_api3_create_success($values = 1, $params = array(
- ), $entity = NULL, $action = NULL, &$dao = NULL, $extraReturnValues = array()) {
+function civicrm_api3_create_success($values = 1, $params = array(), $entity = NULL, $action = NULL, &$dao = NULL, $extraReturnValues = array()) {
$result = array();
$result['is_error'] = 0;
//lets set the ['id'] field if it's not set & we know what the entity is
if(!empty($params['options']['metadata'])) {
// we've made metadata an array but only supporting 'fields' atm
if(in_array('fields', $params['options']['metadata'])) {
- $fields = civicrm_api3($entity, 'getfields', array('action' => $action));
+ $fields = civicrm_api3($entity, 'getfields', array('action' => substr($action, 0, 3) == 'get' ? 'get' : 'create'));
$result['metadata']['fields'] = $fields['values'];
}
}