From 4a94edec26783544cf616d28e92c60b4934f89b5 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Thu, 17 Nov 2016 17:25:09 +0530 Subject: [PATCH] minor change --- CRM/Event/BAO/Event.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index ceb7cf7223..2642c4b268 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -991,13 +991,12 @@ WHERE civicrm_event.is_active = 1 array('entity_value' => $id, 'mapping_id' => $oldMapping->getId()), array('entity_value' => $copyEvent->id, 'mapping_id' => $copyMapping->getId()) ); - - + if (!$afterCreate) { // CRM-19302 self::copyCustomFields($id, $copyEvent->id); } - + $copyEvent->save(); CRM_Utils_System::flushCache(); @@ -1006,12 +1005,12 @@ WHERE civicrm_event.is_active = 1 } return $copyEvent; } - + /** - * Method that copies custom fields values from an old event to a new one. Fixes bug CRM-19302, - * where if a custom field of File type was present, left both events using the same file, + * Method that copies custom fields values from an old event to a new one. Fixes bug CRM-19302, + * where if a custom field of File type was present, left both events using the same file, * breaking download URL's for the old event. - * + * * @param int $oldEventID * @param int $newCopyID */ @@ -1019,20 +1018,19 @@ WHERE civicrm_event.is_active = 1 // Obtain custom values for old event $customParams = $htmlType = array(); $customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($oldEventID, 'Event'); - + // If custom values present, we copy them if (!empty($customValues)) { - // Get Field ID's and identify File type attributes, to handle file copying. $fieldIds = implode(', ', array_keys($customValues)); $sql = "SELECT id FROM civicrm_custom_field WHERE html_type = 'File' AND id IN ( {$fieldIds} )"; $result = CRM_Core_DAO::executeQuery($sql); - + // Build array of File type fields while ($result->fetch()) { $htmlType[] = $result->id; } - + // Build params array of custom values foreach ($customValues as $field => $value) { if ($value !== NULL) { @@ -1050,11 +1048,11 @@ WHERE civicrm_event.is_active = 1 } } } - + // Save Custom Fields for new Event CRM_Core_BAO_CustomValueTable::postProcess($customParams, 'civicrm_event', $newCopyID, 'Event'); } - + // copy activity attachments ( if any ) CRM_Core_BAO_File::copyEntityFile('civicrm_event', $oldEventID, 'civicrm_event', $newCopyID); } -- 2.25.1