ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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->saveParameter($this, 'cal_view');
485 $this->ctrl->saveParameter($this, 'cal_agenda_per');
486 $this->ctrl->redirectByClass($class);
487 }
488
489 protected function forwardToClass(string $a_class): ?ilCalendarViewGUI
490 {
491 $ilUser = $this->user;
492 switch ($a_class) {
493 case 'ilcalendarmonthgui':
494 $this->user->writePref('cal_last_class', $a_class);
495 ilSession::set('cal_last_tab', 'app_month');
496 $this->setCmdClass('ilcalendarmonthgui');
497 $month_gui = new ilCalendarMonthGUI($this->seed);
498 $this->ctrl->forwardCommand($month_gui);
499 return $month_gui;
500
501 case 'ilcalendarweekgui':
502 $this->user->writePref('cal_last_class', $a_class);
503 ilSession::set('cal_last_tab', 'app_week');
504 $this->setCmdClass('ilcalendarweekgui');
505 $week_gui = new ilCalendarWeekGUI($this->seed);
506 $this->ctrl->forwardCommand($week_gui);
507 return $week_gui;
508
509 case 'ilcalendardaygui':
510 $this->user->writePref('cal_last_class', $a_class);
511 ilSession::set('cal_last_tab', 'app_day');
512 $this->setCmdClass('ilcalendardaygui');
513 $day_gui = new ilCalendarDayGUI($this->seed);
514 $this->ctrl->forwardCommand($day_gui);
515 return $day_gui;
516
517 case 'ilcalendarinboxgui':
518 $this->user->writePref('cal_last_class', $a_class);
519 ilSession::set('cal_last_tab', 'cal_upcoming_events_header');
520 $this->setCmdClass('ilcalendarinboxgui');
521 $inbox_gui = new ilCalendarInboxGUI($this->seed);
522 $this->ctrl->forwardCommand($inbox_gui);
523 return $inbox_gui;
524 }
525 return null;
526 }
527
528 protected function showSideBlocks(): void
529 {
530 $tpl = new ilTemplate('tpl.cal_side_block.html', true, true, 'components/ILIAS/Calendar');
531 if ($this->getRepositoryMode()) {
532 $side_cal = new ilCalendarBlockGUI();
533 } else {
534 $side_cal = new ilPDCalendarBlockGUI();
535 }
536 $side_cal->setParentGUI("ilCalendarPresentationGUI");
537 $side_cal->setForceMonthView(true);
538 $side_cal->setRepositoryMode($this->getRepositoryMode());
539 $tpl->setVariable('MINICAL', $this->ctrl->getHTML($side_cal));
540
541 $cat = new ilCalendarCategoryGUI($this->user->getId(), $this->seed, $this->ref_id);
542 $tpl->setVariable('CATEGORIES', $this->ctrl->getHTML($cat));
543
544 $this->tpl->setRightContent($tpl->get());
545 }
546
551 protected function addCategoryTabs(): void
552 {
554 $this->tabs_gui->clearTargets();
555 $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, "category_id", $this->initCategoryIdFromQuery());
556 if ($this->getRepositoryMode()) {
557 if ($this->http->wrapper()->query()->has('backpd')) {
558 $this->tabs_gui->setBack2Target(
559 $this->lng->txt('back_to_pd'),
560 $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
561 );
562 }
563 $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
564 $this->tabs_gui->setBackTarget(
565 $label,
566 $this->ctrl->getParentReturn($this)
567 );
568 } elseif ($this->http->wrapper()->query()->has('backvm')) {
569 // no object calendar => back is back to manage view
570 $this->tabs_gui->setBackTarget(
571 $this->lng->txt("back"),
572 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'manage')
573 );
574 } else {
575 $ctrl->clearParameterByClass(ilCalendarPresentationGUI::class, 'category_id');
576 $this->tabs_gui->setBackTarget(
577 $this->lng->txt("back"),
578 $ctrl->getLinkTargetByClass('ilcalendarpresentationgui', '')
579 );
580 $ctrl->setParameterByClass(ilCalendarPresentationGUI::class, "category_id", $this->initCategoryIdFromQuery());
581 }
582
583 $this->tabs_gui->addTab(
584 "cal_agenda",
585 $this->lng->txt("cal_agenda"),
586 $ctrl->getLinkTargetByClass(ilCalendarPresentationGUI::class, "")
587 );
588
589 if ($this->actions->checkShareCal($this->category_id)) {
590 $this->tabs_gui->addTab(
591 "share",
592 $this->lng->txt("cal_share"),
593 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "shareSearch")
594 );
595 }
596 if ($this->actions->checkSettingsCal($this->category_id)) {
597 $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $this->category_id);
598 $this->tabs_gui->addTab(
599 "edit",
600 $this->lng->txt("settings"),
601 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "edit")
602 );
603 $ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
604 }
605 $this->tabs_gui->activateTab('cal_agenda');
606 }
607
611 protected function addStandardTabs(): void
612 {
615
616 $this->tabs_gui->clearTargets();
617 if ($this->getRepositoryMode()) {
618 if ($this->http->wrapper()->query()->has('backpd')) {
619 $this->tabs_gui->setBack2Target(
620 $this->lng->txt('back_to_pd'),
621 $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
622 );
623 }
624 $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
625 $this->tabs_gui->setBackTarget(
626 $label,
627 $this->ctrl->getParentReturn($this)
628 );
629
630 $obj_id = ilObject::_lookupObjId($this->ref_id);
631 $category = ilCalendarCategory::_getInstanceByObjId($obj_id);
632 $category_id = $category->getCategoryID();
633
634 // agenda tab
635 $this->tabs_gui->addTab(
636 'cal_agenda',
637 $this->lng->txt('cal_agenda'),
638 $this->ctrl->getLinkTarget($this, '')
639 );
640
641 // settings tab
642 if ($access->checkAccess('edit_event', '', $this->ref_id)) {
643 $this->ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $category_id);
644 $this->tabs_gui->addTab(
645 'cal_manage',
646 $this->lng->txt('settings'),
647 $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'edit')
648 );
649 $this->ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
650 }
651 } else {
652 $this->tabs_gui->addTab(
653 'cal_agenda',
654 $this->lng->txt("cal_agenda"),
655 $this->ctrl->getLinkTarget($this, '')
656 );
657
658 if (
659 $this->rbacsystem->checkAccess(
660 'add_consultation_hours',
661 ilCalendarSettings::_getInstance()->getCalendarSettingsId()
662 ) &&
663 ilCalendarSettings::_getInstance()->areConsultationHoursEnabled()
664 ) {
665 $this->tabs_gui->addTab(
666 'app_consultation_hours',
667 $this->lng->txt('app_consultation_hours'),
668 $this->ctrl->getLinkTargetByClass(ilConsultationHoursGUI::class, '')
669 );
670 }
671 $this->tabs_gui->addTarget(
672 'cal_manage',
673 $this->ctrl->getLinkTargetByClass('ilCalendarCategoryGUI', 'manage')
674 );
675 $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI', ''));
676 }
677 }
678
679 protected function prepareOutput(): void
680 {
681 if ($this->category_id) {
682 $this->addCategoryTabs();
683 } else {
684 $this->addStandardTabs();
685 }
686
687 // #0035566
688 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_cal.svg"));
689
690 // if we are in single calendar view
691 if ($this->category_id > 0) {
692 $tabs = $this->tabs_gui;
696
697 $category = new ilCalendarCategory($this->category_id);
698
699 // Set header
700 $header = "";
701 switch ($category->getType()) {
703 $header = $this->lng->txt('cal_type_personal') . ": " . $category->getTitle();
704 break;
705
707 $header = $this->lng->txt('cal_type_system') . ": " . $category->getTitle();
708 break;
709
711 $header = $this->lng->txt('cal_type_' . $category->getObjType()) . ": " . $category->getTitle();
712 break;
713
715 $header = str_replace(
716 "%1",
717 ilObjUser::_lookupFullname($category->getObjId()),
718 $this->lng->txt("cal_consultation_hours_for_user")
719 );
720 break;
721
723 $header = $category->getTitle();
724 break;
725 }
726 $tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_cal.svg"));
727 $tpl->setTitle($header);
728
729 $dropDownItems = array();
730
731 // iCal-Url
732 $ctrl->setParameterByClass("ilcalendarsubscriptiongui", "category_id", $this->category_id);
733 $dropDownItems[] = $this->ui_factory->button()->shy(
734 $this->lng->txt("cal_ical_url"),
735 $ctrl->getLinkTargetByClass("ilcalendarsubscriptiongui", "")
736 );
737
738 // delete action
739 if ($this->actions->checkDeleteCal($this->category_id)) {
740 $ctrl->setParameterByClass("ilcalendarcategorygui", "category_id", $this->category_id);
741 $dropDownItems[] = $this->ui_factory->button()->shy(
742 $this->lng->txt("cal_delete_cal"),
743 $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "confirmDelete")
744 );
745 }
746 $dropDown = $this->ui_factory->dropdown()->standard($dropDownItems)
747 ->withAriaLabel($this->lng->txt('actions'));
748 $tpl->setHeaderActionMenu($this->renderer->render($dropDown));
749 }
750 }
751
752 protected function getRequestedSeedAsString(): string
753 {
754 $seed = '';
755 if ($this->http->wrapper()->query()->has('seed')) {
756 $seed = $this->http->wrapper()->query()->retrieve(
757 'seed',
758 $this->refinery->kindlyTo()->string()
759 );
760 }
761 return $seed;
762 }
763
767 public function initSeed(): void
768 {
770
771 // default to today
772 $now = new \ilDate(time(), IL_CAL_UNIX);
773 $this->seed = new \ilDate($now->get(IL_CAL_DATE), IL_CAL_DATE);
774 if ($seed) {
775 $this->seed = new ilDate($seed, IL_CAL_DATE);
776 } elseif (!$this->getRepositoryMode()) {
777 $session_seed = ilSession::get('cal_seed');
778 if ($session_seed) {
779 $this->seed = new ilDate($session_seed, IL_CAL_DATE);
780 }
781 }
782 $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
783 ilSession::set('cal_seed', $this->seed->get(IL_CAL_DATE));
784 }
785
786
787 #21613
788 public function showToolbarAndSidebar(): bool
789 {
790 #21783
791 return !(
792 $this->ctrl->getCmdClass() == "ilcalendarappointmentgui" ||
793 $this->ctrl->getCmdClass() == 'ilconsultationhoursgui'
794 );
795 }
796}
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