X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FContribution.php;h=cb138a484e0af7120db4d18cccb72075b2f70f85;hb=64a155b595059761e3a852be1a44225b29107366;hp=00aa5ccbdb78f79c026ee22f1c3adb8ad69a59ce;hpb=d4e756e0e56c4842a5266eaa4c7f26cb5a0facae;p=civicrm-core.git diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 00aa5ccbdb..cb138a484e 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -123,21 +123,21 @@ function _civicrm_api3_contribution_create_spec(&$params) { $params['soft_credit_to'] = array( 'name' => 'soft_credit_to', 'title' => 'Soft Credit contact ID (legacy)', - 'type' => 1, + 'type' => CRM_Utils_Type::T_INT, '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 (legacy)', - 'type' => 1, + 'type' => CRM_Utils_Type::T_INT, '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, + 'type' => CRM_Utils_Type::T_INT, 'description' => 'Type of honoree contact (deprecated - use contribution_soft api)', 'pseudoconstant' => TRUE, ); @@ -158,9 +158,14 @@ function _civicrm_api3_contribution_create_spec(&$params) { ); $params['batch_id'] = array( 'title' => 'Batch', - 'type' => 1, + 'type' => CRM_Utils_Type::T_INT, 'description' => 'Batch which relevant transactions should be added to', ); + $params['refund_trxn_id'] = array( + 'title' => 'Refund Transaction ID', + 'type' => CRM_Utils_Type::T_STRING, + 'description' => 'Transaction ID specific to the refund taking place', + ); } /** @@ -241,18 +246,29 @@ function _civicrm_api3_contribution_delete_spec(&$params) { function civicrm_api3_contribution_get($params) { $mode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE; - list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Contribution'); - - $contribution = array(); - while ($dao->fetch()) { - //CRM-8662 - $contribution_details = $query->store($dao); - $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE); - $contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution); + $returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties($mode); + + $contributions = _civicrm_api3_get_using_query_object('Contribution', $params, array(), NULL, $mode, $returnProperties); + + foreach ($contributions as $id => $contribution) { + $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id, TRUE); + $contributions[$id] = array_merge($contribution, $softContribution); // format soft credit for backward compatibility - _civicrm_api3_format_soft_credit($contribution[$dao->contribution_id]); + _civicrm_api3_format_soft_credit($contributions[$id]); } - return civicrm_api3_create_success($contribution, $params, 'Contribution', 'get', $dao); + return civicrm_api3_create_success($contributions, $params, 'Contribution', 'get'); +} + +/** + * Get number of contacts matching the supplied criteria. + * + * @param array $params + * + * @return int + */ +function civicrm_api3_contribution_getcount($params) { + $count = _civicrm_api3_get_using_query_object('Contribution', $params, array(), TRUE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE); + return (int) $count; } /**