From 88fb74bd6f15baf7a104b0d40767e68fa0e44cd2 Mon Sep 17 00:00:00 2001 From: Marc Michalsky forumZFD Date: Tue, 6 Apr 2021 21:29:07 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BE=20bug=20fix:=20broken=20campaign?= =?UTF-8?q?=20tree=20for=20TwingleEvents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CRM/TwingleCampaign/BAO/TwingleEvent.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/CRM/TwingleCampaign/BAO/TwingleEvent.php b/CRM/TwingleCampaign/BAO/TwingleEvent.php index f3e2b8d..04ecb04 100644 --- a/CRM/TwingleCampaign/BAO/TwingleEvent.php +++ b/CRM/TwingleCampaign/BAO/TwingleEvent.php @@ -27,13 +27,11 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign { $this->id_custom_field = Cache::getInstance() ->getCustomFieldMapping()['twingle_event_id']; - if ($id) { - try { - $this->values['parent_id'] = $this->getParentCampaignId(); - } catch (CiviCRM_API3_Exception $e) { - $errorMessage = $e->getMessage(); - throw new Exception("Could not identify parent Campaign: $errorMessage"); - } + try { + $this->values['parent_id'] = $this->getParentCampaignId(); + } catch (CiviCRM_API3_Exception $e) { + $errorMessage = $e->getMessage(); + throw new Exception("Could not identify parent Campaign: $errorMessage"); } } @@ -43,6 +41,7 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign { * Returns _TRUE_ if creation was successful or _FALSE if it creation failed. * * @param bool $no_hook + * * @return bool * @throws \CiviCRM_API3_Exception * @throws \Exception @@ -86,8 +85,10 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign { /** * ## Translate values between CiviCRM Campaigns and Twingle formats * Constants for **$direction**:
- * **TwingleProject::IN** translate array values from Twingle to CiviCRM format
- * **TwingleProject::OUT** translate array values from CiviCRM to Twingle format + * **TwingleProject::IN** translate array values from Twingle to CiviCRM + * format
+ * **TwingleProject::OUT** translate array values from CiviCRM to Twingle + * format * * @param array $values * array of values to translate @@ -241,7 +242,7 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign { $parentCampaign = civicrm_api3('Campaign', 'get', [ 'sequential' => 1, $cf_project_id => $this->values['project_id'], - 'options' => ['limit' => 0] + 'options' => ['limit' => 0], ]); if ($parentCampaign['is_error'] == 0) { return (int) $parentCampaign['id']; @@ -285,4 +286,5 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign { function getEventId(): int { return (int) $this->values['id']; } + }