From 679bd095859ed8fe53b97f69501eac54b90f421c Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Mon, 11 May 2020 18:47:42 -0400 Subject: [PATCH] Move event ical icons to iCalLinks.tpl and supply URLs centrally --- CRM/Event/BAO/Event.php | 41 +++++++++++++++++++ CRM/Event/Form/Registration/ThankYou.php | 2 + CRM/Event/Page/DashBoard.php | 1 + CRM/Event/Page/EventInfo.php | 2 + CRM/Event/Page/ManageEvent.php | 1 + .../CRM/Event/Form/Registration/ThankYou.tpl | 2 + templates/CRM/Event/Page/DashBoard.tpl | 17 +------- templates/CRM/Event/Page/EventInfo.tpl | 5 ++- templates/CRM/Event/Page/ManageEvent.tpl | 6 +-- templates/CRM/Event/Page/iCalLinks.tpl | 18 +++----- 10 files changed, 61 insertions(+), 34 deletions(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 1e178acae2..0399390af6 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -2387,4 +2387,45 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field ]; } + /** + * Get the appropriate links to iCal pages/feeds. + * + * @param int $eventId + * + * @return array + * 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', + ], + ]; + $query = [ + 'reset' => 1, + ]; + if ($eventId) { + $query['id'] = $eventId; + } + $return[] = [ + 'url' => CRM_Utils_System::url('civicrm/event/ical', $query, TRUE, NULL, TRUE), + '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', + ]; + return $return; + } + } diff --git a/CRM/Event/Form/Registration/ThankYou.php b/CRM/Event/Form/Registration/ThankYou.php index d186528e18..4f9898b540 100644 --- a/CRM/Event/Form/Registration/ThankYou.php +++ b/CRM/Event/Form/Registration/ThankYou.php @@ -175,6 +175,8 @@ class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration { $this->assign('friendURL', $url); } + $this->assign('iCal', CRM_Event_BAO_Event::getICalLinks($this->_eventId)); + $this->freeze(); //lets give meaningful status message, CRM-4320. diff --git a/CRM/Event/Page/DashBoard.php b/CRM/Event/Page/DashBoard.php index f92fc7a090..f477b09211 100644 --- a/CRM/Event/Page/DashBoard.php +++ b/CRM/Event/Page/DashBoard.php @@ -50,6 +50,7 @@ class CRM_Event_Page_DashBoard extends CRM_Core_Page { $this->assign('actionColumn', $actionColumn); $this->assign('eventSummary', $eventSummary); + $this->assign('iCal', CRM_Event_BAO_Event::getICalLinks()); } /** diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index 6e3b082981..19ee467fd5 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -46,6 +46,8 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'register'); $this->assign('context', $context); + $this->assign('iCal', CRM_Event_BAO_Event::getICalLinks($this->_id)); + // Sometimes we want to suppress the Event Full msg $noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, FALSE, 'false'); diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index 20b4ed5e86..1e9a7a06d5 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -224,6 +224,7 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { // assign vars to templates $this->assign('action', $action); + $this->assign('iCal', CRM_Event_BAO_Event::getICalLinks()); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0, 'REQUEST' ); diff --git a/templates/CRM/Event/Form/Registration/ThankYou.tpl b/templates/CRM/Event/Form/Registration/ThankYou.tpl index b2e6a65472..3fa05ece88 100644 --- a/templates/CRM/Event/Form/Registration/ThankYou.tpl +++ b/templates/CRM/Event/Form/Registration/ThankYou.tpl @@ -199,7 +199,9 @@ {if $event.is_public } + {/if} {if $event.is_share} {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id=`$event.id`&reset=1" a=1 fe=1 h=1}{/capture} diff --git a/templates/CRM/Event/Page/DashBoard.tpl b/templates/CRM/Event/Page/DashBoard.tpl index 0119172fcc..01d4a32dd1 100644 --- a/templates/CRM/Event/Page/DashBoard.tpl +++ b/templates/CRM/Event/Page/DashBoard.tpl @@ -21,22 +21,7 @@
 

{ts}Event Summary{/ts} {help id="id-event-intro"} - - - {ts}HTML listing of current and future public events.{/ts} - - - - {ts}Get RSS 2.0 feed for current and future public events.{/ts} - - - - {ts}Download iCalendar entry for this event.{/ts} - - - - {ts}iCalendar feed for this event.{/ts} - + {include file="CRM/Event/Page/iCalLinks.tpl"}

{include file="CRM/common/jsortable.tpl"} diff --git a/templates/CRM/Event/Page/EventInfo.tpl b/templates/CRM/Event/Page/EventInfo.tpl index 530476eb8d..a64ccf378c 100644 --- a/templates/CRM/Event/Page/EventInfo.tpl +++ b/templates/CRM/Event/Page/EventInfo.tpl @@ -217,7 +217,10 @@ {/crmRegion} {if $event.is_public } -
{include file="CRM/Event/Page/iCalLinks.tpl"} +
+ {/if} {if $event.is_share } diff --git a/templates/CRM/Event/Page/ManageEvent.tpl b/templates/CRM/Event/Page/ManageEvent.tpl index 0f8812f83e..8703fc6c49 100644 --- a/templates/CRM/Event/Page/ManageEvent.tpl +++ b/templates/CRM/Event/Page/ManageEvent.tpl @@ -15,11 +15,7 @@
- - - - - {help id='icalendar'} + {include file="CRM/Event/Page/iCalLinks.tpl"}