link TwingleEvents to TwingleProject parent campaign
This commit is contained in:
parent
346091307d
commit
146c07e2cf
1 changed files with 18 additions and 0 deletions
|
@ -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
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue