fix campaign cloning

This commit is contained in:
Marc Michalsky forumZFD 2021-02-08 15:33:02 +01:00
parent baa23f8639
commit f17a899b79
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
2 changed files with 6 additions and 3 deletions

View file

@ -91,8 +91,8 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
* @throws \Exception
*/
public function clone() {
unset($this->values['id']);
unset($this->values['identifier']);
$this->values['id'] = 0;
$this->values['identifier'] = 0;
$this->create(); // this will also trigger the postSave hook
}

View file

@ -89,7 +89,10 @@ function twinglecampaign_postSave_callback (
$result = civicrm_api3($entity, 'getsingle',
['id' => $campaign_id]
)['values'][$campaign_id];
$project = new $entity($result);
$className = 'CRM_TwingleCampaign_BAO_' . $entity;
$id = $result['id'];
unset($result['id']);
$project = new $className($result, $id);
try {
$project->clone();
} catch (Exception $e) {