Fix check for financial acls to look for setting rather than sub-key of non-standard...
authoreileen <emcnaughton@wikimedia.org>
Thu, 22 Nov 2018 02:25:46 +0000 (15:25 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 22 Nov 2018 04:08:45 +0000 (17:08 +1300)
CRM/Financial/BAO/FinancialType.php
tests/phpunit/CRMTraits/Financial/FinancialACLTrait.php

index 901e7888ee45c116ff31e9e72386d0070d898a34..788b38eb6f0f13491ba6b4c0c7c24cd684c139a0 100644 (file)
@@ -455,9 +455,12 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
   public static function isACLFinancialTypeStatus() {
     if (!isset(\Civi::$statics[__CLASS__]['is_acl_enabled'])) {
       \Civi::$statics[__CLASS__]['is_acl_enabled'] = FALSE;
-      $contributeSettings = Civi::settings()->get('contribution_invoice_settings');
-      if (CRM_Utils_Array::value('acl_financial_type', $contributeSettings)) {
-        \Civi::$statics[__CLASS__]['is_acl_enabled'] = TRUE;
+      $realSetting = \Civi::$statics[__CLASS__]['is_acl_enabled'] = Civi::settings()->get('acl_financial_type');
+      if (!$realSetting) {
+        $contributeSettings = Civi::settings()->get('contribution_invoice_settings');
+        if (CRM_Utils_Array::value('acl_financial_type', $contributeSettings)) {
+          \Civi::$statics[__CLASS__]['is_acl_enabled'] = TRUE;
+        }
       }
     }
     return \Civi::$statics[__CLASS__]['is_acl_enabled'];
index 93ce6ffad48ddf7fa972987fdae8323b0f6a87e3..da38c5ffc6f0c05105df62452a5ad3ce757f1154 100644 (file)
@@ -38,7 +38,8 @@ trait CRMTraits_Financial_FinancialACLTrait {
   protected function enableFinancialACLs() {
     $contributeSettings = Civi::settings()->get('contribution_invoice_settings');
     $this->callAPISuccess('Setting', 'create', [
-      'contribution_invoice_settings' => array_merge($contributeSettings, ['acl_financial_type' => TRUE])
+      'contribution_invoice_settings' => array_merge($contributeSettings, ['acl_financial_type' => TRUE]),
+      'acl_financial_type' => TRUE,
     ]);
     unset(\Civi::$statics['CRM_Financial_BAO_FinancialType']);
   }
@@ -49,7 +50,8 @@ trait CRMTraits_Financial_FinancialACLTrait {
   protected function disableFinancialACLs() {
     $contributeSettings = Civi::settings()->get('contribution_invoice_settings');
     $this->callAPISuccess('Setting', 'create', [
-      'contribution_invoice_settings' => array_merge($contributeSettings, ['acl_financial_type' => FALSE])
+      'contribution_invoice_settings' => array_merge($contributeSettings, ['acl_financial_type' => FALSE]),
+      'acl_financial_type' => FALSE,
     ]);
     unset(\Civi::$statics['CRM_Financial_BAO_FinancialType']);
   }