24 include_once
'./Services/Calendar/classes/class.ilCalendarUserSettings.php';
25 include_once
'./Services/Calendar/classes/iCal/class.ilICalWriter.php';
26 include_once
'./Services/Calendar/classes/class.ilCalendarCategory.php';
27 include_once
'./Services/Calendar/classes/class.ilCalendarEntry.php';
28 include_once
'./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
82 $this->il_user = $DIC->user();
83 $this->logger = $DIC->logger()->cal();
84 $this->calendars = $a_calendar_ids;
86 $this->appointments = [];
98 $this->appointments = $a_apps;
111 $this->calendars = $a_cal_ids;
124 $this->export_type = $a_type;
134 $this->str_writer_export->clear();
136 $str_writer_prefix->addLine(
'BEGIN:VCALENDAR');
137 $str_writer_prefix->addLine(
'VERSION:2.0');
138 $str_writer_prefix->addLine(
'METHOD:PUBLISH');
139 $str_writer_prefix->addLine(
'PRODID:-//ilias.de/NONSGML ILIAS Calendar V4.4//EN');
142 $str_writer_suffix->addLine(
'END:VCALENDAR');
143 $this->str_writer_export->append($str_writer_prefix);
145 case self::EXPORT_CALENDARS:
146 $byte_sum = $str_writer_prefix->byteCount() + $str_writer_suffix->byteCount();
147 $remaining_bytes = self::BYTE_LIMIT - $byte_sum;
149 $this->str_writer_export->append($str_builder_body);
152 case self::EXPORT_APPOINTMENTS:
154 $this->str_writer_export->append($str_builder_body);
157 $this->str_writer_export->append($str_writer_suffix);
167 $str_writer->addLine(
'X-WR-TIMEZONE:' . $this->il_user->getTimeZone());
169 include_once
'./Services/Calendar/classes/class.ilCalendarUtil.php';
171 if (!is_file($tzid_file)) {
174 $reader = fopen($tzid_file,
'r');
175 while ($line = fgets($reader)) {
176 $line = str_replace(
"\n",
'', $line);
177 $str_writer->addLine($line);
184 $single_appointments = [];
187 foreach ($this->calendars as $category_id) {
192 $str_writer_appointments->append($str_writer_appointment);
195 $single_appointments[] = $appointment;
204 if ($this->is_export_limited) {
205 $single_appointments = array_filter($single_appointments,
function (
ilCalendarEntry $a) {
211 $lower_bound = $now->sub(
new DateInterval(
'P30D'));
212 return $lower_bound <= $start;
216 foreach ($single_appointments as $appointment) {
220 $this->is_export_limited &&
221 ($str_writer_appointments->byteCount() + $str_writer_appointment->byteCount()) > $remaining_bytes
225 $str_writer_appointments->append($str_writer_appointment);
228 return $str_writer_appointments;
241 $str_builder_appointments->append($str_writer_appointment);
243 return $str_builder_appointments;
264 $this->logger->notice(
'Cannot create appointment for app_id: ' . $app->
getEntryId());
268 if (!strlen((
string) $test_date)) {
273 $str_writer->addLine(
'BEGIN:VEVENT');
274 $str_writer->addLine(
'DTSTAMP:' 281 $str_writer->addLine(
'LAST-MODIFIED:' . $last_mod);
284 $endInit = $app->
getEnd();
291 $start = $startInit->get(
IL_CAL_FKT_DATE,
'Ymd', $this->il_user->getTimeZone());
292 $end = $endInit->get(
IL_CAL_FKT_DATE,
'Ymd', $this->il_user->getTimeZone());
293 $str_writer->addLine(
'DTSTART;VALUE=DATE:' . $start);
294 $str_writer->addLine(
'DTEND;VALUE=DATE:' . $end);
299 $str_writer->addLine(
'DTSTART:' . $start);
300 $str_writer->addLine(
'DTEND:' . $end);
302 $start = $startInit->get(
IL_CAL_FKT_DATE,
'Ymd\THis', $this->il_user->getTimeZone());
303 $end = $endInit->get(
IL_CAL_FKT_DATE,
'Ymd\THis', $this->il_user->getTimeZone());
304 $str_writer->addLine(
'DTSTART;TZID=' . $this->il_user->getTimezone() .
':' . $start);
305 $str_writer->addLine(
'DTEND;TZID=' . $this->il_user->getTimezone() .
':' . $end);
321 $str_writer->addLine(
'END:VEVENT');
328 include_once
'./Services/Calendar/classes/class.ilCalendarRecurrences.php';
331 $str_writer->addLine($excl->toICal());
333 $recurrence_ical = $rec->toICal($this->il_user->getId());
334 if (strlen($recurrence_ical)) {
335 $str_writer->addLine($recurrence_ical);
343 return $this->str_writer_export->__toString();
353 $str_writer->addLine(
'URL;VALUE=URI:' . ILIAS_HTTP_PATH);
356 include_once
'./Services/Link/classes/class.ilLink.php';
static _getRecurrences($a_cal_id)
get all recurrences of an appointment
Model for a calendar entry.
getPresentationTitle($a_shorten=true)
get title for presentation.
const EXPORT_APPOINTMENTS
static _getInstanceByUserId($a_user_id)
get singleton instance
static getZoneInfoFile($a_tz)
static _lookupCategories($a_cal_id)
lookup categories
static _getAllReferences($a_id)
get all reference ids of object
isMilestone()
is milestone
createAppointment(ilCalendarEntry $appointment)
getDescription()
get description
createRecurrences(ilCalendarEntry $app)
buildAppointmentUrl(ilCalendarEntry $entry)
Export calendar(s) to ical format
setExportType(int $a_type)
static getInstanceByCategoryId($a_cat_id)
Get instance by category id.
addCategories(int $remaining_bytes)
createVEVENT(ilCalendarEntry $app)
createVTODO(ilCalendarEntry $app)
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
static getExclusionDates($a_cal_id)
Read exclusion dates.
getLocation()
get location
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
isRepeatingAppointment(ilCalendarEntry $appointment)
__construct(array $a_calendar_ids=[], bool $is_export_limited=false)
static escapeText($a_text)
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
getLastUpdate()
get last update
setCalendarIds(array $a_cal_ids)