ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCalendarPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
7 
20 {
24  protected $ctrl;
25 
29  protected $lng;
30 
34  protected $tpl;
35 
39  protected $tabs_gui;
40 
44  protected $user;
45 
49  protected $help;
50 
54  protected $rbacsystem;
55 
59  protected $ui;
60 
64  protected $toolbar;
65 
66  protected $repository_mode = false;
67 
71  protected $seed;
72 
76  protected $cal_view;
77 
81  protected $cal_period;
82 
86  protected $cal_settings;
87 
91  protected $category_id;
92 
100  public function __construct($a_ref_id = 0)
101  {
102  global $DIC;
103 
104  $this->ctrl = $DIC->ctrl();
105  $this->lng = $DIC->language();
106  $this->lng->loadLanguageModule('dateplaner');
107 
108  $this->tpl = $DIC["tpl"];
109  $this->tabs_gui = $DIC->tabs();
110  $this->user = $DIC->user();
111  $this->rbacsystem = $DIC->rbac()->system();
112  $this->help = $DIC["ilHelp"];
113  $this->ui = $DIC->ui();
114  $this->toolbar = $DIC->toolbar();
115  $this->ref_id = $a_ref_id;
116  $this->category_id = (int) $_GET["category_id"];
117  $this->ctrl->setParameter($this, 'category_id', $_REQUEST['category_id']);
118  $this->cal_settings = ilCalendarSettings::_getInstance();
119 
120  // show back to pd
121  $this->ctrl->saveParameter($this, 'backpd');
122 
123  $this->initCalendarView();
124 
125  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
126  $cats = ilCalendarCategories::_getInstance($this->user->getId());
127 
128  include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
129  $this->repository_mode = $a_ref_id > 0;
130 
131  if ($this->repository_mode && $this->category_id === 0) {
132  $obj_id = ilObject::_lookupObjId($this->ref_id);
133  $category = ilCalendarCategory::_getInstanceByObjId($obj_id);
134  $this->category_id = is_null($category) ? 0 : $category->getCategoryID();
135  }
136 
137  if ($this->category_id > 0) { // single calendar view
138  // ensure activation of this category
139  include_once("./Services/Calendar/classes/class.ilCalendarVisibility.php");
140  $vis = ilCalendarVisibility::_getInstanceByUserId($this->user->getId(), $a_ref_id);
141  $vis->forceVisibility($this->category_id);
142 
143  $cats->initialize(ilCalendarCategories::MODE_SINGLE_CALENDAR, 0, false, $this->category_id);
144  } else {
145  if ($a_ref_id > 0) {
146  $cats->initialize(ilCalendarCategories::MODE_REPOSITORY, (int) $a_ref_id, true);
147  } else {
150  } else {
152  }
153  }
154  }
155 
156  include_once("./Services/Calendar/classes/class.ilCalendarActions.php");
157  $this->actions = ilCalendarActions::getInstance();
158 
159  $this->cats = $cats;
160  }
161 
167  public function getRepositoryMode()
168  {
169  return $this->repository_mode;
170  }
171 
176  {
177  $visibility = ilCalendarVisibility::_getInstanceByUserId($this->user->getId(), $this->ref_id);
178  $consultation_hours_initialized = false;
179  foreach ($this->cats->getCategoriesInfo() as $info) {
180  if (
181  $info["type"] == ilCalendarCategory::TYPE_CH &&
182  $info["obj_id"] == $_GET["ch_user_id"]
183  ) {
184  $v = $visibility->getVisible();
185  if (!in_array($info["cat_id"], $v)) {
186  $v[] = $info["cat_id"];
187  }
188  $visibility->showSelected($v);
189  $visibility->save();
190  $this->ctrl->setParameterByClass(\ilCalendarMonthGUI::class, 'seed', $this->seed);
191  $this->ctrl->redirectToURL(
192  $this->ctrl->getLinkTargetByClass(\ilCalendarMonthGUI::class, '')
193  );
194  $consultation_hours_initialized = true;
195  }
196  }
197  if (!$consultation_hours_initialized) {
198  $this->ctrl->redirectToURL(
199  $this->ctrl->getLinkTargetByClass(\ilCalendarMonthGUI::class, '')
200  );
201  }
202  }
203 
207  protected function initCalendarView()
208  {
209  global $DIC;
210 
211  $request = $DIC->http()->request();
212 
213  if (!empty($request->getQueryParams()["cal_view"])) {
214  $this->cal_view = $request->getQueryParams()["cal_view"];
215  } else {
216  $this->cal_view = $this->cal_settings->getDefaultCal();
217  }
218  }
219 
227  public function executeCommand()
228  {
230 
231  $cmd = $this->ctrl->getCmd();
232  // now next class is not empty, which breaks old consultation hour implementation
233  $next_class = $this->getNextClass();
234 
235  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
236  if (!ilCalendarSettings::_getInstance()->isEnabled()) {
237  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
238  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
239  }
240 
241  $this->initSeed();
242  $this->prepareOutput();
243 
244  $this->help->setScreenIdComponent("cal");
245 
246  switch ($cmd) {
247  case 'selectCHCalendarOfUser':
249  break;
250  }
251 
252  switch ($next_class) {
253  case 'ilcalendarinboxgui':
254  $this->tabs_gui->activateTab('cal_agenda');
255  $inbox_gui = $this->forwardToClass('ilcalendarinboxgui');
256  if ($this->showToolbarAndSidebar()) {
257  $this->showViewSelection("cal_list");
258  $this->showSideBlocks();
259  $inbox_gui->addToolbarActions();
260  }
261 
262  break;
263 
264  case 'ilconsultationhoursgui':
265  $this->tabs_gui->activateTab('app_consultation_hours');
266  $this->tabs_gui->clearTargets();
267 
268  // No side blocks
269  $this->tabs_gui->setBackTarget(
270  $this->lng->txt('cal_back_to_cal'),
271  $this->ctrl->getLinkTargetByClass($this->readLastClass())
272  );
273 
274  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHoursGUI.php';
275  $gui = new ilConsultationHoursGUI();
276  $this->ctrl->forwardCommand($gui);
277  if ($this->showToolbarAndSidebar()) {
278  $this->showSideBlocks();
279  }
280  return true;
281 
282  case 'ilcalendarmonthgui':
283  $this->tabs_gui->activateTab('cal_agenda');
284  $month_gui = $this->forwardToClass('ilcalendarmonthgui');
285 
286  if ($this->showToolbarAndSidebar()) {
287  $this->showViewSelection("app_month");
288  $this->showSideBlocks();
289  $month_gui->addToolbarActions();
290  }
291  break;
292 
293  case 'ilcalendarweekgui':
294  $this->tabs_gui->activateTab('cal_agenda');
295  $week_gui = $this->forwardToClass('ilcalendarweekgui');
296  if ($this->showToolbarAndSidebar()) {
297  $this->showViewSelection("app_week");
298  $this->showSideBlocks();
299  $week_gui->addToolbarActions();
300  }
301 
302  break;
303 
304  case 'ilcalendardaygui':
305  $this->tabs_gui->activateTab('cal_agenda');
306  $day_gui = $this->forwardToClass('ilcalendardaygui');
307  if ($this->showToolbarAndSidebar()) {
308  $this->showViewSelection("app_day");
309  $this->showSideBlocks();
310  $day_gui->addToolbarActions();
311  }
312  break;
313 
314  case 'ilcalendarusersettingsgui':
315  $this->ctrl->setReturn($this, '');
316  $this->tabs_gui->activateTab('settings');
317  $this->setCmdClass('ilcalendarusersettingsgui');
318 
319  include_once('./Services/Calendar/classes/class.ilCalendarUserSettingsGUI.php');
320  $user_settings = new ilCalendarUserSettingsGUI();
321  $this->ctrl->forwardCommand($user_settings);
322  // No side blocks
323  return true;
324 
325  case 'ilcalendarappointmentgui':
326  $this->ctrl->setReturn($this, '');
327  $this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
328 
329  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
330  $app = new ilCalendarAppointmentGUI($this->seed, $this->seed, (int) $_GET['app_id']);
331  $this->ctrl->forwardCommand($app);
332  break;
333 
334  case 'ilcalendarsubscriptiongui':
335  $this->ctrl->setReturn($this, '');
336  //$this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
337  $this->tabs_gui->activateTab("cal_agenda");
338  include_once './Services/Calendar/classes/class.ilCalendarSubscriptionGUI.php';
339  $sub = new ilCalendarSubscriptionGUI((int) $_REQUEST['category_id'], (int) $_GET["ref_id"]);
340  $this->ctrl->forwardCommand($sub);
341  if ($this->showToolbarAndSidebar()) {
342  $this->showSideBlocks();
343  }
344  break;
345 
346  case 'ilcalendarcategorygui':
347  $this->ctrl->setReturn($this, '');
348  $this->tabs_gui->activateTab("cal_manage");
349  include_once('Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
350  $category = new ilCalendarCategoryGUI($ilUser->getId(), $this->seed, $this->ref_id);
351  if ($this->ctrl->forwardCommand($category)) {
352  //$this->tabs_gui->activateTab("cal_manage");
353 
354  // no side blocks
355  return;
356  } else {
357  if ($this->getRepositoryMode()) {
358  #$this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, ""));
359  }
360  //$this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
361  $this->showSideBlocks();
362  break;
363  }
364 
365  // no break
366  case 'ilcalendarblockgui':
367  $side_cal = new ilCalendarBlockGUI();
368  $side_cal->setRepositoryMode($this->getRepositoryMode());
369  $side_cal->setForceMonthView(true);
370  $this->ctrl->forwardCommand($side_cal);
371  $this->showSideBlocks();
372  break;
373 
374  case 'ilpdcalendarblockgui':
375  $side_cal = new ilPDCalendarBlockGUI();
376  $side_cal->setRepositoryMode($this->getRepositoryMode());
377  $side_cal->setForceMonthView(true);
378  $this->ctrl->forwardCommand($side_cal);
379  $this->showSideBlocks();
380  break;
381 
382  case 'ilpublicuserprofilegui':
383  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
384  $user_profile = new ilPublicUserProfileGUI($_GET["user_id"]);
385  $html = $this->ctrl->forwardCommand($user_profile);
386  $this->tpl->setContent($html);
387  break;
388 
389  default:
390  $cmd = $this->ctrl->getCmd("show");
391  $this->$cmd();
392  $this->showSideBlocks();
393  break;
394  }
395 
396 
398 
399  return true;
400  }
401 
407  public function showViewSelection($a_active = "cal_list")
408  {
409  $ui = $this->ui;
410  $ctrl = $this->ctrl;
411  $lng = $this->lng;
413 
414  $f = $ui->factory();
415 
416  $actions = array(
417  $lng->txt("app_day") => $ctrl->getLinkTargetByClass('ilCalendarDayGUI', ''),
418  $lng->txt("app_week") => $ctrl->getLinkTargetByClass('ilCalendarWeekGUI', ''),
419  $lng->txt("app_month") => $ctrl->getLinkTargetByClass('ilCalendarMonthGUI', ''),
420  $lng->txt("cal_list") => $ctrl->getLinkTargetByClass('ilCalendarInboxGUI', '')
421  );
422 
423  $view_control = $f->viewControl()->mode($actions, "cal_change_calendar_view")->withActive($lng->txt($a_active));
424 
425  $toolbar->addComponent($view_control);
426 
427  $ctrl->setParameterByClass("ilcalendarappointmentgui", "seed", $this->seed->get(IL_CAL_DATE, ''));
428  $ctrl->setParameterByClass("ilcalendarappointmentgui", "app_id", "");
429  $ctrl->setParameterByClass("ilcalendarappointmentgui", "dt", "");
430 
431  $extra_button_added = false;
432  // add appointment
433  if ($this->category_id == 0 || $this->actions->checkAddEvent($this->category_id)) {
434  $toolbar->addSeparator();
435  $extra_button_added = true;
436  $add_button = $f->button()->standard(
437  $lng->txt("cal_add_appointment"),
438  $ctrl->getLinkTargetByClass("ilcalendarappointmentgui", "add")
439  );
440  $toolbar->addComponent($add_button);
441  }
442 
443  // import appointments
444  if ($this->category_id > 0 && $this->actions->checkAddEvent($this->category_id)) {
445  if (!$extra_button_added) {
446  $toolbar->addSeparator();
447  }
448  $ctrl->setParameterByClass("ilcalendarcategorygui", "category_id", $this->category_id);
449  $add_button = $f->button()->standard(
450  $lng->txt("cal_import_appointments"),
451  $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "importAppointments")
452  );
453  $ctrl->clearParameterByClass("ilcalendarcategorygui", "category_id");
454  $toolbar->addComponent($add_button);
455  }
456  }
457 
458 
464  public function getNextClass()
465  {
466  if (strlen($next_class = $this->ctrl->getNextClass())) {
467  return $next_class;
468  }
469  if ($this->ctrl->getCmdClass() == strtolower(get_class($this)) or $this->ctrl->getCmdClass() == '') {
470  return $this->readLastClass();
471  }
472  }
473 
478  public function readLastClass()
479  {
481 
482  switch ($this->cal_view) {
484  $class = "ilcalendardaygui";
485  break;
487  $class = "ilcalendarweekgui";
488  break;
490  $class = "ilcalendarmonthgui";
491  break;
493  default:
494  $class = "ilcalendarinboxgui";
495  break;
496  }
497 
498  return $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : $class;
499  }
500 
501  public function setCmdClass($a_class)
502  {
503  // If cmd class == 'ilcalendarpresentationgui' the cmd class is set to the the new forwarded class
504  // otherwise e.g ilcalendarmonthgui tries to forward (back) to ilcalendargui.
505 
506  if ($this->ctrl->getCmdClass() == strtolower(get_class($this))) {
507  $this->ctrl->setCmdClass(strtolower($a_class));
508  }
509  return true;
510  }
511 
517  protected function forwardToClass($a_class)
518  {
520 
521  switch ($a_class) {
522  case 'ilcalendarmonthgui':
523  $ilUser->writePref('cal_last_class', $a_class);
524  $_SESSION['cal_last_tab'] = 'app_month';
525  $this->setCmdClass('ilcalendarmonthgui');
526  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
527  $month_gui = new ilCalendarMonthGUI($this->seed);
528  $this->ctrl->forwardCommand($month_gui);
529  return $month_gui;
530  break;
531 
532  case 'ilcalendarweekgui':
533  $ilUser->writePref('cal_last_class', $a_class);
534  $_SESSION['cal_last_tab'] = 'app_week';
535  $this->setCmdClass('ilcalendarweekgui');
536  include_once('./Services/Calendar/classes/class.ilCalendarWeekGUI.php');
537  $week_gui = new ilCalendarWeekGUI($this->seed);
538  $this->ctrl->forwardCommand($week_gui);
539  return $week_gui;
540  break;
541 
542  case 'ilcalendardaygui':
543  $ilUser->writePref('cal_last_class', $a_class);
544  $_SESSION['cal_last_tab'] = 'app_day';
545  $this->setCmdClass('ilcalendardaygui');
546  include_once('./Services/Calendar/classes/class.ilCalendarDayGUI.php');
547  $day_gui = new ilCalendarDayGUI($this->seed);
548  $this->ctrl->forwardCommand($day_gui);
549  return $day_gui;
550  break;
551 
552  case 'ilcalendarinboxgui':
553  $ilUser->writePref('cal_last_class', $a_class);
554  $_SESSION['cal_last_tab'] = 'cal_upcoming_events_header';
555  $this->setCmdClass('ilcalendarinboxgui');
556  include_once('./Services/Calendar/classes/class.ilCalendarInboxGUI.php');
557  $inbox_gui = new ilCalendarinboxGUI($this->seed);
558  $this->ctrl->forwardCommand($inbox_gui);
559  return $inbox_gui;
560  break;
561  }
562  }
563 
571  protected function showSideBlocks()
572  {
574  $ilCtrl = $this->ctrl;
575 
576  $tpl = new ilTemplate('tpl.cal_side_block.html', true, true, 'Services/Calendar');
577  if ($this->getRepositoryMode()) {
578  include_once("./Services/Calendar/classes/class.ilCalendarBlockGUI.php");
579  $side_cal = new ilCalendarBlockGUI();
580  } else {
581  include_once("./Services/Calendar/classes/class.ilPDCalendarBlockGUI.php");
582  $side_cal = new ilPDCalendarBlockGUI();
583  }
584  $side_cal->setParentGUI("ilCalendarPresentationGUI");
585  $side_cal->setForceMonthView(true);
586  $side_cal->setRepositoryMode($this->getRepositoryMode());
587  $tpl->setVariable('MINICAL', $ilCtrl->getHTML($side_cal));
588 
589  include_once('./Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
590  $cat = new ilCalendarCategoryGUI($ilUser->getId(), $this->seed, $this->ref_id);
591  $tpl->setVariable('CATEGORIES', $ilCtrl->getHTML($cat));
592 
593  $this->tpl->setRightContent($tpl->get());
594  }
595 
600  protected function addCategoryTabs()
601  {
602  global $DIC;
603 
604  $ctrl = $DIC->ctrl();
605 
606  $this->tabs_gui->clearTargets();
607  $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, "category_id", $_REQUEST["category_id"]);
608  if ($this->getRepositoryMode()) {
609  $came_from_pd = $_REQUEST['backpd'];
610  if ($came_from_pd) {
611  $this->tabs_gui->setBack2Target(
612  $this->lng->txt('back_to_pd'),
613  $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
614  );
615  }
616  $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
617  $this->tabs_gui->setBackTarget(
618  $label,
619  $this->ctrl->getParentReturn($this)
620  );
621  } else {
622  // no object calendar => back is back to manage view
623  if (array_key_exists('backvm', $_REQUEST)) {
624  $this->tabs_gui->setBackTarget(
625  $this->lng->txt("back"),
626  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'manage')
627  );
628  } else {
629  $ctrl->clearParameterByClass(ilCalendarPresentationGUI::class, 'category_id');
630  $this->tabs_gui->setBackTarget(
631  $this->lng->txt("back"),
632  $ctrl->getLinkTargetByClass('ilcalendarpresentationgui', '')
633  );
634  }
635  $ctrl->setParameterByClass(ilCalendarPresentationGUI::class, "category_id", $_REQUEST["category_id"]);
636  }
637 
638  $this->tabs_gui->addTab(
639  "cal_agenda",
640  $this->lng->txt("cal_agenda"),
641  $ctrl->getLinkTargetByClass(ilCalendarPresentationGUI::class, "")
642  );
643 
644  if ($this->actions->checkShareCal($this->category_id)) {
645  $this->tabs_gui->addTab(
646  "share",
647  $this->lng->txt("cal_share"),
648  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "shareSearch")
649  );
650  }
651  if ($this->actions->checkSettingsCal($this->category_id)) {
652  $ctrl->setParameterByClass("ilcalendarcategorygui", "category_id", $this->category_id);
653  $this->tabs_gui->addTab(
654  "edit",
655  $this->lng->txt("settings"),
656  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "edit")
657  );
658  $ctrl->clearParameterByClass("ilcalendarcategorygui", "category_id");
659  }
660 
661  $this->tabs_gui->activateTab('cal_agenda');
662  return true;
663  }
664 
668  protected function addStandardTabs()
669  {
670  global $DIC;
671 
672  $access = $DIC->access();
673  $rbacsystem = $DIC->rbac()->system();
674 
675  $came_from_pd = $_REQUEST['backpd'];
676 
677  $this->tabs_gui->clearTargets();
678  if ($this->getRepositoryMode()) {
679  if ($came_from_pd) {
680  $this->tabs_gui->setBack2Target(
681  $this->lng->txt('back_to_pd'),
682  $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
683  );
684  }
685  $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
686  $this->tabs_gui->setBackTarget(
687  $label,
688  $this->ctrl->getParentReturn($this)
689  );
690 
691  $obj_id = ilObject::_lookupObjId($this->ref_id);
692  $category = ilCalendarCategory::_getInstanceByObjId($obj_id);
693  $category_id = $category->getCategoryID();
694 
695  // agenda tab
696  $this->tabs_gui->addTab(
697  'cal_agenda',
698  $this->lng->txt('cal_agenda'),
699  $this->ctrl->getLinkTarget($this, '')
700  );
701 
702  // settings tab
703  if ($access->checkAccess('edit_event', '', $this->ref_id)) {
704  $this->ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $category_id);
705  $this->tabs_gui->addTab(
706  'cal_manage',
707  $this->lng->txt('settings'),
708  $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'edit')
709  );
710  $this->ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
711  }
712  return true;
713  } else {
714  $this->tabs_gui->addTab(
715  'cal_agenda',
716  $this->lng->txt("cal_agenda"),
717  $this->ctrl->getLinkTarget($this, '')
718  );
719 
720  if (
721  $rbacsystem->checkAccess(
722  'add_consultation_hours',
723  ilCalendarSettings::_getInstance()->getCalendarSettingsId()
724  ) &&
725  ilCalendarSettings::_getInstance()->areConsultationHoursEnabled()
726  ) {
727  $this->tabs_gui->addTab(
728  'app_consultation_hours',
729  $this->lng->txt('app_consultation_hours'),
730  $this->ctrl->getLinkTargetByClass(ilConsultationHoursGUI::class, '')
731  );
732  }
733  /*
734  $this->tabs_gui->addTab(
735  'cal_manage',
736  $this->lng->txt('cal_manage'),
737  $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class,'manage')
738  );
739  $this->tabs_gui->addTab(
740  'settings',
741  $this->lng->txt('settings'),
742  $this->ctrl->getLinkTargetByClass(ilCalendarUserSettings::class,'')
743  );
744  */
745  $this->tabs_gui->addTarget('cal_manage', $this->ctrl->getLinkTargetByClass('ilCalendarCategoryGUI', 'manage'));
746  $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI', ''));
747  }
748  }
749 
750 
754  protected function prepareOutput()
755  {
756  global $DIC;
757 
758  $tpl = $DIC->ui()->mainTemplate();
759 
760  if ($this->category_id) {
761  $this->addCategoryTabs();
762  } else {
763  $this->addStandardTabs();
764  }
765 
766  $tpl->setTitleIcon(ilUtil::getImagePath("icon_cals.svg"));
767 
768  // if we are in single calendar view
769  if ($this->category_id > 0) {
770  global $DIC;
771 
772  $tabs = $this->tabs_gui;
773  $lng = $this->lng;
774  $ctrl = $this->ctrl;
775  $tpl = $DIC["tpl"];
776 
777  $category = new ilCalendarCategory($this->category_id);
778 
779  // Set header
780  $header = "";
781  switch ($category->getType()) {
783  $header = $this->lng->txt('cal_type_personal') . ": " . $category->getTitle();
784  break;
785 
787  $header = $this->lng->txt('cal_type_system') . ": " . $category->getTitle();
788  break;
789 
791  $header = $this->lng->txt('cal_type_' . $category->getObjType()) . ": " . $category->getTitle();
792  break;
793 
795  $header = str_replace("%1", ilObjUser::_lookupFullname($category->getObjId()), $lng->txt("cal_consultation_hours_for_user"));
796  break;
797 
799  $header = $category->getTitle();
800  break;
801  }
802  $tpl->setTitleIcon(ilUtil::getImagePath("icon_cals.svg"));
803  $tpl->setTitle($header);
804 
805  $this->action_menu = new ilAdvancedSelectionListGUI();
806  $this->action_menu->setAsynch(false);
807  $this->action_menu->setAsynchUrl('');
808  $this->action_menu->setListTitle($lng->txt('actions'));
809  $this->action_menu->setId('act_cal');
810  $this->action_menu->setSelectionHeaderClass('small');
811  $this->action_menu->setItemLinkClass('xsmall');
812  $this->action_menu->setLinksMode('il_ContainerItemCommand2');
813  $this->action_menu->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
814  $this->action_menu->setUseImages(false);
815 
816  // iCal-Url
817  $ctrl->setParameterByClass("ilcalendarsubscriptiongui", "category_id", $this->category_id);
818  $this->action_menu->addItem($lng->txt("cal_ical_url"), "", $ctrl->getLinkTargetByClass("ilcalendarsubscriptiongui", ""));
819 
820  // delete action
821  if ($this->actions->checkDeleteCal($this->category_id)) {
822  $ctrl->setParameterByClass("ilcalendarcategorygui", "category_id", $this->category_id);
823  $this->action_menu->addItem($lng->txt("cal_delete_cal"), "", $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "confirmDelete"));
824  }
825 
826  $tpl->setHeaderActionMenu($this->action_menu->getHTML());
827  }
828  }
829 
835  public function initSeed()
836  {
837  // default to today
838  $now = new \ilDate(time(), IL_CAL_UNIX);
839  $this->seed = new \ilDate($now->get(IL_CAL_DATE), IL_CAL_DATE);
840  if (array_key_exists('seed', $_REQUEST)) {
841  $this->seed = new ilDate($_GET['seed'], IL_CAL_DATE);
842  } elseif (!$this->getRepositoryMode()) {
843  $session_seed = ilSession::get('cal_seed');
844  if ($session_seed) {
845  $this->seed = new ilDate($session_seed, IL_CAL_DATE);
846  }
847  }
848  $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
849  ilSession::set('cal_seed', $this->seed->get(IL_CAL_DATE));
850  }
851 
855  protected function synchroniseExternalCalendars()
856  {
858 
859  if (!ilCalendarSettings::_getInstance()->isWebCalSyncEnabled()) {
860  return false;
861  }
862  // @todo make this thread safe
863 
864  $limit = new ilDateTime(time(), IL_CAL_UNIX);
865  $limit->increment(IL_CAL_HOUR, -1 * ilCalendarSettings::_getInstance()->getWebCalSyncHours());
866 
868  foreach ($cats->getCategoriesInfo() as $cat_id => $info) {
869  if ($info['remote']) {
870  // Check for execution
871  $category = new ilCalendarCategory($cat_id);
872 
873  if (
874  $category->getRemoteSyncLastExecution()->isNull() ||
875  ilDateTime::_before($category->getRemoteSyncLastExecution(), $limit)
876  ) {
877  // update in any case to avoid multiple updates of invalid calendar sources.
878  $category->setRemoteSyncLastExecution(new ilDateTime(time(), IL_CAL_UNIX));
879  $category->update();
880 
881  include_once './Services/Calendar/classes/class.ilCalendarRemoteReader.php';
882  $remote = new ilCalendarRemoteReader($category->getRemoteUrl());
883  $remote->setUser($category->getRemoteUser());
884  $remote->setPass($category->getRemotePass());
885  $remote->read();
886  $remote->import($category);
887  break;
888  }
889  }
890  }
891  }
892 
893  #21613
894  public function showToolbarAndSidebar()
895  {
896  #21783
897  if ($this->ctrl->getCmdClass() == "ilcalendarappointmentgui" || $this->ctrl->getCmdClass() == 'ilconsultationhoursgui') {
898  return false;
899  }
900  return true;
901  }
902 }
$app
Definition: cli.php:38
synchroniseExternalCalendars()
Sync external calendars.
Consultation hours editor.
static _getInstance()
get singleton instance
$_SESSION["AccountId"]
readLastClass()
Read last class from history.
initCalendarView()
Initialises calendar view according to given settings.
$_GET["client_id"]
const IL_CAL_HOUR
static _lookupFullname($a_user_id)
Lookup Full Name.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
initSeed()
init the seed date for presentations (month view, minicalendar)
static getInstance()
Get instance.
static get($a_var)
Get a value.
forwardToClass($a_class)
forward to class
static set($a_var, $a_val)
Set a value.
Stores calendar categories.
Reader for remote ical calendars.
const IL_CAL_UNIX
user()
Definition: user.php:4
Show calendar subscription info.
Calendar blocks, displayed on personal desktop.
help()
Definition: help.php:2
static _getInstanceByUserId($a_user_id, $a_ref_id=0)
get instance by user id
GUI class for public user profile presentation.
Class for single dates.
showViewSelection($a_active="cal_list")
Show view selection.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _getInstance()
get instance for logged in user
static _lookupObjId($a_id)
initAndRedirectToConsultationHours()
Init and redirect to consultation hours.
global $DIC
Definition: goto.php:24
static _getInstanceByObjId($a_obj_id)
get instance by obj_id
ui()
Definition: ui.php:5
static _getInstance($a_usr_id=0)
get singleton instance
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const IL_CAL_DATE
Administrate calendar appointments.
Calendar blocks, displayed in different contexts, e.g.
$ilUser
Definition: imgupload.php:18
addCategoryTabs()
Add tabs for ilCategoryGUI context This cannot be done there since many views (Day Week Agenda) are i...
static redirect($a_script)
Presentation day view.
Administration, Side-Block presentation of calendar categories.