dev/core/issues/653, fixed regression on creating new event using event template
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 16 Jan 2019 23:16:48 +0000 (23:16 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Wed, 23 Jan 2019 00:54:01 +0000 (11:54 +1100)
Use core function to over-ride values

CRM/Core/DAO.php
CRM/Event/BAO/Event.php
CRM/Event/Form/ManageEvent/EventInfo.php

index 0567485e0d2594cece1a7c7de7de5ff31bab952e..3f0d19b886a3827577b45a486cb0442ff7576411 100644 (file)
@@ -1665,9 +1665,7 @@ FROM   civicrm_domain
         }
 
         if ($newData) {
-          foreach ($newData as $k => $v) {
-            $newObject->$k = $v;
-          }
+          $newObject->copyValues($newData);
         }
       }
       $newObject->save();
index d6ead86c26c4dab5a122f22192695851bae92faa..68216a7e5f59c6b52ed3bdf95cbab9cd94d50ecc 100644 (file)
@@ -924,7 +924,7 @@ WHERE civicrm_event.is_active = 1
    * @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 @@ WHERE civicrm_event.is_active = 1
     $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);
index c890a182d4184590e9aba876a97248063f0f2c5f..698fedba47e747cfc772c6a503607c614ac98db4 100644 (file)
@@ -255,7 +255,7 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent {
 
     // 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);