From 2e45b2f8856d701834aae0aef66a14e4411978f6 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 16 Jan 2019 23:16:48 +0000 Subject: [PATCH] dev/core/issues/653, fixed regression on creating new event using event template Use core function to over-ride values --- CRM/Core/DAO.php | 4 +--- CRM/Event/BAO/Event.php | 4 ++-- CRM/Event/Form/ManageEvent/EventInfo.php | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 0567485e0d25..3f0d19b886a3 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1665,9 +1665,7 @@ public static function ©Generic($daoName, $criteria, $newData = NULL, $field } if ($newData) { - foreach ($newData as $k => $v) { - $newObject->$k = $v; - } + $newObject->copyValues($newData); } } $newObject->save(); diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index d6ead86c26c4..68216a7e5f59 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -924,7 +924,7 @@ public static function &getCompleteInfo( * @return CRM_Event_DAO_Event * @throws \CRM_Core_Exception */ - public static function copy($id) { + public static function copy($id, $params = []) { $eventValues = array(); //get the require event values. @@ -947,7 +947,7 @@ public static function copy($id) { $copyEvent = CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event', array('id' => $id), // since the location is sharable, lets use the same loc_block_id. - array('loc_block_id' => CRM_Utils_Array::value('loc_block_id', $eventValues)), + array('loc_block_id' => CRM_Utils_Array::value('loc_block_id', $eventValues)) + $params, $fieldsFix ); CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_event', $id, $copyEvent->id); diff --git a/CRM/Event/Form/ManageEvent/EventInfo.php b/CRM/Event/Form/ManageEvent/EventInfo.php index c890a182d418..698fedba47e7 100644 --- a/CRM/Event/Form/ManageEvent/EventInfo.php +++ b/CRM/Event/Form/ManageEvent/EventInfo.php @@ -255,7 +255,7 @@ public function postProcess() { // now that we have the event’s id, do some more template-based stuff if (!empty($params['template_id'])) { - $event = CRM_Event_BAO_Event::copy($params['template_id']); + $event = CRM_Event_BAO_Event::copy($params['template_id'], $params); } else { $event = CRM_Event_BAO_Event::create($params);