From: Coleman Watts Date: Thu, 20 Nov 2014 21:16:39 +0000 (-0500) Subject: CRM-15625 - Add support for contribution api honor_type_id param X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=33a429d4e1ec211e0d02d627ca81e96a04240fba;p=civicrm-core.git CRM-15625 - Add support for contribution api honor_type_id param --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index bffeb39cd3..2e0fc7551f 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3093,6 +3093,13 @@ WHERE contribution_id = %1 "; $types = (array) CRM_Utils_Array::value('payment_processor', $page, 0); $params['condition'] = 'id IN (' . implode(',', $types) . ')'; } + break; + // CRM-13981 This field was combined with soft_credits in 4.5 but the api still supports it + case 'honor_type_id': + $className = 'CRM_Contribute_BAO_ContributionSoft'; + $fieldName = 'soft_credit_type_id'; + $params['condition'] = "v.name IN ('in_honor_of','in_memory_of')"; + break; } return CRM_Core_PseudoConstant::get($className, $fieldName, $params, $context); } diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 80216edb4c..052d488ca0 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -100,18 +100,25 @@ function _civicrm_api3_contribution_create_spec(&$params) { ); $params['soft_credit_to'] = array( 'name' => 'soft_credit_to', - 'title' => 'Soft Credit contact ID', + 'title' => 'Soft Credit contact ID (legacy)', 'type' => 1, - 'description' => 'ID of Contact to be Soft credited to', + 'description' => 'ID of Contact to be Soft credited to (deprecated - use contribution_soft api)', 'FKClassName' => 'CRM_Contact_DAO_Contact', ); $params['honor_contact_id'] = array( 'name' => 'honor_contact_id', - 'title' => 'Honoree contact ID', + 'title' => 'Honoree contact ID (legacy)', 'type' => 1, - 'description' => 'ID of honoree contact', + 'description' => 'ID of honoree contact (deprecated - use contribution_soft api)', 'FKClassName' => 'CRM_Contact_DAO_Contact', ); + $params['honor_type_id'] = array( + 'name' => 'honor_type_id', + 'title' => 'Honoree Type (legacy)', + 'type' => 1, + 'description' => 'Type of honoree contact (deprecated - use contribution_soft api)', + 'pseudoconstant' => TRUE, + ); // note this is a recommended option but not adding as a default to avoid // creating unnecessary changes for the dev $params['skipRecentView'] = array( @@ -143,16 +150,18 @@ function _civicrm_api3_contribution_create_spec(&$params) { function _civicrm_api3_contribution_create_legacy_support_45(&$params){ //legacy soft credit handling - recommended approach is chaining if(!empty($params['soft_credit_to'])){ - $params['soft_credit'] = array(array( + $params['soft_credit'][] = array( 'contact_id' => $params['soft_credit_to'], 'amount' => $params['total_amount'], - 'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"))); + 'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type") + ); } if(!empty($params['honor_contact_id'])){ - $params['soft_credit'] = array(array( + $params['soft_credit'][] = array( 'contact_id' => $params['honor_contact_id'], 'amount' => $params['total_amount'], - 'soft_credit_type_id' => CRM_Core_OptionGroup::getValue('soft_credit_type', 'in_honor_of', 'name'))); + 'soft_credit_type_id' => CRM_Utils_Array::value('honor_type_id', $params, CRM_Core_OptionGroup::getValue('soft_credit_type', 'in_honor_of', 'name')) + ); } }