ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilCalendarAppointmentGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
33include_once('./Services/Calendar/classes/class.ilTimeZone.php');
34include_once('./Services/Calendar/classes/class.ilDateTime.php');
35
37{
38 protected $seed = null;
39 protected $initialDate = null;
40 protected $default_fulltime = true;
41
42 protected $app = null;
43 protected $rec = null;
44 protected $timezone = null;
45
46 protected $tpl;
47 protected $lng;
48 protected $ctrl;
49
57 public function __construct(ilDate $seed,ilDate $initialDate, $a_appointment_id = 0)
58 {
59 global $ilCtrl,$lng;
60
61 $this->lng = $lng;
62 $lng->loadLanguageModule('dateplaner');
63 $this->ctrl = $ilCtrl;
64
65 $this->initTimeZone();
66 $this->initSeed($seed);
67 $this->initInitialDate($initialDate);
68 $this->initAppointment($a_appointment_id);
69 }
70
78 public function executeCommand()
79 {
80 global $ilUser, $ilSetting,$tpl, $ilTabs;
81
82
83 // Clear tabs and set back target
84 $ilTabs->clearTargets();
85 $ilTabs->setBackTarget(
86 $this->lng->txt('cal_back_to_cal'),
87 $this->ctrl->getLinkTarget($this,'cancel')
88 );
89
90 $next_class = $this->ctrl->getNextClass($this);
91 switch($next_class)
92 {
93
94 default:
95 $cmd = $this->ctrl->getCmd("add");
96 $this->$cmd();
97 break;
98 }
99 return true;
100 }
101
106 public function getAppointment()
107 {
108 return $this->app;
109 }
110
118 protected function cancel()
119 {
120 $this->ctrl->returnToParent($this);
121 }
122
130 protected function initForm($a_mode, $a_as_milestone = false, $a_edit_single_app = false)
131 {
132 global $ilUser,$tpl;
133
134 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
135 include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceGUI.php');
136 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
137 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
138 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
139
140 $this->form = new ilPropertyFormGUI();
141
142 include_once('./Services/YUI/classes/class.ilYuiUtil.php');
144 $resp_info = false;
145 switch($a_mode)
146 {
147 case 'create':
148 $this->ctrl->saveParameter($this,array('seed','idate'));
149 $this->form->setFormAction($this->ctrl->getFormAction($this));
150 if ($a_as_milestone)
151 {
152 $this->form->setTitle($this->lng->txt('cal_new_ms'));
153 $this->form->addCommandButton('saveMilestone',$this->lng->txt('cal_add_milestone'));
154 $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
155 }
156 else
157 {
158 $this->form->setTitle($this->lng->txt('cal_new_app'));
159 $this->form->addCommandButton('save',$this->lng->txt('cal_add_appointment'));
160 $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
161 }
162 break;
163
164 case 'edit':
165 if ($a_as_milestone)
166 {
167 $this->form->setTitle($this->lng->txt('cal_edit_milestone'));
168 }
169 else
170 {
171 $this->form->setTitle($this->lng->txt('cal_edit_appointment'));
172 }
173 $this->ctrl->saveParameter($this,array('seed','app_id','idate'));
174 $this->form->setFormAction($this->ctrl->getFormAction($this));
175
176 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
177 $cat = $ass->getFirstAssignment();
178 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
179 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat);
180 $type = ilObject::_lookupType($cat_info['obj_id']);
181 if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
182 && ($type == "grp" || $type == "crs"))
183 {
184 $resp_info = true;
185 $this->form->addCommandButton('editResponsibleUsers',$this->lng->txt('cal_change_responsible_users'));
186 }
187 $this->form->addCommandButton('update',$this->lng->txt('save'));
188 // $this->form->addCommandButton('askDelete',$this->lng->txt('delete'));
189 $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
190 break;
191 }
192 // title
193 $title = new ilTextInputGUI($this->lng->txt('title'),'title');
194 $title->setValue($this->app->getTitle());
195 $title->setRequired(true);
196 $title->setMaxLength(128);
197 $title->setSize(32);
198 $this->form->addItem($title);
199
200 // calendar selection
201 $calendar = new ilSelectInputGUI($this->lng->txt('cal_category_selection'),'calendar');
202 if($_POST['category'])
203 {
204 $calendar->setValue((int) $_POST['calendar']);
205 $selected_calendar = (int) $_POST['calendar'];
206 }
207 else if($_GET['category_id'])
208 {
209 $calendar->setValue((int) $_GET['category_id']);
210 $selected_calendar = (int) $_GET['category_id'];
211 }
212 elseif($a_mode == 'edit')
213 {
214 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
215 $cat = $ass->getFirstAssignment();
216 $calendar->setValue($cat);
217 $selected_calendar = $cat;
218 }
219 elseif(isset($_GET['ref_id']))
220 {
221 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
222 $obj_cal = ilObject::_lookupObjId($_GET['ref_id']);
223 $calendar->setValue(ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal));
224 $selected_calendar = ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal);
225 }
226 $calendar->setRequired(true);
228 $calendar->setOptions($cats->prepareCategoriesOfUserForSelection());
229
230 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
231 if(ilCalendarSettings::_getInstance()->isNotificationEnabled())
232 {
233 $notification_cals = $cats->getNotificationCalendars();
234 $notification_cals = count($notification_cals) ? implode(',',$notification_cals) : '';
235 $calendar->addCustomAttribute("onchange=\"ilToggleNotification(new Array(".$notification_cals."));\"");
236 }
237 $this->form->addItem($calendar);
238
239 if (!$a_as_milestone)
240 {
241 include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
242 $tpl->addJavaScript('./Services/Form/js/date_duration.js');
243 $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'),'event');
244 $dur->setStartText($this->lng->txt('cal_start'));
245 $dur->setEndText($this->lng->txt('cal_end'));
246 $dur->enableToggleFullTime(
247 $this->lng->txt('cal_fullday_title'),
248 $this->app->isFullday() ? true : false
249 );
250 $dur->setShowTime(true);
251 $dur->setStart($this->app->getStart());
252 $dur->setEnd($this->app->getEnd());
253 $this->form->addItem($dur);
254
255 // recurrence
256 include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
257 $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'),'frequence');
258 $rec->setRecurrence($this->rec);
259 $this->form->addItem($rec);
260
261 // location
262 $where = new ilTextInputGUI($this->lng->txt('cal_where'),'location');
263 $where->setValue($this->app->getLocation());
264 $where->setMaxLength(128);
265 $where->setSize(32);
266 $this->form->addItem($where);
267 }
268 else
269 {
270 $deadline = new ilDateTimeInputGUI($this->lng->txt('cal_deadline'),'event[start]');
271 $deadline->setDate($this->app->getStart());
272 $deadline->setShowTime(false);
273 $deadline->setMinuteStepSize(5);
274 $this->form->addItem($deadline);
275
276 // completion
277 $completion_vals = array();
278 for($i = 0; $i <= 100; $i+=5)
279 {
280 $completion_vals[$i] = $i." %";
281 }
282 $compl = new ilSelectInputGUI($this->lng->txt('cal_task_completion'),
283 'completion');
284 $compl->setOptions($completion_vals);
285 $compl->setValue($this->app->getCompletion());
286 $this->form->addItem($compl);
287 }
288
289 $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
290 $desc->setValue($this->app->getDescription());
291 $desc->setRows(5);
292 $this->form->addItem($desc);
293
294 if ($a_as_milestone && $a_mode == "edit" && $resp_info)
295 {
296 // users responsible
297 $users = $this->app->readResponsibleUsers();
298 $resp = new ilNonEditableValueGUI($this->lng->txt('cal_responsible'),
299 $users);
300 $delim = "";
301 foreach($users as $r)
302 {
303 $value.= $delim.$r["lastname"].", ".$r["firstname"]." [".$r["login"]."]";
304 $delim = "<br />";
305 }
306 if (count($users) > 0)
307 {
308 $resp->setValue($value);
309 }
310 else
311 {
312 $resp->setValue("-");
313 }
314
315 $this->form->addItem($resp);
316 }
317
318
319 if(ilCalendarSettings::_getInstance()->isUserNotificationEnabled())
320 {
321 $notu = new ilTextWizardInputGUI($this->lng->txt('cal_user_notification'), 'notu');
322 $notu->setInfo($this->lng->txt('cal_user_notification_info'));
323 $notu->setSize(20);
324 $notu->setMaxLength(64);
325
326 $values = array();
327 foreach($this->notification->getRecipients() as $rcp)
328 {
329 switch ($rcp['type'])
330 {
332 $values[] = ilObjUser::_lookupLogin($rcp['usr_id']);
333 break;
334
336 $values[] = $rcp['email'];
337 break;
338 }
339 }
340 if(count($values))
341 $notu->setValues($values);
342 else
343 $notu->setValues(array(''));
344 $this->form->addItem($notu);
345 }
346
347 // Notifications
348 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
349 if(ilCalendarSettings::_getInstance()->isNotificationEnabled() and count($cats->getNotificationCalendars()))
350 {
351 $selected_cal = new ilCalendarCategory($selected_calendar);
352 $disabled = true;
353 if($selected_cal->getType() == ilCalendarCategory::TYPE_OBJ)
354 {
355 if(ilObject::_lookupType($selected_cal->getObjId()) == 'crs' or ilObject::_lookupType($selected_cal->getObjId()) == 'grp')
356 {
357 $disabled = false;
358 }
359 }
360
361 $tpl->addJavaScript('./Services/Calendar/js/toggle_notification.js');
362 $not = new ilCheckboxInputGUI($this->lng->txt('cal_cg_notification'),'not');
363 $not->setInfo($this->lng->txt('cal_notification_info'));
364 $not->setValue(1);
365 $not->setChecked($this->app->isNotificationEnabled());
366 $not->setDisabled($disabled);
367 $this->form->addItem($not);
368 }
369 }
370
371
378 protected function add()
379 {
380 global $tpl, $ilHelp;
381
382 $ilHelp->setScreenIdComponent("cal");
383 $ilHelp->setScreenId("app");
384 $ilHelp->setSubScreenId("create");
385
386 $this->initForm('create');
387 $tpl->setContent($this->form->getHTML());
388 }
389
396 protected function addMilestone()
397 {
398 global $tpl, $ilHelp;
399
400 $ilHelp->setScreenIdComponent("cal");
401 $ilHelp->setScreenId("app");
402 $ilHelp->setSubScreenId("create_milestone");
403
404 $this->initForm('create', true);
405 $tpl->setContent($this->form->getHTML());
406 }
407
413 protected function saveMilestone()
414 {
415 $this->save(true);
416 }
417
423 protected function save($a_as_milestone = false)
424 {
425 global $ilErr;
426
427 $this->load($a_as_milestone);
428
429 if($this->app->validate() and $this->notification->validate())
430 {
431 if(!(int) $_POST['calendar'])
432 {
433 $cat_id = $this->createDefaultCalendar();
434 }
435 else
436 {
437 $cat_id = (int) $_POST['calendar'];
438 }
439
440 $this->app->save();
441 $this->notification->setEntryId($this->app->getEntryId());
442 $this->notification->save();
443 $this->rec->setEntryId($this->app->getEntryId());
444 $this->saveRecurrenceSettings();
445
446 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
447 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
448 $ass->addAssignment($cat_id);
449
450 // Send notifications
451 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
452 if(ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not'])
453 {
454 $this->distributeNotifications($cat_id,$this->app->getEntryId(),true);
455 }
456 if(ilCalendarSettings::_getInstance()->isUserNotificationEnabled())
457 {
459 }
460
461 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
462 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
463 $type = ilObject::_lookupType($cat_info['obj_id']);
464
465 if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
466 && ($type == "grp" || $type == "crs"))
467 {
468 ilUtil::sendSuccess($this->lng->txt('cal_created_milestone_resp_q'),true);
469 return $this->showResponsibleUsersList($cat_info['obj_id']);
470 }
471 elseif($a_as_milestone)
472 {
473 ilUtil::sendSuccess($this->lng->txt('cal_created_milestone'),true);
474 $this->ctrl->returnToParent($this);
475 }
476 else
477 {
478 ilUtil::sendSuccess($this->lng->txt('cal_created_appointment'),true);
479 $this->ctrl->returnToParent($this);
480 }
481 }
482 else
483 {
484 ilUtil::sendFailure($ilErr->getMessage());
485 }
486 if ($a_as_milestone)
487 {
488 $this->addMilestone();
489 }
490 else
491 {
492 $this->add();
493 }
494 }
495
500 protected function distributeUserNotifications()
501 {
502 global $ilUser;
503
504 include_once './Services/Calendar/classes/class.ilCalendarMailNotification.php';
505 $notification = new ilCalendarMailNotification();
506 $notification->setAppointmentId($this->app->getEntryId());
507
508 foreach($this->notification->getRecipients() as $rcp)
509 {
510 switch($rcp['type'])
511 {
513 $notification->setSender(ANONYMOUS_USER_ID);
514 $notification->setRecipients(array($rcp['usr_id']));
515 $notification->setType(ilCalendarMailNotification::TYPE_USER);
516 break;
517
519 $notification->setSender(ANONYMOUS_USER_ID);
520 $notification->setRecipients(array($rcp['email']));
522 break;
523 }
524 $notification->send();
525 }
526 }
527
528
533 protected function distributeNotifications($a_cat_id, $app_id, $a_new_appointment = true)
534 {
535 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
536 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($a_cat_id);
537
538 include_once './Services/Calendar/classes/class.ilCalendarMailNotification.php';
539 $notification = new ilCalendarMailNotification();
540 $notification->setAppointmentId($app_id);
541
542 switch($cat_info['type'])
543 {
545
546 switch($cat_info['obj_type'])
547 {
548 case 'crs':
549 $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
550 $ref_id = current($ref_ids);
551 $notification->setRefId($ref_id);
552 $notification->setType(
553 $a_new_appointment ?
556 break;
557
558 case 'grp':
559 $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
560 $ref_id = current($ref_ids);
561 $notification->setRefId($ref_id);
562 $notification->setType(
563 $a_new_appointment ?
566 break;
567 }
568 break;
569 }
570
571 $notification->send();
572 }
573
578 {
579 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
580 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
581 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
582 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
583
584 $this->showResponsibleUsersList($cat_info['obj_id']);
585 }
586
591 function showResponsibleUsersList($a_grp_id)
592 {
593 global $tpl;
594
595 include_once("./Services/Calendar/classes/class.ilMilestoneResponsiblesTableGUI.php");
596 $table_gui = new ilMilestoneResponsiblesTableGUI($this, "", $a_grp_id,
597 $this->app->getEntryId());
598 $tpl->setContent($table_gui->getHTML());
599 }
600
605 {
606 global $ilCtrl;
607
608 $this->app->writeResponsibleUsers($_POST["user_id"]);
609 $ilCtrl->returnToParent($this);
610 }
611
616 protected function askEdit()
617 {
618 // check for recurring entries
619 include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
621 if(!$rec)
622 {
623 return $this->edit(TRUE);
624 }
625 // Show edit single/all appointments
626 $this->ctrl->saveParameter($this,array('seed','app_id','dt','idate'));
627
628 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
629 $confirm = new ilConfirmationGUI();
630 $confirm->setFormAction($this->ctrl->getFormAction($this));
631 #$confirm->setHeaderText($this->lng->txt('cal_edit_app_sure'));
632 $confirm->setCancel($this->lng->txt('cancel'),'cancel');
633 $confirm->addItem('appointments[]',$this->app->getEntryId(),$this->app->getTitle());
634 $confirm->addButton($this->lng->txt('cal_edit_single'),'editSingle');
635 $confirm->setConfirm($this->lng->txt('cal_edit_recurrences'),'edit');
636
637 $GLOBALS['tpl']->setContent($confirm->getHTML());
638 }
639
643 protected function editSingle()
644 {
645 $_REQUEST['rexl'] = 1;
646 $GLOBALS['ilCtrl']->setParameter($this,'rexcl',1);
647 $this->edit(true);
648 }
649
657 protected function edit($a_edit_single_app = false)
658 {
659 global $tpl,$ilUser,$ilErr, $ilHelp;
660
661 $ilHelp->setScreenIdComponent("cal");
662 $ilHelp->setScreenId("app");
663 if ($this->app->isMilestone())
664 {
665 $ilHelp->setSubScreenId("edit_milestone");
666 }
667 else
668 {
669 $ilHelp->setSubScreenId("edit");
670 }
671
672 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
673 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
674 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
675
676 $GLOBALS['ilCtrl']->saveParameter($this,array('seed','app_id','dt','idate'));
677
678 if($_REQUEST['rexl'])
679 {
680 $GLOBALS['ilCtrl']->setParameter($this,'rexl',1);
681
682 // Calculate new appointment time
683 $duration = $this->getAppointment()->getEnd()->get(IL_CAL_UNIX) - $this->getAppointment()->getStart()->get(IL_CAL_UNIX);
684 include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php';
685 $calc = new ilCalendarRecurrenceCalculator($this->getAppointment(), $this->rec);
686
687 $current_date = new ilDateTime($_REQUEST['dt'],IL_CAL_UNIX);
688
689 $yesterday = clone $current_date;
690 $yesterday->increment(IL_CAL_DAY,-1);
691 $tomorrow = clone $current_date;
692 $tomorrow->increment(IL_CAL_DAY, 1);
693
694
695 foreach($calc->calculateDateList($current_date, $tomorrow, 1) as $date_entry)
696 {
697 if(ilDateTime::_equals($current_date, $date_entry,IL_CAL_DAY))
698 {
699 $this->getAppointment()->setStart(new ilDateTime($date_entry->get(IL_CAL_UNIX),IL_CAL_UNIX));
700 $this->getAppointment()->setEnd(new ilDateTime($date_entry->get(IL_CAL_UNIX) + $duration,IL_CAL_UNIX));
701 break;
702 }
703 }
704
705 // Finally reset recurrence
706 $this->rec = new ilCalendarRecurrence();
707 }
708
709 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
711
712 if(!$cats->isVisible($cat_id))
713 {
714 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
715 return false;
716 }
717 if(!$cats->isEditable($cat_id) or $this->app->isAutoGenerated())
718 {
719 $this->showInfoScreen();
720 return true;
721 }
722
723 $this->initForm('edit', $this->app->isMilestone(), $a_edit_single_app);
724 $tpl->setContent($this->form->getHTML());
725 }
726
733 protected function showInfoScreen()
734 {
735 global $tpl,$ilUser;
736
737 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
738 $info = new ilInfoScreenGUI($this);
739 $info->setFormAction($this->ctrl->getFormAction($this));
740
741 if ($this->app->isMilestone())
742 {
743 $info->addSection($this->lng->txt('cal_ms_details'));
744 }
745 else
746 {
747 $info->addSection($this->lng->txt('cal_details'));
748 }
749
750 // Appointment
751 $info->addProperty($this->lng->txt('appointment'),
753 $this->app->getStart(),
754 $this->app->getEnd()));
755 $info->addProperty($this->lng->txt('title'),$this->app->getPresentationTitle());
756
757 // Description
758 if(strlen($desc = $this->app->getDescription()))
759 {
760 $info->addProperty($this->lng->txt('description'),ilUtil::makeClickable(nl2br($desc)));
761 }
762
763 // Location
764 if(strlen($loc = $this->app->getLocation()))
765 {
766 $info->addProperty($this->lng->txt('cal_where'),$loc);
767 }
768
769 // completion
770 if ($this->app->isMilestone() && $this->app->getCompletion() > 0)
771 {
772 $info->addProperty($this->lng->txt('cal_task_completion'),
773 $this->app->getCompletion()." %");
774 }
775
776 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
777 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
778 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
779 $type = ilObject::_lookupType($cat_info['obj_id']);
780 if ($this->app->isMilestone() && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
781 && ($type == "grp" || $type == "crs"))
782 {
783 // users responsible
784 $users = $this->app->readResponsibleUsers();
785 $delim = "";
786 foreach($users as $r)
787 {
788 $value.= $delim.$r["lastname"].", ".$r["firstname"]." [".$r["login"]."]";
789 $delim = "<br />";
790 }
791 if (count($users) > 0)
792 {
793 $info->addProperty($this->lng->txt('cal_responsible'),
794 $value);
795 }
796 }
797
798 $category = new ilCalendarCategory($cat_id);
799
800 if($category->getType() == ilCalendarCategory::TYPE_OBJ)
801 {
802 $info->addSection($this->lng->txt('additional_info'));
803
804 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
805 $refs = ilObject::_getAllReferences($cat_info['obj_id']);
806
807 include_once('./Services/Link/classes/class.ilLink.php');
808 $href = ilLink::_getStaticLink(current($refs),ilObject::_lookupType($cat_info['obj_id']),true);
809 $info->addProperty($this->lng->txt('perma_link'),'<a class="small" href="'.$href.'" target="_top">'.$href.'</a>');
810 }
811
812 $tpl->setContent($info->getHTML());
813 }
814
821 protected function update()
822 {
823 global $ilErr;
824
825 $single_editing = ($_REQUEST['rexl'] ? true : false);
826
827 $this->load($this->app->isMilestone());
828
829 if($this->app->validate() and $this->notification->validate())
830 {
831 if(!(int) $_POST['calendar'])
832 {
833 $cat_id = $this->createDefaultCalendar();
834 }
835 else
836 {
837 $cat_id = (int) $_POST['calendar'];
838 }
839
840 if($single_editing)
841 {
842 $this->getAppointment()->save();
843 $this->deleteExclude(false);
844
845 $this->rec = new ilCalendarRecurrence();
846 $this->rec->setEntryId($this->getAppointment()->getEntryId());
847 }
848 else
849 {
850 $this->getAppointment()->update();
851 }
852 $this->notification->save();
853 $this->saveRecurrenceSettings();
854
855 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
856 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
857 $GLOBALS['ilLog']->write($this->app->getEntryId());
858 $ass->deleteAssignments();
859 $ass->addAssignment($cat_id);
860
861 // Send notifications
862 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
863 if(ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not'])
864 {
865 $this->distributeNotifications($cat_id,$this->app->getEntryId(),false);
866 }
867 if(ilCalendarSettings::_getInstance()->isUserNotificationEnabled())
868 {
870 }
871
872 ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
873 $this->ctrl->returnToParent($this);
874 }
875 else
876 {
877 ilUtil::sendFailure($ilErr->getMessage());
878 }
879
880 $this->edit();
881
882 }
883
890 protected function askDelete()
891 {
892 global $tpl;
893
894 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
895
896 $this->ctrl->saveParameter($this,array('seed','app_id','dt','idate'));
897
898 $confirm = new ilConfirmationGUI();
899 $confirm->setFormAction($this->ctrl->getFormAction($this));
900 $confirm->setHeaderText($this->lng->txt('cal_delete_app_sure'));
901 $confirm->setCancel($this->lng->txt('cancel'),'cancel');
902 $confirm->addItem('appointments[]',$this->app->getEntryId(),$this->app->getTitle());
903
904 include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
906 && !$this->app->isMilestone())
907 {
908 $confirm->addButton($this->lng->txt('cal_delete_single'),'deleteexclude');
909 $confirm->setConfirm($this->lng->txt('cal_delete_recurrences'),'delete');
910 }
911 else
912 {
913 $confirm->setConfirm($this->lng->txt('delete'),'delete');
914 }
915
916 $tpl->setContent($confirm->getHTML());
917
918 }
919
927 protected function delete()
928 {
929 foreach($_POST['appointments'] as $app_id)
930 {
931 $app = new ilCalendarEntry($app_id);
932 $app->delete();
933
934 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
936
937 include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
939 }
940 ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'),true);
941 $this->ctrl->returnToParent($this);
942 }
943
951 protected function deleteExclude($a_return = true)
952 {
953 include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceExclusion.php');
954 $excl = new ilCalendarRecurrenceExclusion();
955 $excl->setEntryId($_REQUEST['app_id']);
956 $excl->setDate(new ilDate($_REQUEST['dt'], IL_CAL_UNIX));
957 $excl->save();
958
959 if($a_return)
960 {
961 ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'),true);
962 $this->ctrl->returnToParent($this);
963 }
964 }
965
973 protected function initTimeZone()
974 {
975 global $ilUser;
976
977 $this->timezone = $ilUser->getTimeZone();
978 }
979
985 {
986 if(!isset($_GET['hour']))
987 {
988 $this->initialDate = clone $initialDate;
989 $this->default_fulltime = true;
990 }
991 else
992 {
993 if((int) $_GET['hour'] < 10)
994 {
995 $time = '0'.(int) $_GET['hour'].':00:00';
996 }
997 else
998 {
999 $time = (int) $_GET['hour'].':00:00';
1000 }
1001 $this->initialDate = new ilDateTime($initialDate->get(IL_CAL_DATE).' '.$time,IL_CAL_DATETIME,$this->timezone);
1002 $this->default_fulltime = false;
1003 }
1004 }
1005
1013 protected function initSeed(ilDate $seed)
1014 {
1015 $this->seed = clone $seed;
1016 $this->default_fulltime = true;
1017 }
1018
1026 protected function initAppointment($a_app_id = 0)
1027 {
1028 include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
1029 include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
1030 $this->app = new ilCalendarEntry($a_app_id);
1031
1032 include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
1033 $this->notification = new ilCalendarUserNotification($this->app->getEntryId());
1034
1035 if(!$a_app_id)
1036 {
1037 $start = clone $this->initialDate;
1038 $this->app->setStart($start);
1039
1040 $seed_end = clone $this->initialDate;
1041 if($this->default_fulltime)
1042 {
1043 #$seed_end->increment(IL_CAL_DAY,1);
1044 }
1045 else
1046 {
1047 $seed_end->increment(IL_CAL_HOUR,1);
1048 }
1049 $this->app->setEnd($seed_end);
1050 $this->app->setFullday($this->default_fulltime);
1051
1052 $this->rec = new ilCalendarRecurrence();
1053 }
1054 else
1055 {
1056 $this->rec = ilCalendarRecurrences::_getFirstRecurrence($this->app->getEntryId());
1057 }
1058
1059 }
1060
1068 protected function load($a_as_milestone = false)
1069 {
1070 if ($a_as_milestone)
1071 {
1072 $this->app->setMilestone(true);
1073 $this->app->setCompletion(ilUtil::stripSlashes($_POST['completion']));
1074 }
1075
1076 $this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
1077 $this->app->setLocation(ilUtil::stripSlashes($_POST['location']));
1078 $this->app->setDescription(ilUtil::stripSlashes($_POST['description']));
1079 $this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
1080 $this->app->enableNotification((int) $_POST['not']);
1081 if ($a_as_milestone) // milestones are always fullday events
1082 {
1083 $this->app->setFullday(true);
1084 }
1085 else
1086 {
1087 $this->app->setFullday(isset($_POST['event']['fulltime']) ? true : false);
1088 }
1089
1090 if($this->app->isFullday())
1091 {
1092 $start = new ilDate($_POST['event']['start']['date']['y'].'-'.$_POST['event']['start']['date']['m'].'-'.$_POST['event']['start']['date']['d'],
1093 IL_CAL_DATE);
1094 $this->app->setStart($start);
1095
1096 $end = new ilDate($_POST['event']['end']['date']['y'].'-'.$_POST['event']['end']['date']['m'].'-'.$_POST['event']['end']['date']['d'],
1097 IL_CAL_DATE);
1098
1099 if ($a_as_milestone)
1100 {
1101 // for milestones is end date = start date
1102 $this->app->setEnd($start);
1103 }
1104 else
1105 {
1106 $this->app->setEnd($end);
1107 }
1108 }
1109 else
1110 {
1111 $start_dt['year'] = (int) $_POST['event']['start']['date']['y'];
1112 $start_dt['mon'] = (int) $_POST['event']['start']['date']['m'];
1113 $start_dt['mday'] = (int) $_POST['event']['start']['date']['d'];
1114 $start_dt['hours'] = (int) $_POST['event']['start']['time']['h'];
1115 $start_dt['minutes'] = (int) $_POST['event']['start']['time']['m'];
1116 $start = new ilDateTime($start_dt,IL_CAL_FKT_GETDATE,$this->timezone);
1117 $this->app->setStart($start);
1118
1119 $end_dt['year'] = (int) $_POST['event']['end']['date']['y'];
1120 $end_dt['mon'] = (int) $_POST['event']['end']['date']['m'];
1121 $end_dt['mday'] = (int) $_POST['event']['end']['date']['d'];
1122 $end_dt['hours'] = (int) $_POST['event']['end']['time']['h'];
1123 $end_dt['minutes'] = (int) $_POST['event']['end']['time']['m'];
1124 $end = new ilDateTime($end_dt,IL_CAL_FKT_GETDATE,$this->timezone);
1125 $this->app->setEnd($end);
1126 }
1128 $this->loadRecurrenceSettings($a_as_milestone = false);
1129 }
1130
1131 protected function loadNotificationRecipients()
1132 {
1133 $this->notification->setRecipients(array());
1134
1135 foreach((array) $_POST['notu'] as $rcp)
1136 {
1137 $rcp = trim(ilUtil::stripSlashes($rcp));
1138 $usr_id = ilObjUser::_loginExists($rcp);
1139
1140 if(strlen($rcp) == 0)
1141 {
1142 continue;
1143 }
1144
1145 if($usr_id)
1146 {
1147 $this->notification->addRecipient(
1149 $usr_id
1150 );
1151 }
1152 else
1153 {
1154 $this->notification->addRecipient(
1156 0,
1157 $rcp
1158 );
1159 }
1160 }
1161 }
1162
1169 protected function loadRecurrenceSettings($a_as_milestone = false)
1170 {
1171 $this->rec->reset();
1172
1173 switch($_POST['frequence'])
1174 {
1175 case IL_CAL_FREQ_DAILY:
1176 $this->rec->setFrequenceType($_POST['frequence']);
1177 $this->rec->setInterval((int) $_POST['count_DAILY']);
1178 break;
1179
1180 case IL_CAL_FREQ_WEEKLY:
1181 $this->rec->setFrequenceType($_POST['frequence']);
1182 $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1183 if(is_array($_POST['byday_WEEKLY']))
1184 {
1185 $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',',$_POST['byday_WEEKLY'])));
1186 }
1187 break;
1188
1190 $this->rec->setFrequenceType($_POST['frequence']);
1191 $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1192 switch((int) $_POST['subtype_MONTHLY'])
1193 {
1194 case 0:
1195 // nothing to do;
1196 break;
1197
1198 case 1:
1199 switch((int) $_POST['monthly_byday_day'])
1200 {
1201 case 8:
1202 // Weekday
1203 $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1204 $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1205 break;
1206
1207 case 9:
1208 // Day of month
1209 $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1210 break;
1211
1212 default:
1213 $this->rec->setBYDAY((int) $_POST['monthly_byday_num'].$_POST['monthly_byday_day']);
1214 break;
1215 }
1216 break;
1217
1218 case 2:
1219 $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1220 break;
1221 }
1222 break;
1223
1224 case IL_CAL_FREQ_YEARLY:
1225 $this->rec->setFrequenceType($_POST['frequence']);
1226 $this->rec->setInterval((int) $_POST['count_YEARLY']);
1227 switch((int) $_POST['subtype_YEARLY'])
1228 {
1229 case 0:
1230 // nothing to do;
1231 break;
1232
1233 case 1:
1234 $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1235 $this->rec->setBYDAY((int) $_POST['yearly_byday_num'].$_POST['yearly_byday']);
1236 break;
1237
1238 case 2:
1239 $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1240 $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1241 break;
1242 }
1243 break;
1244 }
1245
1246 // UNTIL
1247 switch((int) $_POST['until_type'])
1248 {
1249 case 1:
1250 $this->rec->setFrequenceUntilDate(null);
1251 // nothing to do
1252 break;
1253
1254 case 2:
1255 $this->rec->setFrequenceUntilDate(null);
1256 $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1257 break;
1258
1259 case 3:
1260 $end_dt['year'] = (int) $_POST['until_end']['date']['y'];
1261 $end_dt['mon'] = (int) $_POST['until_end']['date']['m'];
1262 $end_dt['mday'] = (int) $_POST['until_end']['date']['d'];
1263
1264 $this->rec->setFrequenceUntilCount(0);
1265 $this->rec->setFrequenceUntilDate(new ilDate($end_dt,IL_CAL_FKT_GETDATE,$this->timezone));
1266 break;
1267 }
1268
1269 }
1270
1278 protected function saveRecurrenceSettings()
1279 {
1280 switch($_POST['frequence'])
1281 {
1282 case 'NONE':
1283 case '':
1284 // No recurrence => delete if there is an recurrence rule
1285 if($this->rec->getRecurrenceId())
1286 {
1287 $this->rec->delete();
1288 }
1289 break;
1290
1291 default:
1292 if($this->rec->getRecurrenceId())
1293 {
1294 $this->rec->update();
1295 }
1296 else
1297 {
1298 $this->rec->save();
1299 }
1300 break;
1301 }
1302 }
1303
1310 protected function createDefaultCalendar()
1311 {
1312 global $ilUser,$lng;
1313
1314 $cat = new ilCalendarCategory();
1315 $cat->setColor(ilCalendarCategory::DEFAULT_COLOR);
1316 $cat->setType(ilCalendarCategory::TYPE_USR);
1317 $cat->setTitle($this->lng->txt('cal_default_calendar'));
1318 $cat->setObjId($ilUser->getId());
1319
1320 // delete calendar cache
1321 include_once './Services/Calendar/classes/class.ilCalendarCache.php';
1322 ilCalendarCache::getInstance()->deleteUserEntries($ilUser->getId());
1323
1324 return $cat->add();
1325 }
1326
1331 protected function confirmRegister()
1332 {
1333 global $tpl;
1334
1335 $entry = new ilCalendarEntry((int) $_GET['app_id']);
1337 new ilDateTime($_GET['dstart'],IL_CAL_UNIX),
1338 new ilDateTime($_GET['dend'],IL_CAL_UNIX)
1339 );
1340
1341
1342 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1343 $conf = new ilConfirmationGUI;
1344
1345 $this->ctrl->setParameter($this,'dstart',(int) $_REQUEST['dstart']);
1346 $this->ctrl->setParameter($this,'dend',(int) $_REQUEST['dend']);
1347
1348 $conf->setFormAction($this->ctrl->getFormAction($this));
1349 $conf->setHeaderText($this->lng->txt('cal_confirm_reg_info'));
1350 $conf->setConfirm($this->lng->txt('cal_reg_register'), 'register');
1351 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1352 $conf->addItem('app_id', $entry->getEntryId(), $entry->getTitle().' ('.$start.')');
1353
1354 $tpl->setContent($conf->getHTML());
1355 }
1356
1361 protected function register()
1362 {
1363 global $ilUser;
1364
1365 include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
1366 $reg = new ilCalendarRegistration((int) $_POST['app_id']);
1367 $reg->register(
1368 $ilUser->getId(),
1369 new ilDateTime((int) $_REQUEST['dstart'],IL_CAL_UNIX),
1370 new ilDateTime((int) $_REQUEST['dend'],IL_CAL_UNIX)
1371 );
1372
1373 ilUtil::sendSuccess($this->lng->txt('cal_reg_registered'),true);
1374 $this->ctrl->returnToParent($this);
1375 }
1376
1380 public function confirmUnregister()
1381 {
1382 global $tpl;
1383
1384
1385 $entry = new ilCalendarEntry((int) $_GET['app_id']);
1387 $dstart = new ilDateTime($_GET['dstart'],IL_CAL_UNIX),
1388 $dend = new ilDateTime($_GET['dend'],IL_CAL_UNIX)
1389 );
1390
1391
1392 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1393 $conf = new ilConfirmationGUI;
1394
1395 $this->ctrl->setParameter($this,'dstart',(int) $_REQUEST['dstart']);
1396 $this->ctrl->setParameter($this,'dend',(int) $_REQUEST['dend']);
1397
1398 $conf->setFormAction($this->ctrl->getFormAction($this));
1399 $conf->setHeaderText($this->lng->txt('cal_confirm_unreg_info'));
1400 $conf->setConfirm($this->lng->txt('cal_reg_unregister'), 'unregister');
1401 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1402 $conf->addItem('app_id', $entry->getEntryId(), $entry->getTitle().' ('.$start.')');
1403
1404 $tpl->setContent($conf->getHTML());
1405 }
1406
1411 protected function unregister()
1412 {
1413 global $ilUser;
1414
1415 include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
1416 $reg = new ilCalendarRegistration((int) $_POST['app_id']);
1417 $reg->unregister(
1418 $ilUser->getId(),
1419 new ilDateTime((int) $_REQUEST['dstart'],IL_CAL_UNIX),
1420 new ilDateTime((int) $_REQUEST['dend'],IL_CAL_UNIX)
1421 );
1422
1423 ilUtil::sendSuccess($this->lng->txt('cal_reg_unregistered'),true);
1424 $this->ctrl->returnToParent($this);
1425 }
1426
1430 public function book()
1431 {
1432 global $ilUser, $tpl;
1433
1434 $entry = (int)$_GET['app_id'];
1435 $user = (int)$_GET['bkid'];
1436
1437 $this->ctrl->saveParameter($this,'app_id');
1438
1439 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1440 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1441 $entry = new ilCalendarEntry($entry);
1442
1443 $form = $this->initFormConfirmBooking();
1444 $form->getItemByPostVar('date')->setValue(ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd()));
1445 $form->getItemByPostVar('title')->setValue($entry->getTitle()." (".ilObjUser::_lookupFullname($user).')');
1446
1447 $tpl->setContent($form->getHTML());
1448 return true;
1449 }
1450
1455 protected function initFormConfirmBooking()
1456 {
1457 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1458 $form = new ilPropertyFormGUI();
1459 $form->setFormAction($this->ctrl->getFormAction($this));
1460 $form->addCommandButton('bookconfirmed',$this->lng->txt('cal_confirm_booking'));
1461 $form->addCommandButton('cancel',$this->lng->txt('cancel'));
1462
1463 $date = new ilNonEditableValueGUI($this->lng->txt('appointment'),'date');
1464 $form->addItem($date);
1465
1466 $title = new ilNonEditableValueGUI($this->lng->txt('title'),'title');
1467 $form->addItem($title);
1468
1469 $message = new ilTextAreaInputGUI($this->lng->txt('cal_ch_booking_message_tbl'), 'comment');
1470 $message->setRows(5);
1471 $form->addItem($message);
1472
1473 return $form;
1474 }
1475
1479 public function bookconfirmed()
1480 {
1481 global $ilUser;
1482
1483 $entry = (int) $_REQUEST['app_id'];
1484 $user = (int) $_REQUEST['bkid'];
1485
1486 $form = $this->initFormConfirmBooking();
1487 if($form->checkInput())
1488 {
1489 // check if appointment is bookable
1490 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
1491 $cal_entry = new ilCalendarEntry($entry);
1492
1493 include_once './Services/Booking/classes/class.ilBookingEntry.php';
1494 $booking = new ilBookingEntry($cal_entry->getContextId());
1495
1496 if(!$booking->isAppointmentBookableForUser($entry, $GLOBALS['ilUser']->getId()))
1497 {
1498 ilUtil::sendFailure($this->lng->txt('cal_booking_failed_info'), true);
1499 $this->ctrl->returnToParent($this);
1500 }
1501
1502 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
1504
1505 include_once './Services/Booking/classes/class.ilBookingEntry.php';
1506 ilBookingEntry::writeBookingMessage($entry, $ilUser->getId(), $form->getInput('comment'));
1507 }
1508 ilUtil::sendSuccess($this->lng->txt('cal_booking_confirmed'),true);
1509 $this->ctrl->returnToParent($this);
1510 }
1511
1516 public function cancelBooking()
1517 {
1518 global $ilUser, $tpl;
1519
1520 $entry = (int)$_GET['app_id'];
1521
1522 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1523 $entry = new ilCalendarEntry($entry);
1524
1525 $category = $this->calendarEntryToCategory($entry);
1526 if($category->getType() == ilCalendarCategory::TYPE_CH)
1527 {
1528 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1529 $booking = new ilBookingEntry($entry->getContextId());
1530 if(!$booking->hasBooked($entry->getEntryId()))
1531 {
1532 $this->ctrl->returnToParent($this);
1533 return false;
1534 }
1535
1536 $entry_title = ' '.$entry->getTitle()." (".ilObjUser::_lookupFullname($booking->getObjId()).')';
1537 }
1538 else if($category->getType() == ilCalendarCategory::TYPE_BOOK)
1539 {
1540 $entry_title = ' '.$entry->getTitle();
1541 }
1542 else
1543 {
1544 $this->ctrl->returnToParent($this);
1545 return false;
1546 }
1547
1548 $title = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd());
1549
1550 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1551 $conf = new ilConfirmationGUI;
1552 $conf->setFormAction($this->ctrl->getFormAction($this));
1553 $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info'));
1554 $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed');
1555 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1556 $conf->addItem('app_id', $entry->getEntryId(), $title.' - '.$entry_title);
1557
1558 $tpl->setContent($conf->getHTML());
1559 }
1560
1565 public function cancelConfirmed()
1566 {
1567 global $ilUser;
1568
1569 $entry = (int)$_POST['app_id'];
1570 $user = (int)$_GET['bkid'];
1571
1572 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1573 $entry = new ilCalendarEntry($entry);
1574
1575 $category = $this->calendarEntryToCategory($entry);
1576 if($category->getType() == ilCalendarCategory::TYPE_CH)
1577 {
1578 // find cloned calendar entry in user calendar
1579 include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
1580 $GLOBALS['ilLog']->dump($entry->getStart());
1582 $ilUser->getId(),
1583 $entry->getContextId(),
1584 $entry->getStart(),
1586 false);
1587 $GLOBALS['ilLog']->dump($apps);
1588
1589 // Fix for wrong, old entries
1590 foreach((array) $apps as $own_app)
1591 {
1592 $ref_entry = new ilCalendarEntry($own_app);
1593 $ref_entry->delete();
1594 }
1595
1596 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1597 $booking = new ilBookingEntry($entry->getContextId());
1598 $booking->cancelBooking($entry->getEntryId());
1599
1600 // do NOT delete original entry
1601 }
1602 else if($category->getType() == ilCalendarCategory::TYPE_BOOK)
1603 {
1604 include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
1605 $booking = new ilBookingReservation($entry->getContextId());
1606 $booking->setStatus(ilBookingReservation::STATUS_CANCELLED);
1607 $booking->update();
1608
1609 $entry->delete();
1610 }
1611
1612 ilUtil::sendSuccess($this->lng->txt('cal_cancel_booking_confirmed'),true);
1613 $this->ctrl->returnToParent($this);
1614 }
1615
1621 protected function calendarEntryToCategory(ilCalendarEntry $entry)
1622 {
1623 include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
1624 include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
1625 $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
1626 $assignment = $assignment->getFirstAssignment();
1627 return new ilCalendarCategory($assignment);
1628 }
1629
1634 protected function doUserAutoComplete()
1635 {
1636 if(!isset($_GET['autoCompleteField']))
1637 {
1638 $a_fields = array('login','firstname','lastname','email');
1639 }
1640 else
1641 {
1642 $a_fields = array((string) $_GET['autoCompleteField']);
1643 }
1644
1645 $GLOBALS['ilLog']->write(print_r($a_fields,true));
1646 include_once './Services/User/classes/class.ilUserAutoComplete.php';
1647 $auto = new ilUserAutoComplete();
1648 $auto->setSearchFields($a_fields);
1649 $auto->enableFieldSearchableCheck(true);
1650 $auto->setMoreLinkAvailable(true);
1651
1652 if(($_REQUEST['fetchall']))
1653 {
1654 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
1655 }
1656
1657 echo $auto->getList($_REQUEST['query']);
1658 exit();
1659 }
1660
1661}
1662?>
$_GET["client_id"]
const IL_CAL_FREQ_YEARLY
const IL_CAL_FREQ_MONTHLY
const IL_CAL_FREQ_WEEKLY
const IL_CAL_FKT_GETDATE
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.
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
edit($a_edit_single_app=false)
edit appointment
createDefaultCalendar()
Create a default calendar.
load($a_as_milestone=false)
load post
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.
save($a_as_milestone=false)
save appointment
saveMilestoneResponsibleUsers()
Save milestone responsibilites.
getAppointment()
Get current 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.
getEntryId()
get entry id
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 formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
static formatDate(ilDateTime $date)
Format a date @access public.
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
_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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static initDomEvent()
Init YUI DomEvent.
$_POST['username']
Definition: cron.php:12
$r
Definition: example_031.php:79
$info
Definition: example_052.php:80
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilUser
Definition: imgupload.php:15