X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FEvent%2FBAO%2FEvent.php;h=5f0f604cd7b77dc523f502ff51b9c4d016507094;hb=fc46016c4d3b47e8f9e8a35bd78b13954e705bbf;hp=0aadbbae0d020bc45214d52da9da88beb7846539;hpb=cb6333b0f7661267b28a53815a1645070a4f75e1;p=civicrm-core.git diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 0aadbbae0d..5f0f604cd7 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -112,6 +112,19 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event { $copy = self::copy($params['template_id']); $params['id'] = $copy->id; unset($params['template_id']); + + //fix for api from template creation bug + civicrm_api4('ActionSchedule', 'update', [ + 'checkPermissions' => FALSE, + 'values' => [ + 'mapping_id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID, + ], + 'where' => [ + ['entity_value', '=', $copy->id], + ['mapping_id', '=', CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID], + ], + ]); + } } @@ -2245,20 +2258,24 @@ WHERE ce.loc_block_id = $locBlockId"; //3. consider event seat as a sum of all seats from line items in case price field value carries count. $query = " - SELECT IF ( SUM( value.count*lineItem.qty ), - SUM( value.count*lineItem.qty ) + - COUNT( DISTINCT participant.id ) - - COUNT( DISTINCT IF ( value.count, participant.id, NULL ) ), - COUNT( DISTINCT participant.id ) ) - FROM civicrm_participant participant -INNER JOIN civicrm_contact contact ON ( contact.id = participant.contact_id AND contact.is_deleted = 0 ) -INNER JOIN civicrm_event event ON ( event.id = participant.event_id ) -LEFT JOIN civicrm_line_item lineItem ON ( lineItem.entity_id = participant.id - AND lineItem.entity_table = 'civicrm_participant' ) -LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_value_id AND value.count ) - WHERE ( participant.event_id = %1 ) - AND participant.is_test = 0 - {$extraWhereClause} + SELECT + IF + -- If the line item count * the line item quantity is not 0 + (SUM(price_field_value.`count` * lineItem.qty), + -- then use the count * the quantity, ensuring each + -- actual participant record gets a result + SUM(price_field_value.`count` * lineItem.qty) + + COUNT(DISTINCT participant.id ) + - COUNT(DISTINCT IF (price_field_value.`count`, participant.id, NULL)), + -- if the line item count is NULL or 0 then count the participants + COUNT(DISTINCT participant.id)) + FROM civicrm_participant participant + INNER JOIN civicrm_contact contact ON (contact.id = participant.contact_id AND contact.is_deleted = 0) + INNER JOIN civicrm_event event ON ( event.id = participant.event_id ) + LEFT JOIN civicrm_line_item lineItem ON ( lineItem.entity_id = participant.id AND lineItem.entity_table = 'civicrm_participant' ) + LEFT JOIN civicrm_price_field_value price_field_value ON (price_field_value.id = lineItem.price_field_value_id AND price_field_value.`count`) + WHERE (participant.event_id = %1) AND participant.is_test = 0 + {$extraWhereClause} GROUP BY participant.event_id"; return (int) CRM_Core_DAO::singleValueQuery($query, [1 => [$eventId, 'Positive']]); @@ -2399,18 +2416,7 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field * All of the icons to show. */ public static function getICalLinks($eventId = NULL) { - $return = $eventId ? [] : [ - [ - 'url' => CRM_Utils_System::url('civicrm/event/ical', 'reset=1&list=1&html=1', TRUE, NULL, TRUE), - 'text' => ts('HTML listing of current and future public events.'), - 'icon' => 'fa-th-list', - ], - [ - 'url' => CRM_Utils_System::url('civicrm/event/ical', 'reset=1&list=1&rss=1', TRUE, NULL, TRUE), - 'text' => ts('Get RSS 2.0 feed for current and future public events.'), - 'icon' => 'fa-rss', - ], - ]; + $return = []; $query = [ 'reset' => 1, ]; @@ -2422,12 +2428,20 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field 'text' => $eventId ? ts('Download iCalendar entry for this event.') : ts('Download iCalendar entry for current and future public events.'), 'icon' => 'fa-download', ]; - $query['list'] = 1; - $return[] = [ - 'url' => CRM_Utils_System::url('civicrm/event/ical', $query, TRUE, NULL, TRUE), - 'text' => $eventId ? ts('iCalendar feed for this event.') : ts('iCalendar feed for current and future public events.'), - 'icon' => 'fa-link', - ]; + if ($eventId) { + $return[] = [ + 'url' => CRM_Utils_System::url('civicrm/event/ical', ['gCalendar' => 1] + $query, TRUE, NULL, TRUE), + 'text' => ts('Add event to Google Calendar'), + 'icon' => 'fa-share', + ]; + } + else { + $return[] = [ + 'url' => CRM_Utils_System::url('civicrm/event/ical', $query, TRUE, NULL, TRUE), + 'text' => ts('iCalendar feed for current and future public events'), + 'icon' => 'fa-link', + ]; + } return $return; }