ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCalendarBlockGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("Services/Block/classes/class.ilBlockGUI.php");
6include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
7
21{
25 public $ctrl = null;
26 protected $mode;
27 protected $display_mode;
28
29 public static $block_type = "cal";
30 public static $st_data;
31
35 protected $tabs;
36
40 protected $obj_data_cache;
41
42 protected $parent_gui = "ilcolumngui";
43
47 protected $ui;
48
49 protected $force_month_view = false;
50
56 public function __construct()
57 {
58 global $DIC;
59
60 parent::__construct();
61
62 $this->tabs = $DIC->tabs();
63 $this->obj_data_cache = $DIC["ilObjDataCache"];
64 $this->ui = $DIC->ui();
65
70 $ilHelp = $DIC["ilHelp"];
71
72
73 $lng->loadLanguageModule("dateplaner");
74 $ilHelp->addHelpSection("cal_block");
75
76 include_once("./Services/News/classes/class.ilNewsItem.php");
77
78 $ilCtrl->saveParameter($this, 'bkid');
79
80 $this->setBlockId($ilCtrl->getContextObjId());
81
82 $this->setLimit(5); // @todo: needed?
83
84 // alex: original detail level 1 did not work anymore
86 $this->setEnableNumInfo(false);
87
88 //if(!isset($_GET["bkid"]))
89 //{
90 $title = $lng->txt("calendar");
91 //}
92 //else
93 //{
94 // $title = $lng->txt("cal_consultation_hours_for")." ".ilObjUser::_lookupFullname($_GET["bkid"]);
95 //}
96
97 $this->setTitle($title);
98 //$this->setData($data);
99 $this->allow_moving = false;
100 //$this->handleView();
101
102 include_once('Services/Calendar/classes/class.ilDate.php');
103 include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
104
105 $seed_str = "";
106 if ((!isset($_GET["seed"]) || $_GET["seed"] == "") &&
107 isset($_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"])) {
108 $seed_str = $_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"];
109 } elseif (isset($_GET["seed"])) {
110 $seed_str = $_GET["seed"];
111 }
112
113 if (isset($_GET["seed"]) && $_GET["seed"] != "") {
114 $_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"]
115 = $_GET["seed"];
116 }
117
118 if ($seed_str == "") {
119 $this->seed = new ilDate(time(), IL_CAL_UNIX); // @todo: check this
120 } else {
121 $this->seed = new ilDate($seed_str, IL_CAL_DATE); // @todo: check this
122 }
123
125 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
126
127 $mode = $ilUser->getPref("il_pd_cal_mode");
128 $this->display_mode = $mode ? $mode : "mmon";
129 }
130
137 public function getShowWeeksColumn()
138 {
139 return ($this->settings->getShowWeeks() && $this->user_settings->getShowWeeks());
140 }
141
142
148 public static function getBlockType()
149 {
150 return self::$block_type;
151 }
152
158 public static function isRepositoryObject()
159 {
160 return false;
161 }
162
168 public function setParentGUI($a_val)
169 {
170 $this->parent_gui = $a_val;
171 }
172
178 public function getParentGUI()
179 {
180 return $this->parent_gui;
181 }
182
188 public function setForceMonthView($a_val)
189 {
190 $this->force_month_view = $a_val;
191 if ($a_val) {
192 $this->display_mode = "mmon";
193 }
194 }
195
201 public function getForceMonthView()
202 {
204 }
205
209 public static function getScreenMode()
210 {
211 global $DIC;
212
213 $ilCtrl = $DIC->ctrl();
214
215 $cmd_class = $ilCtrl->getCmdClass();
216
217 if ($cmd_class == "ilcalendarappointmentgui" ||
218 $cmd_class == "ilconsultationhoursgui" ||
219 $_GET['cmd'] == 'showCalendarSubscription') {
220 return IL_SCREEN_CENTER;
221 }
222
223 switch ($ilCtrl->getCmd()) {
224 case "kkk":
225 // return IL_SCREEN_CENTER;
226 // return IL_SCREEN_FULL;
227
228 default:
229 //return IL_SCREEN_SIDE;
230 break;
231 }
232 }
233
237 public function executeCommand()
238 {
240 $ilTabs = $this->tabs;
241
242
243 $next_class = $ilCtrl->getNextClass();
244 $cmd = $ilCtrl->getCmd("getHTML");
245
246 $this->setSubTabs();
247
248 switch ($next_class) {
249 case "ilcalendarappointmentgui":
250 include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
251 $app_gui = new ilCalendarAppointmentGUI($this->seed, $this->seed);
252 $ilCtrl->forwardCommand($app_gui);
253 break;
254
255 case "ilconsultationhoursgui":
256 include_once('./Services/Calendar/classes/ConsultationHours/class.ilConsultationHoursGUI.php');
257 $hours = new ilConsultationHoursGUI($this->seed);
258 $ilCtrl->forwardCommand($hours);
259 break;
260
261 case "ilcalendarappointmentpresentationgui":
262 $this->initCategories();
263 $presentation = ilCalendarAppointmentPresentationGUI::_getInstance($this->seed, $this->appointment);
264 $ilCtrl->forwardCommand($presentation);
265 break;
266
267 case "ilcalendarmonthgui":
268 $ilTabs->setSubTabActive('app_month');
269 include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
270 $month_gui = new ilCalendarMonthGUI($this->seed);
271 $ilCtrl->forwardCommand($month_gui);
272 break;
273
274 default:
275 return $this->$cmd();
276 }
277 }
278
284 public function setEnableEdit($a_enable_edit = 0)
285 {
286 $this->enable_edit = $a_enable_edit;
287 }
288
294 public function getEnableEdit()
295 {
296 return $this->enable_edit;
297 }
298
302 public function fillDataSection()
303 {
304 // alex: changed from > 1 to > 0 - original detail level 1 did not work anymore
305 if ($this->getCurrentDetailLevel() > 0 && $this->display_mode != "mmon") {
306 $this->setColSpan(1);
307 $this->setRowTemplate("tpl.pd_event_list.html", "Services/Calendar");
308
310 } else {
311 // alex: changed from > 1 to > 0 - original detail level 1 did not work anymore
312 if ($this->getCurrentDetailLevel() > 0) {
313 $tpl = new ilTemplate(
314 "tpl.calendar_block.html",
315 true,
316 true,
317 "Services/Calendar"
318 );
319
320 $this->addMiniMonth($tpl);
321 $this->setDataSection($tpl->get());
322 } else {
323 $this->setDataSection($this->getOverview());
324 }
325 }
326 }
327
334 public function getTargetGUIClassPath()
335 {
336 $target_class = array();
337 if (!$this->getRepositoryMode()) {
338 $target_class = array("ilpersonaldesktopgui", "ilcalendarpresentationgui");
339 } else {
340 switch (ilObject::_lookupType((int) $_GET["ref_id"], true)) {
341 case "crs":
342 $target_class = array("ilobjcoursegui", "ilcalendarpresentationgui");
343 break;
344
345 case "grp":
346 $target_class = array("ilobjgroupgui", "ilcalendarpresentationgui");
347 break;
348 }
349 }
350 return $target_class;
351 }
352
357 public function addMiniMonth($a_tpl)
358 {
362 $ui = $this->ui;
363
364
365 // weekdays
366 include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
367 if ($this->getShowWeeksColumn()) {
368 $a_tpl->setCurrentBlock('month_header_col');
369 $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
370 $a_tpl->parseCurrentBlock();
371 }
372 for ($i = (int) $this->user_settings->getWeekStart();$i < (7 + (int) $this->user_settings->getWeekStart());$i++) {
373 $a_tpl->setCurrentBlock('month_header_col');
374 $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
375 $a_tpl->parseCurrentBlock();
376 }
377
378 if (isset($_GET["bkid"])) {
379 $user_id = $_GET["bkid"];
380 $disable_empty = true;
381 } else {
382 $user_id = $ilUser->getId();
383 $disable_empty = false;
384 }
385 include_once('Services/Calendar/classes/class.ilCalendarSchedule.php');
386 $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id);
387 $this->scheduler->addSubitemCalendars(true);
388 $this->scheduler->calculate();
389
390 $counter = 0;
392 $this->seed->get(IL_CAL_FKT_DATE, 'm'),
393 $this->seed->get(IL_CAL_FKT_DATE, 'Y'),
394 $this->user_settings->getWeekStart()
395 )->get() as $date) {
396 $counter++;
397
398 $events = $this->scheduler->getByDay($date, $ilUser->getTimeZone());
399 $has_events = (bool) count($events);
400 if ($has_events || !$disable_empty) {
401 $a_tpl->setCurrentBlock('month_col_link');
402 } else {
403 $a_tpl->setCurrentBlock('month_col_no_link');
404 }
405
406 if ($disable_empty) {
407 if (!$has_events) {
408 $a_tpl->setVariable('DAY_CLASS', 'calminiinactive');
409 } else {
410 $week_has_events = true;
411 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
412 foreach ($events as $event) {
413 $booking = new ilBookingEntry($event['event']->getContextId());
414 if ($booking->hasBooked($event['event']->getEntryId())) {
415 $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
416 break;
417 }
418 }
419 }
420 } elseif ($has_events) {
421 $week_has_events = true;
422 $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
423 }
424
425
426 $day = $date->get(IL_CAL_FKT_DATE, 'j');
427 $month = $date->get(IL_CAL_FKT_DATE, 'n');
428
429 $month_day = $day;
430
431 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), 'seed', $date->get(IL_CAL_DATE));
432 if ($agenda_view_type = (int) $_GET['cal_agenda_per']) {
433 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "cal_agenda_per", $agenda_view_type);
434 }
435 $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass($this->getTargetGUIClassPath(), ''));
436
437 $a_tpl->setVariable('MONTH_DAY', $month_day);
438
439 $a_tpl->parseCurrentBlock();
440
441
442 $a_tpl->setCurrentBlock('month_col');
443
444 include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
445 if (ilCalendarUtil::_isToday($date)) {
446 $a_tpl->setVariable('TD_CLASS', 'calminitoday');
447 }
448 #elseif(ilDateTime::_equals($date,$this->seed,IL_CAL_DAY))
449 #{
450 # $a_tpl->setVariable('TD_CLASS','calmininow');
451 #}
452 elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
453 $a_tpl->setVariable('TD_CLASS', 'calministd');
454 } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
455 $a_tpl->setVariable('TD_CLASS', 'calminiprev');
456 } else {
457 $a_tpl->setVariable('TD_CLASS', 'calmininext');
458 }
459
460 $a_tpl->parseCurrentBlock();
461
462
463 if ($counter and !($counter % 7)) {
464 if ($this->getShowWeeksColumn()) {
465 $a_tpl->setCurrentBlock('week');
466 $a_tpl->setVariable(
467 'WEEK',
468 $date->get(IL_CAL_FKT_DATE, 'W')
469 );
470 $a_tpl->parseCurrentBlock();
471 }
472
473 $a_tpl->setCurrentBlock('month_row');
474 //$a_tpl->setVariable('TD_CLASS','calminiweek');
475 $a_tpl->parseCurrentBlock();
476
477 $week_has_events = false;
478 }
479 }
480 $a_tpl->setCurrentBlock('mini_month');
481 $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
482
483 $myseed = clone($this->seed);
484
485 $myseed->increment(ilDateTime::MONTH, -1);
486 $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE));
487
488 $prev_link = $ilCtrl->getLinkTarget($this, "setSeed", "", true);
489
490 $myseed->increment(ilDateTime::MONTH, 2);
491 $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE));
492 $next_link = $ilCtrl->getLinkTarget($this, "setSeed", "", true);
493
494 $ilCtrl->setParameter($this, 'seed', "");
495
496 $blockgui = $this;
497
498 // view control
499 // ... previous button
500 $b1 = $ui->factory()->button()->standard($lng->txt("previous"), "#")->withOnLoadCode(function ($id) use ($prev_link, $blockgui) {
501 return
502 "$('#" . $id . "').click(function() { ilBlockJSHandler('block_" . $blockgui->getBlockType() .
503 "_" . $blockgui->getBlockId() . "','" . $prev_link . "'); return false;});";
504 });
505
506 // ... month button
507 $ilCtrl->clearParameterByClass("ilcalendarblockgui", 'seed');
508 $month_link = $ilCtrl->getLinkTarget($this, "setSeed", "", true, false);
509 $seed_parts = explode("-", $this->seed->get(IL_CAL_DATE));
510 $b2 = $ui->factory()->button()->month($seed_parts[1] . "-" . $seed_parts[0])->withOnLoadCode(function ($id) use ($month_link, $blockgui) {
511 return "$('#" . $id . "').on('il.ui.button.month.changed', function(el, id, month) { var m = month.split('-'); ilBlockJSHandler('block_" . $blockgui->getBlockType() .
512 "_" . $blockgui->getBlockId() . "','" . $month_link . "' + '&seed=' + m[1] + '-' + m[0] + '-01'); return false;});";
513 });
514 // ... next button
515 $b3 = $ui->factory()->button()->standard($lng->txt("next"), "#")->withOnLoadCode(function ($id) use ($next_link, $blockgui) {
516 return
517 "$('#" . $id . "').click(function() { ilBlockJSHandler('block_" . $blockgui->getBlockType() .
518 "_" . $blockgui->getBlockId() . "','" . $next_link . "'); return false;});";
519 });
520
521
522 $vc = $ui->factory()->viewControl()->section($b1, $b2, $b3);
523 $a_tpl->setVariable("VIEW_CTRL_SECTION", $ui->renderer()->render($vc));
524
525 $a_tpl->parseCurrentBlock();
526 }
527
531 public function getHTML()
532 {
533 $this->initCategories();
536 $ilAccess = $this->access;
537 $ilObjDataCache = $this->obj_data_cache;
539
540 if ($this->getCurrentDetailLevel() == 0) {
541 return "";
542 }
543
544 // add edit commands
545 #if ($this->getEnableEdit())
546
547 //if($this->mode == ilCalendarCategories::MODE_PERSONAL_DESKTOP_ITEMS or
548 // $this->mode == ilCalendarCategories::MODE_PERSONAL_DESKTOP_MEMBERSHIP)
549 //{
550 /*include_once("./Services/News/classes/class.ilRSSButtonGUI.php");
551 $this->addBlockCommand(
552 $this->ctrl->getLinkTarget($this,'showCalendarSubscription'),
553 $lng->txt('ical_export'),
554 "", "", true, false, ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_ICAL)
555 );*/
556
557 include_once("./Services/News/classes/class.ilRSSButtonGUI.php");
558 $gui_path = $this->getTargetGUIClassPath();
559 $gui_path[] = "ilcalendarsubscriptiongui";
560 $this->addBlockCommand(
561 $this->ctrl->getLinkTargetByClass($gui_path),
562 $lng->txt('ical_export'),
563 "",
564 "",
565 true,
566 false,
568 );
569 //}
570
571
572 if ($this->mode == ilCalendarCategories::MODE_REPOSITORY) {
573 if (!isset($_GET["bkid"])) {
574 /*
575 if($ilAccess->checkAccess('edit_event','',(int) $_GET['ref_id']))
576 {
577 $ilCtrl->setParameter($this, "add_mode", "block");
578 $this->addBlockCommand(
579 $ilCtrl->getLinkTargetByClass("ilCalendarAppointmentGUI",
580 "add"),
581 $lng->txt("add_appointment"));
582 $ilCtrl->setParameter($this, "add_mode", "");
583 }*/
584
585 include_once "Modules/Course/classes/class.ilCourseParticipants.php";
586 $obj_id = $ilObjDataCache->lookupObjId((int) $_GET['ref_id']);
587 $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
588 $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
589 //$users = $participants->getParticipants();
590 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
592 foreach ($users as $user_id) {
593 if (!isset($_GET["bkid"])) {
594 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
595 $now = new ilDateTime(time(), IL_CAL_UNIX);
596
597 // default to last booking entry
598 $appointments = ilConsultationHourAppointments::getAppointments($user_id);
599 $next_app = end($appointments);
600 reset($appointments);
601
602 foreach ($appointments as $entry) {
603 // find next entry
604 if (ilDateTime::_before($entry->getStart(), $now, IL_CAL_DAY)) {
605 continue;
606 }
607 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
608 $booking_entry = new ilBookingEntry($entry->getContextId());
609 if (!in_array($obj_id, $booking_entry->getTargetObjIds())) {
610 continue;
611 }
612
613 if (!$booking_entry->isAppointmentBookableForUser($entry->getEntryId(), $user->getId())) {
614 continue;
615 }
616 $next_app = $entry;
617 break;
618 }
619
620 /*
621 $ilCtrl->setParameter($this, "bkid", $user_id);
622 if($next_app)
623 {
624 $ilCtrl->setParameter(
625 $this,
626 'seed',
627 (string) $next_app->getStart()->get(IL_CAL_DATE)
628 );
629 }*/
630
631 //$ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "bkid", $user_id);
632
633 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "ch_user_id", $user_id);
634
635 if ($next_app) {
636 // this does not work correctly
637 /*$ilCtrl->setParameterByClass(
638 end($this->getTargetGUIClassPath()),
639 'seed',
640 (string) $next_app->getStart()->get(IL_CAL_DATE)
641 );*/
642 }
643
644 if (!$this->getForceMonthView()) {
645 $this->cal_footer[] = array(
646 'link' => $ilCtrl->getLinkTargetByClass($this->getTargetGUIClassPath(), 'selectCHCalendarOfUser'),
647 'txt' => str_replace("%1", ilObjUser::_lookupFullname($user_id), $lng->txt("cal_consultation_hours_for_user"))
648 );
649 }
650 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "ch_user_id", "");
651 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "bkid", $_GET["bkid"]);
652 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "seed", $_GET["seed"]);
653 }
654 }
655 $ilCtrl->setParameter($this, "bkid", "");
656 $ilCtrl->setParameter($this, 'seed', '');
657 } else {
658 $ilCtrl->setParameter($this, "bkid", "");
659 $this->addBlockCommand(
660 $ilCtrl->getLinkTarget($this),
661 $lng->txt("back")
662 );
663 $ilCtrl->setParameter($this, "bkid", (int) $_GET["bkid"]);
664 }
665 }
666
667 if ($this->getProperty("settings") == true) {
668 $this->addBlockCommand(
669 $ilCtrl->getLinkTarget($this, "editSettings"),
670 $lng->txt("settings")
671 );
672 }
673
674 $ilCtrl->setParameterByClass($this->getParentGUI(), "seed", isset($_GET["seed"]) ? $_GET["seed"] : "");
675 $ret = parent::getHTML();
676 $ilCtrl->setParameterByClass($this->getParentGUI(), "seed", "");
677
678 // workaround to include asynch code from ui only one time, see #20853
679 if ($ilCtrl->isAsynch()) {
680 global $DIC;
681 $f = $DIC->ui()->factory()->legacy("");
682 $ret.= $DIC->ui()->renderer()->renderAsync($f);
683 }
684
685 return $ret;
686 }
687
691 public function getOverview()
692 {
695
696
697 include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
698 $schedule = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_INBOX);
699 $events = $schedule->getChangedEvents(true);
700
701 $ilCtrl->setParameterByClass('ilcalendarinboxgui', 'changed', 1);
702 $link = '<a href=' . $ilCtrl->getLinkTargetByClass('ilcalendarinboxgui', '') . '>';
703 $ilCtrl->setParameterByClass('ilcalendarinboxgui', 'changed', '');
704 $text = '<div class="small">' . ((int) count($events)) . " " . $lng->txt("cal_changed_events_header") . "</div>";
705 $end_link = '</a>';
706
707 return $link . $text . $end_link;
708 }
709
710 public function addCloseCommand($a_content_block)
711 {
714
715 $a_content_block->addHeaderCommand(
716 $ilCtrl->getParentReturn($this),
717 $lng->txt("close"),
718 true
719 );
720 }
721
729 protected function initCategories()
730 {
732
734 if ($this->getForceMonthView()) {
735 // @todo: why not
736 }
737 elseif (!$cats->getMode()) {
738 $cats->initialize(
740 (int) $_GET['ref_id'],
741 true
742 );
743 }
744 }
745
751 protected function setSubTabs()
752 {
753 $ilTabs = $this->tabs;
754
755 $ilTabs->clearSubTabs();
756 }
757
761 public function setSeed()
762 {
764
765 //$ilUser->writePref("il_pd_bkm_mode", 'flat');
766 $_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"] =
767 $_GET["seed"];
768 if ($ilCtrl->isAsynch()) {
769 echo $this->getHTML();
770 exit;
771 } else {
772 $this->returnToUpperContext();
773 }
774 }
775
779 public function returnToUpperContext()
780 {
782
783 $ilCtrl->returnToParent($this);
784 }
785
786
791 public function showCalendarSubscription()
792 {
793 return;
796
797 $tpl = new ilTemplate('tpl.show_calendar_subscription.html', true, true, 'Services/Calendar');
798
799 $tpl->setVariable('TXT_TITLE', $lng->txt('cal_subscription_header'));
800 $tpl->setVariable('TXT_INFO', $lng->txt('cal_subscription_info'));
801 $tpl->setVariable('TXT_CAL_URL', $lng->txt('cal_subscription_url'));
802
803 include_once './Services/Calendar/classes/class.ilCalendarAuthenticationToken.php';
804
805 switch ($this->mode) {
809 $calendar = 0;
810 break;
811
812 default:
814 // TODO: calendar id
815 $calendar = ilObject::_lookupObjId((int) $_GET['ref_id']);
816 break;
817 }
818 if ($hash = ilCalendarAuthenticationToken::lookupAuthToken($ilUser->getId(), $selection, $calendar)) {
819 } else {
820 $token = new ilCalendarAuthenticationToken($ilUser->getId());
821 $token->setSelectionType($selection);
822 $token->setCalendar($calendar);
823 $hash = $token->add();
824 }
825 $url = ILIAS_HTTP_PATH . '/calendar.php?client_id=' . CLIENT_ID . '&token=' . $hash;
826
827 $tpl->setVariable('VAL_CAL_URL', $url);
828 $tpl->setVariable('VAL_CAL_URL_TXT', $url);
829
830 include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
831 $content_block = new ilPDContentBlockGUI();
832 $content_block->setContent($tpl->get());
833 $content_block->setTitle($lng->txt("calendar"));
834 $content_block->addHeaderCommand(
835 $this->ctrl->getParentReturn($this),
836 $lng->txt("selected_items_back")
837 );
838
839 return $content_block->getHTML();
840 }
841
842 public function fillFooter()
843 {
844 // begin-patch ch
845 foreach ((array) $this->cal_footer as $link_info) {
846 $this->tpl->setCurrentBlock('data_section');
847 $this->tpl->setVariable(
848 'DATA',
849 sprintf('<a href="%s">%s</a>', $link_info['link'], $link_info['txt'])
850 );
851 $this->tpl->parseCurrentBlock();
852 }
853 // end-patch ch
854
855 $this->setFooterLinks();
856 $this->fillFooterLinks();
857 $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
858 if ($this->tpl->blockExists("block_footer")) {
859 $this->tpl->setCurrentBlock("block_footer");
860 $this->tpl->parseCurrentBlock();
861 }
862 }
863
864 public function setFooterLinks()
865 {
868
869
870 // alex: changed from < 2 to < 1 - original detail level 1 did not work anymore
871 if ($this->getCurrentDetailLevel() < 1) {
872 return;
873 }
874
875 if (!$this->getForceMonthView()) {
876 $this->addFooterLink(
877 $lng->txt("cal_upcoming_events_header"),
878 $ilCtrl->getLinkTarget($this, "setPdModeEvents"),
879 $ilCtrl->getLinkTarget($this, "setPdModeEvents", "", true),
880 "block_" . $this->getBlockType() . "_" . $this->block_id,
881 false,
882 false,
883 ($this->display_mode != 'mmon')
884 );
885
886 $this->addFooterLink(
887 $lng->txt("app_month"),
888 $ilCtrl->getLinkTarget($this, "setPdModeMonth"),
889 $ilCtrl->getLinkTarget($this, "setPdModeMonth", "", true),
890 "block_" . $this->getBlockType() . "_" . $this->block_id,
891 false,
892 false,
893 ($this->display_mode == 'mmon')
894 );
895
896 if ($this->getRepositoryMode()) {
897 #23921
898 $ilCtrl->setParameterByClass('ilcalendarpresentationgui', 'seed', '');
899 $this->addFooterLink(
900 $lng->txt("cal_open_calendar"),
901 $ilCtrl->getLinkTargetByClass($this->getTargetGUIClassPath(), ""),
902 "",
903 "block_" . $this->getBlockType() . "_" . $this->block_id,
904 false,
905 false
906 );
907
908 $ilCtrl->setParameter($this, "add_mode", "");
909 $this->addFooterLink(
910 $lng->txt("add_appointment"),
911 $ilCtrl->getLinkTargetByClass("ilCalendarAppointmentGUI", "add"),
912 "",
913 "block_" . $this->getBlockType() . "_" . $this->block_id,
914 false,
915 false
916 );
917 $ilCtrl->setParameter($this, "add_mode", "");
918 }
919 }
920 }
921
922 public function setPdModeEvents()
923 {
926
927
928 $ilUser->writePref("il_pd_cal_mode", "evt");
929 $this->display_mode = "evt";
930 if ($ilCtrl->isAsynch()) {
931 echo $this->getHTML();
932 exit;
933 } else {
934 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
935 }
936 }
937
938 public function setPdModeMonth()
939 {
942
943 $ilUser->writePref("il_pd_cal_mode", "mmon");
944 $this->display_mode = "mmon";
945 if ($ilCtrl->isAsynch()) {
946 echo $this->getHTML();
947 exit;
948 } else {
949 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
950 }
951 }
952
959 public function getEvents()
960 {
961 $seed = new ilDate(date('Y-m-d', time()), IL_CAL_DATE);
962
963 include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
965 $schedule->addSubitemCalendars(true); // #12007
966 $schedule->setEventsLimit(20);
967 $schedule->calculate();
968 $ev = $schedule->getScheduledEvents(); // #13809
969 return ($ev);
970 }
971
972 public function getData()
973 {
975 $ui = $this->ui;
976
977 $f = $ui->factory();
978
979 $events = $this->getEvents();
980
981 $data = array();
982 if (sizeof($events)) {
983 foreach ($events as $item) {
984 $this->ctrl->setParameter($this, "app_id", $item["event"]->getEntryId());
985 $this->ctrl->setParameter($this, 'dt', $item['dstart']);
986 $url = $this->ctrl->getLinkTarget($this, "getModalForApp", "", true, false);
987 $this->ctrl->setParameter($this, "app_id", $_GET["app_id"]);
988 $this->ctrl->setParameter($this, "dt", $_GET["dt"]);
989 $modal = $f->modal()->roundtrip('', [])->withAsyncRenderUrl($url);
990
991 $dates = $this->getDatesForItem($item);
992
993 $comps = [$f->button()->shy($item["event"]->getPresentationTitle(), "")->withOnClick($modal->getShowSignal()), $modal];
994 $renderer = $ui->renderer();
995 $shy = $renderer->render($comps);
996
997 $data[] = array(
998 "date" => ilDatePresentation::formatPeriod($dates["start"], $dates["end"]),
999 "title" => $item["event"]->getPresentationTitle(),
1000 "url" => "#",
1001 "shy_button" => $shy
1002 );
1003 }
1004 $this->setEnableNumInfo(true);
1005 } else {
1006 $data[] = array(
1007 "date" => $lng->txt("msg_no_search_result"),
1008 "title" => "",
1009 "url" => ""
1010 );
1011
1012 $this->setEnableNumInfo(false);
1013 }
1014
1015 return $data;
1016 }
1017
1024 public function getDatesForItem($item)
1025 {
1026 $start = $item["dstart"];
1027 $end = $item["dend"];
1028 if ($item["fullday"]) {
1029 $start = new ilDate($start, IL_CAL_UNIX);
1030 $end = new ilDate($end, IL_CAL_UNIX);
1031 } else {
1032 $start = new ilDateTime($start, IL_CAL_UNIX);
1034 }
1035 return array("start" => $start, "end" => $end);
1036 }
1037
1038
1043 public function getModalForApp()
1044 {
1045 $this->initCategories();
1046 $ui = $this->ui;
1048
1049 $f = $ui->factory();
1050 $r = $ui->renderer();
1051
1052 // @todo: this needs optimization
1053 $events = $this->getEvents();
1054 foreach ($events as $item) {
1055 if ($item["event"]->getEntryId() == (int) $_GET["app_id"] && $item['dstart'] == (int) $_GET['dt']) {
1056 $dates = $this->getDatesForItem($item);
1057
1058 // content of modal
1059 include_once("./Services/Calendar/classes/class.ilCalendarAppointmentPresentationGUI.php");
1060 $next_gui = ilCalendarAppointmentPresentationGUI::_getInstance($this->seed, $item);
1061 $content = $ilCtrl->getHTML($next_gui);
1062
1063 $modal = $f->modal()->roundtrip(ilDatePresentation::formatPeriod($dates["start"], $dates["end"]), $f->legacy($content));
1064 echo $r->renderAsync($modal);
1065 }
1066 }
1067 exit();
1068 }
1069}
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$users
Definition: authpage.php:44
$_GET["client_id"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_CENTER
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_MONTH
const IL_CAL_FKT_DATE
const IL_CAL_DAY
This class represents a block method of a block.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setLimit($a_limit)
Set Limit.
getCurrentDetailLevel()
Get Current Detail Level.
getBlockId()
Get Block Id.
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
addFooterLink( $a_text, $a_href="", $a_onclick="", $a_block_id="", $a_top=false, $a_omit_separator=false, $a_checked=false)
Add a footer text/link.
getRepositoryMode()
Get RepositoryMode.
fillFooterLinks($a_top=false, $a_numinfo="")
Fill footer links.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
fillDataSection()
Standard implementation for row based data.
getProperty($a_property)
setColSpan($a_colspan)
Set Columns Span.
setTitle($a_title)
Set Title.
setBlockId($a_block_id=0)
Set Block Id.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
addBlockCommand( $a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
getColSpan()
Get Columns Span.
Booking definition.
static lookupBookableUsersForObject($a_obj_id, $a_user_ids)
Consultation hours are offered if 1) consultation hour owner is admin or tutor and no object assignme...
Administrate calendar appointments.
static _getInstance(ilDate $seed, $a_app)
get singleton instance
Handles calendar authentication tokens for external calendar subscriptions.
static lookupAuthToken($a_user_id, $a_selection, $a_calendar=0)
Calendar blocks, displayed in different contexts, e.g.
setParentGUI($a_val)
Set parent gui.
setEnableEdit($a_enable_edit=0)
Set EnableEdit.
static getBlockType()
Get block type.
addMiniMonth($a_tpl)
Add mini version of monthly overview (Maybe extracted to another class, if used in pd calendar tab.
addCloseCommand($a_content_block)
getDatesForItem($item)
Get start/end date for item.
fillDataSection()
Fill data section.
getModalForApp()
Get modal for appointment (see similar code in ilCalendarAgendaListGUI) todo use all this methods fro...
getShowWeeksColumn()
Show weeks column.
getHTML()
Get bloch HTML code.
static getScreenMode()
Get Screen Mode for current command.
returnToUpperContext()
Return to upper context.
static isRepositoryObject()
Is this a repository object.
getTargetGUIClassPath()
Get target gui class path (for presenting the calendar)
getForceMonthView()
Get force month view.
setForceMonthView($a_val)
Set force month view.
static _getInstance($a_usr_id=0)
get singleton instance
Represents a list of calendar appointments (including recurring events) for a specific user in a give...
static _getInstance()
get singleton instance
static _getInstanceByUserId($a_user_id)
get singleton instance
static _isToday($date)
check if a date is today
static _numericDayToString($a_day, $a_long=true)
get
static _buildMonthDayList($a_month, $a_year, $weekstart)
Build a month day list.
static getAppointments($a_user_id)
Get all appointments.
Consultation hours editor.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
@classDescription Date and time handling
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Class for single dates.
static _lookupFullname($a_user_id)
Lookup Full Name.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
BlockGUI class for (centered) Content on Personal Desktop.
static get($a_type, $a_href="")
Get icon html.
special template class to simplify handling of ITX/PEAR
$counter
$i
Definition: disco.tpl.php:19
$r
Definition: example_031.php:79
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
$end
Definition: saml1-acs.php:18
$ret
Definition: parser.php:6
$url
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$text
Definition: errorreport.php:18