/** * Heart of the iCalendar data assignment process. The runner gets all the meta * data for the event and calls the method to output the iCalendar * to the user. If gData param is passed on the URL, outputs gData XML format. * Else outputs iCalendar format per IETF RFC2445. Page param true means send * to browser as inline content. Else, we send .ics file as attachment. * * @return void */ public function run() { $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET'); $type = CRM_Utils_Request::retrieve('type', 'Positive', $this, FALSE, 0); $start = CRM_Utils_Request::retrieve('start', 'Positive', $this, FALSE, 0); $end = CRM_Utils_Request::retrieve('end', 'Positive', $this, FALSE, 0); $iCalPage = CRM_Utils_Request::retrieve('list', 'Positive', $this, FALSE, 0); $gData = CRM_Utils_Request::retrieve('gData', 'Positive', $this, FALSE, 0); $html = CRM_Utils_Request::retrieve('html', 'Positive', $this, FALSE, 0); $rss = CRM_Utils_Request::retrieve('rss', 'Positive', $this, FALSE, 0); $info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end, false); $this->assign('events', $info); $this->assign('timezone', @date_default_timezone_get()); // Send data to the correct template for formatting (iCal vs. gData) $template = CRM_Core_Smarty::singleton(); $config = CRM_Core_Config::singleton(); if ($rss) { // rss 2.0 requires lower case dash delimited locale $this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages))); $calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl'); } elseif ($gData) { $calendar = $template->fetch('CRM/Core/Calendar/GData.tpl'); } elseif ($html) { // check if we're in shopping cart mode for events $enable_cart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart'); if ($enable_cart) { $this->assign('registration_links', TRUE); } return parent::run(); } else { $calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl'); $calendar = preg_replace('/(?<!\\r)\\n/', "\r\n", $calendar); } // Push output for feed or download if ($iCalPage == 1) { if ($gData || $rss) { CRM_Utils_ICalendar::send($calendar, 'text/xml', 'utf-8'); } else { CRM_Utils_ICalendar::send($calendar, 'text/plain', 'utf-8'); } } else { CRM_Utils_ICalendar::send($calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment'); } CRM_Utils_System::civiExit(); }
/** * Heart of the iCalendar data assignment process. The runner gets all the meta * data for the event and calls the method to output the iCalendar * to the user. If gData param is passed on the URL, outputs gData XML format. * Else outputs iCalendar format per IETF RFC2445. Page param true means send * to browser as inline content. Else, we send .ics file as attachment. * * @return void */ function run() { require_once "CRM/Utils/Request.php"; $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, null, 'GET'); $type = CRM_Utils_Request::retrieve('type', 'Positive', $this, false, 0); $start = CRM_Utils_Request::retrieve('start', 'Positive', $this, false, 0); $end = CRM_Utils_Request::retrieve('end', 'Positive', $this, false, 0); $iCalPage = CRM_Utils_Request::retrieve('page', 'Positive', $this, false, 0); $gData = CRM_Utils_Request::retrieve('gData', 'Positive', $this, false, 0); $html = CRM_Utils_Request::retrieve('html', 'Positive', $this, false, 0); $rss = CRM_Utils_Request::retrieve('rss', 'Positive', $this, false, 0); require_once "CRM/Event/BAO/Event.php"; $info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end); $this->assign('events', $info); // Send data to the correct template for formatting (iCal vs. gData) $template = CRM_Core_Smarty::singleton(); $config = CRM_Core_Config::singleton(); if ($rss) { // rss 2.0 requires lower case dash delimited locale $this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages))); $calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl'); } else { if ($gData) { $calendar = $template->fetch('CRM/Core/Calendar/GData.tpl'); } else { if ($html) { return parent::run(); } else { $calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl'); } } } // Push output for feed or download require_once "CRM/Utils/ICalendar.php"; if ($iCalPage == 1) { if ($gData || $rss) { CRM_Utils_ICalendar::send($calendar, 'text/xml', 'utf-8'); } else { CRM_Utils_ICalendar::send($calendar, 'text/plain', 'utf-8'); } } else { CRM_Utils_ICalendar::send($calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment'); } CRM_Utils_System::civiExit(); }
/** * Create the event blocks for upcoming events. * * @return void */ private static function setTemplateEventValues() { $config = CRM_Core_Config::singleton(); $info = CRM_Event_BAO_Event::getCompleteInfo(date("Ymd")); if ($info) { $session = CRM_Core_Session::singleton(); // check if registration link should be displayed foreach ($info as $id => $event) { //@todo FIXME - validRegistraionRequest takes eventID not contactID as a param // this is called via an obscure patch from Joomla event block rendering (only) $info[$id]['onlineRegistration'] = CRM_Event_BAO_Event::validRegistrationRequest($event, $session->get('userID')); } self::setProperty(self::EVENT, 'templateValues', array('eventBlock' => $info)); } }
/** * create the event blocks for upcoming events * * @return void * @access private */ private function setTemplateEventValues() { $config =& CRM_Core_Config::singleton(); require_once 'CRM/Event/BAO/Event.php'; $info = CRM_Event_BAO_Event::getCompleteInfo(); if ($info) { $session =& CRM_Core_Session::singleton(); // check if registration link should be displayed foreach ($info as $id => $event) { $info[$id]['onlineRegistration'] = CRM_Event_BAO_Event::validRegistrationDate($event, $session->get('userID')); } self::setProperty(self::EVENT, 'templateValues', array('eventBlock' => $info)); } }