ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
6include_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 {
142 }
143
148 {
149 $visibility = ilCalendarVisibility::_getInstanceByUserId($this->user->getId(), $this->ref_id);
150 foreach ($this->cats->getCategoriesInfo() as $info) {
151 if (
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->redirect($this, "");
162 }
163 }
164 }
165
173 public function executeCommand()
174 {
176
177 $cmd = $this->ctrl->getCmd();
178 // now next class is not empty, which breaks old consultation hour implementation
179 $next_class = $this->getNextClass();
180
181 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
182 if (!ilCalendarSettings::_getInstance()->isEnabled()) {
183 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
184 ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
185 }
186
187 $this->initSeed();
188 $this->prepareOutput();
189
190 $this->help->setScreenIdComponent("cal");
191
192 switch ($cmd) {
193 case 'selectCHCalendarOfUser':
195 break;
196 }
197
198 switch ($next_class) {
199 case 'ilcalendarinboxgui':
200 $this->tabs_gui->activateTab('cal_agenda');
201 $inbox_gui = $this->forwardToClass('ilcalendarinboxgui');
202 if ($this->showToolbarAndSidebar()) {
203 $this->showViewSelection("cal_list");
204 $this->showSideBlocks();
205 $inbox_gui->addToolbarActions();
206 }
207
208 break;
209
210 case 'ilconsultationhoursgui':
211 $this->tabs_gui->activateTab('app_consultation_hours');
212 $this->tabs_gui->clearTargets();
213
214 // No side blocks
215 $this->tabs_gui->setBackTarget(
216 $this->lng->txt('cal_back_to_cal'),
217 $this->ctrl->getLinkTargetByClass($this->readLastClass())
218 );
219
220 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHoursGUI.php';
221 $gui = new ilConsultationHoursGUI();
222 $this->ctrl->forwardCommand($gui);
223 if ($this->showToolbarAndSidebar()) {
224 $this->showSideBlocks();
225 }
226 return true;
227
228 case 'ilcalendarmonthgui':
229 $this->tabs_gui->activateTab('cal_agenda');
230 $month_gui = $this->forwardToClass('ilcalendarmonthgui');
231
232 if ($this->showToolbarAndSidebar()) {
233 $this->showViewSelection("app_month");
234 $this->showSideBlocks();
235 $month_gui->addToolbarActions();
236 }
237 break;
238
239 case 'ilcalendarweekgui':
240 $this->tabs_gui->activateTab('cal_agenda');
241 $week_gui = $this->forwardToClass('ilcalendarweekgui');
242 if ($this->showToolbarAndSidebar()) {
243 $this->showViewSelection("app_week");
244 $this->showSideBlocks();
245 $week_gui->addToolbarActions();
246 }
247
248 break;
249
250 case 'ilcalendardaygui':
251 $this->tabs_gui->activateTab('cal_agenda');
252 $day_gui = $this->forwardToClass('ilcalendardaygui');
253 if ($this->showToolbarAndSidebar()) {
254 $this->showViewSelection("app_day");
255 $this->showSideBlocks();
256 $day_gui->addToolbarActions();
257 }
258 break;
259
260 case 'ilcalendarusersettingsgui':
261 $this->ctrl->setReturn($this, '');
262 $this->tabs_gui->activateTab('settings');
263 $this->setCmdClass('ilcalendarusersettingsgui');
264
265 include_once('./Services/Calendar/classes/class.ilCalendarUserSettingsGUI.php');
266 $user_settings = new ilCalendarUserSettingsGUI();
267 $this->ctrl->forwardCommand($user_settings);
268 // No side blocks
269 return true;
270
271 case 'ilcalendarappointmentgui':
272 $this->ctrl->setReturn($this, '');
273 $this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
274
275 include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
276 $app = new ilCalendarAppointmentGUI($this->seed, $this->seed, (int) $_GET['app_id']);
277 $this->ctrl->forwardCommand($app);
278 break;
279
280 case 'ilcalendarsubscriptiongui':
281 $this->ctrl->setReturn($this, '');
282 //$this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
283 $this->tabs_gui->activateTab("cal_agenda");
284 include_once './Services/Calendar/classes/class.ilCalendarSubscriptionGUI.php';
285 $sub = new ilCalendarSubscriptionGUI((int) $_REQUEST['category_id'], (int) $_GET["ref_id"]);
286 $this->ctrl->forwardCommand($sub);
287 if ($this->showToolbarAndSidebar()) {
288 $this->showSideBlocks();
289 }
290 break;
291
292 case 'ilcalendarcategorygui':
293 $this->ctrl->setReturn($this, '');
294 $this->tabs_gui->activateTab("cal_manage");
295 include_once('Services/Calendar/classes/class.ilCalendarCategoryGUI.php');
296 $category = new ilCalendarCategoryGUI($ilUser->getId(), $this->seed, $this->ref_id);
297 if ($this->ctrl->forwardCommand($category)) {
298 //$this->tabs_gui->activateTab("cal_manage");
299
300 // no side blocks
301 return;
302 } else {
303 if ($this->getRepositoryMode()) {
304 #$this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, ""));
305 }
306 //$this->tabs_gui->activateTab($_SESSION['cal_last_tab']);
307 $this->showSideBlocks();
308 break;
309 }
310
311 // no break
312 case 'ilcalendarblockgui':
313 $side_cal = new ilCalendarBlockGUI();
314 $side_cal->setAvailableDetailLevels(2, 2);
315 $side_cal->setRepositoryMode($this->getRepositoryMode());
316 $side_cal->setForceMonthView(true);
317 $this->ctrl->forwardCommand($side_cal);
318 $this->showSideBlocks();
319 break;
320
321 case 'ilpdcalendarblockgui':
322 $side_cal = new ilPDCalendarBlockGUI();
323 $side_cal->setAvailableDetailLevels(2, 2);
324 $side_cal->setRepositoryMode($this->getRepositoryMode());
325 $side_cal->setForceMonthView(true);
326 $this->ctrl->forwardCommand($side_cal);
327 $this->showSideBlocks();
328 break;
329
330 case 'ilpublicuserprofilegui':
331 include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
332 $user_profile = new ilPublicUserProfileGUI($_GET["user_id"]);
333 $html = $this->ctrl->forwardCommand($user_profile);
334 $this->tpl->setContent($html);
335 break;
336
337 default:
338 $cmd = $this->ctrl->getCmd("show");
339 $this->$cmd();
340 $this->showSideBlocks();
341 break;
342 }
343
344
346
347 return true;
348 }
349
355 public function showViewSelection($a_active = "cal_list")
356 {
357 $ui = $this->ui;
361
362 $f = $ui->factory();
363
364 $actions = array(
365 $lng->txt("app_day") => $ctrl->getLinkTargetByClass('ilCalendarDayGUI', ''),
366 $lng->txt("app_week") => $ctrl->getLinkTargetByClass('ilCalendarWeekGUI', ''),
367 $lng->txt("app_month") => $ctrl->getLinkTargetByClass('ilCalendarMonthGUI', ''),
368 $lng->txt("cal_list") => $ctrl->getLinkTargetByClass('ilCalendarInboxGUI', '')
369 );
370
371 $aria_label = $lng->txt("cal_change_calendar_view");
372 $view_control = $f->viewControl()->mode($actions, $aria_label)->withActive($lng->txt($a_active));
373
374 $toolbar->addComponent($view_control);
375
376 $ctrl->setParameterByClass("ilcalendarappointmentgui", "seed", $this->seed->get(IL_CAL_DATE, ''));
377 $ctrl->setParameterByClass("ilcalendarappointmentgui", "app_id", "");
378 $ctrl->setParameterByClass("ilcalendarappointmentgui", "dt", "");
379
380 $extra_button_added = false;
381 // add appointment
382 if ($this->category_id == 0 || $this->actions->checkAddEvent($this->category_id)) {
383 $toolbar->addSeparator();
384 $extra_button_added = true;
385 $add_button = $f->button()->standard(
386 $lng->txt("cal_add_appointment"),
387 $ctrl->getLinkTargetByClass("ilcalendarappointmentgui", "add")
388 );
389 $toolbar->addComponent($add_button);
390 }
391
392 // import appointments
393 if ($this->category_id > 0 && $this->actions->checkAddEvent($this->category_id)) {
394 if (!$extra_button_added) {
395 $toolbar->addSeparator();
396 }
397 $add_button = $f->button()->standard(
398 $lng->txt("cal_import_appointments"),
399 $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "importAppointments")
400 );
401 $toolbar->addComponent($add_button);
402 }
403 }
404
405
411 public function getNextClass()
412 {
413 if (strlen($next_class = $this->ctrl->getNextClass())) {
414 return $next_class;
415 }
416 if ($this->ctrl->getCmdClass() == strtolower(get_class($this)) or $this->ctrl->getCmdClass() == '') {
417 return $this->readLastClass();
418 }
419 }
420
425 public function readLastClass()
426 {
428
429 return $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarinboxgui';
430 }
431
432 public function setCmdClass($a_class)
433 {
434 // If cmd class == 'ilcalendarpresentationgui' the cmd class is set to the the new forwarded class
435 // otherwise e.g ilcalendarmonthgui tries to forward (back) to ilcalendargui.
436
437 if ($this->ctrl->getCmdClass() == strtolower(get_class($this))) {
438 $this->ctrl->setCmdClass(strtolower($a_class));
439 }
440 return true;
441 }
442
448 protected function forwardToClass($a_class)
449 {
451
452 switch ($a_class) {
453 case 'ilcalendarmonthgui':
454 $ilUser->writePref('cal_last_class', $a_class);
455 $_SESSION['cal_last_tab'] = 'app_month';
456 $this->setCmdClass('ilcalendarmonthgui');
457 include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
458 $month_gui = new ilCalendarMonthGUI($this->seed);
459 $this->ctrl->forwardCommand($month_gui);
460 return $month_gui;
461 break;
462
463 case 'ilcalendarweekgui':
464 $ilUser->writePref('cal_last_class', $a_class);
465 $_SESSION['cal_last_tab'] = 'app_week';
466 $this->setCmdClass('ilcalendarweekgui');
467 include_once('./Services/Calendar/classes/class.ilCalendarWeekGUI.php');
468 $week_gui = new ilCalendarWeekGUI($this->seed);
469 $this->ctrl->forwardCommand($week_gui);
470 return $week_gui;
471 break;
472
473 case 'ilcalendardaygui':
474 $ilUser->writePref('cal_last_class', $a_class);
475 $_SESSION['cal_last_tab'] = 'app_day';
476 $this->setCmdClass('ilcalendardaygui');
477 include_once('./Services/Calendar/classes/class.ilCalendarDayGUI.php');
478 $day_gui = new ilCalendarDayGUI($this->seed);
479 $this->ctrl->forwardCommand($day_gui);
480 return $day_gui;
481 break;
482
483 case 'ilcalendarinboxgui':
484 #21479
485 if ($view_option = $_GET['cal_agenda_per']) {
486 ilSession::set("cal_list_view", $view_option);
487 } elseif ($view_option = ilSession::get('cal_list_view')) {
488 ilSession::set("cal_list_view", $view_option);
489 }
490 $ilUser->writePref('cal_last_class', $a_class);
491 $_SESSION['cal_last_tab'] = 'cal_upcoming_events_header';
492 $this->setCmdClass('ilcalendarinboxgui');
493 include_once('./Services/Calendar/classes/class.ilCalendarInboxGUI.php');
494 $inbox_gui = new ilCalendarinboxGUI($this->seed);
495 $this->ctrl->forwardCommand($inbox_gui);
496 return $inbox_gui;
497 break;
498 }
499 }
500
508 protected function loadHistory()
509 {
511
512 $this->ctrl->setCmd('');
513 $history = $ilUser->getPref('cal_last_class') ? $ilUser->getPref('cal_last_class') : 'ilcalendarmonthgui';
514 $this->forwardToClass($history);
515 }
516
524 protected function showSideBlocks()
525 {
528
529 $tpl = new ilTemplate('tpl.cal_side_block.html', true, true, 'Services/Calendar');
530 if ($this->getRepositoryMode()) {
531 include_once("./Services/Calendar/classes/class.ilCalendarBlockGUI.php");
532 $side_cal = new ilCalendarBlockGUI();
533 } else {
534 include_once("./Services/Calendar/classes/class.ilPDCalendarBlockGUI.php");
535 $side_cal = new ilPDCalendarBlockGUI();
536 }
537 $side_cal->setAvailableDetailLevels(2, 2);
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
550
558 public function show()
559 {
560 $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem', 'delos.css', 'Services/Calendar'));
561 }
562
567 protected function addCategoryTabs()
568 {
569 global $DIC;
570
571 $ctrl = $DIC->ctrl();
572
573 $this->tabs_gui->clearTargets();
574 $ctrl->setParameterByClass(ilCalendarCategoryGUI::class, "category_id", $_REQUEST["category_id"]);
575 if ($this->getRepositoryMode()) {
576 $came_from_pd = $_REQUEST['backpd'];
577 if ($came_from_pd) {
578 $this->tabs_gui->setBack2Target(
579 $this->lng->txt('back_to_pd'),
580 $this->ctrl->getLinkTargetByClass(ilPersonalDesktopGUI::class, 'jumpToCalendar')
581 );
582 }
583 $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
584 $this->tabs_gui->setBackTarget(
585 $label,
586 $this->ctrl->getParentReturn($this)
587 );
588 } else {
589 // no object calendar => back is back to manage view
590 if (array_key_exists('backvm', $_REQUEST)) {
591 $this->tabs_gui->setBackTarget(
592 $this->lng->txt("back"),
593 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'manage')
594 );
595 } else {
596 $ctrl->clearParameterByClass(ilCalendarPresentationGUI::class, 'category_id');
597 $this->tabs_gui->setBackTarget(
598 $this->lng->txt("back"),
599 $ctrl->getLinkTargetByClass('ilcalendarpresentationgui', '')
600 );
601 }
602 $ctrl->setParameterByClass(ilCalendarPresentationGUI::class, "category_id", $_REQUEST["category_id"]);
603 }
604
605 $this->tabs_gui->addTab(
606 "cal_agenda",
607 $this->lng->txt("cal_agenda"),
608 $ctrl->getLinkTargetByClass(ilCalendarPresentationGUI::class, "")
609 );
610
611 if ($this->actions->checkShareCal($this->category_id)) {
612 $this->tabs_gui->addTab(
613 "share",
614 $this->lng->txt("cal_share"),
615 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "shareSearch")
616 );
617 }
618 if ($this->actions->checkSettingsCal($this->category_id)) {
619 $this->tabs_gui->addTab(
620 "edit",
621 $this->lng->txt("settings"),
622 $ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, "edit")
623 );
624 }
625
626 $this->tabs_gui->activateTab('cal_agenda');
627 return true;
628 }
629
633 protected function addStandardTabs()
634 {
635 global $DIC;
636
637 $access = $DIC->access();
638 $rbacsystem = $DIC->rbac()->system();
639
640 $came_from_pd = $_REQUEST['backpd'];
641
642 $this->tabs_gui->clearTargets();
643 if ($this->getRepositoryMode()) {
644 if ($came_from_pd) {
645 $this->tabs_gui->setBack2Target(
646 $this->lng->txt('back_to_pd'),
647 $this->ctrl->getLinkTargetByClass(ilPersonalDesktopGUI::class, 'jumpToCalendar')
648 );
649 }
650 $label = $this->lng->txt('back_to_' . ilObject::_lookupType($this->ref_id, true));
651 $this->tabs_gui->setBackTarget(
652 $label,
653 $this->ctrl->getParentReturn($this)
654 );
655
656 $obj_id = ilObject::_lookupObjId($this->ref_id);
657 $category = ilCalendarCategory::_getInstanceByObjId($obj_id);
658 $category_id = $category->getCategoryID();
659
660 // agenda tab
661 $this->tabs_gui->addTab(
662 'cal_agenda',
663 $this->lng->txt('cal_agenda'),
664 $this->ctrl->getLinkTarget($this, '')
665 );
666
667 // settings tab
668 if ($access->checkAccess('edit_event', '', $this->ref_id)) {
669 $this->ctrl->setParameterByClass(ilCalendarCategoryGUI::class, 'category_id', $category_id);
670 $this->tabs_gui->addTab(
671 'cal_manage',
672 $this->lng->txt('settings'),
673 $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class, 'edit')
674 );
675 $this->ctrl->clearParameterByClass(ilCalendarCategoryGUI::class, 'category_id');
676 }
677 return true;
678 } else {
679 $this->tabs_gui->addTab(
680 'cal_agenda',
681 $this->lng->txt("cal_agenda"),
682 $this->ctrl->getLinkTarget($this, '')
683 );
684
685 if (
686 $rbacsystem->checkAccess(
687 'add_consultation_hours',
688 ilCalendarSettings::_getInstance()->getCalendarSettingsId()
689 ) &&
690 ilCalendarSettings::_getInstance()->areConsultationHoursEnabled()
691 ) {
692 $this->tabs_gui->addTab(
693 'app_consultation_hours',
694 $this->lng->txt('app_consultation_hours'),
695 $this->ctrl->getLinkTargetByClass(ilConsultationHoursGUI::class, '')
696 );
697 }
698 /*
699 $this->tabs_gui->addTab(
700 'cal_manage',
701 $this->lng->txt('cal_manage'),
702 $this->ctrl->getLinkTargetByClass(ilCalendarCategoryGUI::class,'manage')
703 );
704 $this->tabs_gui->addTab(
705 'settings',
706 $this->lng->txt('settings'),
707 $this->ctrl->getLinkTargetByClass(ilCalendarUserSettings::class,'')
708 );
709 */
710 $this->tabs_gui->addTarget('cal_manage', $this->ctrl->getLinkTargetByClass('ilCalendarCategoryGUI', 'manage'));
711 $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTargetByClass('ilCalendarUserSettingsGUI', ''));
712 }
713 }
714
715
719 protected function prepareOutput()
720 {
721 global $DIC;
722
723 $tpl = $DIC->ui()->mainTemplate();
724
725 if ($this->category_id) {
726 $this->addCategoryTabs();
727 } else {
728 $this->addStandardTabs();
729 }
730
731 $tpl->setTitleIcon(ilUtil::getImagePath("icon_cals.svg"));
732
733 // if we are in single calendar view
734 if ($this->category_id > 0) {
735 global $DIC;
736
740 $tpl = $DIC["tpl"];
741
742 $category = new ilCalendarCategory($this->category_id);
743
744 // Set header
745 $header = "";
746 switch ($category->getType()) {
748 $header = $this->lng->txt('cal_type_personal') . ": " . $category->getTitle();
749 break;
750
752 $header = $this->lng->txt('cal_type_system') . ": " . $category->getTitle();
753 break;
754
756 $header = $this->lng->txt('cal_type_' . $category->getObjType()) . ": " . $category->getTitle();
757 break;
758
760 $header = str_replace("%1", ilObjUser::_lookupFullname($category->getObjId()), $lng->txt("cal_consultation_hours_for_user"));
761 break;
762
764 $header = $category->getTitle();
765 break;
766 }
767 $tpl->setTitleIcon(ilUtil::getImagePath("icon_cals.svg"));
768 $tpl->setTitle($header);
769
770 $this->action_menu = new ilAdvancedSelectionListGUI();
771 $this->action_menu->setAsynch(false);
772 $this->action_menu->setAsynchUrl('');
773 $this->action_menu->setListTitle($lng->txt('actions'));
774 $this->action_menu->setId('act_cal');
775 $this->action_menu->setSelectionHeaderClass('small');
776 $this->action_menu->setItemLinkClass('xsmall');
777 $this->action_menu->setLinksMode('il_ContainerItemCommand2');
778 $this->action_menu->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
779 $this->action_menu->setUseImages(false);
780
781 // iCal-Url
782 $ctrl->setParameterByClass("ilcalendarsubscriptiongui", "category_id", $this->category_id);
783 $this->action_menu->addItem($lng->txt("cal_ical_url"), "", $ctrl->getLinkTargetByClass("ilcalendarsubscriptiongui", ""));
784
785 // delete action
786 if ($this->actions->checkDeleteCal($this->category_id)) {
787 $ctrl->setParameterByClass("ilcalendarcategorygui", "category_id", $this->category_id);
788 $this->action_menu->addItem($lng->txt("cal_delete_cal"), "", $ctrl->getLinkTargetByClass("ilcalendarcategorygui", "confirmDelete"));
789 }
790
791 $tpl->setHeaderActionMenu($this->action_menu->getHTML());
792 }
793 }
794
800 public function initSeed()
801 {
802 // default to today
803 $now = new \ilDate(time(), IL_CAL_UNIX);
804 $this->seed = new \ilDate($now->get(IL_CAL_DATE), IL_CAL_DATE);
805 if (array_key_exists('seed', $_REQUEST)) {
806 $this->seed = new ilDate($_GET['seed'], IL_CAL_DATE);
807 } elseif (!$this->getRepositoryMode()) {
808 $session_seed = ilSession::get('cal_seed');
809 if ($session_seed) {
810 $this->seed = new ilDate($session_seed, IL_CAL_DATE);
811 }
812 }
813 $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
814 ilSession::set('cal_seed', $this->seed->get(IL_CAL_DATE));
815 }
816
820 protected function synchroniseExternalCalendars()
821 {
823
824 if (!ilCalendarSettings::_getInstance()->isWebCalSyncEnabled()) {
825 return false;
826 }
827 // @todo make this thread safe
828
829 $limit = new ilDateTime(time(), IL_CAL_UNIX);
830 $limit->increment(IL_CAL_HOUR, -1 * ilCalendarSettings::_getInstance()->getWebCalSyncHours());
831
833 foreach ($cats->getCategoriesInfo() as $cat_id => $info) {
834 if ($info['remote']) {
835 // Check for execution
836 $category = new ilCalendarCategory($cat_id);
837
838 if (ilDateTime::_before($category->getRemoteSyncLastExecution(), $limit)) {
839 // update in any case to avoid multiple updates of invalid calendar sources.
840 $category->setRemoteSyncLastExecution(new ilDateTime(time(), IL_CAL_UNIX));
841 $category->update();
842
843 include_once './Services/Calendar/classes/class.ilCalendarRemoteReader.php';
844 $remote = new ilCalendarRemoteReader($category->getRemoteUrl());
845 $remote->setUser($category->getRemoteUser());
846 $remote->setPass($category->getRemotePass());
847 $remote->read();
848 $remote->import($category);
849 break;
850 }
851 }
852 }
853 }
854
855 #21613
856 public function showToolbarAndSidebar()
857 {
858 #21783
859 if ($this->ctrl->getCmdClass() == "ilcalendarappointmentgui" || $this->ctrl->getCmdClass() == 'ilconsultationhoursgui') {
860 return false;
861 }
862 return true;
863 }
864}
user()
Definition: user.php:4
$_GET["client_id"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_UNIX
const IL_CAL_HOUR
User interface class for advanced drop-down selection lists.
static getInstance()
Get instance.
Administrate calendar appointments.
Calendar blocks, displayed in different contexts, e.g.
static _getInstance($a_usr_id=0)
get singleton instance
Administration, Side-Block presentation of calendar categories.
Stores calendar categories.
static _getInstanceByObjId($a_obj_id)
get instance by obj_id
Presentation day view.
loadHistory()
forward to last presentation class
addCategoryTabs()
Add tabs for ilCategoryGUI context This cannot be done there since many views (Day Week Agenda) are i...
initSeed()
init the seed date for presentations (month view, minicalendar)
readLastClass()
Read last class from history.
initAndRedirectToConsultationHours()
Init and redirect to consultation hours.
showViewSelection($a_active="cal_list")
Show view selection.
synchroniseExternalCalendars()
Sync external calendars.
Reader for remote ical calendars.
static _getInstance()
get singleton instance
Show calendar subscription info.
static _getInstance()
get instance for logged in user
static _getInstanceByUserId($a_user_id, $a_ref_id=0)
get instance by user id
Consultation hours editor.
@classDescription Date and time handling
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.
Class for single dates.
static _lookupFullname($a_user_id)
Lookup Full Name.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
Calendar blocks, displayed on personal desktop.
GUI class for public user profile presentation.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
if(!empty($this->data['faventry'])) $tabs
Definition: disco.tpl.php:124
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
$info
Definition: index.php:5
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18