ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCalendarAppointmentGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
14  protected $seed = null;
15  protected $initialDate = null;
16  protected $default_fulltime = true;
17 
18  protected $app = null;
19  protected $rec = null;
20  protected $timezone = null;
21 
22  protected $tpl;
23  protected $lng;
24  protected $ctrl;
25 
29  private $logger = null;
30 
38  public function __construct(ilDate $seed, ilDate $initialDate, $a_appointment_id = 0)
39  {
40  global $ilCtrl,$lng;
41 
42  $this->lng = $lng;
43  $lng->loadLanguageModule('dateplaner');
44  $this->ctrl = $ilCtrl;
45 
46  $this->logger = $GLOBALS['DIC']->logger()->cal();
47 
48  $this->initTimeZone();
49  $this->initSeed($seed);
50  $this->initInitialDate($initialDate);
51  $this->initAppointment($a_appointment_id);
52  }
53 
61  public function executeCommand()
62  {
63  global $ilUser, $ilSetting,$tpl, $ilTabs;
64 
65 
66  // Clear tabs and set back target
67  $ilTabs->clearTargets();
68  $ilTabs->setBackTarget(
69  $this->lng->txt('cal_back_to_cal'),
70  $this->ctrl->getLinkTarget($this, 'cancel')
71  );
72 
73  $next_class = $this->ctrl->getNextClass($this);
74  switch ($next_class) {
75 
76  default:
77  $cmd = $this->ctrl->getCmd("add");
78  $this->$cmd();
79  break;
80  }
81  return true;
82  }
83 
88  public function getAppointment()
89  {
90  return $this->app;
91  }
92 
100  protected function cancel()
101  {
102  $this->ctrl->returnToParent($this);
103  }
104 
112  protected function initForm($a_mode, $a_as_milestone = false, $a_edit_single_app = false)
113  {
114  global $ilUser,$tpl;
115 
116  $this->form = new ilPropertyFormGUI();
117 
118  include_once('./Services/YUI/classes/class.ilYuiUtil.php');
120  $resp_info = false;
121  switch ($a_mode) {
122  case 'create':
123  $this->ctrl->saveParameter($this, array('seed','idate'));
124  $this->form->setFormAction($this->ctrl->getFormAction($this));
125  if ($a_as_milestone) {
126  $this->form->setTitle($this->lng->txt('cal_new_ms'));
127  $this->form->addCommandButton('saveMilestone', $this->lng->txt('cal_add_milestone'));
128  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
129  } else {
130  $this->form->setTitle($this->lng->txt('cal_new_app'));
131  $this->form->addCommandButton('save', $this->lng->txt('cal_add_appointment'));
132  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
133  }
134  break;
135 
136  case 'edit':
137  if ($a_as_milestone) {
138  $this->form->setTitle($this->lng->txt('cal_edit_milestone'));
139  } else {
140  $this->form->setTitle($this->lng->txt('cal_edit_appointment'));
141  }
142  $this->ctrl->saveParameter($this, array('seed','app_id','idate'));
143  $this->form->setFormAction($this->ctrl->getFormAction($this));
144 
145  $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
146  $cat = $ass->getFirstAssignment();
147  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
148  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat);
149  $type = ilObject::_lookupType($cat_info['obj_id']);
150  if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
151  && ($type == "grp" || $type == "crs")) {
152  $resp_info = true;
153  $this->form->addCommandButton('editResponsibleUsers', $this->lng->txt('cal_change_responsible_users'));
154  }
155  $this->form->addCommandButton('update', $this->lng->txt('save'));
156  // $this->form->addCommandButton('askDelete',$this->lng->txt('delete'));
157  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
158  break;
159  }
160  // title
161  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
162  $title->setValue($this->app->getTitle());
163  $title->setRequired(true);
164  $title->setMaxLength(128);
165  $title->setSize(32);
166  $this->form->addItem($title);
167 
168  // calendar selection
169  $calendar = new ilSelectInputGUI($this->lng->txt('cal_category_selection'), 'calendar');
170  if ($_POST['category']) {
171  $calendar->setValue((int) $_POST['calendar']);
172  $selected_calendar = (int) $_POST['calendar'];
173  } elseif ($_GET['category_id']) {
174  $calendar->setValue((int) $_GET['category_id']);
175  $selected_calendar = (int) $_GET['category_id'];
176  } elseif ($a_mode == 'edit') {
177  $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
178  $cat = $ass->getFirstAssignment();
179  $calendar->setValue($cat);
180  $selected_calendar = $cat;
181  } elseif (isset($_GET['ref_id'])) {
182  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
183  $obj_cal = ilObject::_lookupObjId($_GET['ref_id']);
184  $calendar->setValue(ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal));
185  $selected_calendar = ilCalendarCategories::_lookupCategoryIdByObjId($obj_cal);
186  $cats = ilCalendarCategories::_getInstance($ilUser->getId());
187  $cats->readSingleCalendar($selected_calendar);
188  } else {
189  $cats = ilCalendarCategories::_getInstance($ilUser->getId());
190  $categories = $cats->prepareCategoriesOfUserForSelection();
191  $selected_calendar = key((array) $categories);
192  $calendar->setValue($selected_calendar);
193  }
194  $calendar->setRequired(true);
195  $cats = ilCalendarCategories::_getInstance($ilUser->getId());
196  $calendar->setOptions($cats->prepareCategoriesOfUserForSelection());
197 
198  include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
199  if (ilCalendarSettings::_getInstance()->isNotificationEnabled()) {
200  $notification_cals = $cats->getNotificationCalendars();
201  $notification_cals = count($notification_cals) ? implode(',', $notification_cals) : '';
202  $calendar->addCustomAttribute("onchange=\"ilToggleNotification([" . $notification_cals . "]);\"");
203  }
204  $this->form->addItem($calendar);
205 
206  if (!$a_as_milestone) {
207  include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
208  $tpl->addJavaScript('./Services/Form/js/date_duration.js');
209  $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'), 'event');
210  $dur->setRequired(true);
211  $dur->enableToggleFullTime(
212  $this->lng->txt('cal_fullday_title'),
213  $this->app->isFullday() ? true : false
214  );
215  $dur->setShowTime(true);
216  $dur->setStart($this->app->getStart());
217  $dur->setEnd($this->app->getEnd());
218  $this->form->addItem($dur);
219 
220  // recurrence
221  include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
222  $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'), 'frequence');
223  $rec->setRecurrence($this->rec);
224  $this->form->addItem($rec);
225 
226  // location
227  $where = new ilTextInputGUI($this->lng->txt('cal_where'), 'location');
228  $where->setValue($this->app->getLocation());
229  $where->setMaxLength(128);
230  $where->setSize(32);
231  $this->form->addItem($where);
232  } else {
233  $deadline = new ilDateTimeInputGUI($this->lng->txt('cal_deadline'), 'event_start');
234  $deadline->setDate($this->app->getStart());
235  $deadline->setShowTime(false);
236  $deadline->setMinuteStepSize(5);
237  $this->form->addItem($deadline);
238 
239  // completion
240  $completion_vals = array();
241  for ($i = 0; $i <= 100; $i+=5) {
242  $completion_vals[$i] = $i . " %";
243  }
244  $compl = new ilSelectInputGUI(
245  $this->lng->txt('cal_task_completion'),
246  'completion'
247  );
248  $compl->setOptions($completion_vals);
249  $compl->setValue($this->app->getCompletion());
250  $this->form->addItem($compl);
251  }
252 
253  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
254  $desc->setValue($this->app->getDescription());
255  $desc->setRows(5);
256  $this->form->addItem($desc);
257 
258  if ($a_as_milestone && $a_mode == "edit" && $resp_info) {
259  // users responsible
260  $users = $this->app->readResponsibleUsers();
261  $resp = new ilNonEditableValueGUI($this->lng->txt('cal_responsible'), "", true);
262  $delim = "";
263  foreach ($users as $r) {
264  $value.= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
265  $delim = "<br />";
266  }
267  if (count($users) > 0) {
268  $resp->setValue($value);
269  } else {
270  $resp->setValue("-");
271  }
272 
273  $this->form->addItem($resp);
274  }
275 
276 
277  if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
278  $notu = new ilTextWizardInputGUI($this->lng->txt('cal_user_notification'), 'notu');
279  $notu->setInfo($this->lng->txt('cal_user_notification_info'));
280  $notu->setSize(20);
281  $notu->setMaxLength(64);
282 
283  $values = array();
284  foreach ($this->notification->getRecipients() as $rcp) {
285  switch ($rcp['type']) {
287  $values[] = ilObjUser::_lookupLogin($rcp['usr_id']);
288  break;
289 
291  $values[] = $rcp['email'];
292  break;
293  }
294  }
295  if (count($values)) {
296  $notu->setValues($values);
297  } else {
298  $notu->setValues(array(''));
299  }
300  $this->form->addItem($notu);
301  }
302 
303  // Notifications
304  include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
305  if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and count($cats->getNotificationCalendars())) {
306  $selected_cal = new ilCalendarCategory($selected_calendar);
307  $disabled = true;
308  if ($selected_cal->getType() == ilCalendarCategory::TYPE_OBJ) {
309  if (ilObject::_lookupType($selected_cal->getObjId()) == 'crs' or ilObject::_lookupType($selected_cal->getObjId()) == 'grp') {
310  $disabled = false;
311  }
312  }
313 
314  $tpl->addJavaScript('./Services/Calendar/js/toggle_notification.js');
315  $not = new ilCheckboxInputGUI($this->lng->txt('cal_cg_notification'), 'not');
316  $not->setInfo($this->lng->txt('cal_notification_info'));
317  $not->setValue(1);
318  $not->setChecked($this->app->isNotificationEnabled());
319  $not->setDisabled($disabled);
320  $this->form->addItem($not);
321  }
322  }
323 
324 
332  protected function add(ilPropertyFormGUI $form = null)
333  {
334  global $tpl, $ilHelp;
335 
336  $ilHelp->setScreenIdComponent("cal");
337  $ilHelp->setScreenId("app");
338  $ilHelp->setSubScreenId("create");
339 
340  if (!$form instanceof ilPropertyFormGUI) {
341  $this->initForm('create');
342  }
343  $tpl->setContent($this->form->getHTML());
344  }
345 
352  protected function addMilestone()
353  {
354  global $tpl, $ilHelp;
355 
356  $ilHelp->setScreenIdComponent("cal");
357  $ilHelp->setScreenId("app");
358  $ilHelp->setSubScreenId("create_milestone");
359 
360  $this->initForm('create', true);
361  $tpl->setContent($this->form->getHTML());
362  }
363 
369  protected function saveMilestone()
370  {
371  $this->save(true);
372  }
373 
379  protected function save($a_as_milestone = false)
380  {
381  global $ilErr;
382 
383  $this->load('create', $a_as_milestone);
384 
385  if ($this->app->validate() and $this->notification->validate()) {
386  if (!(int) $_POST['calendar']) {
387  $cat_id = $this->createDefaultCalendar();
388  } else {
389  $cat_id = (int) $_POST['calendar'];
390  }
391 
392  $this->app->save();
393  $this->notification->setEntryId($this->app->getEntryId());
394  $this->notification->save();
395  $this->rec->setEntryId($this->app->getEntryId());
396  $this->saveRecurrenceSettings();
397 
398  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
399  $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
400  $ass->addAssignment($cat_id);
401 
402  // Send notifications
403  include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
404  if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not']) {
405  $this->distributeNotifications($cat_id, $this->app->getEntryId(), true);
406  }
407  if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
409  }
410 
411  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
412  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
413  $type = ilObject::_lookupType($cat_info['obj_id']);
414 
415  if ($a_as_milestone && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
416  && ($type == "grp" || $type == "crs")) {
417  ilUtil::sendSuccess($this->lng->txt('cal_created_milestone_resp_q'), true);
418  return $this->showResponsibleUsersList($cat_info['obj_id']);
419  } elseif ($a_as_milestone) {
420  ilUtil::sendSuccess($this->lng->txt('cal_created_milestone'), true);
421  $this->ctrl->returnToParent($this);
422  } else {
423  ilUtil::sendSuccess($this->lng->txt('cal_created_appointment'), true);
424  $this->ctrl->returnToParent($this);
425  }
426  } else {
427  $this->form->setValuesByPost();
428  ilUtil::sendFailure($ilErr->getMessage());
429  return $this->add($this->form);
430  }
431  if ($a_as_milestone) {
432  $this->addMilestone();
433  } else {
434  $this->add();
435  }
436  }
437 
442  protected function distributeUserNotifications()
443  {
444  global $ilUser;
445 
446  include_once './Services/Calendar/classes/class.ilCalendarMailNotification.php';
447  $notification = new ilCalendarMailNotification();
448  $notification->setAppointmentId($this->app->getEntryId());
449 
450  foreach ($this->notification->getRecipients() as $rcp) {
451  switch ($rcp['type']) {
453  $notification->setSender(ANONYMOUS_USER_ID);
454  $notification->setRecipients(array($rcp['usr_id']));
455  $notification->setType(ilCalendarMailNotification::TYPE_USER);
456  break;
457 
459  $notification->setSender(ANONYMOUS_USER_ID);
460  $notification->setRecipients(array($rcp['email']));
461  $notification->setType(ilCalendarMailNotification::TYPE_USER_ANONYMOUS);
462  break;
463  }
464  $notification->send();
465  }
466  }
467 
468 
473  protected function distributeNotifications($a_cat_id, $app_id, $a_new_appointment = true)
474  {
475  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
476  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($a_cat_id);
477 
478  include_once './Services/Calendar/classes/class.ilCalendarMailNotification.php';
479  $notification = new ilCalendarMailNotification();
480  $notification->setAppointmentId($app_id);
481 
482  switch ($cat_info['type']) {
484 
485  switch ($cat_info['obj_type']) {
486  case 'crs':
487  $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
488  $ref_id = current($ref_ids);
489  $notification->setRefId($ref_id);
490  $notification->setType(
491  $a_new_appointment ?
494  );
495  break;
496 
497  case 'grp':
498  $ref_ids = ilObject::_getAllReferences($cat_info['obj_id']);
499  $ref_id = current($ref_ids);
500  $notification->setRefId($ref_id);
501  $notification->setType(
502  $a_new_appointment ?
505  );
506  break;
507  }
508  break;
509  }
510 
511  $notification->send();
512  }
513 
517  public function editResponsibleUsers()
518  {
519  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
520  $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
521  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
522  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
523 
524  $this->showResponsibleUsersList($cat_info['obj_id']);
525  }
526 
531  public function showResponsibleUsersList($a_grp_id)
532  {
533  global $tpl;
534 
535  include_once("./Services/Calendar/classes/class.ilMilestoneResponsiblesTableGUI.php");
536  $table_gui = new ilMilestoneResponsiblesTableGUI(
537  $this,
538  "",
539  $a_grp_id,
540  $this->app->getEntryId()
541  );
542  $tpl->setContent($table_gui->getHTML());
543  }
544 
549  {
550  global $ilCtrl;
551 
552  $this->app->writeResponsibleUsers($_POST["user_id"]);
553  $ilCtrl->returnToParent($this);
554  }
555 
560  protected function askEdit()
561  {
562  // check for recurring entries
563  include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
565  if (!$rec) {
566  return $this->edit(true);
567  }
568  // Show edit single/all appointments
569  $this->ctrl->saveParameter($this, array('seed','app_id','dt','idate'));
570 
571  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
572  $confirm = new ilConfirmationGUI();
573  $confirm->setFormAction($this->ctrl->getFormAction($this));
574  #$confirm->setHeaderText($this->lng->txt('cal_edit_app_sure'));
575  $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
576  $confirm->addItem('appointments[]', $this->app->getEntryId(), $this->app->getTitle());
577  $confirm->addButton($this->lng->txt('cal_edit_single'), 'editSingle');
578  $confirm->setConfirm($this->lng->txt('cal_edit_recurrences'), 'edit');
579 
580  $GLOBALS['tpl']->setContent($confirm->getHTML());
581  }
582 
586  protected function editSingle()
587  {
588  $_REQUEST['rexl'] = 1;
589  $GLOBALS['ilCtrl']->setParameter($this, 'rexcl', 1);
590  $this->edit(true);
591  }
592 
601  protected function edit($a_edit_single_app = false, ilPropertyFormGUI $form = null)
602  {
603  global $tpl,$ilUser,$ilErr, $ilHelp;
604 
605  $ilHelp->setScreenIdComponent("cal");
606  $ilHelp->setScreenId("app");
607  if ($this->app->isMilestone()) {
608  $ilHelp->setSubScreenId("edit_milestone");
609  } else {
610  $ilHelp->setSubScreenId("edit");
611  }
612 
613  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
614  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
615  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
616 
617  $GLOBALS['ilCtrl']->saveParameter($this, array('seed','app_id','dt','idate'));
618 
619  if ($_REQUEST['rexl']) {
620  $GLOBALS['ilCtrl']->setParameter($this, 'rexl', 1);
621 
622  // Calculate new appointment time
623  $duration = $this->getAppointment()->getEnd()->get(IL_CAL_UNIX) - $this->getAppointment()->getStart()->get(IL_CAL_UNIX);
624  include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php';
625  $calc = new ilCalendarRecurrenceCalculator($this->getAppointment(), $this->rec);
626 
627  $current_date = new ilDateTime($_REQUEST['dt'], IL_CAL_UNIX);
628 
629  $yesterday = clone $current_date;
630  $yesterday->increment(IL_CAL_DAY, -1);
631  $tomorrow = clone $current_date;
632  $tomorrow->increment(IL_CAL_DAY, 1);
633 
634 
635  foreach ($calc->calculateDateList($current_date, $tomorrow, 1) as $date_entry) {
636  if (ilDateTime::_equals($current_date, $date_entry, IL_CAL_DAY)) {
637  $this->getAppointment()->setStart(new ilDateTime($date_entry->get(IL_CAL_UNIX), IL_CAL_UNIX));
638  $this->getAppointment()->setEnd(new ilDateTime($date_entry->get(IL_CAL_UNIX) + $duration, IL_CAL_UNIX));
639  break;
640  }
641  }
642 
643  // Finally reset recurrence
644  $this->rec = new ilCalendarRecurrence();
645  }
646 
647  $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
648  $cats = ilCalendarCategories::_getInstance($ilUser->getId());
649 
650  if (!$cats->isVisible($cat_id)) {
651  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
652  return false;
653  }
654  if (!$cats->isEditable($cat_id) or $this->app->isAutoGenerated()) {
655  $this->showInfoScreen();
656  return true;
657  }
658  if (!$form instanceof ilPropertyFormGUI) {
659  $this->initForm('edit', $this->app->isMilestone(), $a_edit_single_app);
660  }
661  $tpl->setContent($this->form->getHTML());
662  }
663 
670  protected function showInfoScreen()
671  {
672  global $tpl,$ilUser;
673 
674  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
675  $info = new ilInfoScreenGUI($this);
676  $info->setFormAction($this->ctrl->getFormAction($this));
677 
678  if ($this->app->isMilestone()) {
679  $info->addSection($this->lng->txt('cal_ms_details'));
680  } else {
681  $info->addSection($this->lng->txt('cal_details'));
682  }
683 
684  // Appointment
685  $info->addProperty(
686  $this->lng->txt('appointment'),
688  $this->app->getStart(),
689  $this->app->getEnd()
690  )
691  );
692  $info->addProperty($this->lng->txt('title'), $this->app->getPresentationTitle());
693 
694  // Description
695  if (strlen($desc = $this->app->getDescription())) {
696  $info->addProperty($this->lng->txt('description'), $desc);
697  }
698 
699  // Location
700  if (strlen($loc = $this->app->getLocation())) {
701  $info->addProperty($this->lng->txt('cal_where'), $loc);
702  }
703 
704  // completion
705  if ($this->app->isMilestone() && $this->app->getCompletion() > 0) {
706  $info->addProperty(
707  $this->lng->txt('cal_task_completion'),
708  $this->app->getCompletion() . " %"
709  );
710  }
711 
712  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
713  $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
714  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
715  $type = ilObject::_lookupType($cat_info['obj_id']);
716  if ($this->app->isMilestone() && $cat_info['type'] == ilCalendarCategory::TYPE_OBJ
717  && ($type == "grp" || $type == "crs")) {
718  // users responsible
719  $users = $this->app->readResponsibleUsers();
720  $delim = "";
721  foreach ($users as $r) {
722  $value.= $delim . $r["lastname"] . ", " . $r["firstname"] . " [" . $r["login"] . "]";
723  $delim = "<br />";
724  }
725  if (count($users) > 0) {
726  $info->addProperty(
727  $this->lng->txt('cal_responsible'),
728  $value
729  );
730  }
731  }
732 
733  $category = new ilCalendarCategory($cat_id);
734 
735  if ($category->getType() == ilCalendarCategory::TYPE_OBJ) {
736  $info->addSection($this->lng->txt('additional_info'));
737 
738  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
739  $refs = ilObject::_getAllReferences($cat_info['obj_id']);
740 
741  include_once('./Services/Link/classes/class.ilLink.php');
742  $href = ilLink::_getStaticLink(current($refs), ilObject::_lookupType($cat_info['obj_id']), true);
743  $info->addProperty($this->lng->txt('perma_link'), '<a class="small" href="' . $href . '" target="_top">' . $href . '</a>');
744  }
745 
746  $tpl->setContent($info->getHTML());
747  }
748 
755  protected function update()
756  {
757  global $ilErr;
758 
759  $single_editing = ($_REQUEST['rexl'] ? true : false);
760 
761  $this->load('edit', $this->app->isMilestone());
762 
763  if ($this->app->validate() and $this->notification->validate()) {
764  if (!(int) $_POST['calendar']) {
765  $cat_id = $this->createDefaultCalendar();
766  } else {
767  $cat_id = (int) $_POST['calendar'];
768  }
769 
770  if ($single_editing) {
771  $this->getAppointment()->save();
772  $this->deleteExclude(false);
773 
774  $this->rec = new ilCalendarRecurrence();
775  $this->rec->setEntryId($this->getAppointment()->getEntryId());
776  } else {
777  $this->getAppointment()->update();
778  }
779  $this->notification->save();
780  $this->saveRecurrenceSettings();
781  //var_dump($cat_id);
782  //var_dump($_POST); exit;
783  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
784  $ass = new ilCalendarCategoryAssignments($this->app->getEntryId());
785  $GLOBALS['ilLog']->write($this->app->getEntryId());
786  $ass->deleteAssignments();
787  $ass->addAssignment($cat_id);
788 
789  // Send notifications
790  include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
791  if (ilCalendarSettings::_getInstance()->isNotificationEnabled() and (bool) $_POST['not']) {
792  $this->distributeNotifications($cat_id, $this->app->getEntryId(), false);
793  }
794  if (ilCalendarSettings::_getInstance()->isUserNotificationEnabled()) {
796  }
797 
798  ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
799  $this->ctrl->returnToParent($this);
800  } else {
801  $this->form->setValuesByPost();
802  ilUtil::sendFailure($ilErr->getMessage());
803  }
804  $this->edit(false, $this->form);
805  }
806 
813  protected function askDelete()
814  {
815  global $tpl;
816 
817  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
818 
819  $this->ctrl->saveParameter($this, array('seed','app_id','dt','idate'));
820 
821  $confirm = new ilConfirmationGUI();
822  $confirm->setFormAction($this->ctrl->getFormAction($this));
823  $confirm->setHeaderText($this->lng->txt('cal_delete_app_sure'));
824  $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
825  $confirm->addItem('appointments[]', $this->app->getEntryId(), $this->app->getTitle());
826 
827  include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
828  if (sizeof(ilCalendarRecurrences::_getRecurrences($_GET['app_id']))
829  && !$this->app->isMilestone()) {
830  $confirm->addButton($this->lng->txt('cal_delete_single'), 'deleteexclude');
831  $confirm->setConfirm($this->lng->txt('cal_delete_recurrences'), 'delete');
832  } else {
833  $confirm->setConfirm($this->lng->txt('delete'), 'delete');
834  }
835 
836  $tpl->setContent($confirm->getHTML());
837  }
838 
846  protected function delete()
847  {
848  foreach ($_POST['appointments'] as $app_id) {
849  $app = new ilCalendarEntry($app_id);
850  $app->delete();
851 
852  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
854 
855  include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
857  }
858  ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'), true);
859  $this->ctrl->returnToParent($this);
860  }
861 
869  protected function deleteExclude($a_return = true)
870  {
871  include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceExclusion.php');
872  $excl = new ilCalendarRecurrenceExclusion();
873  $excl->setEntryId($_REQUEST['app_id']);
874  $excl->setDate(new ilDate($_REQUEST['dt'], IL_CAL_UNIX));
875  $excl->save();
876 
877  if ($a_return) {
878  ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'), true);
879  $this->ctrl->returnToParent($this);
880  }
881  }
882 
890  protected function initTimeZone()
891  {
892  global $ilUser;
893 
894  $this->timezone = $ilUser->getTimeZone();
895  }
896 
901  protected function initInitialDate(ilDate $initialDate)
902  {
903  if (!isset($_GET['hour'])) {
904  $this->initialDate = clone $initialDate;
905  $this->default_fulltime = true;
906  } else {
907  if ((int) $_GET['hour'] < 10) {
908  $time = '0' . (int) $_GET['hour'] . ':00:00';
909  } else {
910  $time = (int) $_GET['hour'] . ':00:00';
911  }
912  $this->initialDate = new ilDateTime($initialDate->get(IL_CAL_DATE) . ' ' . $time, IL_CAL_DATETIME, $this->timezone);
913  $this->default_fulltime = false;
914  }
915  }
916 
924  protected function initSeed(ilDate $seed)
925  {
926  $this->seed = clone $seed;
927  $this->default_fulltime = true;
928  }
929 
937  protected function initAppointment($a_app_id = 0)
938  {
939  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
940  include_once('./Services/Calendar/classes/class.ilCalendarRecurrences.php');
941  $this->app = new ilCalendarEntry($a_app_id);
942 
943  include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
944  $this->notification = new ilCalendarUserNotification($this->app->getEntryId());
945 
946  if (!$a_app_id) {
947  $start = clone $this->initialDate;
948  $this->app->setStart($start);
949 
950  $seed_end = clone $this->initialDate;
951  if ($this->default_fulltime) {
952  #$seed_end->increment(IL_CAL_DAY,1);
953  } else {
954  $seed_end->increment(IL_CAL_HOUR, 1);
955  }
956  $this->app->setEnd($seed_end);
957  $this->app->setFullday($this->default_fulltime);
958 
959  $this->rec = new ilCalendarRecurrence();
960  } else {
961  $this->rec = ilCalendarRecurrences::_getFirstRecurrence($this->app->getEntryId());
962  }
963  }
964 
972  protected function load($a_mode, $a_as_milestone = false)
973  {
974  // needed for date handling
975  $this->initForm($a_mode, $a_as_milestone);
976  $this->form->checkInput();
977 
978  if ($a_as_milestone) {
979  $this->app->setMilestone(true);
980  $this->app->setCompletion(ilUtil::stripSlashes($_POST['completion']));
981  }
982 
983  $this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
984  $this->app->setLocation(ilUtil::stripSlashes($_POST['location']));
985  $this->app->setDescription(ilUtil::stripSlashes($_POST['description']));
986  $this->app->setTitle(ilUtil::stripSlashes($_POST['title']));
987  $this->app->enableNotification((int) $_POST['not']);
988 
989  if ($a_as_milestone) { // milestones are always fullday events
990  $start = $this->form->getItemByPostVar('event_start');
991  $start = $start->getDate();
992 
993  $this->app->setFullday(true);
994 
995  // for milestones is end date = start date
996  $this->app->setStart($start);
997  $this->app->setEnd($start);
998  } else {
999  $period = $this->form->getItemByPostVar('event');
1000  $start = $period->getStart();
1001  $end = $period->getEnd();
1002 
1003  $this->app->setFullday($start instanceof ilDate);
1004  $this->app->setStart($start);
1005  $this->app->setEnd($end);
1006  }
1007 
1008  $this->loadNotificationRecipients();
1009  $this->loadRecurrenceSettings($a_as_milestone = false);
1010  }
1011 
1012  protected function loadNotificationRecipients()
1013  {
1014  $this->notification->setRecipients(array());
1015 
1016  foreach ((array) $_POST['notu'] as $rcp) {
1017  $rcp = trim(ilUtil::stripSlashes($rcp));
1018  $usr_id = ilObjUser::_loginExists($rcp);
1019 
1020  if (strlen($rcp) == 0) {
1021  continue;
1022  }
1023 
1024  if ($usr_id) {
1025  $this->notification->addRecipient(
1027  $usr_id
1028  );
1029  } else {
1030  $this->notification->addRecipient(
1032  0,
1033  $rcp
1034  );
1035  }
1036  }
1037  }
1038 
1045  protected function loadRecurrenceSettings($a_as_milestone = false)
1046  {
1047  $this->rec->reset();
1048 
1049  switch ($_POST['frequence']) {
1050  case IL_CAL_FREQ_DAILY:
1051  $this->rec->setFrequenceType($_POST['frequence']);
1052  $this->rec->setInterval((int) $_POST['count_DAILY']);
1053  break;
1054 
1055  case IL_CAL_FREQ_WEEKLY:
1056  $this->rec->setFrequenceType($_POST['frequence']);
1057  $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1058  if (is_array($_POST['byday_WEEKLY'])) {
1059  $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',', $_POST['byday_WEEKLY'])));
1060  }
1061  break;
1062 
1063  case IL_CAL_FREQ_MONTHLY:
1064  $this->rec->setFrequenceType($_POST['frequence']);
1065  $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1066  switch ((int) $_POST['subtype_MONTHLY']) {
1067  case 0:
1068  // nothing to do;
1069  break;
1070 
1071  case 1:
1072  switch ((int) $_POST['monthly_byday_day']) {
1073  case 8:
1074  // Weekday
1075  $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1076  $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1077  break;
1078 
1079  case 9:
1080  // Day of month
1081  $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1082  break;
1083 
1084  default:
1085  $this->rec->setBYDAY((int) $_POST['monthly_byday_num'] . $_POST['monthly_byday_day']);
1086  break;
1087  }
1088  break;
1089 
1090  case 2:
1091  $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1092  break;
1093  }
1094  break;
1095 
1096  case IL_CAL_FREQ_YEARLY:
1097  $this->rec->setFrequenceType($_POST['frequence']);
1098  $this->rec->setInterval((int) $_POST['count_YEARLY']);
1099  switch ((int) $_POST['subtype_YEARLY']) {
1100  case 0:
1101  // nothing to do;
1102  break;
1103 
1104  case 1:
1105  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1106  $this->rec->setBYDAY((int) $_POST['yearly_byday_num'] . $_POST['yearly_byday']);
1107  break;
1108 
1109  case 2:
1110  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1111  $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1112  break;
1113  }
1114  break;
1115  }
1116 
1117  // UNTIL
1118  switch ((int) $_POST['until_type']) {
1119  case 1:
1120  $this->rec->setFrequenceUntilDate(null);
1121  // nothing to do
1122  break;
1123 
1124  case 2:
1125  $this->rec->setFrequenceUntilDate(null);
1126  $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1127  break;
1128 
1129  case 3:
1130  $dt = new ilDateTimeInputGUI('', 'until_end');
1131  $dt->setRequired(true);
1132  if ($dt->checkInput()) {
1133  $this->rec->setFrequenceUntilCount(0);
1134  $this->rec->setFrequenceUntilDate($dt->getDate());
1135  }
1136  break;
1137  }
1138  }
1139 
1147  protected function saveRecurrenceSettings()
1148  {
1149  switch ($_POST['frequence']) {
1150  case 'NONE':
1151  case '':
1152  // No recurrence => delete if there is an recurrence rule
1153  if ($this->rec->getRecurrenceId()) {
1154  $this->rec->delete();
1155  }
1156  break;
1157 
1158  default:
1159  if ($this->rec->getRecurrenceId()) {
1160  $this->rec->update();
1161  } else {
1162  $this->rec->save();
1163  }
1164  break;
1165  }
1166  }
1167 
1174  protected function createDefaultCalendar()
1175  {
1176  global $ilUser,$lng;
1177 
1178  $cat = new ilCalendarCategory();
1179  $cat->setColor(ilCalendarCategory::DEFAULT_COLOR);
1180  $cat->setType(ilCalendarCategory::TYPE_USR);
1181  $cat->setTitle($this->lng->txt('cal_default_calendar'));
1182  $cat->setObjId($ilUser->getId());
1183 
1184  // delete calendar cache
1185  include_once './Services/Calendar/classes/class.ilCalendarCache.php';
1186  ilCalendarCache::getInstance()->deleteUserEntries($ilUser->getId());
1187 
1188  return $cat->add();
1189  }
1190 
1195  protected function confirmRegister()
1196  {
1197  global $tpl;
1198 
1199  $entry = new ilCalendarEntry((int) $_GET['app_id']);
1201  new ilDateTime($_GET['dstart'], IL_CAL_UNIX),
1202  new ilDateTime($_GET['dend'], IL_CAL_UNIX)
1203  );
1204 
1205 
1206  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1207  $conf = new ilConfirmationGUI;
1208 
1209  $this->ctrl->setParameter($this, 'dstart', (int) $_REQUEST['dstart']);
1210  $this->ctrl->setParameter($this, 'dend', (int) $_REQUEST['dend']);
1211 
1212  $conf->setFormAction($this->ctrl->getFormAction($this));
1213  $conf->setHeaderText($this->lng->txt('cal_confirm_reg_info'));
1214  $conf->setConfirm($this->lng->txt('cal_reg_register'), 'register');
1215  $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1216  $conf->addItem('app_id', $entry->getEntryId(), $entry->getTitle() . ' (' . $start . ')');
1217 
1218  $tpl->setContent($conf->getHTML());
1219  }
1220 
1225  protected function register()
1226  {
1227  global $ilUser;
1228 
1229  include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
1230  $reg = new ilCalendarRegistration((int) $_POST['app_id']);
1231  $reg->register(
1232  $ilUser->getId(),
1233  new ilDateTime((int) $_REQUEST['dstart'], IL_CAL_UNIX),
1234  new ilDateTime((int) $_REQUEST['dend'], IL_CAL_UNIX)
1235  );
1236 
1237  ilUtil::sendSuccess($this->lng->txt('cal_reg_registered'), true);
1238  $this->ctrl->returnToParent($this);
1239  }
1240 
1244  public function confirmUnregister()
1245  {
1246  global $tpl;
1247 
1248 
1249  $entry = new ilCalendarEntry((int) $_GET['app_id']);
1251  $dstart = new ilDateTime($_GET['dstart'], IL_CAL_UNIX),
1252  $dend = new ilDateTime($_GET['dend'], IL_CAL_UNIX)
1253  );
1254 
1255 
1256  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1257  $conf = new ilConfirmationGUI;
1258 
1259  $this->ctrl->setParameter($this, 'dstart', (int) $_REQUEST['dstart']);
1260  $this->ctrl->setParameter($this, 'dend', (int) $_REQUEST['dend']);
1261 
1262  $conf->setFormAction($this->ctrl->getFormAction($this));
1263  $conf->setHeaderText($this->lng->txt('cal_confirm_unreg_info'));
1264  $conf->setConfirm($this->lng->txt('cal_reg_unregister'), 'unregister');
1265  $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1266  $conf->addItem('app_id', $entry->getEntryId(), $entry->getTitle() . ' (' . $start . ')');
1267 
1268  $tpl->setContent($conf->getHTML());
1269  }
1270 
1275  protected function unregister()
1276  {
1277  global $ilUser;
1278 
1279  include_once './Services/Calendar/classes/class.ilCalendarRegistration.php';
1280  $reg = new ilCalendarRegistration((int) $_POST['app_id']);
1281  $reg->unregister(
1282  $ilUser->getId(),
1283  new ilDateTime((int) $_REQUEST['dstart'], IL_CAL_UNIX),
1284  new ilDateTime((int) $_REQUEST['dend'], IL_CAL_UNIX)
1285  );
1286 
1287  ilUtil::sendSuccess($this->lng->txt('cal_reg_unregistered'), true);
1288  $this->ctrl->returnToParent($this);
1289  }
1290 
1294  public function book()
1295  {
1296  global $ilUser, $tpl;
1297 
1298  $entry = (int) $_GET['app_id'];
1299  $user = (int) $_GET['bkid'];
1300 
1301  $this->ctrl->saveParameter($this, 'app_id');
1302 
1303  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1304  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1305  $entry = new ilCalendarEntry($entry);
1306 
1307  $form = $this->initFormConfirmBooking();
1308  $form->getItemByPostVar('date')->setValue(ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd()));
1309  $form->getItemByPostVar('title')->setValue($entry->getTitle() . " (" . ilObjUser::_lookupFullname($user) . ')');
1310 
1311  $tpl->setContent($form->getHTML());
1312  return true;
1313  }
1314 
1319  protected function initFormConfirmBooking()
1320  {
1321  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1322  $form = new ilPropertyFormGUI();
1323  $form->setFormAction($this->ctrl->getFormAction($this));
1324  $form->addCommandButton('bookconfirmed', $this->lng->txt('cal_confirm_booking'));
1325  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
1326 
1327  $date = new ilNonEditableValueGUI($this->lng->txt('appointment'), 'date');
1328  $form->addItem($date);
1329 
1330  $title = new ilNonEditableValueGUI($this->lng->txt('title'), 'title');
1331  $form->addItem($title);
1332 
1333  $message = new ilTextAreaInputGUI($this->lng->txt('cal_ch_booking_message_tbl'), 'comment');
1334  $message->setRows(5);
1335  $form->addItem($message);
1336 
1337  return $form;
1338  }
1339 
1343  public function bookconfirmed()
1344  {
1345  global $ilUser;
1346 
1347  $entry = (int) $_REQUEST['app_id'];
1348  $user = (int) $_REQUEST['bkid'];
1349 
1350  $form = $this->initFormConfirmBooking();
1351  if ($form->checkInput()) {
1352  // check if appointment is bookable
1353  include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
1354  $cal_entry = new ilCalendarEntry($entry);
1355 
1356  include_once './Services/Booking/classes/class.ilBookingEntry.php';
1357  $booking = new ilBookingEntry($cal_entry->getContextId());
1358 
1359  if (!$booking->isAppointmentBookableForUser($entry, $GLOBALS['ilUser']->getId())) {
1360  ilUtil::sendFailure($this->lng->txt('cal_booking_failed_info'), true);
1361  $this->ctrl->returnToParent($this);
1362  }
1363 
1364  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
1365  ilConsultationHourUtils::bookAppointment($ilUser->getId(), $entry);
1366 
1367  include_once './Services/Booking/classes/class.ilBookingEntry.php';
1368  ilBookingEntry::writeBookingMessage($entry, $ilUser->getId(), $form->getInput('comment'));
1369  }
1370  ilUtil::sendSuccess($this->lng->txt('cal_booking_confirmed'), true);
1371  $this->ctrl->returnToParent($this);
1372  }
1373 
1378  public function cancelBooking()
1379  {
1380  global $ilUser, $tpl;
1381 
1382  $entry = (int) $_GET['app_id'];
1383 
1384  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1385  $entry = new ilCalendarEntry($entry);
1386 
1387  $category = $this->calendarEntryToCategory($entry);
1388  if ($category->getType() == ilCalendarCategory::TYPE_CH) {
1389  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1390  $booking = new ilBookingEntry($entry->getContextId());
1391  if (!$booking->hasBooked($entry->getEntryId())) {
1392  $this->ctrl->returnToParent($this);
1393  return false;
1394  }
1395 
1396  $entry_title = ' ' . $entry->getTitle() . " (" . ilObjUser::_lookupFullname($booking->getObjId()) . ')';
1397  } elseif ($category->getType() == ilCalendarCategory::TYPE_BOOK) {
1398  $entry_title = ' ' . $entry->getTitle();
1399  } else {
1400  $this->ctrl->returnToParent($this);
1401  return false;
1402  }
1403 
1404  $title = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd());
1405 
1406  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1407  $conf = new ilConfirmationGUI;
1408  $conf->setFormAction($this->ctrl->getFormAction($this));
1409  $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info'));
1410  $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed');
1411  $conf->setCancel($this->lng->txt('cancel'), 'cancel');
1412  $conf->addItem('app_id', $entry->getEntryId(), $title . ' - ' . $entry_title);
1413 
1414  $tpl->setContent($conf->getHTML());
1415  }
1416 
1421  public function cancelConfirmed()
1422  {
1423  global $ilUser;
1424 
1425  $entry = (int) $_POST['app_id'];
1426  $user = (int) $_GET['bkid'];
1427 
1428  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
1429  $entry = new ilCalendarEntry($entry);
1430 
1431  $category = $this->calendarEntryToCategory($entry);
1432  if ($category->getType() == ilCalendarCategory::TYPE_CH) {
1433  // find cloned calendar entry in user calendar
1434  include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
1435  $GLOBALS['ilLog']->dump($entry->getStart());
1437  $ilUser->getId(),
1438  $entry->getContextId(),
1439  $entry->getStart(),
1441  false
1442  );
1443  $GLOBALS['ilLog']->dump($apps);
1444 
1445  // Fix for wrong, old entries
1446  foreach ((array) $apps as $own_app) {
1447  $ref_entry = new ilCalendarEntry($own_app);
1448  $ref_entry->delete();
1449  }
1450 
1451  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
1452  $booking = new ilBookingEntry($entry->getContextId());
1453  $booking->cancelBooking($entry->getEntryId());
1454 
1455  // do NOT delete original entry
1456  } elseif ($category->getType() == ilCalendarCategory::TYPE_BOOK) {
1457  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
1458  $booking = new ilBookingReservation($entry->getContextId());
1460  $booking->update();
1461 
1462  $entry->delete();
1463  }
1464 
1465  ilUtil::sendSuccess($this->lng->txt('cal_cancel_booking_confirmed'), true);
1466  $this->ctrl->returnToParent($this);
1467  }
1468 
1474  protected function calendarEntryToCategory(ilCalendarEntry $entry)
1475  {
1476  include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
1477  include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
1478  $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
1479  $assignment = $assignment->getFirstAssignment();
1480  return new ilCalendarCategory($assignment);
1481  }
1482 
1487  protected function doUserAutoComplete()
1488  {
1489  if (!isset($_GET['autoCompleteField'])) {
1490  $a_fields = array('login','firstname','lastname','email');
1491  } else {
1492  $a_fields = array((string) $_GET['autoCompleteField']);
1493  }
1494 
1495  $GLOBALS['ilLog']->write(print_r($a_fields, true));
1496  include_once './Services/User/classes/class.ilUserAutoComplete.php';
1497  $auto = new ilUserAutoComplete();
1498  $auto->setSearchFields($a_fields);
1499  $auto->enableFieldSearchableCheck(true);
1500  $auto->setMoreLinkAvailable(true);
1501 
1502  if (($_REQUEST['fetchall'])) {
1503  $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
1504  }
1505 
1506  echo $auto->getList($_REQUEST['query']);
1507  exit();
1508  }
1509 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupLogin($a_user_id)
lookup login
getAppointment()
Get current appointment.
static getInstance()
get singleton instance
global $ilErr
Definition: raiseError.php:16
Set timezone
static _lookupCategory($a_cal_id)
Lookup category id.
static _getRecurrences($a_cal_id)
get all recurrences of an appointment
const IL_CAL_FREQ_MONTHLY
Model for a calendar entry.
static _getInstance()
get singleton instance
cancelConfirmed()
Cancel consultation appointment or ressource booking, was confirmed This will delete the calendar ent...
Class ilInfoScreenGUI.
const IL_CAL_DATETIME
setStatus($a_status)
Set booking status.
This class represents a selection list property in a property form.
This class represents a property form user interface.
$type
$_GET["client_id"]
const IL_CAL_HOUR
setFormAction($a_form_action)
static _lookupFullname($a_user_id)
Lookup Full Name.
static _getFirstRecurrence($a_cal_id)
get first recurrence
This class represents an input GUI for recurring events/appointments (course events or calendar appoi...
Distributes calendar mail notifications.
edit($a_edit_single_app=false, ilPropertyFormGUI $form=null)
edit appointment
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
initAppointment($a_app_id=0)
init appointment
$end
Definition: saml1-acs.php:18
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
getEntryId()
get entry id
static getAppointmentIds($a_user_id, $a_context_id=null, $a_start=null, $a_type=null, $a_check_owner=true)
Get all appointment ids.
setValue($a_value)
Set Value.
Booking definition.
initInitialDate(ilDate $initialDate)
init initial date
static _lookupCategoryIdByObjId($a_obj_id)
lookup category by obj_id
This class represents a checkbox property in a property form.
saveMilestoneResponsibleUsers()
Save milestone responsibilites.
Stores calendar categories.
const IL_CAL_UNIX
unregister()
Unregister calendar, was confirmed.
editResponsibleUsers()
Edit responsible users.
askEdit()
Check edit single apppointment / edit all appointments for recurring appointments.
TableGUI class for selection of milestone responsibles.
static _getAllReferences($a_id)
get all reference ids of object
get($a_format, $a_format_str='', $a_tz='')
get formatted date
deleteExclude($a_return=true)
delete single item of recurrence list
Auto completion class for user lists.
This class represents a date/time property in a property form.
global $ilCtrl
Definition: ilias.php:18
confirmUnregister()
Confirmation screen to unregister calendar.
setInfo($a_info)
Set Information Text.
$time
Definition: cron.php:21
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...
const IL_CAL_DAY
input GUI for a time span (start and end date)
static writeBookingMessage($a_entry_id, $a_usr_id, $a_message)
Write booking message.
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
$r
Definition: example_031.php:79
catch(Exception $e) $message
Class for single dates.
if(isset($_POST['submit'])) $form
Calculates an ilDateList for a given calendar entry and recurrence rule.
setValue($a_value)
Set Value.
distributeUserNotifications()
Send mail to selected users ilObjUser $ilUser.
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
const IL_CAL_FREQ_YEARLY
calendarEntryToCategory(ilCalendarEntry $entry)
Get category object of given calendar entry.
static _lookupObjId($a_id)
registration for calendar appointments
This class represents a text property in a property form.
setDate(ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
static initDomEvent()
Init YUI DomEvent.
cancelBooking($a_entry_id, $a_user_id=false)
cancel calendar booking for user
notification()
Definition: notification.php:2
Date and time handling
$ilUser
Definition: imgupload.php:18
save($a_as_milestone=false)
save appointment
initForm($a_mode, $a_as_milestone=false, $a_edit_single_app=false)
init form
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static _deleteByAppointmentId($a_app_id)
Delete appointment assignment.
setOptions($a_options)
Set Options.
static _getInstance($a_usr_id=0)
get singleton instance
cancelBooking()
Confirmation screen to cancel consultation appointment or ressource booking depends on calendar categ...
distributeNotifications($a_cat_id, $app_id, $a_new_appointment=true)
Distribute mail notifications.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
$users
Definition: authpage.php:44
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
bookconfirmed()
Book consultation appointment, was confirmed.
__construct(ilDate $seed, ilDate $initialDate, $a_appointment_id=0)
Constructor.
load($a_mode, $a_as_milestone=false)
load post
loadRecurrenceSettings($a_as_milestone=false)
load recurrence settings
add(ilPropertyFormGUI $form=null)
add new appointment
const IL_CAL_DATE
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
This class represents a non editable value in a property form.
editSingle()
Edit one single appointment ^.
Administrate calendar appointments.
global $ilSetting
Definition: privfeed.php:17
This class represents a text area property in a property form.
$i
Definition: disco.tpl.php:19
saveRecurrenceSettings()
save recurrence settings
Stores exclusion dates for calendar recurrences.
createDefaultCalendar()
Create a default calendar.
This class represents a text wizard property in a property form.
book()
Confirmation screen for booking of consultation appointment.
$info
Definition: index.php:5
static deleteCalendarEntry($a_cal_id)
Delete notification for a calendar entry ilDB $ilDB.
setValue($a_value)
Set Value.
$_POST["username"]
setRequired($a_required)
Set Required.
const IL_CAL_FREQ_WEEKLY
confirmRegister()
Register to an appointment.
showResponsibleUsersList($a_grp_id)
Show responsible uses of a milestone (default set is participants of group)
Confirmation screen class.
static bookAppointment($a_usr_id, $a_app_id)
Book an appointment.