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