From 50a63ee8600504052f06b3c9bb7024c8498d8c7e Mon Sep 17 00:00:00 2001 From: Marc Michalsky forumZFD Date: Mon, 2 Nov 2020 17:40:34 +0100 Subject: [PATCH] bug fix: get all events of all projects --- api/v3/TwingleSync/Post.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/api/v3/TwingleSync/Post.php b/api/v3/TwingleSync/Post.php index 16befa7..9676d06 100644 --- a/api/v3/TwingleSync/Post.php +++ b/api/v3/TwingleSync/Post.php @@ -74,20 +74,20 @@ function civicrm_api3_twingle_sync_Post(array $params) { } } - // Get all events from projects of event type + // Get all events from projects of type "event" and create them as campaigns + // if they do not exist yet + $j = 0; foreach ($result_values['sync']['projects'] as $project) { if ($project['project_type'] == 'event') { $events = $twingleApi->getEvent($project['project_id']); - } - } - - // Create events them as campaigns if they do not exist and store results in - // $result_values - $j = 0; - if ($events) { - foreach ($events as $event) { - $result_values['sync']['events'][$j++] = - TwingleEvent::sync($event, $twingleApi, $is_test); + if (is_array($events)) { + foreach ($events as $event) { + if ($event) { + $result_values['sync']['events'][$j++] = + TwingleEvent::sync($event, $twingleApi, $is_test); + } + } + } } }