ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCalendarAppointmentGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14 protected $seed = null;
15 protected $initialDate = null;
16 protected $default_fulltime = true;
17
18 protected $app = null;
19 protected $rec = null;
20 protected $timezone = null;
21
22 protected $tpl;
23 protected $lng;
24 protected $ctrl;
25
29 private $logger = null;
30
38 public function __construct(ilDate $seed, ilDate $initialDate, $a_appointment_id = 0)
39 {
40 global $DIC;
41
42 $ilCtrl = $DIC['ilCtrl'];
43 $lng = $DIC['lng'];
44
45 $this->lng = $lng;
46 $lng->loadLanguageModule('dateplaner');
47 $this->ctrl = $ilCtrl;
48
49 $this->logger = $GLOBALS['DIC']->logger()->cal();
50
51 $this->initTimeZone();
52 $this->initSeed($seed);
53 $this->initInitialDate($initialDate);
54 $this->initAppointment($a_appointment_id);
55 }
56
64 public function executeCommand()
65 {
66 global $DIC;
67
68 $ilUser = $DIC['ilUser'];
69 $ilSetting = $DIC['ilSetting'];
70 $tpl = $DIC['tpl'];
71 $ilTabs = $DIC['ilTabs'];
72
73
74 // Clear tabs and set back target
75 $ilTabs->clearTargets();
76 $ilTabs->setBackTarget(
77 $this->lng->txt('cal_back_to_cal'),
78 $this->ctrl->getLinkTarget($this, 'cancel')
79 );
80
81 $next_class = $this->ctrl->getNextClass($this);
82 switch ($next_class) {
83
84 default:
85 $cmd = $this->ctrl->getCmd("add");
86 $this->$cmd();
87 break;
88 }
89 return true;
90 }
91
96 public function getAppointment()
97 {
98 return $this->app;
99 }
100
108 protected function cancel()
109 {
110 $this->ctrl->returnToParent($this);
111 }
112
120 protected function initForm($a_mode, $a_as_milestone = false, $a_edit_single_app = false)
121 {
122 global $DIC;
123
124 $ilUser = $DIC['ilUser'];
125 $tpl = $DIC['tpl'];
126
127 $this->form = new ilPropertyFormGUI();
128
129 include_once('./Services/YUI/classes/class.ilYuiUtil.php');
131 $resp_info = false;
132 switch ($a_mode) {
133 case 'create':
134 $this->ctrl->saveParameter($this, array('seed','idate'));
135 $this->form->setFormAction($this->ctrl->getFormAction($this));
136 if ($a_as_milestone) {
137 $this->form->setTitle($this->lng->txt('cal_new_ms'));
138 $this->form->addCommandButton('saveMilestone', $this->lng->txt('cal_add_milestone'));
139 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
140 } else {
141 $this->form->setTitle($this->lng->txt('cal_new_app'));
142 $this->form->addCommandButton('save', $this->lng->txt('cal_add_appointment'));
143 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
144 }
145 break;
146
147 case 'edit':
148 if ($a_as_milestone) {
149 $this->form->setTitle($this->lng->txt('cal_edit_milestone'));
150 } else {
151 $this->form->setTitle($this->lng->txt('cal_edit_appointment'));
152 }
153 $this->ctrl->saveParameter($this, array('seed','app_id','idate'));
154 $this->form->setFormAction($this->ctrl->getFormAction($this));
155
156 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
157 $cat = $ass->getFirstAssignment();
158 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
159 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat);
160 $type = ilObject::_lookupType($cat_info['obj_id']);
161 if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
162 && ($type == "grp" || $type == "crs")) {
163 $resp_info = true;
164 $this->form->addCommandButton('editResponsibleUsers', $this->lng->txt('cal_change_responsible_users'));
165 }
166 $this->form->addCommandButton('update', $this->lng->txt('save'));
167 // $this->form->addCommandButton('askDelete',$this->lng->txt('delete'));
168 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
169 break;
170 }
171 // title
172 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
173 $title->setValue($this->app->getTitle());
174 $title->setRequired(true);
175 $title->setMaxLength(128);
176 $title->setSize(32);
177 $this->form->addItem($title);
178
179 // calendar selection
180 $calendar = new ilSelectInputGUI($this->lng->txt('cal_category_selection'), 'calendar');
181 if ($_POST['category']) {
182 $calendar->setValue((int) $_POST['calendar']);
183 $selected_calendar = (int) $_POST['calendar'];
184 } elseif ($_GET['category_id']) {
185 $calendar->setValue((int) $_GET['category_id']);
186 $selected_calendar = (int) $_GET['category_id'];
187 } elseif ($a_mode == 'edit') {
188 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
189 $cat = $ass->getFirstAssignment();
190 $calendar->setValue($cat);
191 $selected_calendar = $cat;
192 } elseif (isset($_GET['ref_id'])) {
193 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
194 $obj_cal = ilObject::_lookupObjId($_GET['ref_id']);
196 $selected_calendar = ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal);
198 $cats->readSingleCalendar($selected_calendar);
199 } else {
201 $categories = $cats->prepareCategoriesOfUserForSelection();
202 $selected_calendar = key((array) $categories);
203 $calendar->setValue($selected_calendar);
204 }
205 $calendar->setRequired(true);
207 $calendar->setOptions($cats->prepareCategoriesOfUserForSelection());
208
209 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
210 if (ilCalendarSettings::_getInstance()->isNotificationEnabled()) {
211 $notification_cals = $cats->getNotificationCalendars();
212 $notification_cals = count($notification_cals) ? implode(',', $notification_cals) : '';
213 $calendar->addCustomAttribute("onchange=\"ilToggleNotification([" . $notification_cals . "]);\"");
214 }
215 $this->form->addItem($calendar);
216
217 if (!$a_as_milestone) {
218 include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
219 $tpl->addJavaScript('./Services/Form/js/date_duration.js');
220 $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'), 'event');
221 $dur->setRequired(true);
222 $dur->enableToggleFullTime(
223 $this->lng->txt('cal_fullday_title'),
224 $this->app->isFullday() ? true : false
225 );
226 $dur->setShowTime(true);
227 $dur->setStart($this->app->getStart());
228 $dur->setEnd($this->app->getEnd());
229 $this->form->addItem($dur);
230
231 // recurrence
232 include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
233 $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'), 'frequence');
234 $rec->setRecurrence($this->rec);
235 $this->form->addItem($rec);
236
237 // location
238 $where = new ilTextInputGUI($this->lng->txt('cal_where'), 'location');
239 $where->setValue($this->app->getLocation());
240 $where->setMaxLength(128);
241 $where->setSize(32);
242 $this->form->addItem($where);
243 } else {
244 $deadline = new ilDateTimeInputGUI($this->lng->txt('cal_deadline'), 'event_start');
245 $deadline->setDate($this->app->getStart());
246 $deadline->setShowTime(false);
247 $deadline->setMinuteStepSize(5);
248 $this->form->addItem($deadline);
249
250 // completion
251 $completion_vals = array();
252 for ($i = 0; $i <= 100; $i += 5) {
253 $completion_vals[$i] = $i . " %";
254 }
255 $compl = new ilSelectInputGUI(
256 $this->lng->txt('cal_task_completion'),
257 'completion'
258 );
259 $compl->setOptions($completion_vals);
260 $compl->setValue($this->app->getCompletion());
261 $this->form->addItem($compl);
262 }
263
264 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
265 $desc->setValue($this->app->getDescription());
266 $desc->setRows(5);
267 $this->form->addItem($desc);
268
269 if ($a_as_milestone && $a_mode == "edit" && $resp_info) {
270 // users responsible
271 $users = $this->app->readResponsibleUsers();
272 $resp = new ilNonEditableValueGUI($this->lng->txt('cal_responsible'), "", true);
273 $delim = "";
274 foreach ($users as $r) {
275 $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
276 $delim = "<br />";
277 }
278 if (count($users) > 0) {
279 $resp->setValue($value);
280 } else {
281 $resp->setValue("-");
282 }
283
284 $this->form->addItem($resp);
285 }
286
287
288 if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
289 $notu = new ilTextWizardInputGUI($this->lng->txt('cal_user_notification'), 'notu');
290 $notu->setInfo($this->lng->txt('cal_user_notification_info'));
291 $notu->setSize(20);
292 $notu->setMaxLength(64);
293
294 $values = array();
295 foreach ($this->notification->getRecipients() as $rcp) {
296 switch ($rcp['type']) {
298 $values[] = ilObjUser::_lookupLogin($rcp['usr_id']);
299 break;
300
302 $values[] = $rcp['email'];
303 break;
304 }
305 }
306 if (count($values)) {
307 $notu->setValues($values);
308 } else {
309 $notu->setValues(array(''));
310 }
311 $this->form->addItem($notu);
312 }
313
314 // Notifications
315 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
316 if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and count($cats->getNotificationCalendars())) {
317 $selected_cal = new ilCalendarCategory($selected_calendar);
318 $disabled = true;
319 if ($selected_cal->getType() == ilCalendarCategory::TYPE_OBJ) {
320 if (ilObject::_lookupType($selected_cal->getObjId()) == 'crs' or ilObject::_lookupType($selected_cal->getObjId()) == 'grp') {
321 $disabled = false;
322 }
323 }
324
325 $tpl->addJavaScript('./Services/Calendar/js/toggle_notification.js');
326 $not = new ilCheckboxInputGUI($this->lng->txt('cal_cg_notification'), 'not');
327 $not->setInfo($this->lng->txt('cal_notification_info'));
328 $not->setValue(1);
329 $not->setChecked($this->app->isNotificationEnabled());
330 $not->setDisabled($disabled);
331 $this->form->addItem($not);
332 }
333 }
334
335
343 protected function add(ilPropertyFormGUI $form = null)
344 {
345 global $DIC;
346
347 $tpl = $DIC['tpl'];
348 $ilHelp = $DIC['ilHelp'];
349
350 $ilHelp->setScreenIdComponent("cal");
351 $ilHelp->setScreenId("app");
352 $ilHelp->setSubScreenId("create");
353
354 if (!$form instanceof ilPropertyFormGUI) {
355 $this->initForm('create');
356 }
357 $tpl->setContent($this->form->getHTML());
358 }
359
366 protected function addMilestone()
367 {
368 global $DIC;
369
370 $tpl = $DIC['tpl'];
371 $ilHelp = $DIC['ilHelp'];
372
373 $ilHelp->setScreenIdComponent("cal");
374 $ilHelp->setScreenId("app");
375 $ilHelp->setSubScreenId("create_milestone");
376
377 $this->initForm('create', true);
378 $tpl->setContent($this->form->getHTML());
379 }
380
386 protected function saveMilestone()
387 {
388 $this->save(true);
389 }
390
396 protected function save($a_as_milestone = false)
397 {
398 global $DIC;
399
400 $ilErr = $DIC['ilErr'];
401
402 $this->load('create', $a_as_milestone);
403
404 if ($this->app->validate() and $this->notification->validate()) {
405 if (!(int) $_POST['calendar']) {
406 $cat_id = $this->createDefaultCalendar();
407 } else {
408 $cat_id = (int) $_POST['calendar'];
409 }
410
411 $this->app->save();
412 $this->notification->setEntryId($this->app->getEntryId());
413 $this->notification->save();
414 $this->rec->setEntryId($this->app->getEntryId());
415 $this->saveRecurrenceSettings();
416
417 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
418 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
419 $ass->addAssignment($cat_id);
420
421 // Send notifications
422 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
423 if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not']) {
424 $this->distributeNotifications($cat_id, $this->app->getEntryId(), true);
425 }
426 if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
428 }
429
430 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
431 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
432 $type = ilObject::_lookupType($cat_info['obj_id']);
433
434 if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
435 && ($type == "grp" || $type == "crs")) {
436 ilUtil::sendSuccess($this->lng->txt('cal_created_milestone_resp_q'), true);
437 return $this->showResponsibleUsersList($cat_info['obj_id']);
438 } elseif ($a_as_milestone) {
439 ilUtil::sendSuccess($this->lng->txt('cal_created_milestone'), true);
440 $this->ctrl->returnToParent($this);
441 } else {
442 ilUtil::sendSuccess($this->lng->txt('cal_created_appointment'), true);
443 $this->ctrl->returnToParent($this);
444 }
445 } else {
446 $this->form->setValuesByPost();
447 ilUtil::sendFailure($ilErr->getMessage());
448 return $this->add($this->form);
449 }
450 if ($a_as_milestone) {
451 $this->addMilestone();
452 } else {
453 $this->add();
454 }
455 }
456
461 protected function distributeUserNotifications()
462 {
463 global $DIC;
464
465 $ilUser = $DIC['ilUser'];
466
467 include_once './Services/Calendar/classes/class.ilCalendarMailNotification.php';
468 $notification = new ilCalendarMailNotification();
469 $notification->setAppointmentId($this->app->getEntryId());
470
471 foreach ($this->notification->getRecipients() as $rcp) {
472 switch ($rcp['type']) {
474 $notification->setSender(ANONYMOUS_USER_ID);
475 $notification->setRecipients(array($rcp['usr_id']));
476 $notification->setType(ilCalendarMailNotification::TYPE_USER);
477 break;
478
480 $notification->setSender(ANONYMOUS_USER_ID);
481 $notification->setRecipients(array($rcp['email']));
483 break;
484 }
485 $notification->send();
486 }
487 }
488
489
494 protected function distributeNotifications($a_cat_id, $app_id, $a_new_appointment = true)
495 {
496 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
497 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($a_cat_id);
498
499 include_once './Services/Calendar/classes/class.ilCalendarMailNotification.php';
500 $notification = new ilCalendarMailNotification();
501 $notification->setAppointmentId($app_id);
502
503 switch ($cat_info['type']) {
505
506 switch ($cat_info['obj_type']) {
507 case 'crs':
508 $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
509 $ref_id = current($ref_ids);
510 $notification->setRefId($ref_id);
511 $notification->setType(
512 $a_new_appointment ?
515 );
516 break;
517
518 case 'grp':
519 $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
520 $ref_id = current($ref_ids);
521 $notification->setRefId($ref_id);
522 $notification->setType(
523 $a_new_appointment ?
526 );
527 break;
528 }
529 break;
530 }
531
532 $notification->send();
533 }
534
538 public function editResponsibleUsers()
539 {
540 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
541 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
542 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
543 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
544
545 $this->showResponsibleUsersList($cat_info['obj_id']);
546 }
547
552 public function showResponsibleUsersList($a_grp_id)
553 {
554 global $DIC;
555
556 $tpl = $DIC['tpl'];
557
558 include_once("./Services/Calendar/classes/class.ilMilestoneResponsiblesTableGUI.php");
559 $table_gui = new ilMilestoneResponsiblesTableGUI(
560 $this,
561 "",
562 $a_grp_id,
563 $this->app->getEntryId()
564 );
565 $tpl->setContent($table_gui->getHTML());
566 }
567
572 {
573 global $DIC;
574
575 $ilCtrl = $DIC['ilCtrl'];
576
577 $this->app->writeResponsibleUsers($_POST["user_id"]);
578 $ilCtrl->returnToParent($this);
579 }
580
585 protected function askEdit()
586 {
587 // check for recurring entries
588 include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
590 if (!$rec) {
591 return $this->edit(true);
592 }
593 // Show edit single/all appointments
594 $this->ctrl->saveParameter($this, array('seed','app_id','dt','idate'));
595
596 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
597 $confirm = new ilConfirmationGUI();
598 $confirm->setFormAction($this->ctrl->getFormAction($this));
599 #$confirm->setHeaderText($this->lng->txt('cal_edit_app_sure'));
600 $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
601 $confirm->addItem('appointments[]', $this->app->getEntryId(), $this->app->getTitle());
602 $confirm->addButton($this->lng->txt('cal_edit_single'), 'editSingle');
603 $confirm->setConfirm($this->lng->txt('cal_edit_recurrences'), 'edit');
604
605 $GLOBALS['DIC']['tpl']->setContent($confirm->getHTML());
606 }
607
611 protected function editSingle()
612 {
613 $_REQUEST['rexl'] = 1;
614 $GLOBALS['DIC']['ilCtrl']->setParameter($this, 'rexcl', 1);
615 $this->edit(true);
616 }
617
626 protected function edit($a_edit_single_app = false, ilPropertyFormGUI $form = null)
627 {
628 global $DIC;
629
630 $tpl = $DIC['tpl'];
631 $ilUser = $DIC['ilUser'];
632 $ilErr = $DIC['ilErr'];
633 $ilHelp = $DIC['ilHelp'];
634
635 $ilHelp->setScreenIdComponent("cal");
636 $ilHelp->setScreenId("app");
637 if ($this->app->isMilestone()) {
638 $ilHelp->setSubScreenId("edit_milestone");
639 } else {
640 $ilHelp->setSubScreenId("edit");
641 }
642
643 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
644 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
645 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
646
647 $GLOBALS['DIC']['ilCtrl']->saveParameter($this, array('seed','app_id','dt','idate'));
648
649 if ($_REQUEST['rexl']) {
650 $GLOBALS['DIC']['ilCtrl']->setParameter($this, 'rexl', 1);
651
652 // Calculate new appointment time
653 $duration = $this->getAppointment()->getEnd()->get(IL_CAL_UNIX) - $this->getAppointment()->getStart()->get(IL_CAL_UNIX);
654 include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php';
655 $calc = new ilCalendarRecurrenceCalculator($this->getAppointment(), $this->rec);
656
657 $current_date = new ilDateTime($_REQUEST['dt'], IL_CAL_UNIX);
658
659 $yesterday = clone $current_date;
660 $yesterday->increment(IL_CAL_DAY, -1);
661 $tomorrow = clone $current_date;
662 $tomorrow->increment(IL_CAL_DAY, 1);
663
664
665 foreach ($calc->calculateDateList($current_date, $tomorrow, 1) as $date_entry) {
666 if (ilDateTime::_equals($current_date, $date_entry, IL_CAL_DAY)) {
667 $this->getAppointment()->setStart(new ilDateTime($date_entry->get(IL_CAL_UNIX), IL_CAL_UNIX));
668 $this->getAppointment()->setEnd(new ilDateTime($date_entry->get(IL_CAL_UNIX) + $duration, IL_CAL_UNIX));
669 break;
670 }
671 }
672
673 // Finally reset recurrence
674 $this->rec = new ilCalendarRecurrence();
675 }
676
677 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
679
680 if (!$cats->isVisible($cat_id)) {
681 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
682 return false;
683 }
684 if (!$cats->isEditable($cat_id) or $this->app->isAutoGenerated()) {
685 $this->showInfoScreen();
686 return true;
687 }
688 if (!$form instanceof ilPropertyFormGUI) {
689 $this->initForm('edit', $this->app->isMilestone(), $a_edit_single_app);
690 }
691 $tpl->setContent($this->form->getHTML());
692 }
693
700 protected function showInfoScreen()
701 {
702 global $DIC;
703
704 $tpl = $DIC['tpl'];
705 $ilUser = $DIC['ilUser'];
706
707 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
708 $info = new ilInfoScreenGUI($this);
709 $info->setFormAction($this->ctrl->getFormAction($this));
710
711 if ($this->app->isMilestone()) {
712 $info->addSection($this->lng->txt('cal_ms_details'));
713 } else {
714 $info->addSection($this->lng->txt('cal_details'));
715 }
716
717 // Appointment
718 $info->addProperty(
719 $this->lng->txt('appointment'),
721 $this->app->getStart(),
722 $this->app->getEnd()
723 )
724 );
725 $info->addProperty($this->lng->txt('title'), $this->app->getPresentationTitle());
726
727 // Description
728 if (strlen($desc = $this->app->getDescription())) {
729 $info->addProperty($this->lng->txt('description'), $desc);
730 }
731
732 // Location
733 if (strlen($loc = $this->app->getLocation())) {
734 $info->addProperty($this->lng->txt('cal_where'), $loc);
735 }
736
737 // completion
738 if ($this->app->isMilestone() && $this->app->getCompletion() > 0) {
739 $info->addProperty(
740 $this->lng->txt('cal_task_completion'),
741 $this->app->getCompletion() . " %"
742 );
743 }
744
745 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
746 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
747 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
748 $type = ilObject::_lookupType($cat_info['obj_id']);
749 if ($this->app->isMilestone() && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
750 && ($type == "grp" || $type == "crs")) {
751 // users responsible
752 $users = $this->app->readResponsibleUsers();
753 $delim = "";
754 foreach ($users as $r) {
755 $value .= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
756 $delim = "<br />";
757 }
758 if (count($users) > 0) {
759 $info->addProperty(
760 $this->lng->txt('cal_responsible'),
761 $value
762 );
763 }
764 }
765
766 $category = new ilCalendarCategory($cat_id);
767
768 if ($category->getType() == ilCalendarCategory::TYPE_OBJ) {
769 $info->addSection($this->lng->txt('additional_info'));
770
771 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
772 $refs = ilObject::_getAllReferences($cat_info['obj_id']);
773
774 include_once('./Services/Link/classes/class.ilLink.php');
775 $href = ilLink::_getStaticLink(current($refs), ilObject::_lookupType($cat_info['obj_id']), true);
776 $info->addProperty($this->lng->txt('perma_link'), '<a class="small" href="' . $href . '" target="_top">' . $href . '</a>');
777 }
778
779 $tpl->setContent($info->getHTML());
780 }
781
788 protected function update()
789 {
790 global $DIC;
791
792 $ilErr = $DIC['ilErr'];
793
794 $single_editing = ($_REQUEST['rexl'] ? true : false);
795
796 $this->load('edit', $this->app->isMilestone());
797
798 if ($this->app->validate() and $this->notification->validate()) {
799 if (!(int) $_POST['calendar']) {
800 $cat_id = $this->createDefaultCalendar();
801 } else {
802 $cat_id = (int) $_POST['calendar'];
803 }
804
805 if ($single_editing) {
806 $this->getAppointment()->save();
807 $this->deleteExclude(false);
808
809 $this->rec = new ilCalendarRecurrence();
810 $this->rec->setEntryId($this->getAppointment()->getEntryId());
811 } else {
812 $this->getAppointment()->update();
813 }
814 $this->notification->save();
815 $this->saveRecurrenceSettings();
816 //var_dump($cat_id);
817 //var_dump($_POST); exit;
818 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
819 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
820 $this->logger->debug($this->app->getEntryId());
821 $ass->deleteAssignments();
822 $ass->addAssignment($cat_id);
823
824 // Send notifications
825 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
826 if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not']) {
827 $this->distributeNotifications($cat_id, $this->app->getEntryId(), false);
828 }
829 if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
831 }
832
833 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
834 $this->ctrl->returnToParent($this);
835 } else {
836 $this->form->setValuesByPost();
837 ilUtil::sendFailure($ilErr->getMessage());
838 }
839 $this->edit(false, $this->form);
840 }
841
848 protected function askDelete()
849 {
850 global $DIC;
851
852 $tpl = $DIC['tpl'];
853
854 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
855
856 $this->ctrl->saveParameter($this, array('seed','app_id','dt','idate'));
857
858 $confirm = new ilConfirmationGUI();
859 $confirm->setFormAction($this->ctrl->getFormAction($this));
860 $confirm->setHeaderText($this->lng->txt('cal_delete_app_sure'));
861 $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
862 $confirm->addItem('appointments[]', $this->app->getEntryId(), $this->app->getTitle());
863
864 include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
865 if (sizeof(ilCalendarRecurrences::_getRecurrences($_GET['app_id']))
866 && !$this->app->isMilestone()) {
867 $confirm->addButton($this->lng->txt('cal_delete_single'), 'deleteexclude');
868 $confirm->setConfirm($this->lng->txt('cal_delete_recurrences'), 'delete');
869 } else {
870 $confirm->setConfirm($this->lng->txt('delete'), 'delete');
871 }
872
873 $tpl->setContent($confirm->getHTML());
874 }
875
883 protected function delete()
884 {
885 foreach ($_POST['appointments'] as $app_id) {
886 $app = new ilCalendarEntry($app_id);
887 $app->delete();
888
889 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
891
892 include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
894 }
895 ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'), true);
896 $this->ctrl->returnToParent($this);
897 }
898
906 protected function deleteExclude($a_return = true)
907 {
908 include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceExclusion.php');
909 $excl = new ilCalendarRecurrenceExclusion();
910 $excl->setEntryId($_REQUEST['app_id']);
911 $excl->setDate(new ilDate($_REQUEST['dt'], IL_CAL_UNIX));
912 $excl->save();
913
914 if ($a_return) {
915 ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'), true);
916 $this->ctrl->returnToParent($this);
917 }
918 }
919
927 protected function initTimeZone()
928 {
929 global $DIC;
930
931 $ilUser = $DIC['ilUser'];
932
933 $this->timezone = $ilUser->getTimeZone();
934 }
935
941 {
942 if (!isset($_GET['hour'])) {
943 $this->initialDate = clone $initialDate;
944 $this->default_fulltime = true;
945 } else {
946 if ((int) $_GET['hour'] < 10) {
947 $time = '0' . (int) $_GET['hour'] . ':00:00';
948 } else {
949 $time = (int) $_GET['hour'] . ':00:00';
950 }
951 $this->initialDate = new ilDateTime($initialDate->get(IL_CAL_DATE) . ' ' . $time, IL_CAL_DATETIME, $this->timezone);
952 $this->default_fulltime = false;
953 }
954 }
955
963 protected function initSeed(ilDate $seed)
964 {
965 $this->seed = clone $seed;
966 $this->default_fulltime = true;
967 }
968
976 protected function initAppointment($a_app_id = 0)
977 {
978 include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
979 include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
980 $this->app = new ilCalendarEntry($a_app_id);
981
982 include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
983 $this->notification = new ilCalendarUserNotification($this->app->getEntryId());
984
985 if (!$a_app_id) {
987 $this->app->setStart($start);
988
989 $seed_end = clone $this->initialDate;
990 if ($this->default_fulltime) {
991 #$seed_end->increment(IL_CAL_DAY,1);
992 } else {
993 $seed_end->increment(IL_CAL_HOUR, 1);
994 }
995 $this->app->setEnd($seed_end);
996 $this->app->setFullday($this->default_fulltime);
997
998 $this->rec = new ilCalendarRecurrence();
999 } else {
1000 $this->rec = ilCalendarRecurrences::_getFirstRecurrence($this->app->getEntryId());
1001 }
1002 }
1003
1011 protected function load($a_mode, $a_as_milestone = false)
1012 {
1013 // needed for date handling
1014 $this->initForm($a_mode, $a_as_milestone);
1015 $this->form->checkInput();
1016
1017 if ($a_as_milestone) {
1018 $this->app->setMilestone(true);
1019 $this->app->setCompletion(ilUtil::stripSlashes($_POST['completion']));
1020 }
1021
1022 $this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
1023 $this->app->setLocation(ilUtil::stripSlashes($_POST['location']));
1024 $this->app->setDescription(ilUtil::stripSlashes($_POST['description']));
1025 $this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
1026 $this->app->enableNotification((int) $_POST['not']);
1027
1028 if ($a_as_milestone) { // milestones are always fullday events
1029 $start = $this->form->getItemByPostVar('event_start');
1030 $start = $start->getDate();
1031
1032 $this->app->setFullday(true);
1033
1034 // for milestones is end date = start date
1035 $this->app->setStart($start);
1036 $this->app->setEnd($start);
1037 } else {
1038 $period = $this->form->getItemByPostVar('event');
1039 $start = $period->getStart();
1040 $end = $period->getEnd();
1041
1042 $this->app->setFullday($start instanceof ilDate);
1043 $this->app->setStart($start);
1044 $this->app->setEnd($end);
1045 }
1046
1048 $this->loadRecurrenceSettings($a_as_milestone = false);
1049 }
1050
1051 protected function loadNotificationRecipients()
1052 {
1053 $this->notification->setRecipients(array());
1054
1055 foreach ((array) $_POST['notu'] as $rcp) {
1056 $rcp = trim(ilUtil::stripSlashes($rcp));
1057 $usr_id = ilObjUser::_loginExists($rcp);
1058
1059 if (strlen($rcp) == 0) {
1060 continue;
1061 }
1062
1063 if ($usr_id) {
1064 $this->notification->addRecipient(
1066 $usr_id
1067 );
1068 } else {
1069 $this->notification->addRecipient(
1071 0,
1072 $rcp
1073 );
1074 }
1075 }
1076 }
1077
1084 protected function loadRecurrenceSettings($a_as_milestone = false)
1085 {
1086 $this->rec->reset();
1087
1088 switch ($_POST['frequence']) {
1089 case IL_CAL_FREQ_DAILY:
1090 $this->rec->setFrequenceType($_POST['frequence']);
1091 $this->rec->setInterval((int) $_POST['count_DAILY']);
1092 break;
1093
1094 case IL_CAL_FREQ_WEEKLY:
1095 $this->rec->setFrequenceType($_POST['frequence']);
1096 $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1097 if (is_array($_POST['byday_WEEKLY'])) {
1098 $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',', $_POST['byday_WEEKLY'])));
1099 }
1100 break;
1101
1103 $this->rec->setFrequenceType($_POST['frequence']);
1104 $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1105 switch ((int) $_POST['subtype_MONTHLY']) {
1106 case 0:
1107 // nothing to do;
1108 break;
1109
1110 case 1:
1111 switch ((int) $_POST['monthly_byday_day']) {
1112 case 8:
1113 // Weekday
1114 $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1115 $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1116 break;
1117
1118 case 9:
1119 // Day of month
1120 $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1121 break;
1122
1123 default:
1124 $this->rec->setBYDAY((int) $_POST['monthly_byday_num'] . $_POST['monthly_byday_day']);
1125 break;
1126 }
1127 break;
1128
1129 case 2:
1130 $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1131 break;
1132 }
1133 break;
1134
1135 case IL_CAL_FREQ_YEARLY:
1136 $this->rec->setFrequenceType($_POST['frequence']);
1137 $this->rec->setInterval((int) $_POST['count_YEARLY']);
1138 switch ((int) $_POST['subtype_YEARLY']) {
1139 case 0:
1140 // nothing to do;
1141 break;
1142
1143 case 1:
1144 $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1145 $this->rec->setBYDAY((int) $_POST['yearly_byday_num'] . $_POST['yearly_byday']);
1146 break;
1147
1148 case 2:
1149 $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1150 $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1151 break;
1152 }
1153 break;
1154 }
1155
1156 // UNTIL
1157 switch ((int) $_POST['until_type']) {
1158 case 1:
1159 $this->rec->setFrequenceUntilDate(null);
1160 // nothing to do
1161 break;
1162
1163 case 2:
1164 $this->rec->setFrequenceUntilDate(null);
1165 $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1166 break;
1167
1168 case 3:
1169 $dt = new ilDateTimeInputGUI('', 'until_end');
1170 $dt->setRequired(true);
1171 if ($dt->checkInput()) {
1172 $this->rec->setFrequenceUntilCount(0);
1173 $this->rec->setFrequenceUntilDate($dt->getDate());
1174 }
1175 break;
1176 }
1177 }
1178
1186 protected function saveRecurrenceSettings()
1187 {
1188 switch ($_POST['frequence']) {
1189 case 'NONE':
1190 case '':
1191 // No recurrence => delete if there is an recurrence rule
1192 if ($this->rec->getRecurrenceId()) {
1193 $this->rec->delete();
1194 }
1195 break;
1196
1197 default:
1198 if ($this->rec->getRecurrenceId()) {
1199 $this->rec->update();
1200 } else {
1201 $this->rec->save();
1202 }
1203 break;
1204 }
1205 }
1206
1213 protected function createDefaultCalendar()
1214 {
1215 global $DIC;
1216
1217 $ilUser = $DIC['ilUser'];
1218 $lng = $DIC['lng'];
1219
1220 $cat = new ilCalendarCategory();
1221 $cat->setColor(ilCalendarCategory::DEFAULT_COLOR);
1222 $cat->setType(ilCalendarCategory::TYPE_USR);
1223 $cat->setTitle($this->lng->txt('cal_default_calendar'));
1224 $cat->setObjId($ilUser->getId());
1225
1226 // delete calendar cache
1227 include_once './Services/Calendar/classes/class.ilCalendarCache.php';
1228 ilCalendarCache::getInstance()->deleteUserEntries($ilUser->getId());
1229
1230 return $cat->add();
1231 }
1232
1237 protected function confirmRegister()
1238 {
1239 global $DIC;
1240
1241 $tpl = $DIC['tpl'];
1242
1243 $entry = new ilCalendarEntry((int) $_GET['app_id']);
1245 new ilDateTime($_GET['dstart'], IL_CAL_UNIX),
1246 new ilDateTime($_GET['dend'], IL_CAL_UNIX)
1247 );
1248
1249
1250 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1251 $conf = new ilConfirmationGUI;
1252
1253 $this->ctrl->setParameter($this, 'dstart', (int) $_REQUEST['dstart']);
1254 $this->ctrl->setParameter($this, 'dend', (int) $_REQUEST['dend']);
1255
1256 $conf->setFormAction($this->ctrl->getFormAction($this));
1257 $conf->setHeaderText($this->lng->txt('cal_confirm_reg_info'));
1258 $conf->setConfirm($this->lng->txt('cal_reg_register'), 'register');
1259 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1260 $conf->addItem('app_id', $entry->getEntryId(), $entry->getTitle() . ' (' . $start . ')');
1261
1262 $tpl->setContent($conf->getHTML());
1263 }
1264
1269 protected function register()
1270 {
1271 global $DIC;
1272
1273 $ilUser = $DIC['ilUser'];
1274
1275 include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
1276 $reg = new ilCalendarRegistration((int) $_POST['app_id']);
1277 $reg->register(
1278 $ilUser->getId(),
1279 new ilDateTime((int) $_REQUEST['dstart'], IL_CAL_UNIX),
1280 new ilDateTime((int) $_REQUEST['dend'], IL_CAL_UNIX)
1281 );
1282
1283 ilUtil::sendSuccess($this->lng->txt('cal_reg_registered'), true);
1284 $this->ctrl->returnToParent($this);
1285 }
1286
1290 public function confirmUnregister()
1291 {
1292 global $DIC;
1293
1294 $tpl = $DIC['tpl'];
1295
1296
1297 $entry = new ilCalendarEntry((int) $_GET['app_id']);
1299 $dstart = new ilDateTime($_GET['dstart'], IL_CAL_UNIX),
1300 $dend = new ilDateTime($_GET['dend'], IL_CAL_UNIX)
1301 );
1302
1303
1304 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1305 $conf = new ilConfirmationGUI;
1306
1307 $this->ctrl->setParameter($this, 'dstart', (int) $_REQUEST['dstart']);
1308 $this->ctrl->setParameter($this, 'dend', (int) $_REQUEST['dend']);
1309
1310 $conf->setFormAction($this->ctrl->getFormAction($this));
1311 $conf->setHeaderText($this->lng->txt('cal_confirm_unreg_info'));
1312 $conf->setConfirm($this->lng->txt('cal_reg_unregister'), 'unregister');
1313 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1314 $conf->addItem('app_id', $entry->getEntryId(), $entry->getTitle() . ' (' . $start . ')');
1315
1316 $tpl->setContent($conf->getHTML());
1317 }
1318
1323 protected function unregister()
1324 {
1325 global $DIC;
1326
1327 $ilUser = $DIC['ilUser'];
1328
1329 include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
1330 $reg = new ilCalendarRegistration((int) $_POST['app_id']);
1331 $reg->unregister(
1332 $ilUser->getId(),
1333 new ilDateTime((int) $_REQUEST['dstart'], IL_CAL_UNIX),
1334 new ilDateTime((int) $_REQUEST['dend'], IL_CAL_UNIX)
1335 );
1336
1337 ilUtil::sendSuccess($this->lng->txt('cal_reg_unregistered'), true);
1338 $this->ctrl->returnToParent($this);
1339 }
1340
1344 public function book()
1345 {
1346 global $DIC;
1347
1348 $ilUser = $DIC['ilUser'];
1349 $tpl = $DIC['tpl'];
1350
1351 $entry = (int) $_GET['app_id'];
1352 $user = (int) $_GET['bkid'];
1353
1354 $this->ctrl->saveParameter($this, 'app_id');
1355
1356 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1357 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1358 $entry = new ilCalendarEntry($entry);
1359
1360 $form = $this->initFormConfirmBooking();
1361 $form->getItemByPostVar('date')->setValue(ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd()));
1362 $form->getItemByPostVar('title')->setValue($entry->getTitle() . " (" . ilObjUser::_lookupFullname($user) . ')');
1363
1364 $tpl->setContent($form->getHTML());
1365 return true;
1366 }
1367
1372 protected function initFormConfirmBooking()
1373 {
1374 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1375 $form = new ilPropertyFormGUI();
1376 $form->setFormAction($this->ctrl->getFormAction($this));
1377 $form->addCommandButton('bookconfirmed', $this->lng->txt('cal_confirm_booking'));
1378 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
1379
1380 $date = new ilNonEditableValueGUI($this->lng->txt('appointment'), 'date');
1381 $form->addItem($date);
1382
1383 $title = new ilNonEditableValueGUI($this->lng->txt('title'), 'title');
1384 $form->addItem($title);
1385
1386 $message = new ilTextAreaInputGUI($this->lng->txt('cal_ch_booking_message_tbl'), 'comment');
1387 $message->setRows(5);
1388 $form->addItem($message);
1389
1390 return $form;
1391 }
1392
1396 public function bookconfirmed()
1397 {
1398 global $DIC;
1399
1400 $ilUser = $DIC['ilUser'];
1401
1402 $entry = (int) $_REQUEST['app_id'];
1403 $user = (int) $_REQUEST['bkid'];
1404
1405 $form = $this->initFormConfirmBooking();
1406 if ($form->checkInput()) {
1407 // check if appointment is bookable
1408 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
1409 $cal_entry = new ilCalendarEntry($entry);
1410
1411 include_once './Services/Booking/classes/class.ilBookingEntry.php';
1412 $booking = new ilBookingEntry($cal_entry->getContextId());
1413
1414 if (!$booking->isAppointmentBookableForUser($entry, $GLOBALS['DIC']['ilUser']->getId())) {
1415 ilUtil::sendFailure($this->lng->txt('cal_booking_failed_info'), true);
1416 $this->ctrl->returnToParent($this);
1417 }
1418
1419 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
1421
1422 include_once './Services/Booking/classes/class.ilBookingEntry.php';
1423 ilBookingEntry::writeBookingMessage($entry, $ilUser->getId(), $form->getInput('comment'));
1424 }
1425 ilUtil::sendSuccess($this->lng->txt('cal_booking_confirmed'), true);
1426 $this->ctrl->returnToParent($this);
1427 }
1428
1433 public function cancelBooking()
1434 {
1435 global $DIC;
1436
1437 $ilUser = $DIC['ilUser'];
1438 $tpl = $DIC['tpl'];
1439
1440 $entry = (int) $_GET['app_id'];
1441
1442 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1443 $entry = new ilCalendarEntry($entry);
1444
1445 $category = $this->calendarEntryToCategory($entry);
1446 if ($category->getType() == ilCalendarCategory::TYPE_CH) {
1447 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1448 $booking = new ilBookingEntry($entry->getContextId());
1449 if (!$booking->hasBooked($entry->getEntryId())) {
1450 $this->ctrl->returnToParent($this);
1451 return false;
1452 }
1453
1454 $entry_title = ' ' . $entry->getTitle() . " (" . ilObjUser::_lookupFullname($booking->getObjId()) . ')';
1455 } elseif ($category->getType() == ilCalendarCategory::TYPE_BOOK) {
1456 $entry_title = ' ' . $entry->getTitle();
1457 } else {
1458 $this->ctrl->returnToParent($this);
1459 return false;
1460 }
1461
1462 $title = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd());
1463
1464 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1465 $conf = new ilConfirmationGUI;
1466 $conf->setFormAction($this->ctrl->getFormAction($this));
1467 $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info'));
1468 $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed');
1469 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1470 $conf->addItem('app_id', $entry->getEntryId(), $title . ' - ' . $entry_title);
1471
1472 $tpl->setContent($conf->getHTML());
1473 }
1474
1479 public function cancelConfirmed()
1480 {
1481 global $DIC;
1482
1483 $ilUser = $DIC['ilUser'];
1484
1485 $entry = (int) $_POST['app_id'];
1486 $user = (int) $_GET['bkid'];
1487
1488 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1489 $entry = new ilCalendarEntry($entry);
1490
1491 $category = $this->calendarEntryToCategory($entry);
1492 if ($category->getType() == ilCalendarCategory::TYPE_CH) {
1493 // find cloned calendar entry in user calendar
1494 include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
1496 $ilUser->getId(),
1497 $entry->getContextId(),
1498 $entry->getStart(),
1500 false
1501 );
1502
1503 // Fix for wrong, old entries
1504 foreach ((array) $apps as $own_app) {
1505 $ref_entry = new ilCalendarEntry($own_app);
1506 $ref_entry->delete();
1507 }
1508
1509 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1510 $booking = new ilBookingEntry($entry->getContextId());
1511 $booking->cancelBooking($entry->getEntryId());
1512
1513 // do NOT delete original entry
1514 } elseif ($category->getType() == ilCalendarCategory::TYPE_BOOK) {
1515 include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
1516 $booking = new ilBookingReservation($entry->getContextId());
1517 $booking->setStatus(ilBookingReservation::STATUS_CANCELLED);
1518 $booking->update();
1519
1520 $entry->delete();
1521 }
1522
1523 ilUtil::sendSuccess($this->lng->txt('cal_cancel_booking_confirmed'), true);
1524 $this->ctrl->returnToParent($this);
1525 }
1526
1532 protected function calendarEntryToCategory(ilCalendarEntry $entry)
1533 {
1534 include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
1535 include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
1536 $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
1537 $assignment = $assignment->getFirstAssignment();
1538 return new ilCalendarCategory($assignment);
1539 }
1540
1545 protected function doUserAutoComplete()
1546 {
1547 if (!isset($_GET['autoCompleteField'])) {
1548 $a_fields = array('login','firstname','lastname','email');
1549 } else {
1550 $a_fields = array((string) $_GET['autoCompleteField']);
1551 }
1552
1553 include_once './Services/User/classes/class.ilUserAutoComplete.php';
1554 $auto = new ilUserAutoComplete();
1555 $auto->setSearchFields($a_fields);
1556 $auto->enableFieldSearchableCheck(true);
1557 $auto->setMoreLinkAvailable(true);
1558
1559 if (($_REQUEST['fetchall'])) {
1560 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
1561 }
1562
1563 echo $auto->getList($_REQUEST['query']);
1564 exit();
1565 }
1566}
$users
Definition: authpage.php:44
exit
Definition: backend.php:16
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_FREQ_YEARLY
const IL_CAL_FREQ_MONTHLY
const IL_CAL_FREQ_WEEKLY
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_CAL_HOUR
const IL_CAL_DAY
Booking definition.
static writeBookingMessage($a_entry_id, $a_usr_id, $a_message)
Write booking message.
Administrate calendar appointments.
askEdit()
Check edit single apppointment / edit all appointments for recurring appointments.
initForm($a_mode, $a_as_milestone=false, $a_edit_single_app=false)
init form
deleteExclude($a_return=true)
delete single item of recurrence list
__construct(ilDate $seed, ilDate $initialDate, $a_appointment_id=0)
Constructor.
calendarEntryToCategory(ilCalendarEntry $entry)
Get category object of given calendar entry.
editSingle()
Edit one single appointment ^.
initInitialDate(ilDate $initialDate)
init initial date
bookconfirmed()
Book consultation appointment, was confirmed.
distributeUserNotifications()
Send mail to selected users @global ilObjUser $ilUser.
load($a_mode, $a_as_milestone=false)
load post
loadRecurrenceSettings($a_as_milestone=false)
load recurrence settings
showResponsibleUsersList($a_grp_id)
Show responsible uses of a milestone (default set is participants of group)
distributeNotifications($a_cat_id, $app_id, $a_new_appointment=true)
Distribute mail notifications.
saveRecurrenceSettings()
save recurrence settings
createDefaultCalendar()
Create a default calendar.
confirmRegister()
Register to an appointment.
cancelConfirmed()
Cancel consultation appointment or ressource booking, was confirmed This will delete the calendar ent...
book()
Confirmation screen for booking of consultation appointment.
add(ilPropertyFormGUI $form=null)
add new appointment
save($a_as_milestone=false)
save appointment
saveMilestoneResponsibleUsers()
Save milestone responsibilites.
getAppointment()
Get current appointment.
edit($a_edit_single_app=false, ilPropertyFormGUI $form=null)
edit appointment
initAppointment($a_app_id=0)
init appointment
editResponsibleUsers()
Edit responsible users.
cancelBooking()
Confirmation screen to cancel consultation appointment or ressource booking depends on calendar categ...
confirmUnregister()
Confirmation screen to unregister calendar.
unregister()
Unregister calendar, was confirmed.
static getInstance()
get singleton instance
static _lookupCategoryIdByObjId($a_obj_id)
lookup category by obj_id
static _getInstance($a_usr_id=0)
get singleton instance
static _lookupCategory($a_cal_id)
Lookup category id.
static _deleteByAppointmentId($a_app_id)
Delete appointment assignment.
Stores calendar categories.
Model for a calendar entry.
Distributes calendar mail notifications.
Calculates an ilDateList for a given calendar entry and recurrence rule.
Stores exclusion dates for calendar recurrences.
static _getRecurrences($a_cal_id)
get all recurrences of an appointment
static _getFirstRecurrence($a_cal_id)
get first recurrence
registration for calendar appointments
static _getInstance()
get singleton instance
static deleteCalendarEntry($a_cal_id)
Delete notification for a calendar entry @global ilDB $ilDB.
This class represents a checkbox property in a property form.
Confirmation screen class.
setFormAction($a_form_action)
static getAppointmentIds($a_user_id, $a_context_id=null, $a_start=null, $a_type=null, $a_check_owner=true)
Get all appointment ids.
static bookAppointment($a_usr_id, $a_app_id)
Book an appointment.
input GUI for a time span (start and end date)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
This class represents a date/time property in a property form.
@classDescription Date and time handling
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Class for single dates.
Class ilInfoScreenGUI.
TableGUI class for selection of milestone responsibles.
This class represents a non editable value in a property form.
static _lookupLogin($a_user_id)
lookup login
static _lookupFullname($a_user_id)
Lookup Full Name.
static _loginExists($a_login, $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 _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.
This class represents an input GUI for recurring events/appointments (course events or calendar appoi...
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
This class represents a text wizard property in a property form.
Auto completion class for user lists.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static initDomEvent()
Init YUI DomEvent.
$i
Definition: disco.tpl.php:19
$r
Definition: example_031.php:79
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
global $ilCtrl
Definition: ilias.php:18
$time
Definition: cron.php:21
catch(Exception $e) $message
$info
Definition: index.php:5
$user
Definition: migrateto20.php:57
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
notification()
Definition: notification.php:2
global $ilSetting
Definition: privfeed.php:17
$type
$ilErr
Definition: raiseError.php:18
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$values
$ilUser
Definition: imgupload.php:18
$start
Definition: bench.php:8