Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not check financial permissions on contribution.create if check_perrmissions is FALSE. #13318

Merged
merged 1 commit into from
Jan 5, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Alters Contribution.create api to respect the check_permissions flag when Financial ACLs are enabled

Before

when calling
civicrm_api3('Contribution', 'create', ['check_permissions' => FALSE.....

The check_permissions is ignored when applying financial type acls

After

In above scenario the flag is respected

Technical Details

Our standard is to only check permissions at the api layer if check_permissions is TRUE
(which is is by default for javascript calls but not in php calls)

Comments

@monishdeb @JoeMurray

@civibot
Copy link

civibot bot commented Dec 19, 2018

(Standard links)

@civibot civibot bot added the master label Dec 19, 2018
@eileenmcnaughton
Copy link
Contributor Author

@monishdeb can you check this? It came up when writing unit tests for the annual query

@monishdeb
Copy link
Member

monishdeb commented Jan 2, 2019

I agree with this one-liner change about respecting check_permissions on create action. Also Lineitem get and delete API does this similar check too. In addition I think you also need to add this check inside Contribution.delete API too:

diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php
index a52600f6d8..2e671b0876 100644
--- a/api/v3/Contribution.php
+++ b/api/v3/Contribution.php
@@ -221,7 +221,7 @@ function civicrm_api3_contribution_delete($params) {
   // First check contribution financial type
   $financialType = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionID, 'financial_type_id');
   // Now check permissioned lineitems & permissioned contribution
-  if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()
+  if (!empty($params['check_permissions']) && CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()
     && !CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($financialType)) ||
       !CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributionID, 'delete', FALSE)
   ) {

@eileenmcnaughton
Copy link
Contributor Author

@monishdeb good spotting - I added to delete - took a bit of getting the braces right - double check you agree.

@monishdeb
Copy link
Member

Yes, working fine. Marking with Merge-on-Pass

@monishdeb
Copy link
Member

Jenkins test this please

…rmissions is FALSE.

Our standard is to only check permissions at the api layer if check_permissions is TRUE
(which is is by default for javascript calls but not in php calls)
@eileenmcnaughton
Copy link
Contributor Author

merging per @monishdeb approval

@eileenmcnaughton eileenmcnaughton deleted the api_perm branch January 5, 2019 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants