ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $now = new \ilDate(time(), IL_CAL_UNIX);
120 $this->seed = new \ilDate($now->get(IL_CAL_DATE), IL_CAL_DATE);
121 } else {
122 $this->seed = new ilDate($seed_str, IL_CAL_DATE); // @todo: check this
123 }
124
126 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
127
128 $mode = $ilUser->getPref("il_pd_cal_mode");
129 $this->display_mode = $mode ? $mode : "mmon";
130 }
131
138 public function getShowWeeksColumn()
139 {
140 return ($this->settings->getShowWeeks() && $this->user_settings->getShowWeeks());
141 }
142
143
147 public function getBlockType() : string
148 {
149 return self::$block_type;
150 }
151
155 protected function isRepositoryObject() : bool
156 {
157 return false;
158 }
159
165 public function setParentGUI($a_val)
166 {
167 $this->parent_gui = $a_val;
168 }
169
175 public function getParentGUI()
176 {
177 return $this->parent_gui;
178 }
179
185 public function setForceMonthView($a_val)
186 {
187 $this->force_month_view = $a_val;
188 if ($a_val) {
189 $this->display_mode = "mmon";
190 }
191 }
192
198 public function getForceMonthView()
199 {
201 }
202
206 public static function getScreenMode()
207 {
208 global $DIC;
209
210 $ilCtrl = $DIC->ctrl();
211
212 $cmd_class = $ilCtrl->getCmdClass();
213
214 if ($cmd_class == "ilcalendarappointmentgui" ||
215 $cmd_class == "ilconsultationhoursgui" ||
216 $_GET['cmd'] == 'showCalendarSubscription') {
217 return IL_SCREEN_CENTER;
218 }
219
220 switch ($ilCtrl->getCmd()) {
221 case "kkk":
222 // return IL_SCREEN_CENTER;
223 // return IL_SCREEN_FULL;
224
225 default:
226 //return IL_SCREEN_SIDE;
227 break;
228 }
229 }
230
234 public function executeCommand()
235 {
237 $ilTabs = $this->tabs;
238
239
240 $next_class = $ilCtrl->getNextClass();
241 $cmd = $ilCtrl->getCmd("getHTML");
242
243 $this->setSubTabs();
244
245 switch ($next_class) {
246 case "ilcalendarappointmentgui":
247 include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
248 $app_gui = new ilCalendarAppointmentGUI($this->seed, $this->seed);
249 $ilCtrl->forwardCommand($app_gui);
250 break;
251
252 case "ilconsultationhoursgui":
253 include_once('./Services/Calendar/classes/ConsultationHours/class.ilConsultationHoursGUI.php');
254 $hours = new ilConsultationHoursGUI($this->seed);
255 $ilCtrl->forwardCommand($hours);
256 break;
257
258 case "ilcalendarappointmentpresentationgui":
259 $this->initCategories();
260 $presentation = ilCalendarAppointmentPresentationGUI::_getInstance($this->seed, $this->appointment);
261 $ilCtrl->forwardCommand($presentation);
262 break;
263
264 case "ilcalendarmonthgui":
265 $ilTabs->setSubTabActive('app_month');
266 include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
267 $month_gui = new ilCalendarMonthGUI($this->seed);
268 $ilCtrl->forwardCommand($month_gui);
269 break;
270
271 default:
272 return $this->$cmd();
273 }
274 }
275
281 public function setEnableEdit($a_enable_edit = 0)
282 {
283 $this->enable_edit = $a_enable_edit;
284 }
285
291 public function getEnableEdit()
292 {
293 return $this->enable_edit;
294 }
295
299 public function fillDataSection()
300 {
301 // alex: changed from > 1 to > 0 - original detail level 1 did not work anymore
302 if ($this->getCurrentDetailLevel() > 0 && $this->display_mode != "mmon") {
303 $this->setColSpan(1);
304 $this->setRowTemplate("tpl.pd_event_list.html", "Services/Calendar");
305
307 } else {
308 // alex: changed from > 1 to > 0 - original detail level 1 did not work anymore
309 if ($this->getCurrentDetailLevel() > 0) {
310 $tpl = new ilTemplate(
311 "tpl.calendar_block.html",
312 true,
313 true,
314 "Services/Calendar"
315 );
316
317 $this->addMiniMonth($tpl);
318 $this->setDataSection($tpl->get());
319 } else {
320 $this->setDataSection($this->getOverview());
321 }
322 }
323 }
324
331 public function getTargetGUIClassPath()
332 {
333 $target_class = array();
334 if (!$this->getRepositoryMode()) {
335 $target_class = array("ilpersonaldesktopgui", "ilcalendarpresentationgui");
336 } else {
337 switch (ilObject::_lookupType((int) $_GET["ref_id"], true)) {
338 case "crs":
339 $target_class = array("ilobjcoursegui", "ilcalendarpresentationgui");
340 break;
341
342 case "grp":
343 $target_class = array("ilobjgroupgui", "ilcalendarpresentationgui");
344 break;
345 }
346 }
347 return $target_class;
348 }
349
354 public function addMiniMonth($a_tpl)
355 {
359 $ui = $this->ui;
360
361
362 // weekdays
363 include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
364 if ($this->getShowWeeksColumn()) {
365 $a_tpl->setCurrentBlock('month_header_col');
366 $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
367 $a_tpl->parseCurrentBlock();
368 }
369 for ($i = (int) $this->user_settings->getWeekStart();$i < (7 + (int) $this->user_settings->getWeekStart());$i++) {
370 $a_tpl->setCurrentBlock('month_header_col');
371 $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
372 $a_tpl->parseCurrentBlock();
373 }
374
375 if (isset($_GET["bkid"])) {
376 $user_id = $_GET["bkid"];
377 $disable_empty = true;
378 } else {
379 $user_id = $ilUser->getId();
380 $disable_empty = false;
381 }
382 include_once('Services/Calendar/classes/class.ilCalendarSchedule.php');
383 $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id);
384 $this->scheduler->addSubitemCalendars(true);
385 $this->scheduler->calculate();
386
387 $counter = 0;
389 $this->seed->get(IL_CAL_FKT_DATE, 'm'),
390 $this->seed->get(IL_CAL_FKT_DATE, 'Y'),
391 $this->user_settings->getWeekStart()
392 )->get() as $date) {
393 $counter++;
394
395 $events = $this->scheduler->getByDay($date, $ilUser->getTimeZone());
396 $has_events = (bool) count($events);
397 if ($has_events || !$disable_empty) {
398 $a_tpl->setCurrentBlock('month_col_link');
399 } else {
400 $a_tpl->setCurrentBlock('month_col_no_link');
401 }
402
403 if ($disable_empty) {
404 if (!$has_events) {
405 $a_tpl->setVariable('DAY_CLASS', 'calminiinactive');
406 } else {
407 $week_has_events = true;
408 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
409 foreach ($events as $event) {
410 $booking = new ilBookingEntry($event['event']->getContextId());
411 if ($booking->hasBooked($event['event']->getEntryId())) {
412 $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
413 break;
414 }
415 }
416 }
417 } elseif ($has_events) {
418 $week_has_events = true;
419 $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
420 }
421
422
423 $day = $date->get(IL_CAL_FKT_DATE, 'j');
424 $month = $date->get(IL_CAL_FKT_DATE, 'n');
425
426 $month_day = $day;
427
428 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), 'seed', $date->get(IL_CAL_DATE));
429 if ($agenda_view_type = (int) $_GET['cal_agenda_per']) {
430 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "cal_agenda_per", $agenda_view_type);
431 }
432 $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass($this->getTargetGUIClassPath(), ''));
433
434 $a_tpl->setVariable('MONTH_DAY', $month_day);
435
436 $a_tpl->parseCurrentBlock();
437
438
439 $a_tpl->setCurrentBlock('month_col');
440
441 include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
442 if (ilCalendarUtil::_isToday($date)) {
443 $a_tpl->setVariable('TD_CLASS', 'calminitoday');
444 }
445 #elseif(ilDateTime::_equals($date,$this->seed,IL_CAL_DAY))
446 #{
447 # $a_tpl->setVariable('TD_CLASS','calmininow');
448 #}
449 elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
450 $a_tpl->setVariable('TD_CLASS', 'calministd');
451 } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
452 $a_tpl->setVariable('TD_CLASS', 'calminiprev');
453 } else {
454 $a_tpl->setVariable('TD_CLASS', 'calmininext');
455 }
456
457 $a_tpl->parseCurrentBlock();
458
459
460 if ($counter and !($counter % 7)) {
461 if ($this->getShowWeeksColumn()) {
462 $a_tpl->setCurrentBlock('week');
463 $a_tpl->setVariable(
464 'WEEK',
465 $date->get(IL_CAL_FKT_DATE, 'W')
466 );
467 $a_tpl->parseCurrentBlock();
468 }
469
470 $a_tpl->setCurrentBlock('month_row');
471 //$a_tpl->setVariable('TD_CLASS','calminiweek');
472 $a_tpl->parseCurrentBlock();
473
474 $week_has_events = false;
475 }
476 }
477 $a_tpl->setCurrentBlock('mini_month');
478 //$a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
479
480 $first_of_month = substr($this->seed->get(IL_CAL_DATE), 0, 7) . "-01";
481 $myseed = new ilDate($first_of_month, IL_CAL_DATE);
482
483 $myseed->increment(ilDateTime::MONTH, -1);
484 $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE));
485
486 $prev_link = $ilCtrl->getLinkTarget($this, "setSeed", "", true);
487
488 $myseed->increment(ilDateTime::MONTH, 2);
489 $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE));
490 $next_link = $ilCtrl->getLinkTarget($this, "setSeed", "", true);
491
492 $ilCtrl->setParameter($this, 'seed', "");
493
494 $blockgui = $this;
495
496 // view control
497 // ... previous button
498 $b1 = $ui->factory()->button()->standard($lng->txt("previous"), "#")->withOnLoadCode(function ($id) use ($prev_link, $blockgui) {
499 return
500 "$('#" . $id . "').click(function() { ilBlockJSHandler('block_" . $blockgui->getBlockType() .
501 "_" . $blockgui->getBlockId() . "','" . $prev_link . "'); return false;});";
502 });
503
504 // ... month button
505 $ilCtrl->clearParameterByClass("ilcalendarblockgui", 'seed');
506 $month_link = $ilCtrl->getLinkTarget($this, "setSeed", "", true, false);
507 $seed_parts = explode("-", $this->seed->get(IL_CAL_DATE));
508 $b2 = $ui->factory()->button()->month($seed_parts[1] . "-" . $seed_parts[0])->withOnLoadCode(function ($id) use ($month_link, $blockgui) {
509 return "$('#" . $id . "').on('il.ui.button.month.changed', function(el, id, month) { var m = month.split('-'); ilBlockJSHandler('block_" . $blockgui->getBlockType() .
510 "_" . $blockgui->getBlockId() . "','" . $month_link . "' + '&seed=' + m[1] + '-' + m[0] + '-01'); return false;});";
511 });
512 // ... next button
513 $b3 = $ui->factory()->button()->standard($lng->txt("next"), "#")->withOnLoadCode(function ($id) use ($next_link, $blockgui) {
514 return
515 "$('#" . $id . "').click(function() { ilBlockJSHandler('block_" . $blockgui->getBlockType() .
516 "_" . $blockgui->getBlockId() . "','" . $next_link . "'); return false;});";
517 });
518
519
520 $vc = $ui->factory()->viewControl()->section($b1, $b2, $b3);
521 $a_tpl->setVariable("VIEW_CTRL_SECTION", $ui->renderer()->render($vc));
522
523 $a_tpl->parseCurrentBlock();
524 }
525
529 protected function addSubscriptionBlockCommand()
530 {
531 global $DIC;
532
533 $lng = $DIC->language();
534
535 $ui_factory = $DIC->ui()->factory();
536 $ui_renderer = $DIC->ui()->renderer();
537
538 $gui_path = $this->getTargetGUIClassPath();
539 $gui_path[] = "ilcalendarsubscriptiongui";
540 $url = $this->ctrl->getLinkTargetByClass($gui_path, 'getModalForSubscription', "", true, false);
541
542 $roundtrip = $ui_factory->modal()->roundtrip('', [])->withAsyncRenderUrl($url);
543
544 $standard_button = $ui_factory->button()->standard($lng->txt('btn_ical'), '')->withOnClick(
545 $roundtrip->getShowSignal()
546 );
547 $components = [
548 $roundtrip,
549 $standard_button
550 ];
551
552 $out = $ui_renderer->render($components);
553 $this->addBlockCommand(
554 '',
555 '',
556 "",
557 "",
558 true,
559 false,
560 '<span class="ilIcalIcon">' . $out . '</span>'
561 );
562 }
563
564
568 public function getHTML()
569 {
570 $this->initCategories();
573 $ilAccess = $this->access;
574 $ilObjDataCache = $this->obj_data_cache;
576
577 if ($this->getCurrentDetailLevel() == 0) {
578 return "";
579 }
580
582
583 if ($this->mode == ilCalendarCategories::MODE_REPOSITORY) {
584 if (!isset($_GET["bkid"])) {
585 /*
586 if($ilAccess->checkAccess('edit_event','',(int) $_GET['ref_id']))
587 {
588 $ilCtrl->setParameter($this, "add_mode", "block");
589 $this->addBlockCommand(
590 $ilCtrl->getLinkTargetByClass("ilCalendarAppointmentGUI",
591 "add"),
592 $lng->txt("add_appointment"));
593 $ilCtrl->setParameter($this, "add_mode", "");
594 }*/
595
596 include_once "Modules/Course/classes/class.ilCourseParticipants.php";
597 $obj_id = $ilObjDataCache->lookupObjId((int) $_GET['ref_id']);
598 $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
599 $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
600 //$users = $participants->getParticipants();
601 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
603 foreach ($users as $user_id) {
604 if (!isset($_GET["bkid"])) {
605 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
606 $now = new ilDateTime(time(), IL_CAL_UNIX);
607
608 // default to last booking entry
609 $appointments = ilConsultationHourAppointments::getAppointments($user_id);
610 $next_app = end($appointments);
611 reset($appointments);
612
613 foreach ($appointments as $entry) {
614 // find next entry
615 if (ilDateTime::_before($entry->getStart(), $now, IL_CAL_DAY)) {
616 continue;
617 }
618 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
619 $booking_entry = new ilBookingEntry($entry->getContextId());
620 if (!in_array($obj_id, $booking_entry->getTargetObjIds())) {
621 continue;
622 }
623
624 if (!$booking_entry->isAppointmentBookableForUser($entry->getEntryId(), $user->getId())) {
625 continue;
626 }
627 $next_app = $entry;
628 break;
629 }
630
631 /*
632 $ilCtrl->setParameter($this, "bkid", $user_id);
633 if($next_app)
634 {
635 $ilCtrl->setParameter(
636 $this,
637 'seed',
638 (string) $next_app->getStart()->get(IL_CAL_DATE)
639 );
640 }*/
641
642 //$ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "bkid", $user_id);
643
644 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "ch_user_id", $user_id);
645
646 if ($next_app) {
647 // this does not work correctly
648 /*$ilCtrl->setParameterByClass(
649 end($this->getTargetGUIClassPath()),
650 'seed',
651 (string) $next_app->getStart()->get(IL_CAL_DATE)
652 );*/
653 }
654
655 if (!$this->getForceMonthView()) {
656 $this->cal_footer[] = array(
657 'link' => $ilCtrl->getLinkTargetByClass($this->getTargetGUIClassPath(), 'selectCHCalendarOfUser'),
658 'txt' => str_replace("%1", ilObjUser::_lookupFullname($user_id), $lng->txt("cal_consultation_hours_for_user"))
659 );
660 }
661 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "ch_user_id", "");
662 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "bkid", $_GET["bkid"]);
663 $ilCtrl->setParameterByClass(end($this->getTargetGUIClassPath()), "seed", $_GET["seed"]);
664 }
665 }
666 $ilCtrl->setParameter($this, "bkid", "");
667 $ilCtrl->setParameter($this, 'seed', '');
668 } else {
669 $ilCtrl->setParameter($this, "bkid", "");
670 $this->addBlockCommand(
671 $ilCtrl->getLinkTarget($this),
672 $lng->txt("back")
673 );
674 $ilCtrl->setParameter($this, "bkid", (int) $_GET["bkid"]);
675 }
676 }
677
678 if ($this->getProperty("settings") == true) {
679 $this->addBlockCommand(
680 $ilCtrl->getLinkTarget($this, "editSettings"),
681 $lng->txt("settings")
682 );
683 }
684
685 $ilCtrl->setParameterByClass($this->getParentGUI(), "seed", isset($_GET["seed"]) ? $_GET["seed"] : "");
686 $ret = parent::getHTML();
687 $ilCtrl->setParameterByClass($this->getParentGUI(), "seed", "");
688
689 // workaround to include asynch code from ui only one time, see #20853
690 if ($ilCtrl->isAsynch()) {
691 global $DIC;
692 $f = $DIC->ui()->factory()->legacy("");
693 $ret .= $DIC->ui()->renderer()->renderAsync($f);
694 }
695
696 return $ret;
697 }
698
702 public function getOverview()
703 {
706
707
708 include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
709 $schedule = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_INBOX);
710 $events = $schedule->getChangedEvents(true);
711
712 $ilCtrl->setParameterByClass('ilcalendarinboxgui', 'changed', 1);
713 $link = '<a href=' . $ilCtrl->getLinkTargetByClass('ilcalendarinboxgui', '') . '>';
714 $ilCtrl->setParameterByClass('ilcalendarinboxgui', 'changed', '');
715 $text = '<div class="small">' . ((int) count($events)) . " " . $lng->txt("cal_changed_events_header") . "</div>";
716 $end_link = '</a>';
717
718 return $link . $text . $end_link;
719 }
720
721 public function addCloseCommand($a_content_block)
722 {
725
726 $a_content_block->addHeaderCommand(
727 $ilCtrl->getParentReturn($this),
728 $lng->txt("close"),
729 true
730 );
731 }
732
740 protected function initCategories()
741 {
743
745 if ($this->getForceMonthView()) {
746 // @todo: why not
747 }
748 elseif (!$cats->getMode()) {
749 $cats->initialize(
751 (int) $_GET['ref_id'],
752 true
753 );
754 }
755 }
756
762 protected function setSubTabs()
763 {
764 $ilTabs = $this->tabs;
765
766 $ilTabs->clearSubTabs();
767 }
768
772 public function setSeed()
773 {
775
776 //$ilUser->writePref("il_pd_bkm_mode", 'flat');
777 $_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"] =
778 $_GET["seed"];
779 if ($ilCtrl->isAsynch()) {
780 echo $this->getHTML();
781 exit;
782 } else {
783 $this->returnToUpperContext();
784 }
785 }
786
790 public function returnToUpperContext()
791 {
793
794 $ilCtrl->returnToParent($this);
795 }
796
797
802 public function showCalendarSubscription()
803 {
804 return;
807
808 $tpl = new ilTemplate('tpl.show_calendar_subscription.html', true, true, 'Services/Calendar');
809
810 $tpl->setVariable('TXT_TITLE', $lng->txt('cal_subscription_header'));
811 $tpl->setVariable('TXT_INFO', $lng->txt('cal_subscription_info'));
812 $tpl->setVariable('TXT_CAL_URL', $lng->txt('cal_subscription_url'));
813
814 include_once './Services/Calendar/classes/class.ilCalendarAuthenticationToken.php';
815
816 switch ($this->mode) {
820 $calendar = 0;
821 break;
822
823 default:
825 // TODO: calendar id
826 $calendar = ilObject::_lookupObjId((int) $_GET['ref_id']);
827 break;
828 }
829 if ($hash = ilCalendarAuthenticationToken::lookupAuthToken($ilUser->getId(), $selection, $calendar)) {
830 } else {
832 $token->setSelectionType($selection);
833 $token->setCalendar($calendar);
834 $hash = $token->add();
835 }
836 $url = ILIAS_HTTP_PATH . '/calendar.php?client_id=' . CLIENT_ID . '&token=' . $hash;
837
838 $tpl->setVariable('VAL_CAL_URL', $url);
839 $tpl->setVariable('VAL_CAL_URL_TXT', $url);
840
841 include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
842 $content_block = new ilPDContentBlockGUI();
843 $content_block->setContent($tpl->get());
844 $content_block->setTitle($lng->txt("calendar"));
845 $content_block->addHeaderCommand(
846 $this->ctrl->getParentReturn($this),
847 $lng->txt("selected_items_back")
848 );
849
850 return $content_block->getHTML();
851 }
852
853 public function fillFooter()
854 {
855 // begin-patch ch
856 foreach ((array) $this->cal_footer as $link_info) {
857 $this->tpl->setCurrentBlock('data_section');
858 $this->tpl->setVariable(
859 'DATA',
860 sprintf('<a href="%s">%s</a>', $link_info['link'], $link_info['txt'])
861 );
862 $this->tpl->parseCurrentBlock();
863 }
864 // end-patch ch
865
866 $this->setFooterLinks();
867 $this->fillFooterLinks();
868 $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
869 if ($this->tpl->blockExists("block_footer")) {
870 $this->tpl->setCurrentBlock("block_footer");
871 $this->tpl->parseCurrentBlock();
872 }
873 }
874
875 public function setFooterLinks()
876 {
879
880
881 // alex: changed from < 2 to < 1 - original detail level 1 did not work anymore
882 if ($this->getCurrentDetailLevel() < 1) {
883 return;
884 }
885
886 if (!$this->getForceMonthView()) {
887 $this->addFooterLink(
888 $lng->txt("cal_upcoming_events_header"),
889 $ilCtrl->getLinkTarget($this, "setPdModeEvents"),
890 $ilCtrl->getLinkTarget($this, "setPdModeEvents", "", true),
891 "block_" . $this->getBlockType() . "_" . $this->block_id,
892 false,
893 false,
894 ($this->display_mode != 'mmon')
895 );
896
897 $this->addFooterLink(
898 $lng->txt("app_month"),
899 $ilCtrl->getLinkTarget($this, "setPdModeMonth"),
900 $ilCtrl->getLinkTarget($this, "setPdModeMonth", "", true),
901 "block_" . $this->getBlockType() . "_" . $this->block_id,
902 false,
903 false,
904 ($this->display_mode == 'mmon')
905 );
906
907 if ($this->getRepositoryMode()) {
908 #23921
909 $ilCtrl->setParameterByClass('ilcalendarpresentationgui', 'seed', '');
910 $this->addFooterLink(
911 $lng->txt("cal_open_calendar"),
912 $ilCtrl->getLinkTargetByClass($this->getTargetGUIClassPath(), ""),
913 "",
914 "block_" . $this->getBlockType() . "_" . $this->block_id,
915 false,
916 false
917 );
918
919 $ilCtrl->setParameter($this, "add_mode", "");
920 $this->addFooterLink(
921 $lng->txt("add_appointment"),
922 $ilCtrl->getLinkTargetByClass("ilCalendarAppointmentGUI", "add"),
923 "",
924 "block_" . $this->getBlockType() . "_" . $this->block_id,
925 false,
926 false
927 );
928 $ilCtrl->setParameter($this, "add_mode", "");
929 }
930 }
931 }
932
933 public function setPdModeEvents()
934 {
937
938
939 $ilUser->writePref("il_pd_cal_mode", "evt");
940 $this->display_mode = "evt";
941 if ($ilCtrl->isAsynch()) {
942 echo $this->getHTML();
943 exit;
944 } else {
945 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
946 }
947 }
948
949 public function setPdModeMonth()
950 {
953
954 $ilUser->writePref("il_pd_cal_mode", "mmon");
955 $this->display_mode = "mmon";
956 if ($ilCtrl->isAsynch()) {
957 echo $this->getHTML();
958 exit;
959 } else {
960 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
961 }
962 }
963
970 public function getEvents()
971 {
972 $seed = new ilDate(date('Y-m-d', time()), IL_CAL_DATE);
973
974 include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
976 $schedule->addSubitemCalendars(true); // #12007
977 $schedule->setEventsLimit(20);
978 $schedule->calculate();
979 $ev = $schedule->getScheduledEvents(); // #13809
980 return ($ev);
981 }
982
983 public function getData()
984 {
986 $ui = $this->ui;
987
988 $f = $ui->factory();
989
990 $events = $this->getEvents();
991
992 $data = array();
993 if (sizeof($events)) {
994 foreach ($events as $item) {
995 $this->ctrl->setParameter($this, "app_id", $item["event"]->getEntryId());
996 $this->ctrl->setParameter($this, 'dt', $item['dstart']);
997 $url = $this->ctrl->getLinkTarget($this, "getModalForApp", "", true, false);
998 $this->ctrl->setParameter($this, "app_id", $_GET["app_id"]);
999 $this->ctrl->setParameter($this, "dt", $_GET["dt"]);
1000 $modal = $f->modal()->roundtrip('', [])->withAsyncRenderUrl($url);
1001
1002 $dates = $this->getDatesForItem($item);
1003
1004 $comps = [$f->button()->shy($item["event"]->getPresentationTitle(), "")->withOnClick($modal->getShowSignal()), $modal];
1005 $renderer = $ui->renderer();
1006 $shy = $renderer->render($comps);
1007
1008 $data[] = array(
1009 "date" => ilDatePresentation::formatPeriod($dates["start"], $dates["end"]),
1010 "title" => $item["event"]->getPresentationTitle(),
1011 "url" => "#",
1012 "shy_button" => $shy
1013 );
1014 }
1015 $this->setEnableNumInfo(true);
1016 } else {
1017 $data[] = array(
1018 "date" => $lng->txt("msg_no_search_result"),
1019 "title" => "",
1020 "url" => ""
1021 );
1022
1023 $this->setEnableNumInfo(false);
1024 }
1025
1026 return $data;
1027 }
1028
1035 public function getDatesForItem($item)
1036 {
1037 $start = $item["dstart"];
1038 $end = $item["dend"];
1039 if ($item["fullday"]) {
1041 $end = new ilDate($end, IL_CAL_UNIX);
1042 } else {
1045 }
1046 return array("start" => $start, "end" => $end);
1047 }
1048
1049
1054 public function getModalForApp()
1055 {
1056 $this->initCategories();
1057 $ui = $this->ui;
1059
1060 $f = $ui->factory();
1061 $r = $ui->renderer();
1062
1063 // @todo: this needs optimization
1064 $events = $this->getEvents();
1065 foreach ($events as $item) {
1066 if ($item["event"]->getEntryId() == (int) $_GET["app_id"] && $item['dstart'] == (int) $_GET['dt']) {
1067 $dates = $this->getDatesForItem($item);
1068
1069 // content of modal
1070 include_once("./Services/Calendar/classes/class.ilCalendarAppointmentPresentationGUI.php");
1071 $next_gui = ilCalendarAppointmentPresentationGUI::_getInstance($this->seed, $item);
1072 $content = $ilCtrl->getHTML($next_gui);
1073
1074 $modal = $f->modal()->roundtrip(ilDatePresentation::formatPeriod($dates["start"], $dates["end"]), $f->legacy($content));
1075 echo $r->renderAsync($modal);
1076 }
1077 }
1078 exit();
1079 }
1080}
$users
Definition: authpage.php:44
exit
Definition: backend.php:16
$_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.
addMiniMonth($a_tpl)
Add mini version of monthly overview (Maybe extracted to another class, if used in pd calendar tab.
addCloseCommand($a_content_block)
isRepositoryObject()
Returns whether block has a corresponding repository object.bool
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.
addSubscriptionBlockCommand()
Add subscription block command.
static getScreenMode()
Get Screen Mode for current command.
returnToUpperContext()
Return to upper context.
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.
special template class to simplify handling of ITX/PEAR
$i
Definition: disco.tpl.php:19
$r
Definition: example_031.php:79
if(!array_key_exists('StateId', $_REQUEST)) $id
if($argc< 2) $events
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$url
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$start
Definition: bench.php:8
$text
Definition: errorreport.php:18