3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
24 class CRM_Event_Page_ICalendar
extends CRM_Core_Page
{
27 * Heart of the iCalendar data assignment process. The runner gets all the meta
28 * data for the event and calls the method to output the iCalendar
29 * to the user. If gData param is passed on the URL, outputs gData XML format.
30 * Else outputs iCalendar format per IETF RFC2445. Page param true means send
31 * to browser as inline content. Else, we send .ics file as attachment.
35 public function run() {
36 $id = CRM_Utils_Request
::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET');
37 $type = CRM_Utils_Request
::retrieve('type', 'Positive', $this, FALSE, 0);
38 $start = CRM_Utils_Request
::retrieve('start', 'Positive', $this, FALSE, 0);
39 $end = CRM_Utils_Request
::retrieve('end', 'Positive', $this, FALSE, 0);
40 $iCalPage = CRM_Utils_Request
::retrieve('list', 'Positive', $this, FALSE, 0);
41 $gData = CRM_Utils_Request
::retrieve('gData', 'Positive', $this, FALSE, 0);
42 $html = CRM_Utils_Request
::retrieve('html', 'Positive', $this, FALSE, 0);
43 $rss = CRM_Utils_Request
::retrieve('rss', 'Positive', $this, FALSE, 0);
45 $info = CRM_Event_BAO_Event
::getCompleteInfo($start, $type, $id, $end);
46 $this->assign('events', $info);
47 $this->assign('timezone', @date_default_timezone_get
());
49 // Send data to the correct template for formatting (iCal vs. gData)
50 $template = CRM_Core_Smarty
::singleton();
51 $config = CRM_Core_Config
::singleton();
53 // rss 2.0 requires lower case dash delimited locale
54 $this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages
)));
55 $calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl');
58 $calendar = $template->fetch('CRM/Core/Calendar/GData.tpl');
61 // check if we're in shopping cart mode for events
62 $enable_cart = Civi
::settings()->get('enable_cart');
64 $this->assign('registration_links', TRUE);
69 $calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl');
70 $calendar = preg_replace('/(?<!\r)\n/', "\r\n", $calendar);
73 // Push output for feed or download
76 CRM_Utils_ICalendar
::send($calendar, 'text/xml', 'utf-8');
79 CRM_Utils_ICalendar
::send($calendar, 'text/plain', 'utf-8');
83 CRM_Utils_ICalendar
::send($calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment');
85 CRM_Utils_System
::civiExit();