ILIAS  release_8 Revision v8.24
class.ilCalendarAppointmentGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use Psr\Http\Message\RequestInterface;
22use Psr\Http\Message\ServerRequestInterface;
23use ILIAS\HTTP\Services as HTTPServices;
24use ILIAS\Refinery\Factory as RefineryFactory;
25
32{
35 protected bool $requested_rexl;
36
37 protected ilDate $seed;
39 protected bool $default_fulltime = true;
42 protected string $timezone;
43
45 protected ilLanguage $lng;
47 protected ilObjUser $user;
48 protected ilTabsGUI $tabs;
50 protected ilHelpGUI $help;
53 protected HTTPServices $http;
54 protected RefineryFactory $refinery;
55 protected RequestInterface $request;
56
60 public function __construct(ilDate $seed, ilDate $initialDate, int $a_appointment_id = 0)
61 {
62 global $DIC;
63
64 $this->lng = $DIC->language();
65 $this->lng->loadLanguageModule('dateplaner');
66 $this->ctrl = $DIC->ctrl();
67 $this->tpl = $DIC->ui()->mainTemplate();
68 $this->logger = $DIC->logger()->cal();
69 $this->user = $DIC->user();
70 $this->settings = $DIC->settings();
71 $this->tabs = $DIC->tabs();
72 $this->help = $DIC->help();
73 $this->error = $DIC['ilErr'];
74
75 $this->http = $DIC->http();
76 $this->refinery = $DIC->refinery();
77 $this->request = $DIC->http()->request();
78
79 $this->initTimeZone();
80 $this->initSeed($seed);
81 $this->initInitialDate($initialDate);
82 $this->initAppointment($a_appointment_id);
83 $this->requested_rexl = (bool) $this->getRecurrenceExclusionFromQuery();
84 }
85
86 protected function getAppointmentIdFromQuery(): int
87 {
88 if ($this->http->wrapper()->query()->has('app_id')) {
89 return $this->http->wrapper()->query()->retrieve(
90 'app_id',
91 $this->refinery->kindlyTo()->int()
92 );
93 }
94 return 0;
95 }
96
98 {
99 $val = 0;
100 if ($this->http->wrapper()->post()->has('rexl')) {
101 $val = $this->http->wrapper()->post()->retrieve(
102 'rexl',
103 $this->refinery->kindlyTo()->int()
104 );
105 }
106 if ($val === 0 && $this->http->wrapper()->query()->has('rexl')) {
107 $val = $this->http->wrapper()->query()->retrieve(
108 'rexl',
109 $this->refinery->kindlyTo()->int()
110 );
111 }
112 return $val;
113 }
114
115 protected function getRecurrenceDateFromQuery(): int
116 {
117 if ($this->http->wrapper()->query()->has('dt')) {
118 return $this->http->wrapper()->query()->retrieve(
119 'dt',
120 $this->refinery->kindlyTo()->int()
121 );
122 }
123 return 0;
124 }
125
126 public function executeCommand(): void
127 {
128 // Clear tabs and set back target
129 $this->tabs->clearTargets();
130 if ($this->http->wrapper()->query()->has('app_id')) {
131 $this->ctrl->saveParameter($this, 'app_id');
132 }
133 $this->tabs->setBackTarget(
134 $this->lng->txt('cal_back_to_cal'),
135 $this->ctrl->getLinkTarget($this, 'cancel')
136 );
137
138 $next_class = $this->ctrl->getNextClass($this);
139 switch ($next_class) {
140
141 default:
142 $cmd = $this->ctrl->getCmd("add");
143 $this->$cmd();
144 break;
145 }
146 }
147
149 {
150 return $this->app;
151 }
152
153 protected function cancel(): void
154 {
155 $this->ctrl->returnToParent($this);
156 }
157
158 protected function initForm(
159 string $a_mode,
160 bool $a_as_milestone = false,
161 bool $a_edit_single_app = false
163 $this->form = new ilPropertyFormGUI();
165 $resp_info = false;
166 switch ($a_mode) {
167 case 'create':
168 $this->ctrl->saveParameter($this, array('seed', 'idate'));
169 $this->form->setFormAction($this->ctrl->getFormAction($this));
170 if ($a_as_milestone) {
171 $this->form->setTitle($this->lng->txt('cal_new_ms'));
172 $this->form->addCommandButton('saveMilestone', $this->lng->txt('cal_add_milestone'));
173 } else {
174 $this->form->setTitle($this->lng->txt('cal_new_app'));
175 $this->form->addCommandButton('save', $this->lng->txt('cal_add_appointment'));
176 }
177 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
178 break;
179
180 case 'edit':
181 if ($a_as_milestone) {
182 $this->form->setTitle($this->lng->txt('cal_edit_milestone'));
183 } else {
184 $this->form->setTitle($this->lng->txt('cal_edit_appointment'));
185 }
186 $this->ctrl->saveParameter($this, array('seed', 'app_id', 'idate'));
187 $this->form->setFormAction($this->ctrl->getFormAction($this));
188
189 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
190 $cat = $ass->getFirstAssignment();
191 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat);
192 $type = ilObject::_lookupType($cat_info['obj_id']);
193 if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
194 && ($type == "grp" || $type == "crs")) {
195 $resp_info = true;
196 $this->form->addCommandButton(
197 'editResponsibleUsers',
198 $this->lng->txt('cal_change_responsible_users')
199 );
200 }
201 $this->form->addCommandButton('update', $this->lng->txt('save'));
202 // $this->form->addCommandButton('askDelete',$this->lng->txt('delete'));
203 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
204 break;
205 }
206 // title
207 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
208 $title->setValue($this->app->getTitle());
209 $title->setRequired(true);
210 $title->setMaxLength(128);
211 $title->setSize(32);
212 $this->form->addItem($title);
213
214 $category_id = 0;
215 if ($this->http->wrapper()->query()->has('category_id')) {
216 $category_id = $this->http->wrapper()->query()->retrieve(
217 'category_id',
218 $this->refinery->kindlyTo()->int()
219 );
220 }
221 $ref_id = 0;
222 if ($this->http->wrapper()->query()->has('ref_id')) {
223 $ref_id = $this->http->wrapper()->query()->retrieve(
224 'ref_id',
225 $this->refinery->kindlyTo()->int()
226 );
227 }
228 // calendar selection
229 $calendar = new ilSelectInputGUI($this->lng->txt('cal_category_selection'), 'calendar');
230
231 $selected_calendar = 0;
232 if ($this->http->wrapper()->post()->has('calendar')) {
233 $selected_calendar = $this->http->wrapper()->post()->retrieve(
234 'calendar',
235 $this->refinery->kindlyTo()->int()
236 );
237 }
238 if ($selected_calendar > 0) {
239 $calendar->setValue($selected_calendar);
240 } elseif ($category_id) {
241 $calendar->setValue((int) $category_id);
242 $selected_calendar = (int) $category_id;
243 } elseif ($a_mode == 'edit') {
244 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
245 $cat = $ass->getFirstAssignment();
246 $calendar->setValue($cat);
247 $selected_calendar = $cat;
248 } elseif ($ref_id) {
250 $calendar->setValue(ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal));
251 $selected_calendar = ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal);
252 $cats = ilCalendarCategories::_getInstance($this->user->getId());
253 $cats->readSingleCalendar($selected_calendar);
254 } else {
255 $cats = ilCalendarCategories::_getInstance($this->user->getId());
256 $categories = $cats->prepareCategoriesOfUserForSelection();
257 $selected_calendar = key($categories);
258 $calendar->setValue($selected_calendar);
259 }
260 $calendar->setRequired(true);
261 $cats = ilCalendarCategories::_getInstance($this->user->getId());
262 $calendar->setOptions($cats->prepareCategoriesOfUserForSelection());
263
264 if (ilCalendarSettings::_getInstance()->isNotificationEnabled()) {
265 $notification_cals = $cats->getNotificationCalendars();
266 $notification_cals = count($notification_cals) ? implode(',', $notification_cals) : '';
267 $calendar->addCustomAttribute("onchange=\"ilToggleNotification([" . $notification_cals . "]);\"");
268 }
269 $this->form->addItem($calendar);
270
271 if (!$a_as_milestone) {
272 $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'), 'event');
273 $dur->setRequired(true);
274 $dur->enableToggleFullTime(
275 $this->lng->txt('cal_fullday_title'),
276 $this->app->isFullday()
277 );
278 $dur->setShowTime(true);
279 $dur->setStart($this->app->getStart());
280 $dur->setEnd($this->app->getEnd());
281 $this->form->addItem($dur);
282
283 // recurrence
284 $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'), 'frequence');
285 $rec->setRecurrence($this->rec);
286 $this->form->addItem($rec);
287
288 // location
289 $where = new ilTextInputGUI($this->lng->txt('cal_where'), 'location');
290 $where->setValue($this->app->getLocation());
291 $where->setMaxLength(128);
292 $where->setSize(32);
293 $this->form->addItem($where);
294 } else {
295 $deadline = new ilDateTimeInputGUI($this->lng->txt('cal_deadline'), 'event_start');
296 $deadline->setDate($this->app->getStart());
297 $deadline->setShowTime(false);
298 $deadline->setMinuteStepSize(5);
299 $this->form->addItem($deadline);
300
301 // completion
302 $completion_vals = array();
303 for ($i = 0; $i <= 100; $i += 5) {
304 $completion_vals[$i] = $i . " %";
305 }
306 $compl = new ilSelectInputGUI(
307 $this->lng->txt('cal_task_completion'),
308 'completion'
309 );
310 $compl->setOptions($completion_vals);
311 $compl->setValue($this->app->getCompletion());
312 $this->form->addItem($compl);
313 }
314
315 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
316 $desc->setValue($this->app->getDescription());
317 $desc->setRows(5);
318 $this->form->addItem($desc);
319
320 if ($a_as_milestone && $a_mode == "edit" && $resp_info) {
321 // users responsible
322 $users = $this->app->readResponsibleUsers();
323 $resp = new ilNonEditableValueGUI($this->lng->txt('cal_responsible'), "", true);
324 $delim = "";
325 $value = '';
326 foreach ($users as $r) {
327 $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
328 $delim = "<br />";
329 }
330 if (count($users) > 0) {
331 $resp->setValue($value);
332 } else {
333 $resp->setValue("-");
334 }
335
336 $this->form->addItem($resp);
337 }
338
339 if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
340 $ajax_url = $this->ctrl->getLinkTarget(
341 $this,
342 'doUserAutoComplete',
343 '',
344 true,
345 false
346 );
347
348 $notu = new ilTextInputGUI(
349 $this->lng->txt('cal_user_notification'),
350 'notu'
351 );
352 $notu->setMulti(true, true);
353 $notu->setInfo($this->lng->txt('cal_user_notification_info'));
354 $notu->setDataSource($ajax_url, ',');
355
356 $values = [];
357 foreach ($this->notification->getRecipients() as $rcp) {
358 switch ($rcp['type']) {
360 $values[] = ilObjUser::_lookupLogin($rcp['usr_id']);
361 break;
362
364 $values[] = $rcp['email'];
365 break;
366 }
367 }
368 $notu->setValue($values);
369 $this->form->addItem($notu);
370 }
371
372 // Notifications
373 if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and count($cats->getNotificationCalendars())) {
374 $selected_cal = new ilCalendarCategory($selected_calendar);
375 $disabled = true;
376 if ($selected_cal->getType() == ilCalendarCategory::TYPE_OBJ) {
377 if (ilObject::_lookupType($selected_cal->getObjId()) == 'crs' or ilObject::_lookupType($selected_cal->getObjId()) == 'grp') {
378 $disabled = false;
379 }
380 }
381
382 $this->tpl->addJavaScript('./Services/Calendar/js/toggle_notification.js');
383 $not = new ilCheckboxInputGUI($this->lng->txt('cal_cg_notification'), 'not');
384 $not->setInfo($this->lng->txt('cal_notification_info'));
385 $not->setValue('1');
386 $not->setChecked($this->app->isNotificationEnabled());
387 $not->setDisabled($disabled);
388 $this->form->addItem($not);
389 }
390 return $this->form;
391 }
392
393
394 protected function doUserAutoComplete(): ?string
395 {
396 // hide anonymout request
397 if ($this->user->getId() == ANONYMOUS_USER_ID) {
398 return json_encode(new stdClass(), JSON_THROW_ON_ERROR);
399 }
400 if (!$this->http->wrapper()->query()->has('autoCompleteField')) {
401 $a_fields = [
402 'login',
403 'firstname',
404 'lastname',
405 'email'
406 ];
407 $result_field = 'login';
408 } else {
409 $auto_complete_field = $this->http->wrapper()->query()->retrieve(
410 'autoCompleteField',
411 $this->refinery->kindlyTo()->string()
412 );
413 $a_fields = [$auto_complete_field];
414 $result_field = $auto_complete_field;
415 }
416 $auto = new ilUserAutoComplete();
418
419 if ($this->http->wrapper()->query()->has('fetchall')) {
420 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
421 }
422
423 $auto->setMoreLinkAvailable(true);
424 $auto->setSearchFields($a_fields);
425 $auto->setResultField($result_field);
426 $auto->enableFieldSearchableCheck(true);
427 $query = '';
428 if ($this->http->wrapper()->post()->has('term')) {
429 $query = $this->http->wrapper()->post()->retrieve(
430 'term',
431 $this->refinery->kindlyTo()->string()
432 );
433 }
434 echo $auto->getList($query);
435 return null;
436 }
437
441 protected function add(?ilPropertyFormGUI $form = null): void
442 {
443 $this->help->setScreenIdComponent("cal");
444 $this->help->setScreenId("app");
445 $this->help->setSubScreenId("create");
446
447 if (!$form instanceof ilPropertyFormGUI) {
448 $form = $this->initForm('create');
449 }
450 $this->tpl->setContent($form->getHTML());
451 }
452
456 protected function addMilestone(): void
457 {
458 $this->help->setScreenIdComponent("cal");
459 $this->help->setScreenId("app");
460 $this->help->setSubScreenId("create_milestone");
461
462 $form = $this->initForm('create', true);
463 $this->tpl->setContent($form->getHTML());
464 }
465
466 protected function saveMilestone(): void
467 {
468 $this->save(true);
469 }
470
471 protected function save(bool $a_as_milestone = false): void
472 {
473 $form = $this->load('create', $a_as_milestone);
474
475 if ($this->app->validate() and $this->notification->validate()) {
476 if ((int) $form->getInput('calendar') === 0) {
477 $cat_id = $this->createDefaultCalendar();
478 } else {
479 $cat_id = (int) $form->getInput('calendar');
480 }
481
482 $this->app->save();
483 $this->notification->setEntryId($this->app->getEntryId());
484 $this->notification->save();
485 $this->rec->setEntryId($this->app->getEntryId());
486 $this->saveRecurrenceSettings();
487
488 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
489 $ass->addAssignment($cat_id);
490
491 // Send notifications
492 if (
493 ilCalendarSettings::_getInstance()->isNotificationEnabled() &&
494 (int) $form->getInput('not')
495 ) {
496 $this->distributeNotifications($cat_id, $this->app->getEntryId(), true);
497 }
498 if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
499 $this->distributeUserNotifications();
500 }
501
502 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
503 $type = ilObject::_lookupType($cat_info['obj_id'] ?? 0);
504
505 if (
506 $a_as_milestone &&
508 ($type == "grp" || $type == "crs")
509 ) {
510 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_created_milestone_resp_q'), true);
511 $this->showResponsibleUsersList($cat_info['obj_id'] ?? 0);
512 return;
513 } elseif ($a_as_milestone) {
514 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_created_milestone'), true);
515 $this->ctrl->returnToParent($this);
516 } else {
517 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_created_appointment'), true);
518 $this->ctrl->returnToParent($this);
519 }
520 } else {
521 $this->form->setValuesByPost();
522 if ($this->error->getMessage() !== '') {
523 $this->tpl->setOnScreenMessage('failure', $this->error->getMessage());
524 } else {
525 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
526 }
527 $this->add($this->form);
528 return;
529 }
530 if ($a_as_milestone) {
531 $this->addMilestone();
532 } else {
533 $this->add();
534 }
535 }
536
540 protected function distributeUserNotifications(): void
541 {
542 $notification = new ilCalendarMailNotification();
543 $notification->setAppointmentId($this->app->getEntryId());
544
545 foreach ($this->notification->getRecipients() as $rcp) {
546 switch ($rcp['type']) {
548 $notification->setSender(ANONYMOUS_USER_ID);
549 $notification->setRecipients(array($rcp['usr_id']));
550 $notification->setType(ilCalendarMailNotification::TYPE_USER);
551 break;
552
554 $notification->setSender(ANONYMOUS_USER_ID);
555 $notification->setRecipients(array($rcp['email']));
557 break;
558 }
559 $notification->send();
560 }
561 }
562
563 protected function distributeNotifications(int $a_cat_id, int $app_id, bool $a_new_appointment = true): void
564 {
565 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($a_cat_id);
566
567 $notification = new ilCalendarMailNotification();
568 $notification->setAppointmentId($app_id);
569
570 switch ($cat_info['type']) {
572
573 switch ($cat_info['obj_type']) {
574 case 'crs':
575 $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
576 $ref_id = current($ref_ids);
577 $notification->setRefId($ref_id);
578 $notification->setType(
579 $a_new_appointment ?
582 );
583 break;
584
585 case 'grp':
586 $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
587 $ref_id = current($ref_ids);
588 $notification->setRefId($ref_id);
589 $notification->setType(
590 $a_new_appointment ?
593 );
594 break;
595 }
596 break;
597 }
598 $notification->send();
599 }
600
601 public function editResponsibleUsers(): void
602 {
603 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
604 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
605 $this->showResponsibleUsersList($cat_info['obj_id']);
606 }
607
612 public function showResponsibleUsersList(int $a_grp_id): void
613 {
614 $table_gui = new ilMilestoneResponsiblesTableGUI(
615 $this,
616 "",
617 $a_grp_id,
618 $this->app->getEntryId()
619 );
620 $this->tpl->setContent($table_gui->getHTML());
621 }
622
626 public function saveMilestoneResponsibleUsers(): void
627 {
628 $user_ids = [];
629 if ($this->http->wrapper()->post()->has('user_id')) {
630 $user_ids = $this->http->wrapper()->post()->retrieve(
631 'user_id',
632 $this->refinery->kindlyTo()->dictOf(
633 $this->refinery->kindlyTo()->int()
634 )
635 );
636 }
637 $this->app->writeResponsibleUsers($user_ids);
638 $this->ctrl->returnToParent($this);
639 }
640
645 protected function askEdit(): void
646 {
647 // check for recurring entries
648 $rec = ilCalendarRecurrences::_getRecurrences($this->getAppointment()->getEntryId());
649 if (!$rec) {
650 $this->edit(true);
651 return;
652 }
653 // Show edit single/all appointments
654 $this->ctrl->saveParameter($this, array('seed', 'app_id', 'dt', 'idate'));
655
656 $confirm = new ilConfirmationGUI();
657 $confirm->setHeaderText($this->lng->txt('cal_edit_single_or_all_info'));
658 $confirm->setFormAction($this->ctrl->getFormAction($this));
659 $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
660 $confirm->addItem('appointments[]', (string) $this->app->getEntryId(), $this->app->getTitle());
661 $confirm->addButton($this->lng->txt('cal_edit_single'), 'editSingle');
662 $confirm->setConfirm($this->lng->txt('cal_edit_recurrences'), 'edit');
663
664 $this->tpl->setContent($confirm->getHTML());
665 }
666
670 protected function editSingle(): void
671 {
672 $this->ctrl->setParameter($this, 'rexl', "1");
673 $this->requested_rexl = true;
674 $this->edit(true);
675 }
676
680 protected function edit(bool $a_edit_single_app = false, ilPropertyFormGUI $form = null): void
681 {
682 $this->help->setScreenIdComponent("cal");
683 $this->help->setScreenId("app");
684 if ($this->app->isMilestone()) {
685 $this->help->setSubScreenId("edit_milestone");
686 } else {
687 $this->help->setSubScreenId("edit");
688 }
689
690 $this->ctrl->saveParameter($this, array('seed', 'app_id', 'dt', 'idate'));
691 if ($this->requested_rexl) {
692 $this->ctrl->setParameter($this, 'rexl', 1);
693 // Calculate new appointment time
694 $duration = $this->getAppointment()->getEnd()->get(IL_CAL_UNIX) - $this->getAppointment()->getStart()->get(IL_CAL_UNIX);
695 $calc = new ilCalendarRecurrenceCalculator($this->getAppointment(), $this->rec);
696
697 $current_date = new ilDateTime($this->getRecurrenceDateFromQuery(), IL_CAL_UNIX);
698
699 $yesterday = clone $current_date;
700 $yesterday->increment(IL_CAL_DAY, -1);
701 $tomorrow = clone $current_date;
702 $tomorrow->increment(IL_CAL_DAY, 1);
703
704 foreach ($calc->calculateDateList($current_date, $tomorrow, 1) as $date_entry) {
705 if (ilDateTime::_equals($current_date, $date_entry, IL_CAL_DAY)) {
706 $this->getAppointment()->setStart(new ilDateTime($date_entry->get(IL_CAL_UNIX), IL_CAL_UNIX));
707 $this->getAppointment()->setEnd(new ilDateTime(
708 $date_entry->get(IL_CAL_UNIX) + $duration,
710 ));
711 break;
712 }
713 }
714 // Finally reset recurrence
715 $this->rec = new ilCalendarRecurrence();
716 }
717
718 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
719 $cats = ilCalendarCategories::_getInstance($this->user->getId());
720
721 if (!$cats->isVisible($cat_id)) {
722 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->WARNING);
723 return;
724 }
725 if (!$cats->isEditable($cat_id) or $this->app->isAutoGenerated()) {
726 $this->showInfoScreen();
727 return;
728 }
729 if (!$form instanceof ilPropertyFormGUI) {
730 $form = $this->initForm('edit', $this->app->isMilestone(), $a_edit_single_app);
731 }
732 $this->tpl->setContent($form->getHTML());
733 }
734
735 protected function showInfoScreen(): void
736 {
737 $info = new ilInfoScreenGUI($this);
738 $info->setFormAction($this->ctrl->getFormAction($this));
739
740 if ($this->app->isMilestone()) {
741 $info->addSection($this->lng->txt('cal_ms_details'));
742 } else {
743 $info->addSection($this->lng->txt('cal_details'));
744 }
745
746 // Appointment
747 $info->addProperty(
748 $this->lng->txt('appointment'),
750 $this->app->getStart(),
751 $this->app->getEnd()
752 )
753 );
754 $info->addProperty($this->lng->txt('title'), $this->app->getPresentationTitle());
755
756 // Description
757 if (strlen($desc = $this->app->getDescription())) {
758 $info->addProperty($this->lng->txt('description'), $desc);
759 }
760
761 // Location
762 if (strlen($loc = $this->app->getLocation())) {
763 $info->addProperty($this->lng->txt('cal_where'), $loc);
764 }
765
766 // completion
767 if ($this->app->isMilestone() && $this->app->getCompletion() > 0) {
768 $info->addProperty(
769 $this->lng->txt('cal_task_completion'),
770 $this->app->getCompletion() . " %"
771 );
772 }
773
774 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
775 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
776 $type = ilObject::_lookupType($cat_info['obj_id']);
777 if ($this->app->isMilestone() && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
778 && ($type == "grp" || $type == "crs")) {
779 // users responsible
780 $users = $this->app->readResponsibleUsers();
781 $delim = "";
782 $value = '';
783 foreach ($users as $r) {
784 $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
785 $delim = "<br />";
786 }
787 if (count($users) > 0) {
788 $info->addProperty(
789 $this->lng->txt('cal_responsible'),
790 $value
791 );
792 }
793 }
794
795 $category = new ilCalendarCategory($cat_id);
796
797 if ($category->getType() == ilCalendarCategory::TYPE_OBJ) {
798 $info->addSection($this->lng->txt('additional_info'));
799
800 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
801 $refs = ilObject::_getAllReferences($cat_info['obj_id']);
802
803 $href = ilLink::_getStaticLink(current($refs), ilObject::_lookupType($cat_info['obj_id']), true);
804 $info->addProperty(
805 $this->lng->txt('perma_link'),
806 '<a class="small" href="' . $href . '" target="_top">' . $href . '</a>'
807 );
808 }
809 $this->tpl->setContent($info->getHTML());
810 }
811
812 protected function update(): void
813 {
814 $single_editing = $this->requested_rexl;
815 $form = $this->load('edit', $this->app->isMilestone());
816
817 if ($this->app->validate() and $this->notification->validate()) {
818 if (!(int) $form->getInput('calendar')) {
819 $cat_id = $this->createDefaultCalendar();
820 } else {
821 $cat_id = (int) $form->getInput('calendar');
822 }
823
824 if ($single_editing) {
825 $original_id = $this->getAppointment()->getEntryId();
826 $this->getAppointment()->save();
827 $selected_ut = $this->getRecurrenceDateFromQuery();
828 if ($selected_ut > 0) {
829 $exclusion = new ilCalendarRecurrenceExclusion();
830 $exclusion->setEntryId($original_id);
831 $exclusion->setDate(new ilDate($selected_ut, IL_CAL_UNIX));
832 $this->logger->dump($this->getAppointment()->getEntryId());
833 $this->logger->dump(ilDatePresentation::formatDate(new ilDate($selected_ut, IL_CAL_UNIX)));
834 $exclusion->save();
835 }
836 $this->rec = new ilCalendarRecurrence();
837 $this->rec->setEntryId($this->getAppointment()->getEntryId());
838 } else {
839 $this->getAppointment()->update();
840 }
841 $this->notification->save();
842 $this->saveRecurrenceSettings();
843 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
844 $ass->deleteAssignments();
845 $ass->addAssignment($cat_id);
846
847 // Send notifications
848 $notification = (bool) $form->getInput('not');
849 if (
850 ilCalendarSettings::_getInstance()->isNotificationEnabled() &&
851 $notification
852 ) {
853 $this->distributeNotifications($cat_id, $this->app->getEntryId(), false);
854 }
855 if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
856 $this->distributeUserNotifications();
857 }
858
859 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
860 $this->ctrl->returnToParent($this);
861 } else {
862 $this->form->setValuesByPost();
863 $this->tpl->setOnScreenMessage('failure', $this->error->getMessage());
864 }
865 $this->edit(false, $this->form);
866 }
867
868 protected function askDelete(): void
869 {
870 $this->ctrl->saveParameter(
871 $this,
872 [
873 'seed',
874 'app_id',
875 'dt',
876 'idate'
877 ]
878 );
879
880 $app_id = (int) ($this->request->getQueryParams()['app_id'] ?? 0);
881 if (!$app_id) {
882 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
883 $this->ctrl->returnToParent($this);
884 }
885
886 $entry = new ilCalendarEntry($app_id);
888 if (
889 !count($recs) ||
890 $this->app->isMilestone()
891 ) {
892 $confirm = new ilConfirmationGUI();
893 $confirm->setFormAction($this->ctrl->getFormAction($this));
894 $confirm->setHeaderText($this->lng->txt('cal_delete_app_sure'));
895 $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
896 $confirm->addItem('appointments[]', (string) $this->app->getEntryId(), $this->app->getTitle());
897 $confirm->setConfirm($this->lng->txt('delete'), 'delete');
898 $this->tpl->setContent($confirm->getHTML());
899 } else {
900 $table = new ilCalendarRecurrenceTableGUI(
901 $this->app,
902 $this,
903 'askDelete'
904 );
905 $table->init();
906 $table->parse();
907 $this->tpl->setContent($table->getHTML());
908 $this->tpl->setOnScreenMessage('question', $this->lng->txt('cal_delete_app_sure'));
909 $this->tpl->setOnScreenMessage('info', $this->lng->txt('cal_recurrence_confirm_deletion'));
910 }
911 }
912
913 protected function delete(): void
914 {
915 $app_ids = (array) ($this->request->getParsedBody()['appointment_ids'] ?? []);
916 if (!$app_ids) {
917 $this->logger->dump($app_ids);
918 $app_ids = (array) ($this->request->getQueryParams()['app_id'] ?? []);
919 }
920 if (!$app_ids) {
921 $this->ctrl->returnToParent($this);
922 }
923 foreach ($app_ids as $app_id) {
924 $app_id = (int) $app_id;
925 $app = new ilCalendarEntry($app_id);
926 $app->delete();
929 }
930 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_deleted_app'), true);
931 $this->ctrl->returnToParent($this);
932 }
933
934 protected function deleteExclude(bool $a_return = true): void
935 {
936 $recurrence_ids = (array) ($this->request->getParsedBody()['recurrence_ids'] ?? []);
937 $app_id = (int) ($this->request->getQueryParams()['app_id'] ?? 0);
938 if (!count($recurrence_ids)) {
939 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
940 $this->ctrl->redirect($this, 'askDelete');
941 }
942 if (!$app_id) {
943 $this->ctrl->returnToParent($this);
944 }
945 foreach ($recurrence_ids as $rdate) {
946 $exclusion = new ilCalendarRecurrenceExclusion();
947 $exclusion->setEntryId($app_id);
948 $exclusion->setDate(new ilDate($rdate, IL_CAL_UNIX));
949 $exclusion->save();
950 }
951 if ($a_return) {
952 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_deleted_app'), true);
953 $this->ctrl->returnToParent($this);
954 }
955 }
956
957 protected function initTimeZone(): void
958 {
959 $this->timezone = $this->user->getTimeZone();
960 }
961
962 protected function initInitialDate(ilDate $initialDate): void
963 {
964 $hour = 0;
965 if ($this->http->wrapper()->query()->has('hour')) {
966 $hour = $this->http->wrapper()->query()->retrieve(
967 'hour',
968 $this->refinery->kindlyTo()->int()
969 );
970 }
971
972 if (!$hour) {
973 $this->initialDate = clone $initialDate;
974 $this->default_fulltime = true;
975 } else {
976 if ($hour < 10) {
977 $time = '0' . $hour . ':00:00';
978 } else {
979 $time = (int) $hour . ':00:00';
980 }
981 $this->initialDate = new ilDateTime(
982 $initialDate->get(IL_CAL_DATE) . ' ' . $time,
984 $this->timezone
985 );
986 $this->default_fulltime = false;
987 }
988 }
989
990 protected function initSeed(ilDate $seed): void
991 {
992 $this->seed = clone $seed;
993 $this->default_fulltime = true;
994 }
995
996 protected function initAppointment(int $a_app_id = 0): void
997 {
998 $this->app = new ilCalendarEntry($a_app_id);
999 $this->notification = new ilCalendarUserNotification($this->app->getEntryId());
1000
1001 if (!$a_app_id) {
1002 $start = clone $this->initialDate;
1003 $this->app->setStart($start);
1004
1005 $seed_end = clone $this->initialDate;
1006 if ($this->default_fulltime) {
1007 #$seed_end->increment(IL_CAL_DAY,1);
1008 } else {
1009 $seed_end->increment(IL_CAL_HOUR, 1);
1010 }
1011 $this->app->setEnd($seed_end);
1012 $this->app->setFullday($this->default_fulltime);
1013
1014 $this->rec = new ilCalendarRecurrence();
1015 } else {
1016 $this->rec = ilCalendarRecurrences::_getFirstRecurrence($this->app->getEntryId());
1017 }
1018 }
1019
1020 protected function load($a_mode, $a_as_milestone = false): ilPropertyFormGUI
1021 {
1022 // needed for date handling
1023 $form = $this->initForm($a_mode, $a_as_milestone);
1024 $this->form->checkInput();
1025
1026 if ($a_as_milestone) {
1027 $this->app->setMilestone(true);
1028 $this->app->setCompletion((int) $form->getInput('completion'));
1029 }
1030
1031 $this->app->setTitle($form->getInput('title'));
1032 $this->app->setLocation($form->getInput('location'));
1033 $this->app->setDescription($form->getInput('description'));
1034 $this->app->enableNotification((bool) $form->getInput('not'));
1035
1036 if ($a_as_milestone) { // milestones are always fullday events
1037 $start = $this->form->getItemByPostVar('event_start');
1038 $start = $start->getDate();
1039 $this->app->setFullday(true);
1040 // for milestones is end date = start date
1041 $this->app->setStart($start);
1042 $this->app->setEnd($start);
1043 } else {
1044 $period = $this->form->getItemByPostVar('event');
1045 $start = $period->getStart();
1046 $end = $period->getEnd();
1047
1048 $this->app->setFullday($start instanceof ilDate);
1049 $this->app->setStart($start);
1050 $this->app->setEnd($end);
1051 }
1052
1053 $this->loadNotificationRecipients($form);
1054 $this->loadRecurrenceSettings($form, $a_as_milestone = false);
1055 return $form;
1056 }
1057
1058 protected function loadNotificationRecipients(ilPropertyFormGUI $form): void
1059 {
1060 $this->notification->setRecipients(array());
1061 $map = [];
1062 foreach ((array) $form->getInput('notu') as $rcp) {
1063 $rcp = trim($rcp);
1064 $usr_id = (int) ilObjUser::_loginExists($rcp);
1065 if ($rcp === '') {
1066 continue;
1067 }
1068 if (in_array($rcp, $map)) {
1069 continue;
1070 }
1071 $map[] = $rcp;
1072 if ($usr_id) {
1073 $this->notification->addRecipient(
1075 $usr_id
1076 );
1077 } else {
1078 $this->notification->addRecipient(
1080 0,
1081 $rcp
1082 );
1083 }
1084 }
1085 }
1086
1087 protected function loadRecurrenceSettings(ilPropertyFormGUI $form, bool $a_as_milestone = false): void
1088 {
1089 if ($form->getItemByPostVar('frequence') instanceof ilRecurrenceInputGUI) {
1090 $this->rec = $form->getItemByPostVar('frequence')->getRecurrence();
1091 } else {
1092 $this->rec = new ilCalendarRecurrence();
1093 }
1094 }
1095
1096 protected function saveRecurrenceSettings(): void
1097 {
1098 switch ($this->rec->getFrequenceType()) {
1099 case '':
1101 // No recurrence => delete if there is an recurrence rule
1102 if ($this->rec->getRecurrenceId()) {
1103 $this->rec->delete();
1104 }
1105 break;
1106
1107 default:
1108 if ($this->rec->getRecurrenceId()) {
1109 $this->rec->update();
1110 } else {
1111 $this->rec->save();
1112 }
1113 break;
1114 }
1115 }
1116
1117 protected function createDefaultCalendar(): int
1118 {
1119 $cat = new ilCalendarCategory();
1120 $cat->setColor(ilCalendarCategory::DEFAULT_COLOR);
1121 $cat->setType(ilCalendarCategory::TYPE_USR);
1122 $cat->setTitle($this->lng->txt('cal_default_calendar'));
1123 $cat->setObjId($this->user->getId());
1124
1125 // delete calendar cache
1126 ilCalendarCache::getInstance()->deleteUserEntries($this->user->getId());
1127
1128 return $cat->add();
1129 }
1130
1134 protected function confirmRegister(): void
1135 {
1136 $dstart = 0;
1137 if ($this->http->wrapper()->query()->has('dstart')) {
1138 $dstart = $this->http->wrapper()->query()->retrieve(
1139 'dstart',
1140 $this->refinery->kindlyTo()->int()
1141 );
1142 }
1143 $dend = 0;
1144 if ($this->http->wrapper()->query()->has('dend')) {
1145 $dend = $this->http->wrapper()->query()->retrieve(
1146 'dend',
1147 $this->refinery->kindlyTo()->int()
1148 );
1149 }
1150
1151 $app_id = $this->getAppointmentIdFromQuery();
1152 $entry = new ilCalendarEntry($app_id);
1154 new ilDateTime($dstart, IL_CAL_UNIX),
1155 new ilDateTime($dend, IL_CAL_UNIX)
1156 );
1157
1158 $conf = new ilConfirmationGUI();
1159 $this->ctrl->setParameter($this, 'dstart', $dstart);
1160 $this->ctrl->setParameter($this, 'dend', $dend);
1161
1162 $conf->setFormAction($this->ctrl->getFormAction($this));
1163 $conf->setHeaderText($this->lng->txt('cal_confirm_reg_info'));
1164 $conf->setConfirm($this->lng->txt('cal_reg_register'), 'register');
1165 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1166 $conf->addItem('app_id', (string) $entry->getEntryId(), $entry->getTitle() . ' (' . $start . ')');
1167 $this->tpl->setContent($conf->getHTML());
1168 }
1169
1170 protected function register(): void
1171 {
1172 $dstart = 0;
1173 if ($this->http->wrapper()->query()->has('dstart')) {
1174 $dstart = $this->http->wrapper()->query()->retrieve(
1175 'dstart',
1176 $this->refinery->kindlyTo()->int()
1177 );
1178 }
1179 $dend = 0;
1180 if ($this->http->wrapper()->query()->has('dend')) {
1181 $dend = $this->http->wrapper()->query()->retrieve(
1182 'dend',
1183 $this->refinery->kindlyTo()->int()
1184 );
1185 }
1186 $app_id = 0;
1187 if ($this->http->wrapper()->post()->has('app_id')) {
1188 $app_id = $this->http->wrapper()->post()->retrieve(
1189 'app_id',
1190 $this->refinery->kindlyTo()->int()
1191 );
1192 }
1193 $reg = new ilCalendarRegistration($app_id);
1194 $reg->register(
1195 $this->user->getId(),
1196 new ilDateTime($dstart, IL_CAL_UNIX),
1197 new ilDateTime((int) $dend, IL_CAL_UNIX)
1198 );
1199
1200 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_reg_registered'), true);
1201 $this->ctrl->returnToParent($this);
1202 }
1203
1204 public function confirmUnregister(): void
1205 {
1206 $dstart = 0;
1207 if ($this->http->wrapper()->query()->has('dstart')) {
1208 $dstart = $this->http->wrapper()->query()->retrieve(
1209 'dstart',
1210 $this->refinery->kindlyTo()->int()
1211 );
1212 }
1213 $dend = 0;
1214 if ($this->http->wrapper()->query()->has('dend')) {
1215 $dend = $this->http->wrapper()->query()->retrieve(
1216 'dend',
1217 $this->refinery->kindlyTo()->int()
1218 );
1219 }
1220
1221 $app_id = $this->getAppointmentIdFromQuery();
1222 $entry = new ilCalendarEntry($app_id);
1224 new ilDateTime($dstart, IL_CAL_UNIX),
1225 new ilDateTime($dend, IL_CAL_UNIX)
1226 );
1227
1228 $this->ctrl->setParameter($this, 'dstart', (int) $dstart);
1229 $this->ctrl->setParameter($this, 'dend', (int) $dend);
1230
1231 $conf = new ilConfirmationGUI();
1232 $conf->setFormAction($this->ctrl->getFormAction($this));
1233 $conf->setHeaderText($this->lng->txt('cal_confirm_unreg_info'));
1234 $conf->setConfirm($this->lng->txt('cal_reg_unregister'), 'unregister');
1235 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1236 $conf->addItem('app_id', (string) $entry->getEntryId(), $entry->getTitle() . ' (' . $start . ')');
1237
1238 $this->tpl->setContent($conf->getHTML());
1239 }
1240
1244 protected function unregister(): void
1245 {
1246 $dstart = 0;
1247 if ($this->http->wrapper()->query()->has('dstart')) {
1248 $dstart = $this->http->wrapper()->query()->retrieve(
1249 'dstart',
1250 $this->refinery->kindlyTo()->int()
1251 );
1252 }
1253 $dend = 0;
1254 if ($this->http->wrapper()->query()->has('dend')) {
1255 $dend = $this->http->wrapper()->query()->retrieve(
1256 'dend',
1257 $this->refinery->kindlyTo()->int()
1258 );
1259 }
1260 $app_id = 0;
1261 if ($this->http->wrapper()->post()->has('app_id')) {
1262 $app_id = $this->http->wrapper()->post()->retrieve(
1263 'app_id',
1264 $this->refinery->kindlyTo()->int()
1265 );
1266 }
1267 $reg = new ilCalendarRegistration($app_id);
1268 $reg->unregister(
1269 $this->user->getId(),
1270 new ilDateTime((int) $dstart, IL_CAL_UNIX),
1271 new ilDateTime((int) $dend, IL_CAL_UNIX)
1272 );
1273
1274 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_reg_unregistered'), true);
1275 $this->ctrl->returnToParent($this);
1276 }
1277
1281 public function book(): void
1282 {
1283 $entry_id = $this->getAppointmentIdFromQuery();
1284 $this->ctrl->saveParameter($this, 'app_id');
1285
1286 $entry = new ilCalendarEntry($entry_id);
1287 $booking = new \ilBookingEntry($entry->getContextId());
1288 $user = $booking->getObjId();
1289
1290 $form = $this->initFormConfirmBooking();
1291 $form->getItemByPostVar('date')->setValue(ilDatePresentation::formatPeriod(
1292 $entry->getStart(),
1293 $entry->getEnd()
1294 ));
1295 $form->getItemByPostVar('title')->setValue($entry->getTitle() . " (" . ilObjUser::_lookupFullname($user) . ')');
1296
1297 $this->tpl->setContent($form->getHTML());
1298 }
1299
1301 {
1302 $form = new ilPropertyFormGUI();
1303 $form->setFormAction($this->ctrl->getFormAction($this));
1304 $form->addCommandButton('bookconfirmed', $this->lng->txt('cal_confirm_booking'));
1305 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
1306
1307 $date = new ilNonEditableValueGUI($this->lng->txt('appointment'), 'date');
1308 $form->addItem($date);
1309
1310 $title = new ilNonEditableValueGUI($this->lng->txt('title'), 'title');
1311 $form->addItem($title);
1312
1313 $message = new ilTextAreaInputGUI($this->lng->txt('cal_ch_booking_message_tbl'), 'comment');
1314 $message->setRows(5);
1315 $form->addItem($message);
1316
1317 return $form;
1318 }
1319
1323 public function bookconfirmed()
1324 {
1325 $entry = $this->getAppointmentIdFromQuery();
1326 $form = $this->initFormConfirmBooking();
1327 if ($form->checkInput()) {
1328 // check if appointment is bookable
1329 $cal_entry = new ilCalendarEntry($entry);
1330
1331 $booking = new ilBookingEntry($cal_entry->getContextId());
1332
1333 if (!$booking->isAppointmentBookableForUser($entry, $GLOBALS['DIC']['ilUser']->getId())) {
1334 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('cal_booking_failed_info'), true);
1335 $this->ctrl->returnToParent($this);
1336 }
1337
1338 ilConsultationHourUtils::bookAppointment($this->user->getId(), $entry);
1339 ilBookingEntry::writeBookingMessage($entry, $this->user->getId(), $form->getInput('comment'));
1340 }
1341 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_booking_confirmed'), true);
1342 $this->ctrl->returnToParent($this);
1343 }
1344
1349 public function cancelBooking(): void
1350 {
1351 $entry = $this->getAppointmentIdFromQuery();
1352 $entry = new ilCalendarEntry($entry);
1353
1354 $category = $this->calendarEntryToCategory($entry);
1355 if ($category->getType() == ilCalendarCategory::TYPE_CH) {
1356 $booking = new ilBookingEntry($entry->getContextId());
1357 if (!$booking->hasBooked($entry->getEntryId())) {
1358 $this->ctrl->returnToParent($this);
1359 return;
1360 }
1361
1362 $entry_title = ' ' . $entry->getTitle() . " (" . ilObjUser::_lookupFullname($booking->getObjId()) . ')';
1363 } elseif ($category->getType() == ilCalendarCategory::TYPE_BOOK) {
1364 $entry_title = ' ' . $entry->getTitle();
1365 } else {
1366 $this->ctrl->returnToParent($this);
1367 return;
1368 }
1369
1370 $title = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd());
1371
1372 $conf = new ilConfirmationGUI();
1373 $conf->setFormAction($this->ctrl->getFormAction($this));
1374 $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info'));
1375 $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed');
1376 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1377 $conf->addItem('app_id', (string) $entry->getEntryId(), $title . ' - ' . $entry_title);
1378
1379 $this->tpl->setContent($conf->getHTML());
1380 }
1381
1386 public function cancelConfirmed(): void
1387 {
1388 $app_id = 0;
1389 if ($this->http->wrapper()->post()->has('app_id')) {
1390 $app_id = $this->http->wrapper()->post()->retrieve(
1391 'app_id',
1392 $this->refinery->kindlyTo()->int()
1393 );
1394 }
1395 $entry = new ilCalendarEntry($app_id);
1396 $category = $this->calendarEntryToCategory($entry);
1397 if ($category->getType() == ilCalendarCategory::TYPE_CH) {
1398 // find cloned calendar entry in user calendar
1400 $this->user->getId(),
1401 $entry->getContextId(),
1402 $entry->getStart(),
1404 false
1405 );
1406
1407 // Fix for wrong, old entries
1408 foreach ($apps as $own_app) {
1409 $ref_entry = new ilCalendarEntry($own_app);
1410 $ref_entry->delete();
1411 }
1412
1413 $booking = new ilBookingEntry($entry->getContextId());
1414 $booking->cancelBooking($entry->getEntryId());
1415
1416 // do NOT delete original entry
1417 } elseif ($category->getType() == ilCalendarCategory::TYPE_BOOK) {
1418 $booking = new ilBookingReservation($entry->getContextId());
1419 $booking->setStatus(ilBookingReservation::STATUS_CANCELLED);
1420 $booking->update();
1421
1422 $entry->delete();
1423 }
1424
1425 $this->tpl->setOnScreenMessage('success', $this->lng->txt('cal_cancel_booking_confirmed'), true);
1426 $this->ctrl->returnToParent($this);
1427 }
1428
1433 {
1434 $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
1435 $assignment = $assignment->getFirstAssignment();
1436 return new ilCalendarCategory($assignment);
1437 }
1438}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Builds data types.
Definition: Factory.php:21
Class Services.
Definition: Services.php:38
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_CAL_HOUR
const IL_CAL_DAY
error(string $a_errmsg)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static writeBookingMessage(int $a_entry_id, int $a_usr_id, string $a_message)
Write booking message.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Administrate calendar appointments.
askEdit()
Check edit single apppointment / edit all appointments for recurring appointments.
initForm(string $a_mode, bool $a_as_milestone=false, bool $a_edit_single_app=false)
calendarEntryToCategory(ilCalendarEntry $entry)
Get category object of given calendar entry.
editSingle()
Edit one single appointment ^.
add(?ilPropertyFormGUI $form=null)
add new appointment
bookconfirmed()
Book consultation appointment, was confirmed.
distributeUserNotifications()
Send mail to selected users.
load($a_mode, $a_as_milestone=false)
__construct(ilDate $seed, ilDate $initialDate, int $a_appointment_id=0)
ilCalendarUserNotification $notification
distributeNotifications(int $a_cat_id, int $app_id, bool $a_new_appointment=true)
loadRecurrenceSettings(ilPropertyFormGUI $form, bool $a_as_milestone=false)
showResponsibleUsersList(int $a_grp_id)
Show responsible uses of a milestone (default set is participants of group)
confirmRegister()
Register to an appointment.
cancelConfirmed()
Cancel consultation appointment or ressource booking, was confirmed This will delete the calendar ent...
edit(bool $a_edit_single_app=false, ilPropertyFormGUI $form=null)
edit appointment
book()
Confirmation screen for booking of consultation appointment.
loadNotificationRecipients(ilPropertyFormGUI $form)
saveMilestoneResponsibleUsers()
Save milestone responsibilites.
cancelBooking()
Confirmation screen to cancel consultation appointment or ressource booking depends on calendar categ...
unregister()
Unregister calendar, was confirmed.
static _lookupCategoryIdByObjId(int $a_obj_id)
lookup category by obj_id
static _getInstance($a_usr_id=0)
get singleton instance
static _deleteByAppointmentId(int $a_app_id)
Delete appointment assignment.
Stores calendar categories.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Distributes calendar mail notifications.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Stores exclusion dates for calendar recurrences.
Class ilCalendarRecurrenceTableGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRecurrence(int $a_type)
set type of recurrence @access public
static _getRecurrences(int $a_cal_id)
get all recurrences of an appointment
registration for calendar appointments
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAppointmentIds(int $a_user_id, int $a_context_id=null, ?ilDateTime $a_start=null, ?int $a_type=null, bool $a_check_owner=true)
static bookAppointment(int $a_usr_id, int $a_app_id)
Book an appointment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@classDescription Date and time handling
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
Class for single dates.
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
Error Handling & global info handling uses PEAR error class.
setFormAction(string $a_formaction)
Help GUI class.
Class ilInfoScreenGUI.
language handling
Component logger with individual log levels by component id.
TableGUI class for selection of milestone responsibles.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static _lookupFullname(int $a_user_id)
static _lookupLogin(int $a_user_id)
static _loginExists(string $a_login, int $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static initDomEvent(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI DomEvent used in Services/Calendar, Modules/Session, Modules/Test (Jan 2022)
$app
Definition: cli.php:39
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
$i
Definition: metadata.php:41
static http()
Fetches the global http state from ILIAS.
form( $class_path, string $cmd)
$query
$type
$message
Definition: xapiexit.php:32