[REF] Move clone template functionality from api to bao
authorColeman Watts <coleman@civicrm.org>
Thu, 29 Aug 2019 16:11:07 +0000 (12:11 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 29 Aug 2019 16:11:07 +0000 (12:11 -0400)
CRM/Event/BAO/Event.php
api/v3/Event.php

index 54e4b727bfe0558a11899a5a2594bdfbb7927803..9499f12d488254c29755c79ce81b98d8a6efa21f 100644 (file)
@@ -132,6 +132,13 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event {
         $params['created_id'] = $session->get('userID');
       }
       $params['created_date'] = date('YmdHis');
+
+      // Clone from template
+      if (!empty($params['template_id'])) {
+        $copy = self::copy($params['template_id']);
+        $params['id'] = $copy->id;
+        unset($params['template_id']);
+      }
     }
 
     $event = self::add($params);
index b3dbd7adcddc5658a359fdf6978eb76d6c5aff23..830379d3a6e47cab7214211cc2391e4753de64fe 100644 (file)
@@ -57,13 +57,6 @@ function civicrm_api3_event_create($params) {
     ]);
   }
 
-  // Clone event from template
-  if (!empty($params['template_id']) && empty($params['id'])) {
-    $copy = CRM_Event_BAO_Event::copy($params['template_id']);
-    $params['id'] = $copy->id;
-    unset($params['template_id']);
-  }
-
   _civicrm_api3_event_create_legacy_support_42($params);
   return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Event');
 }