Move addSelectWhere-like function to be located on BAO_Contribution using correct...
authoreileen <emcnaughton@wikimedia.org>
Wed, 13 Feb 2019 03:45:11 +0000 (16:45 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 15 Feb 2019 01:07:51 +0000 (14:07 +1300)
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
CRM/Financial/BAO/FinancialType.php

index dc7a4f208f41552a06e6d8ea51b3d3b869d788b6..2a16383aafa4ff4a65771ab3b516c895c1859d0f 100644 (file)
@@ -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
index 1b81f316fcbee1160371a073a9fe4c6b754594c3..8ce7ad05fb3547156982691fdaf5ab786ac9f397 100644 (file)
@@ -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)) . ')'
-      ];
-    }
   }
 
   /**