👾 bug fix: TwingleCampaign cannot find parent campaign

This commit is contained in:
Marc Michalsky forumZFD 2021-04-12 14:40:04 +02:00
parent a658190a68
commit cc6777e206
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
5 changed files with 36 additions and 9 deletions

View file

@ -20,12 +20,19 @@ function _civicrm_api3_twingle_campaign_Sync_spec(array &$spec) {
'description' => E::ts('The Twingle Campaign ID'),
];
$spec['project_id'] = [
'name' => 'project_id',
'name' => 'parent_project_id',
'title' => E::ts('Parent Twingle Project ID'),
'type' => CRM_Utils_Type::T_INT,
'api.required' => 0,
'description' => E::ts('Twingle ID of the parent TwingleProject'),
];
$spec['parent_id'] = [
'name' => 'parent_id',
'title' => E::ts('Parent Project ID'),
'type' => CRM_Utils_Type::T_INT,
'api.required' => 0,
'description' => E::ts('ID of the parent TwingleProject'),
];
}
/**
@ -52,7 +59,17 @@ function civicrm_api3_twingle_campaign_Sync(array $params): array {
$returnValues = [];
$errors_occurred = 0;
if ($campaigns['is_error'] == 0 && $campaigns['count'] > 0) {
// Abort if TwingleProject does not have TingleCampaign children
if ($campaigns['count'] == 0) {
return civicrm_api3_create_success(
$returnValues,
$params,
'TwingleCampaign',
'Sync'
);
}
if ($campaigns['is_error'] == 0) {
// Instantiate and re-create TwingleCampaigns
foreach ($campaigns['values'] as $campaign) {