✨ make TwingleCampaings clonable
TwingleCampaings can be cloned. Cloned campaigns will generate a new cid and url.
This commit is contained in:
parent
f059abf5a8
commit
a01367a161
6 changed files with 66 additions and 18 deletions
|
@ -32,15 +32,30 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
|||
$this->id = $values['id'] ?? NULL;
|
||||
$this->values['campaign_type_id'] = 'twingle_campaign';
|
||||
|
||||
// If there is already an ID for this TwingleProject, get its values from
|
||||
// the database
|
||||
if ($this->id != NULL) {
|
||||
$this->fetch($this->id);
|
||||
}
|
||||
|
||||
// Update the campaign values
|
||||
$this->update($values);
|
||||
|
||||
// Get the parent TwingleProject
|
||||
// (it doesn't matter how many levels above in the campaign tree it is)
|
||||
$this->getParentProject();
|
||||
if (!isset($this->values['cid'])) {
|
||||
|
||||
// If this is a new TwingleCampaign or if it is a cloned TwingleCampaign,
|
||||
// calculate a cid
|
||||
if (
|
||||
!isset($this->values['cid']) ||
|
||||
(isset($values['clone']) && $values['clone'])
|
||||
) {
|
||||
$this->createCid();
|
||||
}
|
||||
|
||||
// Create an url from the parent TwingleProject url and the cid of this
|
||||
// TwingleCampaign
|
||||
$this->createUrl();
|
||||
}
|
||||
|
||||
|
@ -351,20 +366,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ## Clone this TwingleProject
|
||||
*
|
||||
* This method removes the id from this instance and in the next step it
|
||||
* creates the clone as a new TwingleCampaign with the same values to
|
||||
* Twingle.
|
||||
*
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
public
|
||||
function clone() {
|
||||
// TODO: implement cloning
|
||||
}
|
||||
|
||||
/**
|
||||
* ## Get ID
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue