️ Do not sync Twingle projects to CiviCRM which are marked as such

There is a checkbox in TwingleMANAGER that allows you to enable and disable API calls to the Twingl API (de.systopia.twingle). This commit makes the TwingleCampaign extension pay attention to this checkbox, so if it is unchecked, no campaign will be created in CiviCRM for this Twingle project.
This commit is contained in:
Marc Michalsky 2021-08-25 16:06:50 +02:00
parent 066a0096df
commit bbbf6e1cc6
2 changed files with 13 additions and 3 deletions

View file

@ -165,6 +165,11 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
*/
public function create(bool $no_hook = FALSE): bool {
# If this project is not meant to be synced, do not create a campaign
if (!$this->values['project_options']['has_civi_crm_activated']) {
return FALSE;
}
$result = parent::create($no_hook);
// Check if campaign was created successfully

View file

@ -230,9 +230,14 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
$project->getResponse('Ready to create TwingleProject');
}
$project->create(TRUE);
$returnValues[$project->getId()] =
$project->getResponse('TwingleProject created');
if ($project->create(TRUE)) {
$returnValues[$project->getId()] =
$project->getResponse('TwingleProject created');
}
else {
$returnValues[$project->getId()] =
$project->getResponse('TwingleProject not selected for synchronization');
}
} catch (Exception $e) {
$errors[$project_from_twingle['id']] = $e->getMessage();
Civi::log()->error(