ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 
80  public function __construct($a_ref_id = 0)
81  {
82  global $DIC;
83 
84  $this->ctrl = $DIC->ctrl();
85  $this->lng = $DIC->language();
86  $this->lng->loadLanguageModule('dateplaner');
87 
88  $this->tpl = $DIC["tpl"];
89  $this->tabs_gui = $DIC->tabs();
90  $this->user = $DIC->user();
91  $this->rbacsystem = $DIC->rbac()->system();
92  $this->help = $DIC["ilHelp"];
93  $this->ui = $DIC->ui();
94  $this->toolbar = $DIC->toolbar();
95  $this->ref_id = $a_ref_id;
96  $this->category_id = $_GET["category_id"];
97  $this->ctrl->setParameter($this, 'category_id', $_REQUEST['category_id']);
98 
99  // show back to pd
100  $this->ctrl->saveParameter($this, 'backpd');
101 
102  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
103  $cats = ilCalendarCategories::_getInstance($this->user->getId());
104 
105  include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
106  if ($a_ref_id > 0) {
107  $this->repository_mode = true;
108  }
109  if ($this->category_id > 0) { // single calendar view
110  // ensure activation of this category
111  include_once("./Services/Calendar/classes/class.ilCalendarVisibility.php");
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  } else {
117  if ($a_ref_id > 0) {
118  $cats->initialize(ilCalendarCategories::MODE_REPOSITORY, (int) $a_ref_id, true);
119  } else {
122  } else {
124  }
125  }
126  }
127 
128  include_once("./Services/Calendar/classes/class.ilCalendarActions.php");
129  $this->actions = ilCalendarActions::getInstance();
130 
131  $this->cats = $cats;
132  }
133 
139  public function getRepositoryMode()
140  {
141  return $this->repository_mode;
142  }
143 
148  {
149  $visibility = ilCalendarVisibility::_getInstanceByUserId($this->user->getId(), $this->ref_id);
150  foreach ($this->cats->getCategoriesInfo() as $info) {
151  if (
152  $info["type"] == ilCalendarCategory::TYPE_CH &&
153  $info["obj_id"] == $_GET["ch_user_id"]
154  ) {
155  $v = $visibility->getVisible();
156  if (!in_array($info["cat_id"], $v)) {
157  $v[] = $info["cat_id"];
158  }
159  $visibility->showSelected($v);
160  $visibility->save();
161  $this->ctrl->setParameterByClass(\ilCalendarMonthGUI::class, 'seed' , $this->seed);
162  $this->ctrl->redirectToURL(
163  $this->ctrl->getLinkTargetByClass(\ilCalendarMonthGUI::class,'')
164  );
165  }
166  }
167  }
168 
176  public function executeCommand()
177  {
179 
180  $cmd = $this->ctrl->getCmd();
181  // now next class is not empty, which breaks old consultation hour implementation
182  $next_class = $this->getNextClass();
183 
184  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
185  if (!ilCalendarSettings::_getInstance()->isEnabled()) {
186  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
187  ilUtil::redirect('ilias.php?baseClass=ilDashboardGUI');
188  }
189 
190  $this->initSeed();
191  $this->prepareOutput();
192 
193  $this->help->setScreenIdComponent("cal");
194 
195  switch ($cmd) {
196  case 'selectCHCalendarOfUser':
198  break;
199  }
200 
201  switch ($next_class) {
202  case 'ilcalendarinboxgui':
203  $this->tabs_gui->activateTab('cal_agenda');
204  $inbox_gui = $this->forwardToClass('ilcalendarinboxgui');
205  if ($this->showToolbarAndSidebar()) {
206  $this->showViewSelection("cal_list");
207  $this->showSideBlocks();
208  $inbox_gui->addToolbarActions();
209  }
210 
211  break;
212 
213  case 'ilconsultationhoursgui':
214  $this->tabs_gui->activateTab('app_consultation_hours');
215  $this->tabs_gui->clearTargets();
216 
217  // No side blocks
218  $this->tabs_gui->setBackTarget(
219  $this->lng->txt('cal_back_to_cal'),
220  $this->ctrl->getLinkTargetByClass($this->readLastClass())
221  );
222 
223  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHoursGUI.php';
224  $gui = new ilConsultationHoursGUI();
225  $this->ctrl->forwardCommand($gui);
226  if ($this->showToolbarAndSidebar()) {
227  $this->showSideBlocks();
228  }
229  return true;
230 
231  case 'ilcalendarmonthgui':
232  $this->tabs_gui->activateTab('cal_agenda');
233  $month_gui = $this->forwardToClass('ilcalendarmonthgui');
234 
235  if ($this->showToolbarAndSidebar()) {
236  $this->showViewSelection("app_month");
237  $this->showSideBlocks();
238  $month_gui->addToolbarActions();
239  }
240  break;
241 
242  case 'ilcalendarweekgui':
243  $this->tabs_gui->activateTab('cal_agenda');
244  $week_gui = $this->forwardToClass('ilcalendarweekgui');
245  if ($this->showToolbarAndSidebar()) {
246  $this->showViewSelection("app_week");
247  $this->showSideBlocks();
248  $week_gui->addToolbarActions();
249  }
250 
251  break;
252 
253  case 'ilcalendardaygui':
254  $this->tabs_gui->activateTab('cal_agenda');
255  $day_gui = $this->forwardToClass('ilcalendardaygui');
256  if ($this->showToolbarAndSidebar()) {
257  $this->showViewSelection("app_day");
258  $this->showSideBlocks();
259  $day_gui->addToolbarActions();
260  }
261  break;
262 
263  case 'ilcalendarusersettingsgui':
264  $this->ctrl->setReturn($this, '');
265  $this->tabs_gui->activateTab('settings');
266  $this->setCmdClass('ilcalendarusersettingsgui');
267 
268  include_once('./Services/Calendar/classes/class.ilCalendarUserSettingsGUI.php');
269  $user_settings = new ilCalendarUserSettingsGUI();
270  $this->ctrl->forwardCommand($user_settings);
271  // No side blocks
272  return true;
273 
274  case 'ilcalendarappointmentgui':
275  $this->ctrl->setReturn($this, '');
276  $this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
277 
278  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
279  $app = new ilCalendarAppointmentGUI($this->seed, $this->seed, (int) $_GET['app_id']);
280  $this->ctrl->forwardCommand($app);
281  break;
282 
283  case 'ilcalendarsubscriptiongui':
284  $this->ctrl->setReturn($this, '');
285  //$this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
286  $this->tabs_gui->activateTab("cal_agenda");
287  include_once './Services/Calendar/classes/class.ilCalendarSubscriptionGUI.php';
288  $sub = new ilCalendarSubscriptionGUI((int) $_REQUEST['category_id'], (int) $_GET["ref_id"]);
289  $this->ctrl->forwardCommand($sub);
290  if ($this->showToolbarAndSidebar()) {
291  $this->showSideBlocks();
292  }
293  break;
294 
295  case 'ilcalendarcategorygui':
296  $this->ctrl->setReturn($this, '');
297  $this->tabs_gui->activateTab("cal_manage");
298  include_once('Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
299  $category = new ilCalendarCategoryGUI($ilUser->getId(), $this->seed, $this->ref_id);
300  if ($this->ctrl->forwardCommand($category)) {
301  //$this->tabs_gui->activateTab("cal_manage");
302 
303  // no side blocks
304  return;
305  } else {
306  if ($this->getRepositoryMode()) {
307  #$this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, ""));
308  }
309  //$this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
310  $this->showSideBlocks();
311  break;
312  }
313 
314  // no break
315  case 'ilcalendarblockgui':
316  $side_cal = new ilCalendarBlockGUI();
317  $side_cal->setRepositoryMode($this->getRepositoryMode());
318  $side_cal->setForceMonthView(true);
319  $this->ctrl->forwardCommand($side_cal);
320  $this->showSideBlocks();
321  break;
322 
323  case 'ilpdcalendarblockgui':
324  $side_cal = new ilPDCalendarBlockGUI();
325  $side_cal->setRepositoryMode($this->getRepositoryMode());
326  $side_cal->setForceMonthView(true);
327  $this->ctrl->forwardCommand($side_cal);
328  $this->showSideBlocks();
329  break;
330 
331  case 'ilpublicuserprofilegui':
332  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
333  $user_profile = new ilPublicUserProfileGUI($_GET["user_id"]);
334  $html = $this->ctrl->forwardCommand($user_profile);
335  $this->tpl->setContent($html);
336  break;
337 
338  default:
339  $cmd = $this->ctrl->getCmd("show");
340  $this->$cmd();
341  $this->showSideBlocks();
342  break;
343  }
344 
345 
347 
348  return true;
349  }
350 
356  public function showViewSelection($a_active = "cal_list")
357  {
358  $ui = $this->ui;
359  $ctrl = $this->ctrl;
360  $lng = $this->lng;
362 
363  $f = $ui->factory();
364 
365  $actions = array(
366  $lng->txt("app_day") => $ctrl->getLinkTargetByClass('ilCalendarDayGUI', ''),
367  $lng->txt("app_week") => $ctrl->getLinkTargetByClass('ilCalendarWeekGUI', ''),
368  $lng->txt("app_month") => $ctrl->getLinkTargetByClass('ilCalendarMonthGUI', ''),
369  $lng->txt("cal_list") => $ctrl->getLinkTargetByClass('ilCalendarInboxGUI', '')
370  );
371 
372  $aria_label = $lng->txt("cal_change_calendar_view");
373  $view_control = $f->viewControl()->mode($actions, $aria_label)->withActive($lng->txt($a_active));
374 
375  $toolbar->addComponent($view_control);
376 
377  $ctrl->setParameterByClass("ilcalendarappointmentgui", "seed", $this->seed->get(IL_CAL_DATE, ''));
378  $ctrl->setParameterByClass("ilcalendarappointmentgui", "app_id", "");
379  $ctrl->setParameterByClass("ilcalendarappointmentgui", "dt", "");
380 
381  $extra_button_added = false;
382  // add appointment
383  if ($this->category_id == 0 || $this->actions->checkAddEvent($this->category_id)) {
384  $toolbar->addSeparator();
385  $extra_button_added = true;
386  $add_button = $f->button()->standard(
387  $lng->txt("cal_add_appointment"),
388  $ctrl->getLinkTargetByClass("ilcalendarappointmentgui", "add")
389  );
390  $toolbar->addComponent($add_button);
391  }
392 
393  // import appointments
394  if ($this->category_id > 0 && $this->actions->checkAddEvent($this->category_id)) {
395  if (!$extra_button_added) {
396  $toolbar->addSeparator();
397  }
398  $add_button = $f->button()->standard(
399  $lng->txt("cal_import_appointments"),
400  $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "importAppointments")
401  );
402  $toolbar->addComponent($add_button);
403  }
404  }
405 
406 
412  public function getNextClass()
413  {
414  if (strlen($next_class = $this->ctrl->getNextClass())) {
415  return $next_class;
416  }
417  if ($this->ctrl->getCmdClass() == strtolower(get_class($this)) or $this->ctrl->getCmdClass() == '') {
418  return $this->readLastClass();
419  }
420  }
421 
426  public function readLastClass()
427  {
429 
430  return $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarinboxgui';
431  }
432 
433  public function setCmdClass($a_class)
434  {
435  // If cmd class == 'ilcalendarpresentationgui' the cmd class is set to the the new forwarded class
436  // otherwise e.g ilcalendarmonthgui tries to forward (back) to ilcalendargui.
437 
438  if ($this->ctrl->getCmdClass() == strtolower(get_class($this))) {
439  $this->ctrl->setCmdClass(strtolower($a_class));
440  }
441  return true;
442  }
443 
449  protected function forwardToClass($a_class)
450  {
452 
453  switch ($a_class) {
454  case 'ilcalendarmonthgui':
455  $ilUser->writePref('cal_last_class', $a_class);
456  $_SESSION['cal_last_tab'] = 'app_month';
457  $this->setCmdClass('ilcalendarmonthgui');
458  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
459  $month_gui = new ilCalendarMonthGUI($this->seed);
460  $this->ctrl->forwardCommand($month_gui);
461  return $month_gui;
462  break;
463 
464  case 'ilcalendarweekgui':
465  $ilUser->writePref('cal_last_class', $a_class);
466  $_SESSION['cal_last_tab'] = 'app_week';
467  $this->setCmdClass('ilcalendarweekgui');
468  include_once('./Services/Calendar/classes/class.ilCalendarWeekGUI.php');
469  $week_gui = new ilCalendarWeekGUI($this->seed);
470  $this->ctrl->forwardCommand($week_gui);
471  return $week_gui;
472  break;
473 
474  case 'ilcalendardaygui':
475  $ilUser->writePref('cal_last_class', $a_class);
476  $_SESSION['cal_last_tab'] = 'app_day';
477  $this->setCmdClass('ilcalendardaygui');
478  include_once('./Services/Calendar/classes/class.ilCalendarDayGUI.php');
479  $day_gui = new ilCalendarDayGUI($this->seed);
480  $this->ctrl->forwardCommand($day_gui);
481  return $day_gui;
482  break;
483 
484  case 'ilcalendarinboxgui':
485  #21479
486  if ($view_option = $_GET['cal_agenda_per']) {
487  ilSession::set("cal_list_view", $view_option);
488  } elseif ($view_option = ilSession::get('cal_list_view')) {
489  ilSession::set("cal_list_view", $view_option);
490  }
491  $ilUser->writePref('cal_last_class', $a_class);
492  $_SESSION['cal_last_tab'] = 'cal_upcoming_events_header';
493  $this->setCmdClass('ilcalendarinboxgui');
494  include_once('./Services/Calendar/classes/class.ilCalendarInboxGUI.php');
495  $inbox_gui = new ilCalendarinboxGUI($this->seed);
496  $this->ctrl->forwardCommand($inbox_gui);
497  return $inbox_gui;
498  break;
499  }
500  }
501 
509  protected function loadHistory()
510  {
512 
513  $this->ctrl->setCmd('');
514  $history = $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarmonthgui';
515  $this->forwardToClass($history);
516  }
517 
525  protected function showSideBlocks()
526  {
529 
530  $tpl = new ilTemplate('tpl.cal_side_block.html', true, true, 'Services/Calendar');
531  if ($this->getRepositoryMode()) {
532  include_once("./Services/Calendar/classes/class.ilCalendarBlockGUI.php");
533  $side_cal = new ilCalendarBlockGUI();
534  } else {
535  include_once("./Services/Calendar/classes/class.ilPDCalendarBlockGUI.php");
536  $side_cal = new ilPDCalendarBlockGUI();
537  }
538  $side_cal->setParentGUI("ilCalendarPresentationGUI");
539  $side_cal->setForceMonthView(true);
540  $side_cal->setRepositoryMode($this->getRepositoryMode());
541  $tpl->setVariable('MINICAL', $ilCtrl->getHTML($side_cal));
542 
543  include_once('./Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
544  $cat = new ilCalendarCategoryGUI($ilUser->getId(), $this->seed, $this->ref_id);
545  $tpl->setVariable('CATEGORIES', $ilCtrl->getHTML($cat));
546 
547  $this->tpl->setRightContent($tpl->get());
548  }
549 
554  protected function addCategoryTabs()
555  {
556  global $DIC;
557 
558  $ctrl = $DIC->ctrl();
559 
560  $this->tabs_gui->clearTargets();
561  $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, "category_id", $_REQUEST["category_id"]);
562  if ($this->getRepositoryMode()) {
563  $came_from_pd = $_REQUEST['backpd'];
564  if ($came_from_pd) {
565  $this->tabs_gui->setBack2Target(
566  $this->lng->txt('back_to_pd'),
567  $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
568  );
569  }
570  $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
571  $this->tabs_gui->setBackTarget(
572  $label,
573  $this->ctrl->getParentReturn($this)
574  );
575  } else {
576  // no object calendar => back is back to manage view
577  if (array_key_exists('backvm', $_REQUEST)) {
578  $this->tabs_gui->setBackTarget(
579  $this->lng->txt("back"),
580  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'manage')
581  );
582  } else {
583  $ctrl->clearParameterByClass(ilCalendarPresentationGUI::class, 'category_id');
584  $this->tabs_gui->setBackTarget(
585  $this->lng->txt("back"),
586  $ctrl->getLinkTargetByClass('ilcalendarpresentationgui', '')
587  );
588  }
589  $ctrl->setParameterByClass(ilCalendarPresentationGUI::class, "category_id", $_REQUEST["category_id"]);
590  }
591 
592  $this->tabs_gui->addTab(
593  "cal_agenda",
594  $this->lng->txt("cal_agenda"),
595  $ctrl->getLinkTargetByClass(ilCalendarPresentationGUI::class, "")
596  );
597 
598  if ($this->actions->checkShareCal($this->category_id)) {
599  $this->tabs_gui->addTab(
600  "share",
601  $this->lng->txt("cal_share"),
602  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "shareSearch")
603  );
604  }
605  if ($this->actions->checkSettingsCal($this->category_id)) {
606  $this->tabs_gui->addTab(
607  "edit",
608  $this->lng->txt("settings"),
609  $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "edit")
610  );
611  }
612 
613  $this->tabs_gui->activateTab('cal_agenda');
614  return true;
615  }
616 
620  protected function addStandardTabs()
621  {
622  global $DIC;
623 
624  $access = $DIC->access();
625  $rbacsystem = $DIC->rbac()->system();
626 
627  $came_from_pd = $_REQUEST['backpd'];
628 
629  $this->tabs_gui->clearTargets();
630  if ($this->getRepositoryMode()) {
631  if ($came_from_pd) {
632  $this->tabs_gui->setBack2Target(
633  $this->lng->txt('back_to_pd'),
634  $this->ctrl->getLinkTargetByClass(ilDashboardGUI::class, 'jumpToCalendar')
635  );
636  }
637  $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
638  $this->tabs_gui->setBackTarget(
639  $label,
640  $this->ctrl->getParentReturn($this)
641  );
642 
643  $obj_id = ilObject::_lookupObjId($this->ref_id);
644  $category = ilCalendarCategory::_getInstanceByObjId($obj_id);
645  $category_id = $category->getCategoryID();
646 
647  // agenda tab
648  $this->tabs_gui->addTab(
649  'cal_agenda',
650  $this->lng->txt('cal_agenda'),
651  $this->ctrl->getLinkTarget($this, '')
652  );
653 
654  // settings tab
655  if ($access->checkAccess('edit_event', '', $this->ref_id)) {
656  $this->ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $category_id);
657  $this->tabs_gui->addTab(
658  'cal_manage',
659  $this->lng->txt('settings'),
660  $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'edit')
661  );
662  $this->ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
663  }
664  return true;
665  } else {
666  $this->tabs_gui->addTab(
667  'cal_agenda',
668  $this->lng->txt("cal_agenda"),
669  $this->ctrl->getLinkTarget($this, '')
670  );
671 
672  if (
673  $rbacsystem->checkAccess(
674  'add_consultation_hours',
675  ilCalendarSettings::_getInstance()->getCalendarSettingsId()
676  ) &&
677  ilCalendarSettings::_getInstance()->areConsultationHoursEnabled()
678  ) {
679  $this->tabs_gui->addTab(
680  'app_consultation_hours',
681  $this->lng->txt('app_consultation_hours'),
682  $this->ctrl->getLinkTargetByClass(ilConsultationHoursGUI::class, '')
683  );
684  }
685  /*
686  $this->tabs_gui->addTab(
687  'cal_manage',
688  $this->lng->txt('cal_manage'),
689  $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class,'manage')
690  );
691  $this->tabs_gui->addTab(
692  'settings',
693  $this->lng->txt('settings'),
694  $this->ctrl->getLinkTargetByClass(ilCalendarUserSettings::class,'')
695  );
696  */
697  $this->tabs_gui->addTarget('cal_manage', $this->ctrl->getLinkTargetByClass('ilCalendarCategoryGUI', 'manage'));
698  $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI', ''));
699  }
700  }
701 
702 
706  protected function prepareOutput()
707  {
708  global $DIC;
709 
710  $tpl = $DIC->ui()->mainTemplate();
711 
712  if ($this->category_id) {
713  $this->addCategoryTabs();
714  } else {
715  $this->addStandardTabs();
716  }
717 
718  $tpl->setTitleIcon(ilUtil::getImagePath("icon_cals.svg"));
719 
720  // if we are in single calendar view
721  if ($this->category_id > 0) {
722  global $DIC;
723 
724  $tabs = $this->tabs_gui;
725  $lng = $this->lng;
726  $ctrl = $this->ctrl;
727  $tpl = $DIC["tpl"];
728 
729  $category = new ilCalendarCategory($this->category_id);
730 
731  // Set header
732  $header = "";
733  switch ($category->getType()) {
735  $header = $this->lng->txt('cal_type_personal') . ": " . $category->getTitle();
736  break;
737 
739  $header = $this->lng->txt('cal_type_system') . ": " . $category->getTitle();
740  break;
741 
743  $header = $this->lng->txt('cal_type_' . $category->getObjType()) . ": " . $category->getTitle();
744  break;
745 
747  $header = str_replace("%1", ilObjUser::_lookupFullname($category->getObjId()), $lng->txt("cal_consultation_hours_for_user"));
748  break;
749 
751  $header = $category->getTitle();
752  break;
753  }
754  $tpl->setTitleIcon(ilUtil::getImagePath("icon_cals.svg"));
755  $tpl->setTitle($header);
756 
757  $this->action_menu = new ilAdvancedSelectionListGUI();
758  $this->action_menu->setAsynch(false);
759  $this->action_menu->setAsynchUrl('');
760  $this->action_menu->setListTitle($lng->txt('actions'));
761  $this->action_menu->setId('act_cal');
762  $this->action_menu->setSelectionHeaderClass('small');
763  $this->action_menu->setItemLinkClass('xsmall');
764  $this->action_menu->setLinksMode('il_ContainerItemCommand2');
765  $this->action_menu->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
766  $this->action_menu->setUseImages(false);
767 
768  // iCal-Url
769  $ctrl->setParameterByClass("ilcalendarsubscriptiongui", "category_id", $this->category_id);
770  $this->action_menu->addItem($lng->txt("cal_ical_url"), "", $ctrl->getLinkTargetByClass("ilcalendarsubscriptiongui", ""));
771 
772  // delete action
773  if ($this->actions->checkDeleteCal($this->category_id)) {
774  $ctrl->setParameterByClass("ilcalendarcategorygui", "category_id", $this->category_id);
775  $this->action_menu->addItem($lng->txt("cal_delete_cal"), "", $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "confirmDelete"));
776  }
777 
778  $tpl->setHeaderActionMenu($this->action_menu->getHTML());
779  }
780  }
781 
787  public function initSeed()
788  {
789  // default to today
790  $now = new \ilDate(time(), IL_CAL_UNIX);
791  $this->seed = new \ilDate($now->get(IL_CAL_DATE), IL_CAL_DATE);
792  if (array_key_exists('seed', $_REQUEST)) {
793  $this->seed = new ilDate($_GET['seed'], IL_CAL_DATE);
794  } elseif (!$this->getRepositoryMode()) {
795  $session_seed = ilSession::get('cal_seed');
796  if ($session_seed) {
797  $this->seed = new ilDate($session_seed, IL_CAL_DATE);
798  }
799  }
800  $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
801  ilSession::set('cal_seed', $this->seed->get(IL_CAL_DATE));
802  }
803 
807  protected function synchroniseExternalCalendars()
808  {
810 
811  if (!ilCalendarSettings::_getInstance()->isWebCalSyncEnabled()) {
812  return false;
813  }
814  // @todo make this thread safe
815 
816  $limit = new ilDateTime(time(), IL_CAL_UNIX);
817  $limit->increment(IL_CAL_HOUR, -1 * ilCalendarSettings::_getInstance()->getWebCalSyncHours());
818 
820  foreach ($cats->getCategoriesInfo() as $cat_id => $info) {
821  if ($info['remote']) {
822  // Check for execution
823  $category = new ilCalendarCategory($cat_id);
824 
825  if (
826  $category->getRemoteSyncLastExecution()->isNull() ||
827  ilDateTime::_before($category->getRemoteSyncLastExecution(), $limit)
828  ) {
829  // update in any case to avoid multiple updates of invalid calendar sources.
830  $category->setRemoteSyncLastExecution(new ilDateTime(time(), IL_CAL_UNIX));
831  $category->update();
832 
833  include_once './Services/Calendar/classes/class.ilCalendarRemoteReader.php';
834  $remote = new ilCalendarRemoteReader($category->getRemoteUrl());
835  $remote->setUser($category->getRemoteUser());
836  $remote->setPass($category->getRemotePass());
837  $remote->read();
838  $remote->import($category);
839  break;
840  }
841  }
842  }
843  }
844 
845  #21613
846  public function showToolbarAndSidebar()
847  {
848  #21783
849  if ($this->ctrl->getCmdClass() == "ilcalendarappointmentgui" || $this->ctrl->getCmdClass() == 'ilconsultationhoursgui') {
850  return false;
851  }
852  return true;
853  }
854 }
$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.
$_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
global $ilCtrl
Definition: ilias.php:18
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.
static _getInstanceByObjId($a_obj_id)
get instance by obj_id
$ilUser
Definition: imgupload.php:18
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.
$DIC
Definition: xapitoken.php:46
addCategoryTabs()
Add tabs for ilCategoryGUI context This cannot be done there since many views (Day Week Agenda) are i...
static redirect($a_script)
loadHistory()
forward to last presentation class
Presentation day view.
Administration, Side-Block presentation of calendar categories.