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

Move financial acl setting to the extension #21120

Merged
merged 1 commit into from
Aug 30, 2021
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
10 changes: 10 additions & 0 deletions ext/financialacls/financialacls.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,16 @@ function financialacls_is_acl_limiting_enabled(): bool {
return (bool) Civi::settings()->get('acl_financial_type');
}

/**
* Clear the statics cache when the setting is enabled or disabled.
*
* Note the setting will eventually disappear in favour of whether
* the extension is enabled or disabled.
*/
function financialacls_toggle() {
unset(\Civi::$statics['CRM_Financial_BAO_FinancialType']);
}

// --- Functions below this ship commented out. Uncomment as required. ---

/**
Expand Down
22 changes: 22 additions & 0 deletions ext/financialacls/settings/financialacls.setting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
return [
'acl_financial_type' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'acl_financial_type',
'type' => 'Boolean',
'html_type' => 'checkbox',
'quick_form_type' => 'Element',
'default' => 0,
'add' => '4.7',
'title' => ts('Enable Access Control by Financial Type'),
'is_domain' => 1,
'is_contact' => 0,
'help_text' => NULL,
'help' => ['id' => 'acl_financial_type'],
'settings_pages' => ['contribute' => ['weight' => 30]],
'on_change' => [
'financialacls_toggle',
],
],
];
16 changes: 0 additions & 16 deletions settings/Contribute.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,6 @@
'is_contact' => 0,
'pseudoconstant' => ['callback' => 'CRM_Core_SelectValues::taxDisplayOptions'],
],
'acl_financial_type' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'acl_financial_type',
'type' => 'Boolean',
'html_type' => 'checkbox',
'quick_form_type' => 'Element',
'default' => 0,
'add' => '4.7',
'title' => ts('Enable Access Control by Financial Type'),
'is_domain' => 1,
'is_contact' => 0,
'help_text' => NULL,
'help' => ['id' => 'acl_financial_type'],
'settings_pages' => ['contribute' => ['weight' => 30]],
],
'deferred_revenue_enabled' => [
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
Expand Down
8 changes: 1 addition & 7 deletions tests/phpunit/CRMTraits/Financial/FinancialACLTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,18 @@ trait CRMTraits_Financial_FinancialACLTrait {
* Enable financial ACLs.
*/
protected function enableFinancialACLs() {
$contributeSettings = Civi::settings()->get('contribution_invoice_settings');
$this->callAPISuccess('Setting', 'create', [
'contribution_invoice_settings' => array_merge($contributeSettings, ['acl_financial_type' => TRUE]),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was actually the first setting we separated out of the contribution_invoice_settings borg & has been a free agent even longer than the rest

'acl_financial_type' => TRUE,
]);
unset(\Civi::$statics['CRM_Financial_BAO_FinancialType']);
}

/**
* Disable financial ACLs.
*/
protected function disableFinancialACLs() {
$contributeSettings = Civi::settings()->get('contribution_invoice_settings');
protected function disableFinancialACLs(): void {
$this->callAPISuccess('Setting', 'create', [
'contribution_invoice_settings' => array_merge($contributeSettings, ['acl_financial_type' => FALSE]),
'acl_financial_type' => FALSE,
]);
unset(\Civi::$statics['CRM_Financial_BAO_FinancialType']);
}

/**
Expand Down