Skip to content

Commit

Permalink
Fix check for financial acls to look for setting rather than sub-key …
Browse files Browse the repository at this point in the history
…of non-standard civicontribute_settings' setting
  • Loading branch information
eileenmcnaughton committed Nov 22, 2018
1 parent c00aeff commit 2fc43bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions CRM/Financial/BAO/FinancialType.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,12 @@ public static function checkPermissionToEditFinancialType($financialTypeID) {
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'];
Expand Down
6 changes: 4 additions & 2 deletions tests/phpunit/CRMTraits/Financial/FinancialACLTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand All @@ -49,7 +50,8 @@ protected function enableFinancialACLs() {
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']);
}
Expand Down

0 comments on commit 2fc43bb

Please sign in to comment.