[#27] minor adjustments

This commit is contained in:
B. Endres 2020-06-04 10:52:50 +02:00
commit 00c55b261f
2 changed files with 5 additions and 2 deletions

View file

@ -372,6 +372,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
'recurring' => E::ts("Recurring Contribution"), 'recurring' => E::ts("Recurring Contribution"),
'membership' => E::ts("Membership"), 'membership' => E::ts("Membership"),
'mandate' => E::ts("SEPA Mandate"), 'mandate' => E::ts("SEPA Mandate"),
'contact' => E::ts("Contacts (XCM)"),
], ],
FALSE, // is not required FALSE, // is not required
['class' => 'crm-select2 huge', 'multiple' => 'multiple'] ['class' => 'crm-select2 huge', 'multiple' => 'multiple']

View file

@ -369,13 +369,15 @@ class CRM_Twingle_Submission {
* the twingle profile used * the twingle profile used
*/ */
public static function setCampaign(&$entity_data, $context, $submission, $profile) { public static function setCampaign(&$entity_data, $context, $submission, $profile) {
// first: make sure it's not set from other workflows
unset($entity_data['campaign_id']);
// then: check if campaign should be set it this context
$enabled_contexts = $profile->getAttribute('campaign_targets'); $enabled_contexts = $profile->getAttribute('campaign_targets');
if ($enabled_contexts === null || !is_array($enabled_contexts)) { if ($enabled_contexts === null || !is_array($enabled_contexts)) {
// backward compatibility: // backward compatibility:
$enabled_contexts = ['contribution', 'contact']; $enabled_contexts = ['contribution', 'contact'];
} }
// check if campaign should be set it this context
if (in_array($context, $enabled_contexts)) { if (in_array($context, $enabled_contexts)) {
// use the submitted campaign if set // use the submitted campaign if set
if (!empty($submission['campaign_id'])) { if (!empty($submission['campaign_id'])) {