Skip to content

Commit 40c125f

Browse files
committed
Merge pull request civicrm#28 from Edzelopez/CIVI-28
CIVI-28 Added support for delete contribution API
2 parents f496823 + 8fd2c9d commit 40c125f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/v3/Contribution.php

+8
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ function _civicrm_api3_contribution_create_legacy_support_45(&$params) {
191191
function civicrm_api3_contribution_delete($params) {
192192

193193
$contributionID = !empty($params['contribution_id']) ? $params['contribution_id'] : $params['id'];
194+
// First check contribution financial type
195+
$financialType = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionID, 'financial_type_id');
196+
197+
// Now check permissioned lineitems & permissioned contribution
198+
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($financialType)) ||
199+
!CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributionID, 'delete', FALSE)) {
200+
return civicrm_api3_create_error('You do not have permission to delete this contribution');
201+
}
194202
if (CRM_Contribute_BAO_Contribution::deleteContribution($contributionID)) {
195203
return civicrm_api3_create_success(array($contributionID => 1));
196204
}

0 commit comments

Comments
 (0)