[#27] remove campaign if it somehow got it before

This commit is contained in:
B. Endres 2020-06-04 10:52:11 +02:00
parent b256b59fe5
commit 1d2c66b375

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'])) {