Skip to content

Commit 9065177

Browse files
committed
Merge pull request civicrm#21 from Edzelopez/CIVI-28
CIVI-28 Handled permission for create contribution API
2 parents e62c836 + 4cf6773 commit 9065177

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
@@ -46,6 +46,14 @@ function civicrm_api3_contribution_create(&$params) {
4646
_civicrm_api3_custom_format_params($params, $values, 'Contribution');
4747
$params = array_merge($params, $values);
4848

49+
if (empty($params['id'])) {
50+
$op = 'add';
51+
}
52+
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op);
53+
if (!in_array($params['financial_type_id'], array_keys($types))) {
54+
return civicrm_api3_create_error('You do not have permission to create this contribution');
55+
}
56+
4957
if (!empty($params['id']) && !empty($params['contribution_status_id'])) {
5058
$error = array();
5159
//throw error for invalid status change such as setting completed back to pending

0 commit comments

Comments
 (0)