make soft credits optional

This commit is contained in:
Marc Michalsky forumZFD 2021-03-04 17:55:19 +01:00
parent 6cac4882b5
commit db15d5deb1
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
4 changed files with 26 additions and 3 deletions

View file

@ -7,6 +7,7 @@ class CRM_TwingleCampaign_BAO_Configuration {
'twingle_api_key',
'twinglecampaign_xcm_profile',
'twinglecampaign_start_case',
'twinglecampaign_soft_credits'
];
@ -17,13 +18,19 @@ class CRM_TwingleCampaign_BAO_Configuration {
* Expects an array with key => value for the setting
*/
public static function set(array $settings) {
// Set twinglecampaign_soft_credits to '0' if checkbox is unchecked
if (!array_key_exists('twinglecampaign_soft_credits', $settings)) {
Civi::settings()->set('twinglecampaign_soft_credits', 0);
}
Civi::settings()->add($settings);
}
/**
* Returns a specific value of a setting if the key is passed as parameter.
* Else all settings will be returned als associative array.
* Else all settings will be returned as associative array.
*
* @param null $key
* The name of the setting or NULL
@ -31,7 +38,7 @@ class CRM_TwingleCampaign_BAO_Configuration {
* @return array|mixed|null
*/
public static function get($key = NULL) {
if ($key) {
if (!is_null($key)) {
return Civi::settings()->get($key);
}
else {