From: eileen Date: Wed, 13 Feb 2019 03:45:11 +0000 (+1300) Subject: Move addSelectWhere-like function to be located on BAO_Contribution using correct... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6107673687a5fdefcc6056eb25988ed40ae61310;p=civicrm-core.git 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. --- 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)) . ')' - ]; - } } /**