3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
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.
51 public function run() {
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 $info = CRM_Event_BAO_Event
::getCompleteInfo($start, $type, $id, $end);
62 $this->assign('events', $info);
63 $this->assign('timezone', @date_default_timezone_get
());
65 // Send data to the correct template for formatting (iCal vs. gData)
66 $template = CRM_Core_Smarty
::singleton();
67 $config = CRM_Core_Config
::singleton();
69 // rss 2.0 requires lower case dash delimited locale
70 $this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages
)));
71 $calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl');
74 $calendar = $template->fetch('CRM/Core/Calendar/GData.tpl');
77 // check if we're in shopping cart mode for events
78 $enable_cart = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::EVENT_PREFERENCES_NAME
,
82 $this->assign('registration_links', TRUE);
87 $calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl');
88 $calendar = preg_replace('/(?<!\r)\n/', "\r\n", $calendar);
91 // Push output for feed or download
94 CRM_Utils_ICalendar
::send($calendar, 'text/xml', 'utf-8');
97 CRM_Utils_ICalendar
::send($calendar, 'text/plain', 'utf-8');
101 CRM_Utils_ICalendar
::send($calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment');
103 CRM_Utils_System
::civiExit();