X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FEvent%2FBAO%2FEvent.php;h=cf52a5f32cc057dad9088c673c292575837c5b2d;hb=ee1da343d1593483e73bcd891b8a877e307e887c;hp=2729d09693898b09922341e1d215caf6ec347bc4;hpb=be59734a3b9bede8946b25118ccf65846c169cf0;p=civicrm-core.git diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 2729d09693..cf52a5f32c 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -921,15 +921,15 @@ WHERE civicrm_event.is_active = 1 * * @param int $id * The event id to copy. - * boolean $afterCreate call to copy after the create function * @param array $params + * * @return CRM_Event_DAO_Event * @throws \CRM_Core_Exception */ public static function copy($id, $params = []) { $eventValues = []; - //get the require event values. + //get the required event values. $eventParams = ['id' => $id]; $returnProperties = [ 'loc_block_id', @@ -946,11 +946,15 @@ WHERE civicrm_event.is_active = 1 $fieldsFix['prefix']['is_show_location'] = 0; } + $blockCopyOfCustomValue = (!empty($params['custom'])); + $copyEvent = CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event', ['id' => $id], // since the location is sharable, lets use the same loc_block_id. ['loc_block_id' => CRM_Utils_Array::value('loc_block_id', $eventValues)] + $params, - $fieldsFix + $fieldsFix, + NULL, + $blockCopyOfCustomValue ); CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_event', $id, $copyEvent->id); CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', @@ -991,6 +995,10 @@ WHERE civicrm_event.is_active = 1 $copyEvent->save(); + if ($blockCopyOfCustomValue) { + CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_event', $copyEvent->id); + } + CRM_Utils_System::flushCache(); CRM_Utils_Hook::copy('Event', $copyEvent); @@ -1638,6 +1646,10 @@ WHERE id = $cfID } $skip = TRUE; } + // for checkboxes, change array of [key => bool] to array of [idx => key] + elseif ($dao->html_type == 'CheckBox') { + $customVal = array_keys(array_filter($params[$name])); + } else { $customVal = $params[$name]; }