link TwingleEvents to TwingleProject parent campaign

This commit is contained in:
Marc Michalsky forumZFD 2020-11-02 17:50:38 +01:00
parent 346091307d
commit 146c07e2cf
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -40,6 +40,7 @@ class TwingleEvent extends Campaign {
// Get custom field name for event_id // Get custom field name for event_id
$this->id_custom_field = Cache::getInstance() $this->id_custom_field = Cache::getInstance()
->getCustomFieldMapping()['twingle_event_id']; ->getCustomFieldMapping()['twingle_event_id'];
$this->values['parent_id'] = $this->getParentCampaignId();
} }
@ -335,6 +336,23 @@ class TwingleEvent extends Campaign {
} }
} }
/**
* Gets the campaign id of the parent TwingleProject campaign.
* @return int|null
* @throws CiviCRM_API3_Exception
*/
private function getParentCampaignId() {
$cf_project_id = Cache::getInstance()->getCustomFieldMapping()['twingle_project_id'];
$parentCampaign = civicrm_api3('Campaign', 'get', [
'sequential' => 1,
$cf_project_id => $this->values['project_id']
]);
if ($parentCampaign['is_error'] == 0) {
return (int) $parentCampaign['id'];
}
else return NULL;
}
/** /**
* Return a timestamp of the last update of the Campaign * Return a timestamp of the last update of the Campaign
* *