From 6107673687a5fdefcc6056eb25988ed40ae61310 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 13 Feb 2019 16:45:11 +1300 Subject: [PATCH] Move addSelectWhere-like function to be located on BAO_Contribution using correct name. Since the contribution api uses the BAO_Query object I think it will not call this, nor reports AFAIK However, this should cause the v4 api to apply these. --- CRM/Contribute/BAO/Contribution.php | 27 +++++++++++++++++++++++++++ CRM/Financial/BAO/FinancialType.php | 22 ++-------------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index dc7a4f208f..2a16383aaf 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -879,6 +879,33 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { return self::$_exportableFields; } + /** + * @inheritDoc + */ + public function addSelectWhereClause() { + $whereClauses = parent::addSelectWhereClause(); + if ($whereClauses !== []) { + // In this case permisssions have been applied & we assume the + // financialaclreport is applying these + // https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport/blob/master/financialaclreport.php#L107 + return $whereClauses; + } + + if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { + return $whereClauses; + } + $types = CRM_Financial_BAO_FinancialType::getAllEnabledAvailableFinancialTypes(); + if (empty($types)) { + $whereClauses['financial_type_id'] = 'IN (0)'; + } + else { + $whereClauses['financial_type_id'] = [ + 'IN (' . implode(',', array_keys($types)) . ')' + ]; + } + return $whereClauses; + } + /** * @param null $status * @param null $startDate diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 1b81f316fc..8ce7ad05fb 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -360,27 +360,9 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { * @param array $whereClauses */ public static function addACLClausesToWhereClauses(&$whereClauses) { - $originalWhereClauses = $whereClauses; - CRM_Utils_Hook::selectWhereClause('Contribution', $whereClauses); - if ($whereClauses !== $originalWhereClauses) { - // In this case permisssions have been applied & we assume the - // financialaclreport is applying these - // https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport/blob/master/financialaclreport.php#L107 - return; - } + $contributionBAO = new CRM_Contribute_BAO_Contribution(); + $whereClauses = array_merge($whereClauses, $contributionBAO->addSelectWhereClause()); - if (!self::isACLFinancialTypeStatus()) { - return; - } - $types = self::getAllEnabledAvailableFinancialTypes(); - if (empty($types)) { - $whereClauses['financial_type_id'] = 'IN (0)'; - } - else { - $whereClauses['financial_type_id'] = [ - 'IN (' . implode(',', array_keys($types)) . ')' - ]; - } } /** -- 2.25.1