3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
40 class CRM_Event_Page_ICalendar
extends CRM_Core_Page
{
43 * Heart of the iCalendar data assignment process. The runner gets all the meta
44 * data for the event and calls the method to output the iCalendar
45 * to the user. If gData param is passed on the URL, outputs gData XML format.
46 * Else outputs iCalendar format per IETF RFC2445. Page param true means send
47 * to browser as inline content. Else, we send .ics file as attachment.
52 $id = CRM_Utils_Request
::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET');
53 $type = CRM_Utils_Request
::retrieve('type', 'Positive', $this, FALSE, 0);
54 $start = CRM_Utils_Request
::retrieve('start', 'Positive', $this, FALSE, 0);
55 $end = CRM_Utils_Request
::retrieve('end', 'Positive', $this, FALSE, 0);
56 $iCalPage = CRM_Utils_Request
::retrieve('list', 'Positive', $this, FALSE, 0);
57 $gData = CRM_Utils_Request
::retrieve('gData', 'Positive', $this, FALSE, 0);
58 $html = CRM_Utils_Request
::retrieve('html', 'Positive', $this, FALSE, 0);
59 $rss = CRM_Utils_Request
::retrieve('rss', 'Positive', $this, FALSE, 0);
61 CRM_Utils_System
::setTitle(ts('Current and Upcoming Events'));
63 $info = CRM_Event_BAO_Event
::getCompleteInfo($start, $type, $id, $end);
64 $this->assign('events', $info);
65 $this->assign('timezone', @date_default_timezone_get
());
67 // Send data to the correct template for formatting (iCal vs. gData)
68 $template = CRM_Core_Smarty
::singleton();
69 $config = CRM_Core_Config
::singleton();
71 // rss 2.0 requires lower case dash delimited locale
72 $this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages
)));
73 $calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl');
76 $calendar = $template->fetch('CRM/Core/Calendar/GData.tpl');
79 // check if we're in shopping cart mode for events
80 $enable_cart = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::EVENT_PREFERENCES_NAME
,
84 $this->assign('registration_links', TRUE);
89 $calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl');
90 $calendar = preg_replace('/(?<!\r)\n/', "\r\n", $calendar);
93 // Push output for feed or download
96 CRM_Utils_ICalendar
::send($calendar, 'text/xml', 'utf-8');
99 CRM_Utils_ICalendar
::send($calendar, 'text/plain', 'utf-8');
103 CRM_Utils_ICalendar
::send($calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment');
105 CRM_Utils_System
::civiExit();