ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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->ui_factory = $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 
206  if (!ilCalendarSettings::_getInstance()->isEnabled()) {
207  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
208  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
209  }
210 
211  $this->initSeed();
212  if (!$this->ctrl->isAsynch()) {
213  $this->prepareOutput();
214  }
215 
216  $this->help->setScreenIdComponent("cal");
217  switch ($cmd) {
218  case 'selectCHCalendarOfUser':
220  break;
221  }
222 
223  // now next class is not empty, which breaks old consultation hour implementation
224  $next_class = $this->getNextClass();
225 
226  switch ($next_class) {
227  case 'ilcalendarinboxgui':
228  $this->tabs_gui->activateTab('cal_agenda');
229  $inbox_gui = $this->forwardToClass('ilcalendarinboxgui');
230  if ($this->showToolbarAndSidebar()) {
231  $this->showViewSelection("cal_list");
232  $this->showSideBlocks();
233  $inbox_gui->addToolbarFileDownload();
234  }
235 
236  break;
237 
238  case 'ilconsultationhoursgui':
239  $this->tabs_gui->activateTab('app_consultation_hours');
240  $this->tabs_gui->clearTargets();
241 
242  // No side blocks
243  $this->tabs_gui->setBackTarget(
244  $this->lng->txt('cal_back_to_cal'),
245  $this->ctrl->getLinkTargetByClass($this->readLastClass())
246  );
247  $this->ctrl->forwardCommand(new ilConsultationHoursGUI());
248  if ($this->showToolbarAndSidebar()) {
249  $this->showSideBlocks();
250  }
251  return;
252 
253  case 'ilcalendarmonthgui':
254  $this->tabs_gui->activateTab('cal_agenda');
255  $month_gui = $this->forwardToClass('ilcalendarmonthgui');
256 
257  if ($this->showToolbarAndSidebar()) {
258  $this->showViewSelection("app_month");
259  $this->showSideBlocks();
260  $month_gui->addToolbarFileDownload();
261  }
262  break;
263 
264  case 'ilcalendarweekgui':
265  $this->tabs_gui->activateTab('cal_agenda');
266  $week_gui = $this->forwardToClass('ilcalendarweekgui');
267  if ($this->showToolbarAndSidebar()) {
268  $this->showViewSelection("app_week");
269  $this->showSideBlocks();
270  $week_gui->addToolbarFileDownload();
271  }
272 
273  break;
274 
275  case 'ilcalendardaygui':
276  $this->tabs_gui->activateTab('cal_agenda');
277  $day_gui = $this->forwardToClass('ilcalendardaygui');
278  if ($this->showToolbarAndSidebar()) {
279  $this->showViewSelection("app_day");
280  $this->showSideBlocks();
281  $day_gui->addToolbarFileDownload();
282  }
283  break;
284 
285  case 'ilcalendarusersettingsgui':
286  $this->ctrl->setReturn($this, '');
287  $this->tabs_gui->activateTab('settings');
288  $this->setCmdClass('ilcalendarusersettingsgui');
289 
290  $user_settings = new ilCalendarUserSettingsGUI();
291  $this->ctrl->forwardCommand($user_settings);
292  // No side blocks
293  return;
294 
295  case 'ilcalendarappointmentgui':
296  $this->ctrl->setReturn($this, '');
297  $this->tabs_gui->activateTab((string) ilSession::get('cal_last_tab'));
298 
299  $app = new ilCalendarAppointmentGUI($this->seed, $this->seed, $this->initAppointmentIdFromQuery());
300  $this->ctrl->forwardCommand($app);
301  break;
302 
303  case 'ilcalendarsubscriptiongui':
304  $this->ctrl->setReturn($this, '');
305  $this->tabs_gui->activateTab("cal_agenda");
306 
307  $ref_id = 0;
308  if ($this->http->wrapper()->query()->has('ref_id')) {
309  $ref_id = $this->http->wrapper()->query()->retrieve(
310  'ref_id',
311  $this->refinery->kindlyTo()->int()
312  );
313  }
314  $sub = new ilCalendarSubscriptionGUI($this->category_id, $ref_id);
315  $this->ctrl->forwardCommand($sub);
316  if ($this->showToolbarAndSidebar()) {
317  $this->showSideBlocks();
318  }
319  break;
320 
321  case 'ilcalendarcategorygui':
322  $this->ctrl->setReturn($this, '');
323  $this->tabs_gui->activateTab("cal_manage");
324  $category = new ilCalendarCategoryGUI($this->user->getId(), $this->seed, $this->ref_id);
325  if ($this->ctrl->forwardCommand($category)) {
326  return;
327  } else {
328  $this->showSideBlocks();
329  break;
330  }
331 
332  // no break
333  case 'ilcalendarblockgui':
334  $side_cal = new ilCalendarBlockGUI();
335  $side_cal->setRepositoryMode($this->getRepositoryMode());
336  $side_cal->setForceMonthView(true);
337  $this->ctrl->forwardCommand($side_cal);
338  $this->showSideBlocks();
339  break;
340 
341  case 'ilpdcalendarblockgui':
342  $side_cal = new ilPDCalendarBlockGUI();
343  $side_cal->setRepositoryMode($this->getRepositoryMode());
344  $side_cal->setForceMonthView(true);
345  $this->ctrl->forwardCommand($side_cal);
346  $this->showSideBlocks();
347  break;
348 
349  case 'ilpublicuserprofilegui':
350  $user_id = $this->user->getId();
351  if ($this->http->wrapper()->query()->has('user_id')) {
352  $user_id = $this->http->wrapper()->query()->retrieve(
353  'user_id',
354  $this->refinery->kindlyTo()->int()
355  );
356  }
357  $user_profile = new ilPublicUserProfileGUI($user_id);
358  $html = $this->ctrl->forwardCommand($user_profile);
359  $this->tpl->setContent($html);
360  break;
361 
362  default:
363  $cmd = $this->ctrl->getCmd("show");
364  $this->$cmd();
365  $this->showSideBlocks();
366  break;
367  }
368  }
369 
370  public function showViewSelection(string $a_active = "cal_list"): void
371  {
372  $ui = $this->ui;
373  $ctrl = $this->ctrl;
374  $lng = $this->lng;
375  $toolbar = $this->toolbar;
376 
377  $f = $ui->factory();
378 
379  $actions = array(
380  $this->lng->txt("app_day") => $ctrl->getLinkTargetByClass('ilCalendarDayGUI', ''),
381  $this->lng->txt("app_week") => $ctrl->getLinkTargetByClass('ilCalendarWeekGUI', ''),
382  $this->lng->txt("app_month") => $ctrl->getLinkTargetByClass('ilCalendarMonthGUI', ''),
383  $this->lng->txt("cal_list") => $ctrl->getLinkTargetByClass('ilCalendarInboxGUI', '')
384  );
385 
386 
387  $view_control = $f->viewControl()->mode($actions, "cal_change_calendar_view")->withActive($this->lng->txt($a_active));
388  $toolbar->addComponent($view_control);
389  $ctrl->setParameterByClass("ilcalendarappointmentgui", "seed", $this->seed->get(IL_CAL_DATE, ''));
390  $ctrl->setParameterByClass("ilcalendarappointmentgui", "app_id", "");
391  $ctrl->setParameterByClass("ilcalendarappointmentgui", "dt", "");
392  $ctrl->setParameterByClass("ilcalendarappointmentgui", "idate", (new ilDate(time(), IL_CAL_UNIX))->get(IL_CAL_DATE));
393 
394  $extra_button_added = false;
395  // add appointment
396  if ($this->category_id == 0 || $this->actions->checkAddEvent($this->category_id)) {
397  $toolbar->addSeparator();
398  $extra_button_added = true;
399  $add_button = $f->button()->standard(
400  $this->lng->txt("cal_add_appointment"),
401  $ctrl->getLinkTargetByClass("ilcalendarappointmentgui", "add")
402  );
403  $toolbar->addComponent($add_button);
404  }
405 
406  // import appointments
407  if ($this->category_id > 0 && $this->actions->checkAddEvent($this->category_id)) {
408  if (!$extra_button_added) {
409  $toolbar->addSeparator();
410  }
411  $add_button = $f->button()->standard(
412  $this->lng->txt("cal_import_appointments"),
413  $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "importAppointments")
414  );
415  $toolbar->addComponent($add_button);
416  }
417  }
418 
419  public function getNextClass(): string
420  {
421  if (strlen($next_class = $this->ctrl->getNextClass())) {
422  return $next_class;
423  }
424  if (
425  strcasecmp($this->ctrl->getCmdClass(), ilCalendarPresentationGUI::class) === 0 ||
426  $this->ctrl->getCmdClass() == ''
427  ) {
428  $cmd_class = $this->readLastClass();
429  $this->redirectWithParameters($cmd_class);
430  return $cmd_class;
431  }
432  return '';
433  }
434 
438  public function readLastClass(): string
439  {
440  $ilUser = $this->user;
441  switch ($this->cal_view) {
443  $class = "ilcalendardaygui";
444  break;
446  $class = "ilcalendarweekgui";
447  break;
449  $class = "ilcalendarmonthgui";
450  break;
452  default:
453  $class = "ilcalendarinboxgui";
454  break;
455  }
456 
457  // see #34998, if cal_view is requested (e.g. through starting point)
458  // it must get high prio than history entry
459  $user_pref = $this->user->getPref('cal_last_class');
460  $use_pref = $user_pref && ($user_pref !== "") && !$this->http->wrapper()->query()->has('cal_view');
461 
462  return $use_pref ? $user_pref : $class;
463  }
464 
465  public function setCmdClass($a_class): void
466  {
467  // If cmd class == 'ilcalendarpresentationgui' the cmd class is set to the the new forwarded class
468  // otherwise e.g ilcalendarmonthgui tries to forward (back) to ilcalendargui.
469  if ($this->ctrl->getCmdClass() == strtolower(get_class($this))) {
470  $this->redirectWithParameters($a_class);
471  }
472  }
473 
474  protected function redirectWithParameters(string $class): void
475  {
476  $this->ctrl->saveParameter($this, 'seed');
477  $this->ctrl->redirectByClass($class);
478  }
479 
480  protected function forwardToClass(string $a_class): ?ilCalendarViewGUI
481  {
482  $ilUser = $this->user;
483  switch ($a_class) {
484  case 'ilcalendarmonthgui':
485  $this->user->writePref('cal_last_class', $a_class);
486  ilSession::set('cal_last_tab', 'app_month');
487  $this->setCmdClass('ilcalendarmonthgui');
488  $month_gui = new ilCalendarMonthGUI($this->seed);
489  $this->ctrl->forwardCommand($month_gui);
490  return $month_gui;
491 
492  case 'ilcalendarweekgui':
493  $this->user->writePref('cal_last_class', $a_class);
494  ilSession::set('cal_last_tab', 'app_week');
495  $this->setCmdClass('ilcalendarweekgui');
496  $week_gui = new ilCalendarWeekGUI($this->seed);
497  $this->ctrl->forwardCommand($week_gui);
498  return $week_gui;
499 
500  case 'ilcalendardaygui':
501  $this->user->writePref('cal_last_class', $a_class);
502  ilSession::set('cal_last_tab', 'app_day');
503  $this->setCmdClass('ilcalendardaygui');
504  $day_gui = new ilCalendarDayGUI($this->seed);
505  $this->ctrl->forwardCommand($day_gui);
506  return $day_gui;
507 
508  case 'ilcalendarinboxgui':
509  $this->user->writePref('cal_last_class', $a_class);
510  ilSession::set('cal_last_tab', 'cal_upcoming_events_header');
511  $this->setCmdClass('ilcalendarinboxgui');
512  $inbox_gui = new ilCalendarInboxGUI($this->seed);
513  $this->ctrl->forwardCommand($inbox_gui);
514  return $inbox_gui;
515  }
516  return null;
517  }
518 
519  protected function showSideBlocks(): void
520  {
521  $tpl = new ilTemplate('tpl.cal_side_block.html', true, true, 'components/ILIAS/Calendar');
522  if ($this->getRepositoryMode()) {
523  $side_cal = new ilCalendarBlockGUI();
524  } else {
525  $side_cal = new ilPDCalendarBlockGUI();
526  }
527  $side_cal->setParentGUI("ilCalendarPresentationGUI");
528  $side_cal->setForceMonthView(true);
529  $side_cal->setRepositoryMode($this->getRepositoryMode());
530  $tpl->setVariable('MINICAL', $this->ctrl->getHTML($side_cal));
531 
532  $cat = new ilCalendarCategoryGUI($this->user->getId(), $this->seed, $this->ref_id);
533  $tpl->setVariable('CATEGORIES', $this->ctrl->getHTML($cat));
534 
535  $this->tpl->setRightContent($tpl->get());
536  }
537 
542  protected function addCategoryTabs(): void
543  {
544  $ctrl = $this->ctrl;
545  $this->tabs_gui->clearTargets();
546  $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, "category_id", $this->initCategoryIdFromQuery());
547  if ($this->getRepositoryMode()) {
548  if ($this->http->wrapper()->query()->has('backpd')) {
549  $this->tabs_gui->setBack2Target(
550  $this->lng->txt('back_to_pd'),
551  $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
552  );
553  }
554  $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
555  $this->tabs_gui->setBackTarget(
556  $label,
557  $this->ctrl->getParentReturn($this)
558  );
559  } elseif ($this->http->wrapper()->query()->has('backvm')) {
560  // no object calendar => back is back to manage view
561  $this->tabs_gui->setBackTarget(
562  $this->lng->txt("back"),
563  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'manage')
564  );
565  } else {
566  $ctrl->clearParameterByClass(ilCalendarPresentationGUI::class, 'category_id');
567  $this->tabs_gui->setBackTarget(
568  $this->lng->txt("back"),
569  $ctrl->getLinkTargetByClass('ilcalendarpresentationgui', '')
570  );
571  $ctrl->setParameterByClass(ilCalendarPresentationGUI::class, "category_id", $this->initCategoryIdFromQuery());
572  }
573 
574  $this->tabs_gui->addTab(
575  "cal_agenda",
576  $this->lng->txt("cal_agenda"),
577  $ctrl->getLinkTargetByClass(ilCalendarPresentationGUI::class, "")
578  );
579 
580  if ($this->actions->checkShareCal($this->category_id)) {
581  $this->tabs_gui->addTab(
582  "share",
583  $this->lng->txt("cal_share"),
584  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "shareSearch")
585  );
586  }
587  if ($this->actions->checkSettingsCal($this->category_id)) {
588  $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $this->category_id);
589  $this->tabs_gui->addTab(
590  "edit",
591  $this->lng->txt("settings"),
592  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "edit")
593  );
594  $ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
595  }
596  $this->tabs_gui->activateTab('cal_agenda');
597  }
598 
602  protected function addStandardTabs(): void
603  {
604  $access = $this->access;
605  $rbacsystem = $this->rbacsystem;
606 
607  $this->tabs_gui->clearTargets();
608  if ($this->getRepositoryMode()) {
609  if ($this->http->wrapper()->query()->has('backpd')) {
610  $this->tabs_gui->setBack2Target(
611  $this->lng->txt('back_to_pd'),
612  $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
613  );
614  }
615  $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
616  $this->tabs_gui->setBackTarget(
617  $label,
618  $this->ctrl->getParentReturn($this)
619  );
620 
621  $obj_id = ilObject::_lookupObjId($this->ref_id);
622  $category = ilCalendarCategory::_getInstanceByObjId($obj_id);
623  $category_id = $category->getCategoryID();
624 
625  // agenda tab
626  $this->tabs_gui->addTab(
627  'cal_agenda',
628  $this->lng->txt('cal_agenda'),
629  $this->ctrl->getLinkTarget($this, '')
630  );
631 
632  // settings tab
633  if ($access->checkAccess('edit_event', '', $this->ref_id)) {
634  $this->ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $category_id);
635  $this->tabs_gui->addTab(
636  'cal_manage',
637  $this->lng->txt('settings'),
638  $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'edit')
639  );
640  $this->ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
641  }
642  } else {
643  $this->tabs_gui->addTab(
644  'cal_agenda',
645  $this->lng->txt("cal_agenda"),
646  $this->ctrl->getLinkTarget($this, '')
647  );
648 
649  if (
650  $this->rbacsystem->checkAccess(
651  'add_consultation_hours',
652  ilCalendarSettings::_getInstance()->getCalendarSettingsId()
653  ) &&
654  ilCalendarSettings::_getInstance()->areConsultationHoursEnabled()
655  ) {
656  $this->tabs_gui->addTab(
657  'app_consultation_hours',
658  $this->lng->txt('app_consultation_hours'),
659  $this->ctrl->getLinkTargetByClass(ilConsultationHoursGUI::class, '')
660  );
661  }
662  $this->tabs_gui->addTarget(
663  'cal_manage',
664  $this->ctrl->getLinkTargetByClass('ilCalendarCategoryGUI', 'manage')
665  );
666  $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI', ''));
667  }
668  }
669 
670  protected function prepareOutput(): void
671  {
672  if ($this->category_id) {
673  $this->addCategoryTabs();
674  } else {
675  $this->addStandardTabs();
676  }
677 
678  // #0035566
679  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_cal.svg"));
680 
681  // if we are in single calendar view
682  if ($this->category_id > 0) {
683  $tabs = $this->tabs_gui;
684  $lng = $this->lng;
685  $ctrl = $this->ctrl;
686  $tpl = $this->tpl;
687 
688  $category = new ilCalendarCategory($this->category_id);
689 
690  // Set header
691  $header = "";
692  switch ($category->getType()) {
694  $header = $this->lng->txt('cal_type_personal') . ": " . $category->getTitle();
695  break;
696 
698  $header = $this->lng->txt('cal_type_system') . ": " . $category->getTitle();
699  break;
700 
702  $header = $this->lng->txt('cal_type_' . $category->getObjType()) . ": " . $category->getTitle();
703  break;
704 
706  $header = str_replace(
707  "%1",
708  ilObjUser::_lookupFullname($category->getObjId()),
709  $this->lng->txt("cal_consultation_hours_for_user")
710  );
711  break;
712 
714  $header = $category->getTitle();
715  break;
716  }
717  $tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_cal.svg"));
718  $tpl->setTitle($header);
719 
720  $dropDownItems = array();
721 
722  // iCal-Url
723  $ctrl->setParameterByClass("ilcalendarsubscriptiongui", "category_id", $this->category_id);
724  $dropDownItems[] = $this->ui_factory->button()->shy(
725  $this->lng->txt("cal_ical_url"),
726  $ctrl->getLinkTargetByClass("ilcalendarsubscriptiongui", "")
727  );
728 
729  // delete action
730  if ($this->actions->checkDeleteCal($this->category_id)) {
731  $ctrl->setParameterByClass("ilcalendarcategorygui", "category_id", $this->category_id);
732  $dropDownItems[] = $this->ui_factory->button()->shy(
733  $this->lng->txt("cal_delete_cal"),
734  $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "confirmDelete")
735  );
736  }
737  $dropDown = $this->ui_factory->dropdown()->standard($dropDownItems)
738  ->withAriaLabel($this->lng->txt('actions'));
739  $tpl->setHeaderActionMenu($this->renderer->render($dropDown));
740  }
741  }
742 
743  protected function getRequestedSeedAsString(): string
744  {
745  $seed = '';
746  if ($this->http->wrapper()->query()->has('seed')) {
747  $seed = $this->http->wrapper()->query()->retrieve(
748  'seed',
749  $this->refinery->kindlyTo()->string()
750  );
751  }
752  return $seed;
753  }
754 
758  public function initSeed(): void
759  {
760  $seed = $this->getRequestedSeedAsString();
761 
762  // default to today
763  $now = new \ilDate(time(), IL_CAL_UNIX);
764  $this->seed = new \ilDate($now->get(IL_CAL_DATE), IL_CAL_DATE);
765  if ($seed) {
766  $this->seed = new ilDate($seed, IL_CAL_DATE);
767  } elseif (!$this->getRepositoryMode()) {
768  $session_seed = ilSession::get('cal_seed');
769  if ($session_seed) {
770  $this->seed = new ilDate($session_seed, IL_CAL_DATE);
771  }
772  }
773  $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
774  ilSession::set('cal_seed', $this->seed->get(IL_CAL_DATE));
775  }
776 
777 
778  #21613
779  public function showToolbarAndSidebar(): bool
780  {
781  #21783
782  return !(
783  $this->ctrl->getCmdClass() == "ilcalendarappointmentgui" ||
784  $this->ctrl->getCmdClass() == 'ilconsultationhoursgui'
785  );
786  }
787 }
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 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) ...
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.
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.
global $DIC
Definition: shib_login.php:25
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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.