/** * read permissions * * @access private * @param * @return */ private function readPermissions() { global $ilUser, $rbacsystem, $ilAccess; $this->editable = false; $this->visible = false; $this->importable = false; include_once './Services/Calendar/classes/class.ilCalendarShared.php'; $shared = ilCalendarShared::getSharedCalendarsForUser($ilUser->getId()); $cat = new ilCalendarCategory((int) $_GET['category_id']); switch ($cat->getType()) { case ilCalendarCategory::TYPE_USR: if ($cat->getObjId() == $ilUser->getId()) { $this->visible = true; $this->editable = true; $this->importable = true; } elseif (isset($shared[$cat->getCategoryID()])) { $this->visible = true; } break; case ilCalendarCategory::TYPE_GLOBAL: $this->importable = $this->editable = $rbacsystem->checkAccess('edit_event', ilCalendarSettings::_getInstance()->getCalendarSettingsId()); $this->visible = true; break; case ilCalendarCategory::TYPE_OBJ: $this->editable = false; $refs = ilObject::_getAllReferences($cat->getObjId()); foreach ($refs as $ref) { if ($ilAccess->checkAccess('read', '', $ref)) { $this->visible = true; } if ($ilAccess->checkAccess('edit_event', '', $ref)) { $this->importable = true; } } break; case ilCalendarCategory::TYPE_BOOK: case ilCalendarCategory::TYPE_CH: $this->editable = $ilUser->getId() == $cat->getCategoryID(); $this->visible = true; $this->importable = false; break; } }
/** * Read info about selected calendar * @param type $a_cal_id */ protected function readSelectedCalendar($a_cal_id) { include_once './Services/Calendar/classes/class.ilCalendarCategory.php'; $cat = new ilCalendarCategory($a_cal_id); if ($cat->getType() == ilCalendarCategory::TYPE_OBJ) { $this->readSelectedCategories(array($cat->getObjId())); $this->addSubitemCalendars(); } else { $this->categories[] = $a_cal_id; } }
/** * calculate * * @access protected */ public function calculate() { global $ilDB; $events = $this->getEvents(); // we need category type for booking handling $ids = array(); foreach ($events as $event) { $ids[] = $event->getEntryId(); } include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; $cat_map = ilCalendarCategoryAssignments::_getAppointmentCalendars($ids); include_once 'Services/Calendar/classes/class.ilCalendarCategory.php'; $cat_types = array(); foreach (array_unique($cat_map) as $cat_id) { $cat = new ilCalendarCategory($cat_id); $cat_types[$cat_id] = $cat->getType(); } $counter = 0; foreach ($events as $event) { // Calculdate recurring events include_once 'Services/Calendar/classes/class.ilCalendarRecurrences.php'; if ($recs = ilCalendarRecurrences::_getRecurrences($event->getEntryId())) { $duration = $event->getEnd()->get(IL_CAL_UNIX) - $event->getStart()->get(IL_CAL_UNIX); foreach ($recs as $rec) { $calc = new ilCalendarRecurrenceCalculator($event, $rec); foreach ($calc->calculateDateList($this->start, $this->end)->get() as $rec_date) { $this->schedule[$counter]['event'] = $event; $this->schedule[$counter]['dstart'] = $rec_date->get(IL_CAL_UNIX); $this->schedule[$counter]['dend'] = $this->schedule[$counter]['dstart'] + $duration; $this->schedule[$counter]['fullday'] = $event->isFullday(); $this->schedule[$counter]['category_id'] = $cat_map[$event->getEntryId()]; $this->schedule[$counter]['category_type'] = $cat_types[$cat_map[$event->getEntryId()]]; switch ($this->type) { case self::TYPE_DAY: case self::TYPE_WEEK: // store date info (used for calculation of overlapping events) $tmp_date = new ilDateTime($this->schedule[$counter]['dstart'], IL_CAL_UNIX, $this->timezone); $this->schedule[$counter]['start_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone); $tmp_date = new ilDateTime($this->schedule[$counter]['dend'], IL_CAL_UNIX, $this->timezone); $this->schedule[$counter]['end_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone); break; default: break; } $counter++; if ($this->areEventsLimited() && $counter >= $this->getEventsLimit()) { break; } } } } else { $this->schedule[$counter]['event'] = $event; $this->schedule[$counter]['dstart'] = $event->getStart()->get(IL_CAL_UNIX); $this->schedule[$counter]['dend'] = $event->getEnd()->get(IL_CAL_UNIX); $this->schedule[$counter]['fullday'] = $event->isFullday(); $this->schedule[$counter]['category_id'] = $cat_map[$event->getEntryId()]; $this->schedule[$counter]['category_type'] = $cat_types[$cat_map[$event->getEntryId()]]; if (!$event->isFullday()) { switch ($this->type) { case self::TYPE_DAY: case self::TYPE_WEEK: // store date info (used for calculation of overlapping events) $tmp_date = new ilDateTime($this->schedule[$counter]['dstart'], IL_CAL_UNIX, $this->timezone); $this->schedule[$counter]['start_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone); $tmp_date = new ilDateTime($this->schedule[$counter]['dend'], IL_CAL_UNIX, $this->timezone); $this->schedule[$counter]['end_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone); break; default: break; } } $counter++; if ($this->areEventsLimited() && $counter >= $this->getEventsLimit()) { break; } } } }
/** * show info screen * * @access protected * @return */ protected function showInfoScreen() { global $tpl, $ilUser; include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php"; $info = new ilInfoScreenGUI($this); $info->setFormAction($this->ctrl->getFormAction($this)); if ($this->app->isMilestone()) { $info->addSection($this->lng->txt('cal_ms_details')); } else { $info->addSection($this->lng->txt('cal_details')); } // Appointment $info->addProperty($this->lng->txt('appointment'), ilDatePresentation::formatPeriod($this->app->getStart(), $this->app->getEnd())); $info->addProperty($this->lng->txt('title'), $this->app->getPresentationTitle()); // Description if (strlen($desc = $this->app->getDescription())) { $info->addProperty($this->lng->txt('description'), $desc); } // Location if (strlen($loc = $this->app->getLocation())) { $info->addProperty($this->lng->txt('cal_where'), $loc); } // completion if ($this->app->isMilestone() && $this->app->getCompletion() > 0) { $info->addProperty($this->lng->txt('cal_task_completion'), $this->app->getCompletion() . " %"); } include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId()); $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id); $type = ilObject::_lookupType($cat_info['obj_id']); if ($this->app->isMilestone() && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ && ($type == "grp" || $type == "crs")) { // users responsible $users = $this->app->readResponsibleUsers(); $delim = ""; foreach ($users as $r) { $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]"; $delim = "<br />"; } if (count($users) > 0) { $info->addProperty($this->lng->txt('cal_responsible'), $value); } } $category = new ilCalendarCategory($cat_id); if ($category->getType() == ilCalendarCategory::TYPE_OBJ) { $info->addSection($this->lng->txt('additional_info')); $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id); $refs = ilObject::_getAllReferences($cat_info['obj_id']); include_once './Services/Link/classes/class.ilLink.php'; $href = ilLink::_getStaticLink(current($refs), ilObject::_lookupType($cat_info['obj_id']), true); $info->addProperty($this->lng->txt('perma_link'), '<a class="small" href="' . $href . '" target="_top">' . $href . '</a>'); } $tpl->setContent($info->getHTML()); }
/** * 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()); }