ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarPresentationGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Refinery\Factory as RefineryFactory;
22use ILIAS\HTTP\Services as HttpServices;
23use ILIAS\UI\Factory as UIFactory;
24use ILIAS\UI\Renderer as UIRenderer;
26
36{
38 protected ilLanguage $lng;
41 protected ilObjUser $user;
42 protected ilHelpGUI $help;
44 protected \ILIAS\DI\UIServices $ui;
47 protected HttpServices $http;
48 protected RefineryFactory $refinery;
49
50
54 protected bool $repository_mode = false;
55 protected int $ref_id = 0;
56 protected int $category_id = 0;
57 protected ?ilDate $seed = null;
58
59 protected int $cal_view = 0;
60 protected int $cal_period = 0;
61
62 private UIRenderer $renderer;
63 private UIFactory $ui_factory;
64
65 public function __construct($a_ref_id = 0)
66 {
67 global $DIC;
68
69 $this->ctrl = $DIC->ctrl();
70 $this->lng = $DIC->language();
71 $this->lng->loadLanguageModule('dateplaner');
72
73 $this->renderer = $DIC->ui()->renderer();
74 $this->ui_factory = $DIC->ui()->factory();
75
76 $this->http = $DIC->http();
77 $this->refinery = $DIC->refinery();
78 $this->tpl = $DIC->ui()->mainTemplate();
79 $this->tabs_gui = $DIC->tabs();
80 $this->user = $DIC->user();
81 $this->rbacsystem = $DIC->rbac()->system();
82 $this->access = $DIC->access();
83 $this->help = $DIC["ilHelp"];
84 $this->ui = $DIC->ui();
85 $this->toolbar = $DIC->toolbar();
86 $this->ref_id = $a_ref_id;
87 $this->category_id = 0;
88 if ($this->http->wrapper()->query()->has('category_id')) {
89 $this->category_id = $this->http->wrapper()->query()->retrieve(
90 'category_id',
91 $this->refinery->kindlyTo()->int()
92 );
93 }
94
95 $this->repository_mode = $a_ref_id > 0;
96 if ($this->repository_mode && $this->category_id === 0) {
97 $obj_id = ilObject::_lookupObjId($this->ref_id);
98 $category = ilCalendarCategory::_getInstanceByObjId($obj_id);
99 $this->category_id = is_null($category) ? 0 : $category->getCategoryID();
100 }
101 $this->ctrl->setParameter($this, 'category_id', $this->category_id);
102 $this->cal_settings = ilCalendarSettings::_getInstance();
103
104 // show back to pd
105 $this->ctrl->saveParameter($this, 'backpd');
106
107 $this->initCalendarView();
108 $cats = ilCalendarCategories::_getInstance($this->user->getId());
109
110 if ($this->category_id > 0 && $this->ref_id <= 0) { // single calendar view
111 // ensure activation of this category
112 $vis = ilCalendarVisibility::_getInstanceByUserId($this->user->getId(), $a_ref_id);
113 $vis->forceVisibility($this->category_id);
114
115 $cats->initialize(ilCalendarCategories::MODE_SINGLE_CALENDAR, 0, false, $this->category_id);
116 } elseif ($a_ref_id > 0) {
120 } else {
122 }
123
124 $this->actions = ilCalendarActions::getInstance();
125 $this->cats = $cats;
126 }
127
128 public function getRepositoryMode(): bool
129 {
131 }
132
133 protected function initAppointmentIdFromQuery(): int
134 {
135 if ($this->http->wrapper()->query()->has('app_id')) {
136 return $this->http->wrapper()->query()->retrieve(
137 'app_id',
138 $this->refinery->kindlyTo()->int()
139 );
140 }
141 return 0;
142 }
143
144 protected function initCategoryIdFromQuery(): int
145 {
146 if ($this->http->wrapper()->query()->has('category_id')) {
147 return $this->http->wrapper()->query()->retrieve(
148 'category_id',
149 $this->refinery->kindlyTo()->int()
150 );
151 }
152 return 0;
153 }
154
155
159 protected function initAndRedirectToConsultationHours(): void
160 {
161 $ch_user_id = 0;
162 if ($this->http->wrapper()->query()->has('ch_user_id')) {
163 $ch_user_id = $this->http->wrapper()->query()->retrieve(
164 'ch_user_id',
165 $this->refinery->kindlyTo()->int()
166 );
167 }
168 $visibility = ilCalendarVisibility::_getInstanceByUserId($this->user->getId(), $this->ref_id);
169 foreach ($this->cats->getCategoriesInfo() as $info) {
170 if (
172 $info["obj_id"] == $ch_user_id
173 ) {
174 $v = $visibility->getVisible();
175 if (!in_array($info["cat_id"], $v)) {
176 $v[] = $info["cat_id"];
177 }
178 $visibility->showSelected($v);
179 $visibility->save();
180 $this->ctrl->setParameterByClass(ilCalendarMonthGUI::class, 'category_id', $info['cat_id']);
181 $this->ctrl->setParameterByClass(\ilCalendarMonthGUI::class, 'seed', $this->getRequestedSeedAsString());
182 }
183 }
184 $this->ctrl->redirectToURL(
185 $this->ctrl->getLinkTargetByClass(\ilCalendarMonthGUI::class, '')
186 );
187 }
188
192 protected function initCalendarView(): void
193 {
194 $this->cal_view = $this->cal_settings->getDefaultCal();
195 if ($this->http->wrapper()->query()->has('cal_view')) {
196 $this->cal_view = $this->http->wrapper()->query()->retrieve(
197 'cal_view',
198 $this->refinery->kindlyTo()->int()
199 );
200 }
201 }
202
203 public function executeCommand(): void
204 {
205 $cmd = $this->ctrl->getCmd();
206
207 if (!ilCalendarSettings::_getInstance()->isEnabled()) {
208 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
209 ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
210 }
211
212 $this->initSeed();
213 if (!$this->ctrl->isAsynch()) {
214 $this->prepareOutput();
215 }
216
217 $this->help->setScreenIdComponent("cal");
218 switch ($cmd) {
219 case 'selectCHCalendarOfUser':
221 break;
222 }
223
224 // now next class is not empty, which breaks old consultation hour implementation
225 $next_class = $this->getNextClass();
226
227 switch ($next_class) {
228 case 'ilcalendarinboxgui':
229 $this->tabs_gui->activateTab('cal_agenda');
230 $inbox_gui = $this->forwardToClass('ilcalendarinboxgui');
231 if ($this->showToolbarAndSidebar()) {
232 $this->showViewSelection("cal_list");
233 $this->showSideBlocks();
234 $inbox_gui->addToolbarFileDownload();
235 }
236
237 break;
238
239 case 'ilconsultationhoursgui':
240 $this->tabs_gui->activateTab('app_consultation_hours');
241 $this->tabs_gui->clearTargets();
242
243 // No side blocks
244 $this->tabs_gui->setBackTarget(
245 $this->lng->txt('cal_back_to_cal'),
246 $this->ctrl->getLinkTargetByClass($this->readLastClass())
247 );
248 $this->ctrl->forwardCommand(new ilConsultationHoursGUI());
249 if ($this->showToolbarAndSidebar()) {
250 $this->showSideBlocks();
251 }
252 return;
253
254 case 'ilcalendarmonthgui':
255 $this->tabs_gui->activateTab('cal_agenda');
256 $month_gui = $this->forwardToClass('ilcalendarmonthgui');
257
258 if ($this->showToolbarAndSidebar()) {
259 $this->showViewSelection("app_month");
260 $this->showSideBlocks();
261 $month_gui->addToolbarFileDownload();
262 }
263 break;
264
265 case 'ilcalendarweekgui':
266 $this->tabs_gui->activateTab('cal_agenda');
267 $week_gui = $this->forwardToClass('ilcalendarweekgui');
268 if ($this->showToolbarAndSidebar()) {
269 $this->showViewSelection("app_week");
270 $this->showSideBlocks();
271 $week_gui->addToolbarFileDownload();
272 }
273
274 break;
275
276 case 'ilcalendardaygui':
277 $this->tabs_gui->activateTab('cal_agenda');
278 $day_gui = $this->forwardToClass('ilcalendardaygui');
279 if ($this->showToolbarAndSidebar()) {
280 $this->showViewSelection("app_day");
281 $this->showSideBlocks();
282 $day_gui->addToolbarFileDownload();
283 }
284 break;
285
286 case 'ilcalendarusersettingsgui':
287 $this->ctrl->setReturn($this, '');
288 $this->tabs_gui->activateTab('settings');
289 $this->setCmdClass('ilcalendarusersettingsgui');
290
291 $user_settings = new ilCalendarUserSettingsGUI();
292 $this->ctrl->forwardCommand($user_settings);
293 // No side blocks
294 return;
295
296 case 'ilcalendarappointmentgui':
297 $this->ctrl->setReturn($this, '');
298 $this->tabs_gui->activateTab((string) ilSession::get('cal_last_tab'));
299
300 $app = new ilCalendarAppointmentGUI($this->seed, $this->seed, $this->initAppointmentIdFromQuery());
301 $this->ctrl->forwardCommand($app);
302 break;
303
304 case 'ilcalendarsubscriptiongui':
305 $this->ctrl->setReturn($this, '');
306 $this->tabs_gui->activateTab("cal_agenda");
307
308 $ref_id = 0;
309 if ($this->http->wrapper()->query()->has('ref_id')) {
310 $ref_id = $this->http->wrapper()->query()->retrieve(
311 'ref_id',
312 $this->refinery->kindlyTo()->int()
313 );
314 }
315 $sub = new ilCalendarSubscriptionGUI($this->category_id, $ref_id);
316 $this->ctrl->forwardCommand($sub);
317 if ($this->showToolbarAndSidebar()) {
318 $this->showSideBlocks();
319 }
320 break;
321
322 case 'ilcalendarcategorygui':
323 $this->ctrl->setReturn($this, '');
324 $this->tabs_gui->activateTab("cal_manage");
325 $category = new ilCalendarCategoryGUI($this->user->getId(), $this->seed, $this->ref_id);
326 if ($this->ctrl->forwardCommand($category)) {
327 return;
328 } else {
329 $this->showSideBlocks();
330 break;
331 }
332
333 // no break
334 case 'ilcalendarblockgui':
335 $side_cal = new ilCalendarBlockGUI();
336 $side_cal->setRepositoryMode($this->getRepositoryMode());
337 $side_cal->setForceMonthView(true);
338 $this->ctrl->forwardCommand($side_cal);
339 $this->showSideBlocks();
340 break;
341
342 case 'ilpdcalendarblockgui':
343 $side_cal = new ilPDCalendarBlockGUI();
344 $side_cal->setRepositoryMode($this->getRepositoryMode());
345 $side_cal->setForceMonthView(true);
346 $this->ctrl->forwardCommand($side_cal);
347 $this->showSideBlocks();
348 break;
349
350 case strtolower(PublicProfileGUI::class):
351 $user_id = $this->user->getId();
352 if ($this->http->wrapper()->query()->has('user_id')) {
353 $user_id = $this->http->wrapper()->query()->retrieve(
354 'user_id',
355 $this->refinery->kindlyTo()->int()
356 );
357 }
358 $user_profile = new PublicProfileGUI($user_id);
359 $html = $this->ctrl->forwardCommand($user_profile);
360 $this->tpl->setContent($html);
361 break;
362
363 default:
364 $cmd = $this->ctrl->getCmd("show");
365 $this->$cmd();
366 $this->showSideBlocks();
367 break;
368 }
369 }
370
371 public function showViewSelection(string $a_active = "cal_list"): void
372 {
373 $ui = $this->ui;
377
378 $f = $ui->factory();
379
380 $actions = array(
381 $this->lng->txt("app_day") => $ctrl->getLinkTargetByClass('ilCalendarDayGUI', ''),
382 $this->lng->txt("app_week") => $ctrl->getLinkTargetByClass('ilCalendarWeekGUI', ''),
383 $this->lng->txt("app_month") => $ctrl->getLinkTargetByClass('ilCalendarMonthGUI', ''),
384 $this->lng->txt("cal_list") => $ctrl->getLinkTargetByClass('ilCalendarInboxGUI', '')
385 );
386
387
388 $view_control = $f->viewControl()->mode($actions, "cal_change_calendar_view")->withActive($this->lng->txt($a_active));
389 $toolbar->addComponent($view_control);
390 $ctrl->setParameterByClass("ilcalendarappointmentgui", "seed", $this->seed->get(IL_CAL_DATE, ''));
391 $ctrl->setParameterByClass("ilcalendarappointmentgui", "app_id", "");
392 $ctrl->setParameterByClass("ilcalendarappointmentgui", "dt", "");
393 $ctrl->setParameterByClass("ilcalendarappointmentgui", "idate", (new ilDate(time(), IL_CAL_UNIX))->get(IL_CAL_DATE));
394
395 $extra_button_added = false;
396 // add appointment
397 if ($this->category_id == 0 || $this->actions->checkAddEvent($this->category_id)) {
399 $extra_button_added = true;
400
401 // create appointment should default to current hour
402 $current_hour = (new ilDateTime(time(), IL_CAL_UNIX))->get(IL_CAL_FKT_DATE, 'G', $this->user->getTimeZone());
403 $ctrl->setParameterByClass("ilcalendarappointmentgui", "hour", $current_hour);
404 $add_button = $f->button()->standard(
405 $this->lng->txt("cal_add_appointment"),
406 $ctrl->getLinkTargetByClass("ilcalendarappointmentgui", "add")
407 );
408 $ctrl->clearParameterByClass("ilcalendarappointmentgui", "hour");
409
410 $toolbar->addComponent($add_button);
411 }
412
413 // import appointments
414 if ($this->category_id > 0 && $this->actions->checkAddEvent($this->category_id)) {
415 if (!$extra_button_added) {
417 }
418 $add_button = $f->button()->standard(
419 $this->lng->txt("cal_import_appointments"),
420 $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "importAppointments")
421 );
422 $toolbar->addComponent($add_button);
423 }
424 }
425
426 public function getNextClass(): string
427 {
428 if (strlen($next_class = $this->ctrl->getNextClass())) {
429 return $next_class;
430 }
431 if (
432 strcasecmp($this->ctrl->getCmdClass(), ilCalendarPresentationGUI::class) === 0 ||
433 $this->ctrl->getCmdClass() == ''
434 ) {
435 $cmd_class = $this->readLastClass();
436 $this->redirectWithParameters($cmd_class);
437 return $cmd_class;
438 }
439 return '';
440 }
441
445 public function readLastClass(): string
446 {
447 $ilUser = $this->user;
448 switch ($this->cal_view) {
450 $class = "ilcalendardaygui";
451 break;
453 $class = "ilcalendarweekgui";
454 break;
456 $class = "ilcalendarmonthgui";
457 break;
459 default:
460 $class = "ilcalendarinboxgui";
461 break;
462 }
463
464 // see #34998, if cal_view is requested (e.g. through starting point)
465 // it must get high prio than history entry
466 $user_pref = $this->user->getPref('cal_last_class');
467 $use_pref = $user_pref && ($user_pref !== "") && !$this->http->wrapper()->query()->has('cal_view');
468
469 return $use_pref ? $user_pref : $class;
470 }
471
472 public function setCmdClass($a_class): void
473 {
474 // If cmd class == 'ilcalendarpresentationgui' the cmd class is set to the the new forwarded class
475 // otherwise e.g ilcalendarmonthgui tries to forward (back) to ilcalendargui.
476 if ($this->ctrl->getCmdClass() == strtolower(get_class($this))) {
477 $this->redirectWithParameters($a_class);
478 }
479 }
480
481 protected function redirectWithParameters(string $class): void
482 {
483 $this->ctrl->saveParameter($this, 'seed');
484 $this->ctrl->redirectByClass($class);
485 }
486
487 protected function forwardToClass(string $a_class): ?ilCalendarViewGUI
488 {
489 $ilUser = $this->user;
490 switch ($a_class) {
491 case 'ilcalendarmonthgui':
492 $this->user->writePref('cal_last_class', $a_class);
493 ilSession::set('cal_last_tab', 'app_month');
494 $this->setCmdClass('ilcalendarmonthgui');
495 $month_gui = new ilCalendarMonthGUI($this->seed);
496 $this->ctrl->forwardCommand($month_gui);
497 return $month_gui;
498
499 case 'ilcalendarweekgui':
500 $this->user->writePref('cal_last_class', $a_class);
501 ilSession::set('cal_last_tab', 'app_week');
502 $this->setCmdClass('ilcalendarweekgui');
503 $week_gui = new ilCalendarWeekGUI($this->seed);
504 $this->ctrl->forwardCommand($week_gui);
505 return $week_gui;
506
507 case 'ilcalendardaygui':
508 $this->user->writePref('cal_last_class', $a_class);
509 ilSession::set('cal_last_tab', 'app_day');
510 $this->setCmdClass('ilcalendardaygui');
511 $day_gui = new ilCalendarDayGUI($this->seed);
512 $this->ctrl->forwardCommand($day_gui);
513 return $day_gui;
514
515 case 'ilcalendarinboxgui':
516 $this->user->writePref('cal_last_class', $a_class);
517 ilSession::set('cal_last_tab', 'cal_upcoming_events_header');
518 $this->setCmdClass('ilcalendarinboxgui');
519 $inbox_gui = new ilCalendarInboxGUI($this->seed);
520 $this->ctrl->forwardCommand($inbox_gui);
521 return $inbox_gui;
522 }
523 return null;
524 }
525
526 protected function showSideBlocks(): void
527 {
528 $tpl = new ilTemplate('tpl.cal_side_block.html', true, true, 'components/ILIAS/Calendar');
529 if ($this->getRepositoryMode()) {
530 $side_cal = new ilCalendarBlockGUI();
531 } else {
532 $side_cal = new ilPDCalendarBlockGUI();
533 }
534 $side_cal->setParentGUI("ilCalendarPresentationGUI");
535 $side_cal->setForceMonthView(true);
536 $side_cal->setRepositoryMode($this->getRepositoryMode());
537 $tpl->setVariable('MINICAL', $this->ctrl->getHTML($side_cal));
538
539 $cat = new ilCalendarCategoryGUI($this->user->getId(), $this->seed, $this->ref_id);
540 $tpl->setVariable('CATEGORIES', $this->ctrl->getHTML($cat));
541
542 $this->tpl->setRightContent($tpl->get());
543 }
544
549 protected function addCategoryTabs(): void
550 {
552 $this->tabs_gui->clearTargets();
553 $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, "category_id", $this->initCategoryIdFromQuery());
554 if ($this->getRepositoryMode()) {
555 if ($this->http->wrapper()->query()->has('backpd')) {
556 $this->tabs_gui->setBack2Target(
557 $this->lng->txt('back_to_pd'),
558 $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
559 );
560 }
561 $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
562 $this->tabs_gui->setBackTarget(
563 $label,
564 $this->ctrl->getParentReturn($this)
565 );
566 } elseif ($this->http->wrapper()->query()->has('backvm')) {
567 // no object calendar => back is back to manage view
568 $this->tabs_gui->setBackTarget(
569 $this->lng->txt("back"),
570 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'manage')
571 );
572 } else {
573 $ctrl->clearParameterByClass(ilCalendarPresentationGUI::class, 'category_id');
574 $this->tabs_gui->setBackTarget(
575 $this->lng->txt("back"),
576 $ctrl->getLinkTargetByClass('ilcalendarpresentationgui', '')
577 );
578 $ctrl->setParameterByClass(ilCalendarPresentationGUI::class, "category_id", $this->initCategoryIdFromQuery());
579 }
580
581 $this->tabs_gui->addTab(
582 "cal_agenda",
583 $this->lng->txt("cal_agenda"),
584 $ctrl->getLinkTargetByClass(ilCalendarPresentationGUI::class, "")
585 );
586
587 if ($this->actions->checkShareCal($this->category_id)) {
588 $this->tabs_gui->addTab(
589 "share",
590 $this->lng->txt("cal_share"),
591 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "shareSearch")
592 );
593 }
594 if ($this->actions->checkSettingsCal($this->category_id)) {
595 $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $this->category_id);
596 $this->tabs_gui->addTab(
597 "edit",
598 $this->lng->txt("settings"),
599 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "edit")
600 );
601 $ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
602 }
603 $this->tabs_gui->activateTab('cal_agenda');
604 }
605
609 protected function addStandardTabs(): void
610 {
613
614 $this->tabs_gui->clearTargets();
615 if ($this->getRepositoryMode()) {
616 if ($this->http->wrapper()->query()->has('backpd')) {
617 $this->tabs_gui->setBack2Target(
618 $this->lng->txt('back_to_pd'),
619 $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
620 );
621 }
622 $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
623 $this->tabs_gui->setBackTarget(
624 $label,
625 $this->ctrl->getParentReturn($this)
626 );
627
628 $obj_id = ilObject::_lookupObjId($this->ref_id);
629 $category = ilCalendarCategory::_getInstanceByObjId($obj_id);
630 $category_id = $category->getCategoryID();
631
632 // agenda tab
633 $this->tabs_gui->addTab(
634 'cal_agenda',
635 $this->lng->txt('cal_agenda'),
636 $this->ctrl->getLinkTarget($this, '')
637 );
638
639 // settings tab
640 if ($access->checkAccess('edit_event', '', $this->ref_id)) {
641 $this->ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $category_id);
642 $this->tabs_gui->addTab(
643 'cal_manage',
644 $this->lng->txt('settings'),
645 $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'edit')
646 );
647 $this->ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
648 }
649 } else {
650 $this->tabs_gui->addTab(
651 'cal_agenda',
652 $this->lng->txt("cal_agenda"),
653 $this->ctrl->getLinkTarget($this, '')
654 );
655
656 if (
657 $this->rbacsystem->checkAccess(
658 'add_consultation_hours',
659 ilCalendarSettings::_getInstance()->getCalendarSettingsId()
660 ) &&
661 ilCalendarSettings::_getInstance()->areConsultationHoursEnabled()
662 ) {
663 $this->tabs_gui->addTab(
664 'app_consultation_hours',
665 $this->lng->txt('app_consultation_hours'),
666 $this->ctrl->getLinkTargetByClass(ilConsultationHoursGUI::class, '')
667 );
668 }
669 $this->tabs_gui->addTarget(
670 'cal_manage',
671 $this->ctrl->getLinkTargetByClass('ilCalendarCategoryGUI', 'manage')
672 );
673 $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI', ''));
674 }
675 }
676
677 protected function prepareOutput(): void
678 {
679 if ($this->category_id) {
680 $this->addCategoryTabs();
681 } else {
682 $this->addStandardTabs();
683 }
684
685 // #0035566
686 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_cal.svg"));
687
688 // if we are in single calendar view
689 if ($this->category_id > 0) {
690 $tabs = $this->tabs_gui;
694
695 $category = new ilCalendarCategory($this->category_id);
696
697 // Set header
698 $header = "";
699 switch ($category->getType()) {
701 $header = $this->lng->txt('cal_type_personal') . ": " . $category->getTitle();
702 break;
703
705 $header = $this->lng->txt('cal_type_system') . ": " . $category->getTitle();
706 break;
707
709 $header = $this->lng->txt('cal_type_' . $category->getObjType()) . ": " . $category->getTitle();
710 break;
711
713 $header = str_replace(
714 "%1",
715 ilObjUser::_lookupFullname($category->getObjId()),
716 $this->lng->txt("cal_consultation_hours_for_user")
717 );
718 break;
719
721 $header = $category->getTitle();
722 break;
723 }
724 $tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_cal.svg"));
725 $tpl->setTitle($header);
726
727 $dropDownItems = array();
728
729 // iCal-Url
730 $ctrl->setParameterByClass("ilcalendarsubscriptiongui", "category_id", $this->category_id);
731 $dropDownItems[] = $this->ui_factory->button()->shy(
732 $this->lng->txt("cal_ical_url"),
733 $ctrl->getLinkTargetByClass("ilcalendarsubscriptiongui", "")
734 );
735
736 // delete action
737 if ($this->actions->checkDeleteCal($this->category_id)) {
738 $ctrl->setParameterByClass("ilcalendarcategorygui", "category_id", $this->category_id);
739 $dropDownItems[] = $this->ui_factory->button()->shy(
740 $this->lng->txt("cal_delete_cal"),
741 $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "confirmDelete")
742 );
743 }
744 $dropDown = $this->ui_factory->dropdown()->standard($dropDownItems)
745 ->withAriaLabel($this->lng->txt('actions'));
746 $tpl->setHeaderActionMenu($this->renderer->render($dropDown));
747 }
748 }
749
750 protected function getRequestedSeedAsString(): string
751 {
752 $seed = '';
753 if ($this->http->wrapper()->query()->has('seed')) {
754 $seed = $this->http->wrapper()->query()->retrieve(
755 'seed',
756 $this->refinery->kindlyTo()->string()
757 );
758 }
759 return $seed;
760 }
761
765 public function initSeed(): void
766 {
768
769 // default to today
770 $now = new \ilDate(time(), IL_CAL_UNIX);
771 $this->seed = new \ilDate($now->get(IL_CAL_DATE), IL_CAL_DATE);
772 if ($seed) {
773 $this->seed = new ilDate($seed, IL_CAL_DATE);
774 } elseif (!$this->getRepositoryMode()) {
775 $session_seed = ilSession::get('cal_seed');
776 if ($session_seed) {
777 $this->seed = new ilDate($session_seed, IL_CAL_DATE);
778 }
779 }
780 $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
781 ilSession::set('cal_seed', $this->seed->get(IL_CAL_DATE));
782 }
783
784
785 #21613
786 public function showToolbarAndSidebar(): bool
787 {
788 #21783
789 return !(
790 $this->ctrl->getCmdClass() == "ilcalendarappointmentgui" ||
791 $this->ctrl->getCmdClass() == 'ilconsultationhoursgui'
792 );
793 }
794}
renderer()
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
GUI class for public user profile presentation.
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_FKT_DATE
Checks if certain actions can be performed.
static getInstance()
Get instance.
Administrate calendar appointments.
Calendar blocks, displayed in different contexts, e.g.
class for calendar categories
initialize(int $a_mode, int $a_source_ref_id=0, bool $a_use_cache=false, int $a_cat_id=0)
initialize visible categories
static _getInstance($a_usr_id=0)
get singleton instance
Administration, Side-Block presentation of calendar categories.
Stores calendar categories.
static _getInstanceByObjId(int $a_obj_id)
get instance by obj_id
Presentation day view.
addCategoryTabs()
Add tabs for ilCategoryGUI context This cannot be done there since many views (Day Week Agenda) are i...
showViewSelection(string $a_active="cal_list")
initSeed()
init the seed date for presentations (month view, minicalendar)
initCalendarView()
Initialises calendar view according to given settings.
readLastClass()
Read last class from history.
initAndRedirectToConsultationHours()
Init and redirect to consultation hours.
Stores all calendar relevant settings.
Show calendar subscription info.
static _getInstanceByUserId(int $a_user_id, int $a_ref_id=0)
Consultation hours editor.
@classDescription Date and time handling
Class for single dates.
Help GUI class.
language handling
User class.
static _lookupFullname(int $a_user_id)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
Calendar blocks, displayed on personal desktop.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addComponent(\ILIAS\UI\Component\Component $a_comp)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static redirect(string $a_script)
$info
Definition: entry_point.php:21
setVariable(string $variable, $value='')
Sets the given variable to the given value.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setHeaderActionMenu(string $a_header)
Set header action menu.
An entity that renders components to a string output.
Definition: Renderer.php:31
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
clearParameterByClass(string $a_class, string $a_parameter)
Removes a specific parameter of a specific class that is currently set or saved.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
Sets a parameter for the given GUI class and appends the given value as well.
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
Returns a link target for the given information.
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26