X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FCustomValue.php;h=1ae1f8e14f2fa269eb0d7cd3d9e7309dab1c0a34;hb=beffaf98f29d6d8358e87679d1cb630c68c18dbd;hp=dde56fd8a72c372541aebb1b621dd5323330b5c9;hpb=b5417037203bb99886369cba7a788f3c500c4480;p=civicrm-core.git diff --git a/api/v3/CustomValue.php b/api/v3/CustomValue.php index dde56fd8a7..1ae1f8e14f 100644 --- a/api/v3/CustomValue.php +++ b/api/v3/CustomValue.php @@ -2,9 +2,9 @@ /* +--------------------------------------------------------------------+ - | CiviCRM version 4.4 | + | CiviCRM version 4.5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2013 | + | Copyright CiviCRM LLC (c) 2004-2014 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -32,7 +32,7 @@ * @package CiviCRM_APIv3 * @subpackage API_CustomField * - * @copyright CiviCRM LLC (c) 2004-2013 + * @copyright CiviCRM LLC (c) 2004-2014 * @version $Id: CustomField.php 30879 2010-11-22 15:45:55Z shot $ */ @@ -47,28 +47,28 @@ * * @param $params expected keys are in format custom_fieldID:recordID or custom_groupName:fieldName:recordID * for example: - // entity ID. You do not need to specify entity type, we figure it out based on the fields you're using + * // entity ID. You do not need to specify entity type, we figure it out based on the fields you're using * 'entity_id' => 123, - // (omitting :id) inserts or updates a field in a single-valued group + * // (omitting :id) inserts or updates a field in a single-valued group * 'custom_6' => 'foo', - // custom_24 is checkbox or multiselect, so pass items as an array + * // custom_24 is checkbox or multiselect, so pass items as an array * 'custom_24' => array('bar', 'baz'), - // in this case custom_33 is part of a multi-valued group, and we're updating record id 5 + * // in this case custom_33 is part of a multi-valued group, and we're updating record id 5 * 'custom_33:5' => value, - // inserts new record in multi-valued group + * // inserts new record in multi-valued group * 'custom_33:-1' => value, - // inserts another new record in multi-valued group + * // inserts another new record in multi-valued group * 'custom_33:-2' => value, - // you can use group_name:field_name instead of ID + * // you can use group_name:field_name instead of ID * 'custom_some_group:my_field => 'myinfo', - // updates record ID 8 in my_other_field in multi-valued some_big_group + * // updates record ID 8 in my_other_field in multi-valued some_big_group * 'custom_some_big_group:my_other_field:8 => 'myinfo', * * + * @throws Exception * @return array('values' => TRUE) or array('is_error' => 1, 'error_message' => 'what went wrong') * * @access public - * */ function civicrm_api3_custom_value_create($params) { // @todo it's not clear where the entity_table is used as CRM_Core_BAO_CustomValueTable::setValues($create) @@ -122,6 +122,7 @@ function civicrm_api3_custom_value_create($params) { function _civicrm_api3_custom_value_create_spec(&$params) { $params['entity_id']['api.required'] = 1; } + /** * Use this API to get existing custom values for an entity. * @@ -133,6 +134,7 @@ function _civicrm_api3_custom_value_create_spec(&$params) { * Example: 'entity_id' => 123, 'return.custom_6' => 1, 'return.custom_33' => 1 * If you do not know the ID, you may use group name : field name, for example 'return.foo_stuff:my_field' => 1 * + * @throws API_Exception * @return array. * * @access public @@ -194,7 +196,8 @@ function civicrm_api3_custom_value_get($params) { continue; } $fieldNumber = $idArray[1]; - $info = array_pop(CRM_Core_BAO_CustomField::getNameFromID($fieldNumber)); + $customFieldInfo = CRM_Core_BAO_CustomField::getNameFromID($fieldNumber); + $info = array_pop($customFieldInfo); // id is the index for returned results if (empty($idArray[2])) { @@ -205,14 +208,14 @@ function civicrm_api3_custom_value_get($params) { $n = $idArray[2]; $id = $fieldNumber . "." . $idArray[2]; } - if (CRM_Utils_Array::value('format.field_names', $params)) { + if (!empty($params['format.field_names'])) { $id = $info['field_name']; } else { $id = $fieldNumber; } $values[$id]['entity_id'] = $getParams['entityID']; - if (CRM_Utils_Array::value('entityType', $getParams)) { + if (!empty($getParams['entityType'])) { $values[$n]['entity_table'] = $getParams['entityType']; } //set 'latest' -useful for multi fields but set for single for consistency