👾 bug fix: cid changes when updating TwingleCampaing

This commit is contained in:
Marc Michalsky 2021-10-04 09:37:19 +02:00
parent 06e30f6ef7
commit 108d2c9586

View file

@ -17,32 +17,31 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
private $values;
/**
* ## TwingleCampaign constructor
*
* @param array|null $values
* @param int|null $id
* @param array $values
*
* @throws \CiviCRM_API3_Exception
*/
public function __construct(array $values = [], int $id = NULL) {
public function __construct(array $values = []) {
$this->prefix = 'twingle_campaign_';
$this->id = $id ?? NULL;
$this->id = $values['id'] ?? NULL;
$this->values['campaign_type_id'] = 'twingle_campaign';
if ($this->id != NULL) {
$this->fetch($this->id);
}
$this->update($values);
$this->getParentProject();
if (!isset($this->values['cid'])) {
$this->createCid();
}
$this->createUrl();
}
/**
* ## Create TwingleCampaign
* Create this TwingleCampaign as a campaign in CiviCRM
@ -69,19 +68,17 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
}
}
/**
* ## Fetch TwingleCampaign
* Populate this instance with values from an existing TwingleCampaign.
*
* @throws CiviCRM_API3_Exception
*/
public function fetch() {
public function fetch(int $id) {
$this->values = civicrm_api3('TwingleCampaign', 'getsingle',
['id' => $this->id]);
['id' => $id]);
}
/**
* ## Get Parent Project
* Determines the id of the parent TwingleProject. If there is no parent
@ -128,7 +125,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
}
}
// Set parent_project_id and retrieve parent_project_url
if ($parent_campaign_type_id == $twingle_project_campaign_type_id) {
$this->values['parent_project_id'] = $parent_id;
@ -205,7 +201,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
$this->values['parent_project_url'] . '?tw_cid=' . $this->values['cid'];
}
/**
*
*/
@ -214,7 +209,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
$this->values['cid'] = uniqid();
}
/**
* ## Translate field names and custom field names
*
@ -283,7 +277,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
}
}
/**
* ## Delete TwingleCampaign
* Deletes this TwingleCampaign from CiviCRM
@ -303,7 +296,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
}
}
/**
* ## Get a response
* Get a response that describes the status of this TwingleCampaign instance.
@ -380,5 +372,4 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
return (int) $this->id;
}
}