ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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->setRequired(true);
245 $dur->enableToggleFullTime(
246 $this->lng->txt('cal_fullday_title'),
247 $this->app->isFullday() ? true : false
248 );
249 $dur->setShowTime(true);
250 $dur->setStart($this->app->getStart());
251 $dur->setEnd($this->app->getEnd());
252 $this->form->addItem($dur);
253
254 // recurrence
255 include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
256 $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'),'frequence');
257 $rec->setRecurrence($this->rec);
258 $this->form->addItem($rec);
259
260 // location
261 $where = new ilTextInputGUI($this->lng->txt('cal_where'),'location');
262 $where->setValue($this->app->getLocation());
263 $where->setMaxLength(128);
264 $where->setSize(32);
265 $this->form->addItem($where);
266 }
267 else
268 {
269 $deadline = new ilDateTimeInputGUI($this->lng->txt('cal_deadline'),'event_start');
270 $deadline->setDate($this->app->getStart());
271 $deadline->setShowTime(false);
272 $deadline->setMinuteStepSize(5);
273 $this->form->addItem($deadline);
274
275 // completion
276 $completion_vals = array();
277 for($i = 0; $i <= 100; $i+=5)
278 {
279 $completion_vals[$i] = $i." %";
280 }
281 $compl = new ilSelectInputGUI($this->lng->txt('cal_task_completion'),
282 'completion');
283 $compl->setOptions($completion_vals);
284 $compl->setValue($this->app->getCompletion());
285 $this->form->addItem($compl);
286 }
287
288 $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
289 $desc->setValue($this->app->getDescription());
290 $desc->setRows(5);
291 $this->form->addItem($desc);
292
293 if ($a_as_milestone && $a_mode == "edit" && $resp_info)
294 {
295 // users responsible
296 $users = $this->app->readResponsibleUsers();
297 $resp = new ilNonEditableValueGUI($this->lng->txt('cal_responsible'), "", true);
298 $delim = "";
299 foreach($users as $r)
300 {
301 $value.= $delim.$r["lastname"].", ".$r["firstname"]." [".$r["login"]."]";
302 $delim = "<br />";
303 }
304 if (count($users) > 0)
305 {
306 $resp->setValue($value);
307 }
308 else
309 {
310 $resp->setValue("-");
311 }
312
313 $this->form->addItem($resp);
314 }
315
316
317 if(ilCalendarSettings::_getInstance()->isUserNotificationEnabled())
318 {
319 $notu = new ilTextWizardInputGUI($this->lng->txt('cal_user_notification'), 'notu');
320 $notu->setInfo($this->lng->txt('cal_user_notification_info'));
321 $notu->setSize(20);
322 $notu->setMaxLength(64);
323
324 $values = array();
325 foreach($this->notification->getRecipients() as $rcp)
326 {
327 switch ($rcp['type'])
328 {
330 $values[] = ilObjUser::_lookupLogin($rcp['usr_id']);
331 break;
332
334 $values[] = $rcp['email'];
335 break;
336 }
337 }
338 if(count($values))
339 $notu->setValues($values);
340 else
341 $notu->setValues(array(''));
342 $this->form->addItem($notu);
343 }
344
345 // Notifications
346 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
347 if(ilCalendarSettings::_getInstance()->isNotificationEnabled() and count($cats->getNotificationCalendars()))
348 {
349 $selected_cal = new ilCalendarCategory($selected_calendar);
350 $disabled = true;
351 if($selected_cal->getType() == ilCalendarCategory::TYPE_OBJ)
352 {
353 if(ilObject::_lookupType($selected_cal->getObjId()) == 'crs' or ilObject::_lookupType($selected_cal->getObjId()) == 'grp')
354 {
355 $disabled = false;
356 }
357 }
358
359 $tpl->addJavaScript('./Services/Calendar/js/toggle_notification.js');
360 $not = new ilCheckboxInputGUI($this->lng->txt('cal_cg_notification'),'not');
361 $not->setInfo($this->lng->txt('cal_notification_info'));
362 $not->setValue(1);
363 $not->setChecked($this->app->isNotificationEnabled());
364 $not->setDisabled($disabled);
365 $this->form->addItem($not);
366 }
367 }
368
369
376 protected function add()
377 {
378 global $tpl, $ilHelp;
379
380 $ilHelp->setScreenIdComponent("cal");
381 $ilHelp->setScreenId("app");
382 $ilHelp->setSubScreenId("create");
383
384 $this->initForm('create');
385 $tpl->setContent($this->form->getHTML());
386 }
387
394 protected function addMilestone()
395 {
396 global $tpl, $ilHelp;
397
398 $ilHelp->setScreenIdComponent("cal");
399 $ilHelp->setScreenId("app");
400 $ilHelp->setSubScreenId("create_milestone");
401
402 $this->initForm('create', true);
403 $tpl->setContent($this->form->getHTML());
404 }
405
411 protected function saveMilestone()
412 {
413 $this->save(true);
414 }
415
421 protected function save($a_as_milestone = false)
422 {
423 global $ilErr;
424
425 $this->load('create', $a_as_milestone);
426
427 if($this->app->validate() and $this->notification->validate())
428 {
429 if(!(int) $_POST['calendar'])
430 {
431 $cat_id = $this->createDefaultCalendar();
432 }
433 else
434 {
435 $cat_id = (int) $_POST['calendar'];
436 }
437
438 $this->app->save();
439 $this->notification->setEntryId($this->app->getEntryId());
440 $this->notification->save();
441 $this->rec->setEntryId($this->app->getEntryId());
442 $this->saveRecurrenceSettings();
443
444 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
445 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
446 $ass->addAssignment($cat_id);
447
448 // Send notifications
449 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
450 if(ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not'])
451 {
452 $this->distributeNotifications($cat_id,$this->app->getEntryId(),true);
453 }
454 if(ilCalendarSettings::_getInstance()->isUserNotificationEnabled())
455 {
457 }
458
459 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
460 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
461 $type = ilObject::_lookupType($cat_info['obj_id']);
462
463 if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
464 && ($type == "grp" || $type == "crs"))
465 {
466 ilUtil::sendSuccess($this->lng->txt('cal_created_milestone_resp_q'),true);
467 return $this->showResponsibleUsersList($cat_info['obj_id']);
468 }
469 elseif($a_as_milestone)
470 {
471 ilUtil::sendSuccess($this->lng->txt('cal_created_milestone'),true);
472 $this->ctrl->returnToParent($this);
473 }
474 else
475 {
476 ilUtil::sendSuccess($this->lng->txt('cal_created_appointment'),true);
477 $this->ctrl->returnToParent($this);
478 }
479 }
480 else
481 {
482 ilUtil::sendFailure($ilErr->getMessage());
483 }
484 if ($a_as_milestone)
485 {
486 $this->addMilestone();
487 }
488 else
489 {
490 $this->add();
491 }
492 }
493
498 protected function distributeUserNotifications()
499 {
500 global $ilUser;
501
502 include_once './Services/Calendar/classes/class.ilCalendarMailNotification.php';
503 $notification = new ilCalendarMailNotification();
504 $notification->setAppointmentId($this->app->getEntryId());
505
506 foreach($this->notification->getRecipients() as $rcp)
507 {
508 switch($rcp['type'])
509 {
511 $notification->setSender(ANONYMOUS_USER_ID);
512 $notification->setRecipients(array($rcp['usr_id']));
513 $notification->setType(ilCalendarMailNotification::TYPE_USER);
514 break;
515
517 $notification->setSender(ANONYMOUS_USER_ID);
518 $notification->setRecipients(array($rcp['email']));
520 break;
521 }
522 $notification->send();
523 }
524 }
525
526
531 protected function distributeNotifications($a_cat_id, $app_id, $a_new_appointment = true)
532 {
533 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
534 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($a_cat_id);
535
536 include_once './Services/Calendar/classes/class.ilCalendarMailNotification.php';
537 $notification = new ilCalendarMailNotification();
538 $notification->setAppointmentId($app_id);
539
540 switch($cat_info['type'])
541 {
543
544 switch($cat_info['obj_type'])
545 {
546 case 'crs':
547 $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
548 $ref_id = current($ref_ids);
549 $notification->setRefId($ref_id);
550 $notification->setType(
551 $a_new_appointment ?
554 break;
555
556 case 'grp':
557 $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
558 $ref_id = current($ref_ids);
559 $notification->setRefId($ref_id);
560 $notification->setType(
561 $a_new_appointment ?
564 break;
565 }
566 break;
567 }
568
569 $notification->send();
570 }
571
576 {
577 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
578 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
579 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
580 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
581
582 $this->showResponsibleUsersList($cat_info['obj_id']);
583 }
584
589 function showResponsibleUsersList($a_grp_id)
590 {
591 global $tpl;
592
593 include_once("./Services/Calendar/classes/class.ilMilestoneResponsiblesTableGUI.php");
594 $table_gui = new ilMilestoneResponsiblesTableGUI($this, "", $a_grp_id,
595 $this->app->getEntryId());
596 $tpl->setContent($table_gui->getHTML());
597 }
598
603 {
604 global $ilCtrl;
605
606 $this->app->writeResponsibleUsers($_POST["user_id"]);
607 $ilCtrl->returnToParent($this);
608 }
609
614 protected function askEdit()
615 {
616 // check for recurring entries
617 include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
619 if(!$rec)
620 {
621 return $this->edit(TRUE);
622 }
623 // Show edit single/all appointments
624 $this->ctrl->saveParameter($this,array('seed','app_id','dt','idate'));
625
626 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
627 $confirm = new ilConfirmationGUI();
628 $confirm->setFormAction($this->ctrl->getFormAction($this));
629 #$confirm->setHeaderText($this->lng->txt('cal_edit_app_sure'));
630 $confirm->setCancel($this->lng->txt('cancel'),'cancel');
631 $confirm->addItem('appointments[]',$this->app->getEntryId(),$this->app->getTitle());
632 $confirm->addButton($this->lng->txt('cal_edit_single'),'editSingle');
633 $confirm->setConfirm($this->lng->txt('cal_edit_recurrences'),'edit');
634
635 $GLOBALS['tpl']->setContent($confirm->getHTML());
636 }
637
641 protected function editSingle()
642 {
643 $_REQUEST['rexl'] = 1;
644 $GLOBALS['ilCtrl']->setParameter($this,'rexcl',1);
645 $this->edit(true);
646 }
647
655 protected function edit($a_edit_single_app = false)
656 {
657 global $tpl,$ilUser,$ilErr, $ilHelp;
658
659 $ilHelp->setScreenIdComponent("cal");
660 $ilHelp->setScreenId("app");
661 if ($this->app->isMilestone())
662 {
663 $ilHelp->setSubScreenId("edit_milestone");
664 }
665 else
666 {
667 $ilHelp->setSubScreenId("edit");
668 }
669
670 include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
671 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
672 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
673
674 $GLOBALS['ilCtrl']->saveParameter($this,array('seed','app_id','dt','idate'));
675
676 if($_REQUEST['rexl'])
677 {
678 $GLOBALS['ilCtrl']->setParameter($this,'rexl',1);
679
680 // Calculate new appointment time
681 $duration = $this->getAppointment()->getEnd()->get(IL_CAL_UNIX) - $this->getAppointment()->getStart()->get(IL_CAL_UNIX);
682 include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php';
683 $calc = new ilCalendarRecurrenceCalculator($this->getAppointment(), $this->rec);
684
685 $current_date = new ilDateTime($_REQUEST['dt'],IL_CAL_UNIX);
686
687 $yesterday = clone $current_date;
688 $yesterday->increment(IL_CAL_DAY,-1);
689 $tomorrow = clone $current_date;
690 $tomorrow->increment(IL_CAL_DAY, 1);
691
692
693 foreach($calc->calculateDateList($current_date, $tomorrow, 1) as $date_entry)
694 {
695 if(ilDateTime::_equals($current_date, $date_entry,IL_CAL_DAY))
696 {
697 $this->getAppointment()->setStart(new ilDateTime($date_entry->get(IL_CAL_UNIX),IL_CAL_UNIX));
698 $this->getAppointment()->setEnd(new ilDateTime($date_entry->get(IL_CAL_UNIX) + $duration,IL_CAL_UNIX));
699 break;
700 }
701 }
702
703 // Finally reset recurrence
704 $this->rec = new ilCalendarRecurrence();
705 }
706
707 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
709
710 if(!$cats->isVisible($cat_id))
711 {
712 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
713 return false;
714 }
715 if(!$cats->isEditable($cat_id) or $this->app->isAutoGenerated())
716 {
717 $this->showInfoScreen();
718 return true;
719 }
720
721 $this->initForm('edit', $this->app->isMilestone(), $a_edit_single_app);
722 $tpl->setContent($this->form->getHTML());
723 }
724
731 protected function showInfoScreen()
732 {
733 global $tpl,$ilUser;
734
735 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
736 $info = new ilInfoScreenGUI($this);
737 $info->setFormAction($this->ctrl->getFormAction($this));
738
739 if ($this->app->isMilestone())
740 {
741 $info->addSection($this->lng->txt('cal_ms_details'));
742 }
743 else
744 {
745 $info->addSection($this->lng->txt('cal_details'));
746 }
747
748 // Appointment
749 $info->addProperty($this->lng->txt('appointment'),
751 $this->app->getStart(),
752 $this->app->getEnd()));
753 $info->addProperty($this->lng->txt('title'),$this->app->getPresentationTitle());
754
755 // Description
756 if(strlen($desc = $this->app->getDescription()))
757 {
758 $info->addProperty($this->lng->txt('description'),ilUtil::makeClickable(nl2br($desc)));
759 }
760
761 // Location
762 if(strlen($loc = $this->app->getLocation()))
763 {
764 $info->addProperty($this->lng->txt('cal_where'),$loc);
765 }
766
767 // completion
768 if ($this->app->isMilestone() && $this->app->getCompletion() > 0)
769 {
770 $info->addProperty($this->lng->txt('cal_task_completion'),
771 $this->app->getCompletion()." %");
772 }
773
774 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
775 $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
776 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
777 $type = ilObject::_lookupType($cat_info['obj_id']);
778 if ($this->app->isMilestone() && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
779 && ($type == "grp" || $type == "crs"))
780 {
781 // users responsible
782 $users = $this->app->readResponsibleUsers();
783 $delim = "";
784 foreach($users as $r)
785 {
786 $value.= $delim.$r["lastname"].", ".$r["firstname"]." [".$r["login"]."]";
787 $delim = "<br />";
788 }
789 if (count($users) > 0)
790 {
791 $info->addProperty($this->lng->txt('cal_responsible'),
792 $value);
793 }
794 }
795
796 $category = new ilCalendarCategory($cat_id);
797
798 if($category->getType() == ilCalendarCategory::TYPE_OBJ)
799 {
800 $info->addSection($this->lng->txt('additional_info'));
801
802 $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
803 $refs = ilObject::_getAllReferences($cat_info['obj_id']);
804
805 include_once('./Services/Link/classes/class.ilLink.php');
806 $href = ilLink::_getStaticLink(current($refs),ilObject::_lookupType($cat_info['obj_id']),true);
807 $info->addProperty($this->lng->txt('perma_link'),'<a class="small" href="'.$href.'" target="_top">'.$href.'</a>');
808 }
809
810 $tpl->setContent($info->getHTML());
811 }
812
819 protected function update()
820 {
821 global $ilErr;
822
823 $single_editing = ($_REQUEST['rexl'] ? true : false);
824
825 $this->load('edit', $this->app->isMilestone());
826
827 if($this->app->validate() and $this->notification->validate())
828 {
829 if(!(int) $_POST['calendar'])
830 {
831 $cat_id = $this->createDefaultCalendar();
832 }
833 else
834 {
835 $cat_id = (int) $_POST['calendar'];
836 }
837
838 if($single_editing)
839 {
840 $this->getAppointment()->save();
841 $this->deleteExclude(false);
842
843 $this->rec = new ilCalendarRecurrence();
844 $this->rec->setEntryId($this->getAppointment()->getEntryId());
845 }
846 else
847 {
848 $this->getAppointment()->update();
849 }
850 $this->notification->save();
851 $this->saveRecurrenceSettings();
852
853 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
854 $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
855 $GLOBALS['ilLog']->write($this->app->getEntryId());
856 $ass->deleteAssignments();
857 $ass->addAssignment($cat_id);
858
859 // Send notifications
860 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
861 if(ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not'])
862 {
863 $this->distributeNotifications($cat_id,$this->app->getEntryId(),false);
864 }
865 if(ilCalendarSettings::_getInstance()->isUserNotificationEnabled())
866 {
868 }
869
870 ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
871 $this->ctrl->returnToParent($this);
872 }
873 else
874 {
875 ilUtil::sendFailure($ilErr->getMessage());
876 }
877
878 $this->edit();
879
880 }
881
888 protected function askDelete()
889 {
890 global $tpl;
891
892 include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
893
894 $this->ctrl->saveParameter($this,array('seed','app_id','dt','idate'));
895
896 $confirm = new ilConfirmationGUI();
897 $confirm->setFormAction($this->ctrl->getFormAction($this));
898 $confirm->setHeaderText($this->lng->txt('cal_delete_app_sure'));
899 $confirm->setCancel($this->lng->txt('cancel'),'cancel');
900 $confirm->addItem('appointments[]',$this->app->getEntryId(),$this->app->getTitle());
901
902 include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
904 && !$this->app->isMilestone())
905 {
906 $confirm->addButton($this->lng->txt('cal_delete_single'),'deleteexclude');
907 $confirm->setConfirm($this->lng->txt('cal_delete_recurrences'),'delete');
908 }
909 else
910 {
911 $confirm->setConfirm($this->lng->txt('delete'),'delete');
912 }
913
914 $tpl->setContent($confirm->getHTML());
915
916 }
917
925 protected function delete()
926 {
927 foreach($_POST['appointments'] as $app_id)
928 {
929 $app = new ilCalendarEntry($app_id);
930 $app->delete();
931
932 include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
934
935 include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
937 }
938 ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'),true);
939 $this->ctrl->returnToParent($this);
940 }
941
949 protected function deleteExclude($a_return = true)
950 {
951 include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceExclusion.php');
952 $excl = new ilCalendarRecurrenceExclusion();
953 $excl->setEntryId($_REQUEST['app_id']);
954 $excl->setDate(new ilDate($_REQUEST['dt'], IL_CAL_UNIX));
955 $excl->save();
956
957 if($a_return)
958 {
959 ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'),true);
960 $this->ctrl->returnToParent($this);
961 }
962 }
963
971 protected function initTimeZone()
972 {
973 global $ilUser;
974
975 $this->timezone = $ilUser->getTimeZone();
976 }
977
983 {
984 if(!isset($_GET['hour']))
985 {
986 $this->initialDate = clone $initialDate;
987 $this->default_fulltime = true;
988 }
989 else
990 {
991 if((int) $_GET['hour'] < 10)
992 {
993 $time = '0'.(int) $_GET['hour'].':00:00';
994 }
995 else
996 {
997 $time = (int) $_GET['hour'].':00:00';
998 }
999 $this->initialDate = new ilDateTime($initialDate->get(IL_CAL_DATE).' '.$time,IL_CAL_DATETIME,$this->timezone);
1000 $this->default_fulltime = false;
1001 }
1002 }
1003
1011 protected function initSeed(ilDate $seed)
1012 {
1013 $this->seed = clone $seed;
1014 $this->default_fulltime = true;
1015 }
1016
1024 protected function initAppointment($a_app_id = 0)
1025 {
1026 include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
1027 include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
1028 $this->app = new ilCalendarEntry($a_app_id);
1029
1030 include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
1031 $this->notification = new ilCalendarUserNotification($this->app->getEntryId());
1032
1033 if(!$a_app_id)
1034 {
1035 $start = clone $this->initialDate;
1036 $this->app->setStart($start);
1037
1038 $seed_end = clone $this->initialDate;
1039 if($this->default_fulltime)
1040 {
1041 #$seed_end->increment(IL_CAL_DAY,1);
1042 }
1043 else
1044 {
1045 $seed_end->increment(IL_CAL_HOUR,1);
1046 }
1047 $this->app->setEnd($seed_end);
1048 $this->app->setFullday($this->default_fulltime);
1049
1050 $this->rec = new ilCalendarRecurrence();
1051 }
1052 else
1053 {
1054 $this->rec = ilCalendarRecurrences::_getFirstRecurrence($this->app->getEntryId());
1055 }
1056
1057 }
1058
1066 protected function load($a_mode, $a_as_milestone = false)
1067 {
1068 // needed for date handling
1069 $this->initForm($a_mode, $a_as_milestone);
1070 $this->form->checkInput();
1071
1072 if ($a_as_milestone)
1073 {
1074 $this->app->setMilestone(true);
1075 $this->app->setCompletion(ilUtil::stripSlashes($_POST['completion']));
1076 }
1077
1078 $this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
1079 $this->app->setLocation(ilUtil::stripSlashes($_POST['location']));
1080 $this->app->setDescription(ilUtil::stripSlashes($_POST['description']));
1081 $this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
1082 $this->app->enableNotification((int) $_POST['not']);
1083
1084 if ($a_as_milestone) // milestones are always fullday events
1085 {
1086 $start = $this->form->getItemByPostVar('event_start');
1087 $start = $start->getDate();
1088
1089 $this->app->setFullday(true);
1090
1091 // for milestones is end date = start date
1092 $this->app->setStart($start);
1093 $this->app->setEnd($start);
1094 }
1095 else
1096 {
1097
1098 $period = $this->form->getItemByPostVar('event');
1099 $start = $period->getStart();
1100 $end = $period->getEnd();
1101
1102 $this->app->setFullday($start instanceof ilDate);
1103 $this->app->setStart($start);
1104 $this->app->setEnd($end);
1105 }
1106
1108 $this->loadRecurrenceSettings($a_as_milestone = false);
1109 }
1110
1111 protected function loadNotificationRecipients()
1112 {
1113 $this->notification->setRecipients(array());
1114
1115 foreach((array) $_POST['notu'] as $rcp)
1116 {
1117 $rcp = trim(ilUtil::stripSlashes($rcp));
1118 $usr_id = ilObjUser::_loginExists($rcp);
1119
1120 if(strlen($rcp) == 0)
1121 {
1122 continue;
1123 }
1124
1125 if($usr_id)
1126 {
1127 $this->notification->addRecipient(
1129 $usr_id
1130 );
1131 }
1132 else
1133 {
1134 $this->notification->addRecipient(
1136 0,
1137 $rcp
1138 );
1139 }
1140 }
1141 }
1142
1149 protected function loadRecurrenceSettings($a_as_milestone = false)
1150 {
1151 $this->rec->reset();
1152
1153 switch($_POST['frequence'])
1154 {
1155 case IL_CAL_FREQ_DAILY:
1156 $this->rec->setFrequenceType($_POST['frequence']);
1157 $this->rec->setInterval((int) $_POST['count_DAILY']);
1158 break;
1159
1160 case IL_CAL_FREQ_WEEKLY:
1161 $this->rec->setFrequenceType($_POST['frequence']);
1162 $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1163 if(is_array($_POST['byday_WEEKLY']))
1164 {
1165 $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',',$_POST['byday_WEEKLY'])));
1166 }
1167 break;
1168
1170 $this->rec->setFrequenceType($_POST['frequence']);
1171 $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1172 switch((int) $_POST['subtype_MONTHLY'])
1173 {
1174 case 0:
1175 // nothing to do;
1176 break;
1177
1178 case 1:
1179 switch((int) $_POST['monthly_byday_day'])
1180 {
1181 case 8:
1182 // Weekday
1183 $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1184 $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1185 break;
1186
1187 case 9:
1188 // Day of month
1189 $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1190 break;
1191
1192 default:
1193 $this->rec->setBYDAY((int) $_POST['monthly_byday_num'].$_POST['monthly_byday_day']);
1194 break;
1195 }
1196 break;
1197
1198 case 2:
1199 $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1200 break;
1201 }
1202 break;
1203
1204 case IL_CAL_FREQ_YEARLY:
1205 $this->rec->setFrequenceType($_POST['frequence']);
1206 $this->rec->setInterval((int) $_POST['count_YEARLY']);
1207 switch((int) $_POST['subtype_YEARLY'])
1208 {
1209 case 0:
1210 // nothing to do;
1211 break;
1212
1213 case 1:
1214 $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1215 $this->rec->setBYDAY((int) $_POST['yearly_byday_num'].$_POST['yearly_byday']);
1216 break;
1217
1218 case 2:
1219 $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1220 $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1221 break;
1222 }
1223 break;
1224 }
1225
1226 // UNTIL
1227 switch((int) $_POST['until_type'])
1228 {
1229 case 1:
1230 $this->rec->setFrequenceUntilDate(null);
1231 // nothing to do
1232 break;
1233
1234 case 2:
1235 $this->rec->setFrequenceUntilDate(null);
1236 $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1237 break;
1238
1239 case 3:
1240 $dt = new ilDateTimeInputGUI('','until_end');
1241 $dt->setRequired(true);
1242 if($dt->checkInput())
1243 {
1244 $this->rec->setFrequenceUntilCount(0);
1245 $this->rec->setFrequenceUntilDate($dt->getDate());
1246 }
1247 break;
1248 }
1249
1250 }
1251
1259 protected function saveRecurrenceSettings()
1260 {
1261 switch($_POST['frequence'])
1262 {
1263 case 'NONE':
1264 case '':
1265 // No recurrence => delete if there is an recurrence rule
1266 if($this->rec->getRecurrenceId())
1267 {
1268 $this->rec->delete();
1269 }
1270 break;
1271
1272 default:
1273 if($this->rec->getRecurrenceId())
1274 {
1275 $this->rec->update();
1276 }
1277 else
1278 {
1279 $this->rec->save();
1280 }
1281 break;
1282 }
1283 }
1284
1291 protected function createDefaultCalendar()
1292 {
1293 global $ilUser,$lng;
1294
1295 $cat = new ilCalendarCategory();
1296 $cat->setColor(ilCalendarCategory::DEFAULT_COLOR);
1297 $cat->setType(ilCalendarCategory::TYPE_USR);
1298 $cat->setTitle($this->lng->txt('cal_default_calendar'));
1299 $cat->setObjId($ilUser->getId());
1300
1301 // delete calendar cache
1302 include_once './Services/Calendar/classes/class.ilCalendarCache.php';
1303 ilCalendarCache::getInstance()->deleteUserEntries($ilUser->getId());
1304
1305 return $cat->add();
1306 }
1307
1312 protected function confirmRegister()
1313 {
1314 global $tpl;
1315
1316 $entry = new ilCalendarEntry((int) $_GET['app_id']);
1318 new ilDateTime($_GET['dstart'],IL_CAL_UNIX),
1319 new ilDateTime($_GET['dend'],IL_CAL_UNIX)
1320 );
1321
1322
1323 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1324 $conf = new ilConfirmationGUI;
1325
1326 $this->ctrl->setParameter($this,'dstart',(int) $_REQUEST['dstart']);
1327 $this->ctrl->setParameter($this,'dend',(int) $_REQUEST['dend']);
1328
1329 $conf->setFormAction($this->ctrl->getFormAction($this));
1330 $conf->setHeaderText($this->lng->txt('cal_confirm_reg_info'));
1331 $conf->setConfirm($this->lng->txt('cal_reg_register'), 'register');
1332 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1333 $conf->addItem('app_id', $entry->getEntryId(), $entry->getTitle().' ('.$start.')');
1334
1335 $tpl->setContent($conf->getHTML());
1336 }
1337
1342 protected function register()
1343 {
1344 global $ilUser;
1345
1346 include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
1347 $reg = new ilCalendarRegistration((int) $_POST['app_id']);
1348 $reg->register(
1349 $ilUser->getId(),
1350 new ilDateTime((int) $_REQUEST['dstart'],IL_CAL_UNIX),
1351 new ilDateTime((int) $_REQUEST['dend'],IL_CAL_UNIX)
1352 );
1353
1354 ilUtil::sendSuccess($this->lng->txt('cal_reg_registered'),true);
1355 $this->ctrl->returnToParent($this);
1356 }
1357
1361 public function confirmUnregister()
1362 {
1363 global $tpl;
1364
1365
1366 $entry = new ilCalendarEntry((int) $_GET['app_id']);
1368 $dstart = new ilDateTime($_GET['dstart'],IL_CAL_UNIX),
1369 $dend = new ilDateTime($_GET['dend'],IL_CAL_UNIX)
1370 );
1371
1372
1373 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1374 $conf = new ilConfirmationGUI;
1375
1376 $this->ctrl->setParameter($this,'dstart',(int) $_REQUEST['dstart']);
1377 $this->ctrl->setParameter($this,'dend',(int) $_REQUEST['dend']);
1378
1379 $conf->setFormAction($this->ctrl->getFormAction($this));
1380 $conf->setHeaderText($this->lng->txt('cal_confirm_unreg_info'));
1381 $conf->setConfirm($this->lng->txt('cal_reg_unregister'), 'unregister');
1382 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1383 $conf->addItem('app_id', $entry->getEntryId(), $entry->getTitle().' ('.$start.')');
1384
1385 $tpl->setContent($conf->getHTML());
1386 }
1387
1392 protected function unregister()
1393 {
1394 global $ilUser;
1395
1396 include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
1397 $reg = new ilCalendarRegistration((int) $_POST['app_id']);
1398 $reg->unregister(
1399 $ilUser->getId(),
1400 new ilDateTime((int) $_REQUEST['dstart'],IL_CAL_UNIX),
1401 new ilDateTime((int) $_REQUEST['dend'],IL_CAL_UNIX)
1402 );
1403
1404 ilUtil::sendSuccess($this->lng->txt('cal_reg_unregistered'),true);
1405 $this->ctrl->returnToParent($this);
1406 }
1407
1411 public function book()
1412 {
1413 global $ilUser, $tpl;
1414
1415 $entry = (int)$_GET['app_id'];
1416 $user = (int)$_GET['bkid'];
1417
1418 $this->ctrl->saveParameter($this,'app_id');
1419
1420 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1421 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1422 $entry = new ilCalendarEntry($entry);
1423
1424 $form = $this->initFormConfirmBooking();
1425 $form->getItemByPostVar('date')->setValue(ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd()));
1426 $form->getItemByPostVar('title')->setValue($entry->getTitle()." (".ilObjUser::_lookupFullname($user).')');
1427
1428 $tpl->setContent($form->getHTML());
1429 return true;
1430 }
1431
1436 protected function initFormConfirmBooking()
1437 {
1438 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1439 $form = new ilPropertyFormGUI();
1440 $form->setFormAction($this->ctrl->getFormAction($this));
1441 $form->addCommandButton('bookconfirmed',$this->lng->txt('cal_confirm_booking'));
1442 $form->addCommandButton('cancel',$this->lng->txt('cancel'));
1443
1444 $date = new ilNonEditableValueGUI($this->lng->txt('appointment'),'date');
1445 $form->addItem($date);
1446
1447 $title = new ilNonEditableValueGUI($this->lng->txt('title'),'title');
1448 $form->addItem($title);
1449
1450 $message = new ilTextAreaInputGUI($this->lng->txt('cal_ch_booking_message_tbl'), 'comment');
1451 $message->setRows(5);
1452 $form->addItem($message);
1453
1454 return $form;
1455 }
1456
1460 public function bookconfirmed()
1461 {
1462 global $ilUser;
1463
1464 $entry = (int) $_REQUEST['app_id'];
1465 $user = (int) $_REQUEST['bkid'];
1466
1467 $form = $this->initFormConfirmBooking();
1468 if($form->checkInput())
1469 {
1470 // check if appointment is bookable
1471 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
1472 $cal_entry = new ilCalendarEntry($entry);
1473
1474 include_once './Services/Booking/classes/class.ilBookingEntry.php';
1475 $booking = new ilBookingEntry($cal_entry->getContextId());
1476
1477 if(!$booking->isAppointmentBookableForUser($entry, $GLOBALS['ilUser']->getId()))
1478 {
1479 ilUtil::sendFailure($this->lng->txt('cal_booking_failed_info'), true);
1480 $this->ctrl->returnToParent($this);
1481 }
1482
1483 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
1485
1486 include_once './Services/Booking/classes/class.ilBookingEntry.php';
1487 ilBookingEntry::writeBookingMessage($entry, $ilUser->getId(), $form->getInput('comment'));
1488 }
1489 ilUtil::sendSuccess($this->lng->txt('cal_booking_confirmed'),true);
1490 $this->ctrl->returnToParent($this);
1491 }
1492
1497 public function cancelBooking()
1498 {
1499 global $ilUser, $tpl;
1500
1501 $entry = (int)$_GET['app_id'];
1502
1503 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1504 $entry = new ilCalendarEntry($entry);
1505
1506 $category = $this->calendarEntryToCategory($entry);
1507 if($category->getType() == ilCalendarCategory::TYPE_CH)
1508 {
1509 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1510 $booking = new ilBookingEntry($entry->getContextId());
1511 if(!$booking->hasBooked($entry->getEntryId()))
1512 {
1513 $this->ctrl->returnToParent($this);
1514 return false;
1515 }
1516
1517 $entry_title = ' '.$entry->getTitle()." (".ilObjUser::_lookupFullname($booking->getObjId()).')';
1518 }
1519 else if($category->getType() == ilCalendarCategory::TYPE_BOOK)
1520 {
1521 $entry_title = ' '.$entry->getTitle();
1522 }
1523 else
1524 {
1525 $this->ctrl->returnToParent($this);
1526 return false;
1527 }
1528
1529 $title = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd());
1530
1531 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1532 $conf = new ilConfirmationGUI;
1533 $conf->setFormAction($this->ctrl->getFormAction($this));
1534 $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info'));
1535 $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed');
1536 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1537 $conf->addItem('app_id', $entry->getEntryId(), $title.' - '.$entry_title);
1538
1539 $tpl->setContent($conf->getHTML());
1540 }
1541
1546 public function cancelConfirmed()
1547 {
1548 global $ilUser;
1549
1550 $entry = (int)$_POST['app_id'];
1551 $user = (int)$_GET['bkid'];
1552
1553 include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1554 $entry = new ilCalendarEntry($entry);
1555
1556 $category = $this->calendarEntryToCategory($entry);
1557 if($category->getType() == ilCalendarCategory::TYPE_CH)
1558 {
1559 // find cloned calendar entry in user calendar
1560 include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
1561 $GLOBALS['ilLog']->dump($entry->getStart());
1563 $ilUser->getId(),
1564 $entry->getContextId(),
1565 $entry->getStart(),
1567 false);
1568 $GLOBALS['ilLog']->dump($apps);
1569
1570 // Fix for wrong, old entries
1571 foreach((array) $apps as $own_app)
1572 {
1573 $ref_entry = new ilCalendarEntry($own_app);
1574 $ref_entry->delete();
1575 }
1576
1577 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1578 $booking = new ilBookingEntry($entry->getContextId());
1579 $booking->cancelBooking($entry->getEntryId());
1580
1581 // do NOT delete original entry
1582 }
1583 else if($category->getType() == ilCalendarCategory::TYPE_BOOK)
1584 {
1585 include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
1586 $booking = new ilBookingReservation($entry->getContextId());
1587 $booking->setStatus(ilBookingReservation::STATUS_CANCELLED);
1588 $booking->update();
1589
1590 $entry->delete();
1591 }
1592
1593 ilUtil::sendSuccess($this->lng->txt('cal_cancel_booking_confirmed'),true);
1594 $this->ctrl->returnToParent($this);
1595 }
1596
1602 protected function calendarEntryToCategory(ilCalendarEntry $entry)
1603 {
1604 include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
1605 include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
1606 $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
1607 $assignment = $assignment->getFirstAssignment();
1608 return new ilCalendarCategory($assignment);
1609 }
1610
1615 protected function doUserAutoComplete()
1616 {
1617 if(!isset($_GET['autoCompleteField']))
1618 {
1619 $a_fields = array('login','firstname','lastname','email');
1620 }
1621 else
1622 {
1623 $a_fields = array((string) $_GET['autoCompleteField']);
1624 }
1625
1626 $GLOBALS['ilLog']->write(print_r($a_fields,true));
1627 include_once './Services/User/classes/class.ilUserAutoComplete.php';
1628 $auto = new ilUserAutoComplete();
1629 $auto->setSearchFields($a_fields);
1630 $auto->enableFieldSearchableCheck(true);
1631 $auto->setMoreLinkAvailable(true);
1632
1633 if(($_REQUEST['fetchall']))
1634 {
1635 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
1636 }
1637
1638 echo $auto->getList($_REQUEST['query']);
1639 exit();
1640 }
1641
1642}
1643?>
$_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
edit($a_edit_single_app=false)
edit appointment
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.
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
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 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.
$r
Definition: example_031.php:79
$info
Definition: example_052.php:80
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
global $ilCtrl
Definition: ilias.php:18
notification()
Definition: notification.php:2
global $ilSetting
Definition: privfeed.php:17
global $ilErr
Definition: raiseError.php:16
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
$ilUser
Definition: imgupload.php:18