From 3a59a6563b839ff53d8358f92bb1f18552a89604 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 14 Dec 2023 20:20:25 +1300 Subject: [PATCH] Remove duplicate check --- ext/financialacls/financialacls.php | 32 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/ext/financialacls/financialacls.php b/ext/financialacls/financialacls.php index 3202d32654..db21117fe1 100644 --- a/ext/financialacls/financialacls.php +++ b/ext/financialacls/financialacls.php @@ -458,25 +458,23 @@ function financialacls_civicrm_links(string $op, ?string $objectName, $objectID, } if ($objectName === 'Contribution') { // Now check for lineItems - if (Civi::settings()->get('acl_financial_type')) { - $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID((int) $objectID); - foreach ($lineItems as $item) { - $financialType = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'financial_type_id', $item['financial_type_id']); - if (!CRM_Core_Permission::check('view contributions of type ' . $financialType)) { - // Remove all links & early return for this contribution if there is an un-viewable financial type. - $links = []; - return; - } - if (!CRM_Core_Permission::check('edit contributions of type ' . $financialType)) { - unset($links[CRM_Core_Action::UPDATE]); - } - if (!CRM_Core_Permission::check('delete contributions of type ' . $financialType)) { - unset($links[CRM_Core_Action::DELETE]); - } + $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID((int) $objectID); + foreach ($lineItems as $item) { + $financialType = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'financial_type_id', $item['financial_type_id']); + if (!CRM_Core_Permission::check('view contributions of type ' . $financialType)) { + // Remove all links & early return for this contribution if there is an un-viewable financial type. + $links = []; + return; + } + if (!CRM_Core_Permission::check('edit contributions of type ' . $financialType)) { + unset($links[CRM_Core_Action::UPDATE]); + } + if (!CRM_Core_Permission::check('delete contributions of type ' . $financialType)) { + unset($links[CRM_Core_Action::DELETE]); } - $financialTypeID = $values['financial_type_id'] ?? CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $objectID, 'financial_type_id'); - $financialType = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'financial_type_id', $financialTypeID); } + $financialTypeID = $values['financial_type_id'] ?? CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $objectID, 'financial_type_id'); + $financialType = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'financial_type_id', $financialTypeID); } if (!empty($financialType)) { -- 2.25.1