make soft credits optional
This commit is contained in:
parent
6cac4882b5
commit
db15d5deb1
4 changed files with 26 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -35,6 +35,13 @@ class CRM_TwingleCampaign_Form_Settings extends CRM_Core_Form {
|
|||
['class' => 'crm-select2 huge']
|
||||
);
|
||||
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
'twinglecampaign_soft_credits',
|
||||
E::ts('Create soft credits for event initiators'),
|
||||
FALSE
|
||||
);
|
||||
|
||||
$this->addButtons([
|
||||
[
|
||||
'type' => 'submit',
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use CRM_TwingleCampaign_ExtensionUtil as E;
|
||||
use CRM_TwingleCampaign_BAO_Configuration as Configuration;
|
||||
|
||||
/**
|
||||
* # APIWrapper class for TwingleDonation.submit
|
||||
|
@ -31,7 +32,10 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
|
|||
*/
|
||||
public static function RESPOND($event) {
|
||||
$request = $event->getApiRequestSig();
|
||||
if ($request == '3.twingledonation.submit') {
|
||||
if (
|
||||
$request == '3.twingledonation.submit' &&
|
||||
Configuration::get('twinglecampaign_soft_credits')
|
||||
) {
|
||||
|
||||
$response = $event->getResponse();
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
<div class="content">{$form.twinglecampaign_start_case.html}</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="crm-section">
|
||||
<div class="label">{$form.twinglecampaign_soft_credits.label}</div>
|
||||
<div class="content">{$form.twinglecampaign_soft_credits.html}</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue