public function testGetVcalIcal() { $iCal = new iCal(); $iCalString = $iCal->getVcalIcal($GLOBALS['current_user'], null); // echo "***********BEGIN iCalString*************\n".$iCalString."***********END iCalString***************\n"; $this->assertContains("VeryImportantMeeting", $iCalString, "Cannot find VEVENT: VeryImportantMeeting"); $this->assertContains("VeryImportantTask", $iCalString, "Cannot find VTODO: VeryImportantTask"); $this->assertContains("VeryImportantProjectTask", $iCalString, "Cannot find VTODO: VeryImportantProjectTask"); }
public function testgetVcalIcal() { error_reporting(E_ERROR | E_PARSE); $ical = new iCal(); $user = new User(1); //break the string in two pieces leaving out date part. $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nX-WR-CALNAME: (SugarCRM)\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:\r\nX-LIC-LOCATION:\r\nEND:VTIMEZONE\r\nCALSCALE:GREGORIAN"; $expectedEnd = "\r\nEND:VCALENDAR\r\n"; $actual = $ical->getVcalIcal($user, 6); //match the leading and trailing string parts to verify it returns expected results $this->assertStringStartsWith($expectedStart, $actual); $this->assertStringEndsWith($expectedEnd, $actual); }
public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $ics = $request->get('ics') . '.ics'; $icsUrl = 'cache/import/' . $ics; if (file_exists($icsUrl)) { $currentUserModel = Users_Record_Model::getCurrentUserModel(); $userId = $currentUserModel->getId(); $lastImport = new iCalLastImport(); $lastImport->clearRecords($userId); $eventModule = 'Events'; $todoModule = 'Calendar'; $skipFields = array($eventModule => array('duration_hours'), $todoModule => array('eventstatus')); $requiredFields = array(); $modules = array($eventModule, $todoModule); $calendarModel = Vtiger_Module_Model::getInstance($moduleName); foreach ($modules as $module) { $moduleRequiredFields = array_keys($calendarModel->getRequiredFields($module)); $requiredFields[$module] = array_diff($moduleRequiredFields, $skipFields[$module]); $totalCount[$module] = 0; $skipCount[$module] = 0; } $ical = new iCal(); $icalActivities = $ical->iCalReader($ics); $noOfActivities = count($icalActivities); for ($i = 0; $i < $noOfActivities; $i++) { if ($icalActivities[$i]['TYPE'] == 'VEVENT') { $activity = new iCalendar_event(); $module = $eventModule; } else { $activity = new iCalendar_todo(); $module = $todoModule; } $totalCount[$module]++; $activityFieldsList = $activity->generateArray($icalActivities[$i]); if (!array_key_exists('visibility', $activityFieldsList)) { $activityFieldsList['visibility'] = ' '; } if (array_key_exists('taskpriority', $activityFieldsList)) { $priorityMap = array('0' => 'Medium', '1' => 'High', '2' => 'Medium', '3' => 'Low'); $priorityval = $activityFieldsList['taskpriority']; if (array_key_exists($priorityval, $priorityMap)) { $activityFieldsList['taskpriority'] = $priorityMap[$priorityval]; } } $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName); $recordModel->setData($activityFieldsList); $recordModel->set('assigned_user_id', $userId); $skipRecord = false; foreach ($requiredFields[$module] as $key) { $value = $recordModel->get($key); if (empty($value)) { $skipCount[$module]++; $skipRecord = true; break; } } $recordModel->save(); $lastImport = new iCalLastImport(); $lastImport->setFields(array('userid' => $userId, 'entitytype' => $todoModule, 'crmid' => $recordModel->getId())); $lastImport->save(); if (!empty($icalActivities[$i]['VALARM'])) { $recordModel->setActivityReminder(0, '', ''); } } $return = 'LBL_IMPORT_ICS_ERROR_NO_RECORD'; $importedEvents = $totalCount[$eventModule] - $skipCount[$eventModule]; $importedTasks = $totalCount[$todoModule] - $skipCount[$todoModule]; if ($importedEvents > 0 || $importedTasks > 0) { $return = 'LBL_IMPORT_ICS_SUCCESS'; } @unlink($icsUrl); } else { $return = 'LBL_IMPORT_ICS_ERROR_NO_RECORD'; } $response = new Vtiger_Response(); $response->setResult(vtranslate($return, $moduleName)); $response->emit(); }
<?php header('Content-Type: text/calendar'); try { require 'classes/twente_milieu.php'; require 'classes/ical.php'; $afvalkalender = new TwenteMilieu($_GET['postcode'], $_GET['huisnummer']); $ical_generator = new iCal('TwenteMilieu', 'Afvalkalender'); // Find first of this month $request_date = new DateTime(); $request_date->setDate($request_date->format('Y'), $request_date->format('m'), 1); $request_date->setTime(0, 0, 0); $request_date->setTimezone(new DateTimeZone('Europe/Amsterdam')); $events = $afvalkalender->getEvents($request_date); echo $ical_generator->render($events); } catch (Exception $e) { echo "ERROR: {$e->getMessage()}"; }
function show() { if (isset($_GET['Kontakt'])) { return $this->kontakt(); } if (isset($this->num_show_next_dates)) { return $this->next_dates(); } if (preg_match("/\\.ics\$/i", SELF_URL)) { $this->http_login(); $this->noframe(); $ical_output = true; } $this->cal = new CalendarLinked(); for ($i = 0; $i < count($this->uri_components); $i++) { if (preg_match('/^[0-9]{4}$/', $this->uri_components[$i])) { $year_offset = $i; } } $year_request = isset($year_offset) ? $this->uri_components[$year_offset] : Date::jahr(); $month_request = isset($this->uri_components[$year_offset + 1]) && preg_match('/^[0-9]{1,2}$/', $this->uri_components[$year_offset + 1]) ? Date::add_0($this->uri_components[$year_offset + 1]) : Date::monat(); $day_request = isset($this->uri_components[$year_offset + 2]) && preg_match('/^[0-9]{1,2}$/', $this->uri_components[$year_offset + 2]) ? Date::add_0($this->uri_components[$year_offset + 2]) : '01'; //Date::tag(); $page_root = '/' . rawurlencode($this->uri_components[0]) . '/' . rawurlencode($this->uri_components[1]); for ($i = 2; $i < ($year_offset ? $year_offset : count($this->uri_components)); $i++) { $page_root .= '/' . rawurlencode($this->uri_components[$i]); } $this->cal->root = $page_root; if ($this->check_right('KalenderIntern')) { $access = ''; } elseif ($this->check_right('KalenderExtern')) { $access = "AND `CLASS` = 'PUBLIC'"; } else { $allowed_categories = array(); foreach ($this->categories as $cat) { if ($cat['Access'] == 'PUBLIC') { $allowed_categories[] = "`CATEGORIES` = '" . $cat['Name'] . "'"; } } $access = "AND `CLASS` = 'PUBLIC'"; if ($allowed_categories) { $access .= " AND (" . implode(' OR ', $allowed_categories) . ")"; } } if (isset($_GET['Kategorie'])) { $cat_filter = array(); foreach ($_GET['Kategorie'] as $cat) { $cat_filter[] = "`CATEGORIES` = '" . rawurldecode($cat) . "'"; $filter = "AND (" . implode(' OR ', $cat_filter) . ")"; } } else { $filter = ''; } $show_sql = "SELECT * FROM `{$this->db_table}` WHERE `DTSTART` >= '" . Date::unify_timestamp($year_request . $month_request . $day_request) . "' {$access} {$filter} ORDER BY `DTSTART` ASC"; $overview_sql = "SELECT * FROM `{$this->db_table}` WHERE `DTSTART` >= NOW() {$access} {$filter} ORDER BY `DTSTART` ASC"; $overview = $this->connection->db_assoc($overview_sql); $this->cal->dates = array(); $this->cal->edit_enabled = $this->scaff->edit_enabled; foreach ($overview as $date) { $date['DTSTART'] = Date::unify_timestamp($date['DTSTART']); $day = Date::jahr($date['DTSTART']) . Date::monat($date['DTSTART']) . Date::tag($date['DTSTART']) . '000000'; $end = Date::jahr($date['DTEND']) . Date::monat($date['DTEND']) . Date::tag($date['DTEND']) . '000000'; $array = array(); $array['start'] = $day; $array['SUMMARY'] = ''; $array['SUMMARY'] .= intval(Date::stunde($date['DTSTART']) . Date::minute($date['DTSTART'])) != 0 ? Date::stunde($date['DTSTART']) . ':' . Date::minute($date['DTSTART']) : ''; $array['SUMMARY'] .= $day == $end ? '-' . Date::stunde($date['DTEND']) . ':' . Date::minute($date['DTEND']) . ' ' : ' '; $array['SUMMARY'] .= $date['SUMMARY']; $array['time'] = Date::stunde($date['DTSTART']) . ':' . Date::minute($date['DTSTART']); $array['id'] = $date['id']; $this->cal->dates[$day][] = $array; if ($day != $end) { while ($day < $end) { $day = Date::add($day, 'day', 1); $this->cal->dates[$day][] = $array; } } } $month[0] = $month_request; $year[0] = $year_request; $month[1] = $month[0] + 1 != 13 ? $month[0] + 1 : 1; $year[1] = $month[0] + 1 != 13 ? $year[0] : $year[0] + 1; $month[2] = $month[1] + 1 != 13 ? $month[1] + 1 : 1; $year[2] = $month[1] + 1 != 13 ? $year[1] : $year[0] + 1; $prev_month = $month[0] - 1 != 0 ? $month[0] - 1 : 12; $prev_year = $month[0] - 1 != 0 ? $year[0] : $year[0] - 1; $this->template = $this->template ? $this->template : INSTALL_PATH . '/Module/Kalender/Templates/KalenderTabelle.template.html'; $prev_month_link = Html::a($page_root . '/' . $prev_year . '/' . $prev_month . $this->cat_get(), '<< '); $next_month_link = Html::a($page_root . '/' . $year[1] . '/' . $month[1] . $this->cat_get(), ' >>'); $sidebar[] = $this->cat_select(); $sidebar[] = $this->cal->getMonthHTML($month[0], $year[0], 1, $prev_month_link, $next_month_link); $sidebar[] = $this->cal->getMonthHTML($month[1], $year[1]); $sidebar[] = $this->cal->getMonthHTML($month[2], $year[2]); $this->scaff->datumsformat = 'tag_kurz'; $result_table = $this->scaff->make_table($show_sql, $this->template); if ($ical_output) { $events = $this->connection->db_assoc($show_sql); if (!class_exists('iCal')) { include_once 'Kalender/iCalExport.php'; } //header("Content-Type: text/calendar"); $ical = new iCal($events); return mb_convert_encoding($ical->display_ical(), 'UTF-8', 'ISO-8859-15'); } $nav = array(); if ($prev = $this->scaff->prev_link()) { $nav[0] = Html::a(SELF . '?' . $prev, 'Zurück'); } if ($next = $this->scaff->next_link()) { $nav[1] = Html::a(SELF . '?' . $next, 'Weiter'); } $return_string = ''; $return_string .= Form::form_tag(SELF); $return_string .= $result_table; //$return_string .=implode(' | ',$nav); $return_string .= Form::close_form(); return Html::div($return_string, array('id' => 'box-mitte', 'class' => 'box-mitte')) . Html::div(implode("\n", $sidebar), array('id' => 'monatskalender')); }
/** * Function to show result of import * @param Vtiger_Request $request */ public function importResult(Vtiger_Request $request) { $currentUserModel = Users_Record_Model::getCurrentUserModel(); $userId = $currentUserModel->getId(); $moduleName = $request->getModule(); $viewer = $this->getViewer($request); $request->set('type', 'ics'); if (Import_Utils_Helper::validateFileUpload($request)) { $lastImport = new iCalLastImport(); $lastImport->clearRecords($userId); $eventModule = 'Events'; $todoModule = 'Calendar'; $skipFields = array($eventModule => array('duration_hours'), $todoModule => array('activitystatus')); $requiredFields = array(); $modules = array($eventModule, $todoModule); $calendarModel = Vtiger_Module_Model::getInstance($moduleName); foreach ($modules as $module) { $moduleRequiredFields = array_keys($calendarModel->getRequiredFields($module)); $requiredFields[$module] = array_diff($moduleRequiredFields, $skipFields[$module]); $totalCount[$module] = 0; $skipCount[$module] = 0; } $ical = new iCal(); $icalActivities = $ical->iCalReader("IMPORT_" . $userId); $noOfActivities = count($icalActivities); for ($i = 0; $i < $noOfActivities; $i++) { if ($icalActivities[$i]['TYPE'] == 'VEVENT') { $activity = new iCalendar_event(); $module = $eventModule; } else { $activity = new iCalendar_todo(); $module = $todoModule; } $totalCount[$module]++; $activityFieldsList = $activity->generateArray($icalActivities[$i]); if (!array_key_exists('visibility', $activityFieldsList)) { $activityFieldsList['visibility'] = ' '; } if (array_key_exists('taskpriority', $activityFieldsList)) { $priorityMap = array('0' => 'Medium', '1' => 'High', '2' => 'Medium', '3' => 'Low'); $priorityval = $activityFieldsList['taskpriority']; if (array_key_exists($priorityval, $priorityMap)) { $activityFieldsList['taskpriority'] = $priorityMap[$priorityval]; } } $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName); $recordModel->setData($activityFieldsList); $recordModel->set('assigned_user_id', $userId); $skipRecord = false; foreach ($requiredFields[$module] as $key) { $value = $recordModel->get($key); if (empty($value)) { $skipCount[$module]++; $skipRecord = true; break; } } if ($skipRecord === true) { continue; } $recordModel->save(); $lastImport = new iCalLastImport(); $lastImport->setFields(array('userid' => $userId, 'entitytype' => $todoModule, 'crmid' => $recordModel->getId())); $lastImport->save(); if (!empty($icalActivities[$i]['VALARM'])) { $recordModel->setActivityReminder(0, '', ''); } } $importedEvents = $totalCount[$eventModule] - $skipCount[$eventModule]; $importedTasks = $totalCount[$todoModule] - $skipCount[$todoModule]; $viewer->assign('SUCCESS_EVENTS', $importedEvents); $viewer->assign('SKIPPED_EVENTS', $skipCount[$eventModule]); $viewer->assign('SUCCESS_TASKS', $importedTasks); $viewer->assign('SKIPPED_TASKS', $skipCount[$todoModule]); } else { $viewer->assign('ERROR_MESSAGE', $request->get('error_message')); } $viewer->assign('MODULE', $moduleName); $viewer->assign('VIEW', 'List'); $viewer->view('ImportResult.tpl', $moduleName); }
$listMember->openMembers($tmpquery); $comptListMember = count($listMember->mem_id); if ($comptListMember != 1) { authenticate(); exit; } if (!is_password_match(mysql_escape_string($_SERVER['PHP_AUTH_USER']), mysql_escape_string($_SERVER['PHP_AUTH_PW']), $listMember->mem_password[0])) { authenticate(); exit; } $_SESSION['idSession'] = $listMember->mem_id[0]; $_SESSION['icalAuth'] = true; } // load the base iCal class require_once '../includes/ical/class.iCal.inc.php'; $iCal = new iCal('-//netoffice.sourceforge.net//NetOffice v' . $version . '//' . strtoupper($langDefault), 0, ''); // now get the open task(s) for user_name $tmpquery = "WHERE tas.assigned_to = '" . $_SESSION['idSession'] . "' AND tas.status IN(0,2,3) AND pro.status IN(0,2,3)"; $listTasks = new request(); $listTasks->openTasks($tmpquery); $comptListTasks = count($listTasks->tas_id); // iCal VTODO: Open Task(s) // iCal VEVENT: Milestones for open projects if ($comptListTasks >= 1) { for ($i = 0; $i < $comptListTasks; $i++) { $title = (string) $listTasks->tas_name[$i]; $description = (string) $listTasks->tas_description[$i]; if (empty($listTasks->tas_start_date[$i]) || $listTasks->tas_start_date[$i] == '--') { $start_date = ''; continue; } else {
$last_import->mark_deleted_by_user_id($current_user->id); $file_details = $_FILES['ics_file']; $binFile = 'vtiger_import' . date('YmdHis'); $file = $import_dir . '' . $binFile; $filetmp_name = $file_details['tmp_name']; $upload_status = move_uploaded_file($filetmp_name, $file); $skip_fields = array('Events' => array('duration_hours'), 'Calendar' => array('eventstatus')); $required_fields = array(); $modules = array('Events', 'Calendar'); foreach ($modules as $module) { $calendar = CRMEntity::getInstance('Calendar'); $calendar->initRequiredFields($module); $val = array_keys($calendar->required_fields); $required_fields[$module] = array_diff($val, $skip_fields[$module]); } $ical = new iCal(); $ical_activities = $ical->iCalReader($binFile); $count['Events'] = $count['Calendar'] = $skip_count['Events'] = $skip_count['Calendar'] = 0; for ($i = 0; $i < count($ical_activities); $i++) { if ($ical_activities[$i]['TYPE'] == 'VEVENT') { $activity = new iCalendar_event(); $module = 'Events'; } else { $activity = new iCalendar_todo(); $module = 'Calendar'; } $count[$module]++; $calendar = CRMEntity::getInstance('Calendar'); $calendar->column_fields = $activity->generateArray($ical_activities[$i]); $calendar->column_fields['assigned_user_id'] = $current_user->id; foreach ($required_fields[$module] as $key) {
* @version 3.0 * @copyright Copyright 2006 Queen's University, MEdTech Unit * * $Id: calendars.php 1103 2010-04-05 15:20:37Z simpson $ */ @set_time_limit(0); @set_include_path(implode(PATH_SEPARATOR, array(dirname(__FILE__) . "/../core", dirname(__FILE__) . "/../core/includes", dirname(__FILE__) . "/../core/library", get_include_path()))); /** * Include the Entrada init code. */ require_once "init.inc.php"; require_once "Entrada/icalendar/class.ical.inc.php"; $tmp_org_id = $_GET["org"]; $PROCESSED["org_id"] = clean_input($tmp_org_id, "int"); if ($PROCESSED["org_id"]) { $cohorts = groups_get_active_cohorts($PROCESSED["org_id"]); foreach ($cohorts as $cohort) { $query = "\n\t\t\t\t\tSELECT a.*, c.`proxy_id`, CONCAT_WS(' ', d.`firstname`, d.`lastname`) AS `fullname`, d.`email`\n\t\t\t\t\tFROM `events` AS a\n\t\t\t\t\tLEFT JOIN `event_audience` AS b\n\t\t\t\t\tON b.`event_id` = a.`event_id`\n\t\t\t\t\tLEFT JOIN `event_contacts` AS c\n\t\t\t\t\tON c.`event_id` = a.`event_id`\n\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_data` AS d\n\t\t\t\t\tON d.`id` = c.`proxy_id`\n\t\t\t\t\tWHERE b.`audience_type` = 'cohort'\n\t\t\t\t\tAND b.`audience_value` = " . $db->qstr($cohort["group_id"]) . "\n\t\t\t\t\tAND (c.`contact_order` IS NULL OR c.`contact_order` = '0')\n\t\t\t\t\tORDER BY a.`event_start` ASC"; $results = $db->GetAll($query); if ($results) { $ical = new iCal("-//" . html_encode($_SERVER["HTTP_HOST"]) . "//iCal" . ($cohort["group_name"] ? html_encode($cohort["group_name"]) : "") . " Learning Events Calendar MIMEDIR//EN", 1, ENTRADA_ABSOLUTE . "/calendars/", $cohort ? clean_input($cohort["group_name"], "numeric") : "all_cohorts"); // (ProgrammID, Method (1 = Publish | 0 = Request), Download Directory) foreach ($results as $result) { $ical->addEvent(array($result["fullname"] != "" ? $result["fullname"] : "", $result["email"] ? $result["email"] : ""), (int) $result["event_start"], (int) $result["event_finish"], $result["event_location"], 1, array("Phase " . $result["event_phase"], html_encode($cohort["group_name"])), strip_tags($result["event_message"]), strip_tags($result["event_title"]), 1, array(), 5, 0, 0, 0, array(), 1, "", 0, 1, str_replace("http://", "https://", ENTRADA_URL) . "/events?id=" . (int) $result["event_id"], "en", md5((int) $result["event_id"])); } $ical->writeFile(); } } } else { echo "When running the calender generation cron job an invalid org_id was provided, or no org_id was provided."; }
$course_ids_array = $db->GetAll($query); foreach ($course_ids_array as $id) { $course_ids[] = $id; } foreach ($learning_events["events"] as $key => $event) { if (array_search($event["course_id"], $course_ids) !== false) { unset($learning_events["events"][$key]); } } } } switch ($calendar_type) { case "ics": add_statistic("calendar.api", "view", "type", "ics"); require_once "Entrada/icalendar/class.ical.inc.php"; $ical = new iCal("-//" . html_encode($_SERVER["HTTP_HOST"]) . "//iCal " . APPLICATION_NAME . " Calendar MIMEDIR//EN", 1, ENTRADA_ABSOLUTE . "/calendars/", $user_username); if (!empty($learning_events["events"])) { foreach ($learning_events["events"] as $event) { $ical->addEvent(array(), (int) $event["event_start"], (int) $event["event_finish"], $event["event_location"] ? $event["event_location"] : "To Be Announced", 1, array(), strip_tags($event["event_message"]), strip_tags($event["event_title"]), 1, array(), 5, 0, 0, 0, array(), 1, "", 0, 1, str_replace("http://", "https://", ENTRADA_URL) . "/events?id=" . (int) $event["event_id"], "en", md5((int) $event["event_id"])); } } $ical->outputFile(); break; case "json": default: $events = array(); if (!empty($learning_events["events"])) { foreach ($learning_events["events"] as $drid => $event) { $cal_type = 1; $cal_updated = ""; if ($event["audience_type"] == "proxy_id") {
public function import() { if (isset($this->urlParams['ID'])) { $file = Director::baseFolder() . "/event_calendar/import/" . $this->urlParams['ID'] . ".ics"; } if (file_exists($file)) { $parser = new iCal(array($file)); $ics_events = $parser->iCalReader(); if (is_array($ics_events) && is_array($ics_events[$file])) { $dt_start = null; $dt_end = null; $i = 1; foreach ($ics_events[$file] as $event) { if (!$dt_start && !$dt_end || (!isset($event[$dt_start]) || !isset($event[$dt_end]))) { foreach ($event as $k => $v) { if (substr($k, 0, 7) == "DTSTART") { $dt_start = $k; } if (substr($k, 0, 5) == "DTEND") { $dt_end = $k; } } } if (isset($event[$dt_start]) && isset($event[$dt_end])) { list($start_date, $end_date, $start_time, $end_time) = CalendarUtil::date_info_from_ics($event[$dt_start], $event[$dt_end]); $c = $this->getModel()->getEventDateTimeClass(); $new_date = new $c(); $new_date->StartDate = $start_date; $new_date->StartTime = $start_time; $new_date->EndDate = $end_date; $new_date->EndTime = $end_time; if (isset($event['DESCRIPTION']) && !empty($event['DESCRIPTION'])) { $new_date->Content = $event['DESCRIPTION']; } if (isset($event['SUMMARY']) && !empty($event['SUMMARY'])) { $new_date->Title = $event['SUMMARY']; } $new_date->is_announcement = 1; $new_date->CalendarID = $this->ID; $new_date->write(); echo sprintf("<p style='color:green;'>Event <em>%s</em> imported successfully, and was assigned ID %d</p>", $new_date->Title, $new_date->ID); } else { echo sprintf("<p style='color:red;'>Event #%d could not be imported.</p>", $i); } $i++; } } die; } else { die("The file {$file} could not be found."); } }
if ($ERROR) { http_authenticate(); } unset($username, $password); } } } switch ($feed_type) { case "calendar.ics": case "ics": require_once "Entrada/icalendar/class.ical.inc.php"; $query = "\tSELECT a.*, CONCAT_WS(' ', b.`firstname`, b.`lastname`) AS `fullname`, b.`email`, c.*, d.`community_title`\n\t\t\t\t\t\t\tFROM `community_events` AS a\n\t\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_data` AS b\n\t\t\t\t\t\t\tON b.`id` = a.`proxy_id`\n\t\t\t\t\t\t\tLEFT JOIN `community_pages` AS c\n\t\t\t\t\t\t\tON c.`cpage_id` = a.`cpage_id`\n\t\t\t\t\t\t\tLEFT JOIN `communities` AS d\n\t\t\t\t\t\t\tON a.`community_id` = d.`community_id`\n\t\t\t\t\t\t\tWHERE c.`cpage_id` = " . $db->qstr($page_record["cpage_id"]) . "\n\t\t\t\t\t\t\tAND a.`event_active` = '1'\n\t\t\t\t\t\t\tAND c.`page_active` = '1'\n\t\t\t\t\t\t\tORDER BY a.`event_start` ASC"; $results = $db->GetAll($query); if ($results) { $community_title = $results[0]["community_title"]; $ical = new iCal("-//" . html_encode($_SERVER["HTTP_HOST"]) . "//iCal Learning Events Calendar MIMEDIR//EN", 1, ENTRADA_ABSOLUTE . "/community/feeds" . $community_url . ":" . $page_url . "/ics", str_replace(array("/", " ", "_"), "-", $community_title . "->" . $page_record["menu_title"])); // (ProgrammID, Method (1 = Publish | 0 = Request), Download Directory) foreach ($results as $result) { $ical->addEvent(array($result["fullname"] != "" ? $result["fullname"] : "", $result["email"] ? $result["email"] : ""), (int) $result["event_start"], (int) $result["event_finish"], $result["event_location"], 1, array($result["community_title"]), strip_tags(str_replace("<br />", " ", $result["event_description"])), strip_tags($result["event_title"]), 1, array(), 5, 0, 0, 0, array(), date("w", (int) $result["event_start"]), "", 0, 1, str_replace("http://", "https://", COMMUNITY_URL) . $page_record["community_url"] . ":" . $page_record["page_url"] . "?id=" . (int) $result["cevent_id"], "en", ""); } if (!isset($ical->output)) { $ical->generateOutput(); } header("Content-Disposition: inline; filename=\"" . str_replace(array("/", " ", "_"), "-", $page_record["menu_title"]) . ".ics\""); header("Content-Type: text/calendar"); echo $ical->output; } break; case "rss": case "rss10": case "rss20":
$validated = true; } if (!$context_item->isPortal() and !$context_item->isServer() and isset($_GET['hid']) and !empty($_GET['hid']) and !$validated) { if (!$context_item->isLocked() and $hash_manager->isICalHashValid($_GET['hid'], $context_item)) { $validated = true; } } if ($validated) { if (!empty($_GET['hid'])) { $l_current_user_item = $hash_manager->getUserByICalHash($_GET['hid']); if (!empty($l_current_user_item)) { $environment->setCurrentUserItem($l_current_user_item); } } include_once 'classes/external_classes/ical/iCal.php'; $iCal = new iCal('', 0); // (ProgrammID, Method [1 = Publish | 0 = Request]) if (isset($_GET['mod'])) { $current_module = $_GET['mod']; } else { $current_module = CS_DATE_TYPE; } if ($current_module == CS_DATE_TYPE) { $dates_manager = $environment->getDatesManager(); $dates_manager->setWithoutDateModeLimit(); if (!$environment->inPrivateRoom()) { $dates_manager->setContextLimit($context_item->getItemID()); } else { $context_item = $environment->getCurrentContextItem(); $date_sel_status = $context_item->getRubrikSelection(CS_DATE_TYPE, 'status'); if (!empty($date_sel_status)) {