From: Coleman Watts Date: Thu, 22 Jan 2015 18:36:19 +0000 (-0500) Subject: CRM-15759 - Fix pseudoconstant matching for api.setvalue X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=99efe93a7eb8ad8355753533dd2863faec158b90;p=civicrm-core.git CRM-15759 - Fix pseudoconstant matching for api.setvalue --- diff --git a/api/v3/Generic/Setvalue.php b/api/v3/Generic/Setvalue.php index 55ba8b5bdf..7edb1785f6 100644 --- a/api/v3/Generic/Setvalue.php +++ b/api/v3/Generic/Setvalue.php @@ -92,7 +92,7 @@ function civicrm_api3_generic_setValue($apiRequest) { $params = array('id' => $id, $field => $value); if ((!empty($def['pseudoconstant']) || !empty($def['option_group_id'])) && $value !== '' && $value !== 'null') { - _civicrm_api3_api_match_pseudoconstant($params, $entity, $field, $def); + _civicrm_api3_api_match_pseudoconstant($params[$field], $entity, $field, $def); } CRM_Utils_Hook::pre('edit', $entity, $id, $params); @@ -106,16 +106,21 @@ function civicrm_api3_generic_setValue($apiRequest) { } CRM_Core_BAO_CustomValueTable::setValues($params); CRM_Utils_Hook::post('edit', $entity, $id, CRM_Core_DAO::$_nullObject); - return civicrm_api3_create_success($params); } // Core fields elseif (CRM_Core_DAO::setFieldValue($dao_name, $id, $field, $params[$field])) { $entityDAO = new $dao_name(); $entityDAO->copyValues($params); CRM_Utils_Hook::post('edit', $entity, $entityDAO->id, $entityDAO); - return civicrm_api3_create_success($params); } else { return civicrm_api3_create_error("error assigning $field=$value for $entity (id=$id)"); } + + // Add changelog entry - TODO: Should we do this for other entities as well? + if (strtolower($entity) === 'contact') { + CRM_Core_BAO_Log::register($id, 'civicrm_contact', $id); + } + + return civicrm_api3_create_success($params); }