Skip to content
Snippets Groups Projects
Commit 2d5eed48 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #48 from dlobo/CRM-11435

fix CRM-11435
parents 6b79f0fa 49f68a22
Branches
Tags
No related merge requests found
......@@ -2006,5 +2006,26 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field
$defaults = array();
return CRM_Event_BAO_Event::retrieve($params, $defaults);
}
/*
* Update the Campaign Id of all the participants of the given event
*
* @params int $eventID event id.
* @params int $eventCampaignID campaign id of that event
*
*/
static function updateParticipantCampaignID($eventID, $eventCampaignID) {
$params = array();
$params[1] = array($eventID, 'Integer');
if(empty($eventCampaignID)) {
$query = "UPDATE civicrm_participant SET campaign_id = NULL WHERE event_id = %1";
}
else {
$query = "UPDATE civicrm_participant SET campaign_id = %2 WHERE event_id = %1";
$params[2] = array($eventCampaignID, 'Integer');
}
CRM_Core_DAO::executeQuery($query, $params);
}
}
......@@ -79,6 +79,12 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
protected $_cancelURL = NULL;
/**
* The campaign id of the existing event, we use this to know if we need to update
* the participant records
*/
protected $_campaignID = NULL;
/**
* Function to set variables up before form is built
*
......@@ -214,6 +220,8 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Event_BAO_Event::retrieve($params, $defaults);
$this->_campaignID = CRM_Utils_Array::value('campaign_id', $defaults);
}
elseif ($this->_templateId) {
$params = array('id' => $this->_templateId);
......@@ -333,6 +341,16 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form {
array(1 => ($subPage == 'friend') ? 'Friend' : $className)
), ts('Saved'), 'success');
$config = CRM_Core_Config::singleton();
if (in_array('CiviCampaign', $config->enableComponents)) {
$values = $this->controller->exportValues($this->_name);
$newCampaignID = CRM_Utils_Array::value('campaign_id', $values);
$eventID = CRM_Utils_Array::value('id', $values);
if ($eventID && $this->_campaignID != $newCampaignID) {
CRM_Event_BAO_Event::updateParticipantCampaignID($eventID, $newCampaignID);
}
}
$this->postProcessHook();
if ($this->controller->getButtonName('submit') == "_qf_{$className}_upload_done") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment