/** * set appointments * * @access public * @return */ public function setAppointments($a_apps) { include_once './Services/Calendar/classes/class.ilCalendarEntry.php'; include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php'; foreach ($a_apps as $event) { $entry = $event['event']; $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId()); $tmp_arr['id'] = $entry->getEntryId(); $tmp_arr['milestone'] = $entry->isMilestone(); $tmp_arr['title'] = $entry->getPresentationTitle(); $tmp_arr['description'] = $entry->getDescription(); $tmp_arr['fullday'] = $entry->isFullday(); #$tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX); #$tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX); $tmp_arr['begin'] = $event['dstart']; $tmp_arr['end'] = $event['dend']; $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin']; if ($tmp_arr['fullday']) { $tmp_arr['duration'] += 60 * 60 * 24; } if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) { $tmp_arr['duration'] = ''; } $tmp_arr['last_update'] = $entry->getLastUpdate()->get(IL_CAL_UNIX); $tmp_arr['frequence'] = $rec->getFrequenceType(); $appointments[] = $tmp_arr; } $this->setData($appointments ? $appointments : array()); }
/** * init appointment * * @access protected * @param int appointment id * @return */ protected function initAppointment($a_app_id = 0) { include_once './Services/Calendar/classes/class.ilCalendarEntry.php'; include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php'; $this->app = new ilCalendarEntry($a_app_id); include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php'; $this->notification = new ilCalendarUserNotification($this->app->getEntryId()); if (!$a_app_id) { $start = clone $this->initialDate; $this->app->setStart($start); $seed_end = clone $this->initialDate; if ($this->default_fulltime) { #$seed_end->increment(IL_CAL_DAY,1); } else { $seed_end->increment(IL_CAL_HOUR, 1); } $this->app->setEnd($seed_end); $this->app->setFullday($this->default_fulltime); $this->rec = new ilCalendarRecurrence(); } else { $this->rec = ilCalendarRecurrences::_getFirstRecurrence($this->app->getEntryId()); } }
protected function createVEVENT($app) { global $ilUser; $this->writer->addLine('BEGIN:VEVENT'); // TODO only domain $this->writer->addLine('UID:' . ilICalWriter::escapeText($app->getEntryId() . '_' . CLIENT_ID . '@' . ILIAS_HTTP_PATH)); $last_mod = $app->getLastUpdate()->get(IL_CAL_FKT_DATE, 'Ymd\\THis\\Z', ilTimeZone::UTC); #$last_mod = $app->getLastUpdate()->get(IL_CAL_FKT_DATE,'Ymd\THis\Z',$ilUser->getTimeZone()); $this->writer->addLine('LAST-MODIFIED:' . $last_mod); // begin-patch aptar include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php'; if ($rec = ilCalendarRecurrences::_getFirstRecurrence($app->getEntryId())) { // Set starting time to first appointment that matches the recurrence rule include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php'; $calc = new ilCalendarRecurrenceCalculator($app, $rec); $pStart = $app->getStart(); $pEnd = clone $app->getStart(); $pEnd->increment(IL_CAL_YEAR, 5); $appDiff = $app->getEnd()->get(IL_CAL_UNIX) - $app->getStart()->get(IL_CAL_UNIX); $recs = $calc->calculateDateList($pStart, $pEnd); foreach ($recs as $dt) { $startInit = $dt; $endInit = clone $dt; $endInit->setDate($startInit->get(IL_CAL_UNIX) + $appDiff, IL_CAL_UNIX); break; } } else { $startInit = $app->getStart(); $endInit = $app->getEnd(); } if ($app->isFullday()) { // According to RFC 5545 3.6.1 DTEND is not inklusive. // But ILIAS stores inklusive dates in the database. #$app->getEnd()->increment(IL_CAL_DAY,1); $endInit->increment(IL_CAL_DATE, 1); #$start = $app->getStart()->get(IL_CAL_FKT_DATE,'Ymd\Z',ilTimeZone::UTC); #$start = $app->getStart()->get(IL_CAL_FKT_DATE,'Ymd',$ilUser->getTimeZone()); $start = $startInit->get(IL_CAL_FKT_DATE, 'Ymd', $ilUser->getTimeZone()); #$end = $app->getEnd()->get(IL_CAL_FKT_DATE,'Ymd\Z',ilTimeZone::UTC); #$end = $app->getEnd()->get(IL_CAL_FKT_DATE,'Ymd',$ilUser->getTimeZone()); $endInit->increment(IL_CAL_DAY, 1); $end = $endInit->get(IL_CAL_FKT_DATE, 'Ymd', $ilUser->getTimeZone()); $this->writer->addLine('DTSTART;VALUE=DATE:' . $start); $this->writer->addLine('DTEND;VALUE=DATE:' . $end); } else { #$start = $app->getStart()->get(IL_CAL_FKT_DATE,'Ymd\THis\Z',ilTimeZone::UTC); #$start = $app->getStart()->get(IL_CAL_FKT_DATE,'Ymd\THis',$ilUser->getTimeZone()); $start = $startInit->get(IL_CAL_FKT_DATE, 'Ymd\\THis', $ilUser->getTimeZone()); #$end = $app->getEnd()->get(IL_CAL_FKT_DATE,'Ymd\THis\Z',ilTimeZone::UTC); #$end = $app->getEnd()->get(IL_CAL_FKT_DATE,'Ymd\THis',$ilUser->getTimeZone()); $end = $endInit->get(IL_CAL_FKT_DATE, 'Ymd\\THis', $ilUser->getTimeZone()); $this->writer->addLine('DTSTART;TZID=' . $ilUser->getTimezone() . ':' . $start); $this->writer->addLine('DTEND;TZID=' . $ilUser->getTimezone() . ':' . $end); } // end-patch aptar $this->createRecurrences($app); $this->writer->addLine('SUMMARY:' . ilICalWriter::escapeText($app->getPresentationTitle())); if (strlen($app->getDescription())) { $this->writer->addLine('DESCRIPTION:' . ilICalWriter::escapeText($app->getDescription())); } if (strlen($app->getLocation())) { $this->writer->addLine('LOCATION:' . ilICalWriter::escapeText($app->getLocation())); } // TODO: URL $this->buildAppointmentUrl($app); $this->writer->addLine('END:VEVENT'); }
/** * set appointments * * @access public * @return */ public function setAppointments($a_apps) { include_once './Services/Calendar/classes/class.ilCalendarEntry.php'; include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php'; include_once './Services/Calendar/classes/class.ilCalendarCategory.php'; $cat = new ilCalendarCategory($this->cat_id); foreach ($a_apps as $cal_entry_id) { $entry = new ilCalendarEntry($cal_entry_id); $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId()); // booking if ($cat->getType() == ilCalendarCategory::TYPE_CH) { include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $book = new ilBookingEntry($entry->getContextId()); if ($book) { $title = $entry->getTitle(); if ($book->isOwner()) { $max = (int) $book->getNumberOfBookings(); $current = (int) $book->getCurrentNumberOfBookings($entry->getEntryId()); if ($max > 1) { $title .= ' (' . $current . '/' . $max . ')'; } else { if ($current == $max) { $title .= ' (' . $this->lng->txt('cal_booked_out') . ')'; } else { $title .= ' (' . $this->lng->txt('cal_book_free') . ')'; } } } else { if ($book->hasBooked($entry->getEntryId())) { $title .= ' (' . $this->lng->txt('cal_date_booked') . ')'; } } } } else { $title = $entry->getPresentationTitle(); } $tmp_arr['id'] = $entry->getEntryId(); $tmp_arr['title'] = $title; $tmp_arr['description'] = $entry->getDescription(); $tmp_arr['fullday'] = $entry->isFullday(); $tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX); $tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX); $tmp_arr['dt_sort'] = $entry->getStart()->get(IL_CAL_UNIX); $tmp_arr['dt'] = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd()); #$tmp_arr['duration'] = ($dur = $tmp_arr['end'] - $tmp_arr['begin']) ? $dur : 60 * 60 * 24; $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin']; if ($tmp_arr['fullday']) { $tmp_arr['duration'] += 60 * 60 * 24; } if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) { $tmp_arr['duration'] = ''; } $tmp_arr['frequence'] = $rec->getFrequenceType(); $tmp_arr['deletable'] = (!$entry->isAutoGenerated() and $this->is_editable); $appointments[] = $tmp_arr; } $this->setData($appointments ? $appointments : array()); }