delete TwingleProject by project_id
This commit is contained in:
parent
f6d46520cd
commit
6affd53c02
1 changed files with 33 additions and 19 deletions
|
@ -81,7 +81,19 @@ function civicrm_api3_twingle_project_Delete(array $params): array {
|
||||||
|
|
||||||
$params['sequential'] = 1;
|
$params['sequential'] = 1;
|
||||||
|
|
||||||
|
// To delete the TwingleProject on Twingle's side, we need the project_id
|
||||||
|
// If no project_id is provided, try to get it via TwingleProject.getsingle
|
||||||
|
if (!$params['project_id']) {
|
||||||
|
try {
|
||||||
|
$project = civicrm_api3('TwingleProject', 'getsingle', $params);
|
||||||
|
$params['project_id'] = $project['values'][0]['project_id'];
|
||||||
|
} catch (CiviCRM_API3_Exception $e) {
|
||||||
|
$result_values['twingle'] = 'Could not delete TwingleProject: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Delete TwingleProject on Twingle's side
|
// Delete TwingleProject on Twingle's side
|
||||||
|
if ($params['project_id']) {
|
||||||
try {
|
try {
|
||||||
$twingleApi->deleteProject($params['project_id']);
|
$twingleApi->deleteProject($params['project_id']);
|
||||||
$result_values['twingle'] = 'TwingleProject deleted';
|
$result_values['twingle'] = 'TwingleProject deleted';
|
||||||
|
@ -102,6 +114,9 @@ function civicrm_api3_twingle_project_Delete(array $params): array {
|
||||||
$result_values['twingle'] = 'Could not delete TwingleProject: ' . $e->getMessage();
|
$result_values['twingle'] = 'Could not delete TwingleProject: ' . $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Delete the TwingleProject campaign on CiviCRM's side
|
// Delete the TwingleProject campaign on CiviCRM's side
|
||||||
try {
|
try {
|
||||||
|
@ -139,5 +154,4 @@ function civicrm_api3_twingle_project_Delete(array $params): array {
|
||||||
'Delete'
|
'Delete'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue