Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check for financial acls to look for setting rather than sub-key of non-standard civicontribute_settings' setting #13150

Merged
merged 1 commit into from
Nov 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Copy link
Member

@monishdeb monishdeb Nov 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm

\Civi::$statics[__CLASS__]['is_acl_enabled'] = Civi::settings()->get('acl_financial_type') ?: CRM_Utils_Array::value('acl_financial_type', Civi::settings()->get('contribution_invoice_settings'), FALSE);

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so but I kinda wanted to parse out the bit that should be deprecated / removed

}
}
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