X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FGeneric.php;h=ee41baa8a80ccab305cf2cb86beb98fa14f4afc0;hb=2241036a1adf3cf03fdcc86f4328ad98f89f6b59;hp=3de180b9ea5b7048080e376c681556a32a3727ab;hpb=0db6c3e15a8324d7f2d73c43c9b219a829351157;p=civicrm-core.git diff --git a/api/v3/Generic.php b/api/v3/Generic.php index 3de180b9ea..ee41baa8a8 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -17,7 +17,7 @@ * - version: string * - function: callback (mixed) * - params: array, varies - * @return array API success object + * @return array API success object */ function civicrm_api3_generic_getfields($apiRequest) { static $results = array(); @@ -25,12 +25,12 @@ function civicrm_api3_generic_getfields($apiRequest) { $results = array(); // we will also clear pseudoconstants here - should potentially be moved to relevant BAO classes CRM_Core_PseudoConstant::flush(); - if(!empty($apiRequest['params']['fieldname'])){ + if (!empty($apiRequest['params']['fieldname'])) { CRM_Utils_PseudoConstant::flushConstant($apiRequest['params']['fieldname']); } - if(!empty($apiRequest['params']['option_group_id'])){ - $optionGroupName = civicrm_api('option_group', 'getvalue', array('version' => 3, 'id' => $apiRequest['params']['option_group_id'], 'return' => 'name') ); - if(is_string($optionGroupName)){ + if (!empty($apiRequest['params']['option_group_id'])) { + $optionGroupName = civicrm_api('option_group', 'getvalue', array('version' => 3, 'id' => $apiRequest['params']['option_group_id'], 'return' => 'name')); + if (is_string($optionGroupName)) { CRM_Utils_PseudoConstant::flushConstant(_civicrm_api_get_camel_name($optionGroupName)); } } @@ -63,15 +63,15 @@ function civicrm_api3_generic_getfields($apiRequest) { case 'getsingle': case 'getcount': $metadata = _civicrm_api_get_fields($apiRequest['entity'], $unique, $apiRequest['params']); - if (empty($metadata['id'])){ + if (empty($metadata['id'])) { // if id is not set we will set it eg. 'id' from 'case_id', case_id will be an alias - if(!empty($metadata[strtolower($apiRequest['entity']) . '_id'])) { + if (!empty($metadata[strtolower($apiRequest['entity']) . '_id'])) { $metadata['id'] = $metadata[$lcase_entity . '_id']; unset($metadata[$lcase_entity . '_id']); $metadata['id']['api.aliases'] = array($lcase_entity . '_id'); } } - else{ + else { // really the preference would be to set the unique name in the xml // question is which is a less risky fix this close to a release - setting in xml for the known failure // (note) or setting for all api where fields is returning 'id' & we want to accept 'note_id' @ the api layer @@ -104,7 +104,8 @@ function civicrm_api3_generic_getfields($apiRequest) { 'title' => 'Context', ), ); - break; + break; + default: // oddballs are on their own $metadata = array(); @@ -152,10 +153,10 @@ function civicrm_api3_generic_getfields($apiRequest) { function civicrm_api3_generic_getcount($apiRequest) { $apiRequest['params']['options']['is_count'] = TRUE; $result = civicrm_api($apiRequest['entity'], 'get', $apiRequest['params']); - if(is_numeric (CRM_Utils_Array::value('values', $result))) { + if (is_numeric(CRM_Utils_Array::value('values', $result))) { return (int) $result['values']; } - if(!isset($result['count'])) { + if (!isset($result['count'])) { throw new API_Exception(ts('Unexpected result from getcount') . print_r($result, TRUE)); } return $result['count']; @@ -315,7 +316,7 @@ function civicrm_api3_generic_getoptions($apiRequest) { * @param array $fieldsToResolve * Anny field resolutions specifically requested. */ -function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fieldname, $fieldSpec, $fieldsToResolve){ +function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fieldname, $fieldSpec, $fieldsToResolve) { if (empty($fieldSpec['pseudoconstant']) && empty($fieldSpec['option_group_id'])) { return; }