ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarSubscriptionGUI.php
Go to the documentation of this file.
1<?php
2
21
27{
28 private int $cal_id = 0;
29 private int $ref_id = 0;
30
31 protected ilObjUser $user;
33 protected ilLanguage $lng;
37
38 public function __construct(int $a_calendar_id, int $a_ref_id = 0)
39 {
40 global $DIC;
41
42 $this->cal_id = $a_calendar_id;
43 $this->ref_id = $a_ref_id;
44 $this->user = $DIC->user();
45 $this->ctrl = $DIC->ctrl();
46 $this->lng = $DIC->language();
47 $this->tpl = $DIC->ui()->mainTemplate();
48 $this->ui_factory = $DIC->ui()->factory();
49 $this->ui_renderer = $DIC->ui()->renderer();
50 }
51
52 public function executeCommand(): void
53 {
54 $next_class = $this->ctrl->getNextClass($this);
55 switch ($next_class) {
56 default:
57 $cmd = $this->ctrl->getCmd("show");
58 $this->$cmd();
59 break;
60 }
61 }
62
66 protected function show(): void
67 {
68 $this->tpl->setOnScreenMessage('info', $this->lng->txt('cal_subscription_info'));
69
70 $info = new ilInfoScreenGUI($this);
71 $info->setFormAction($GLOBALS['DIC']['ilCtrl']->getFormAction($this));
72
73 if ($this->cal_id > 0) {
76 } elseif ($this->ref_id > 0) {
79 $id = $category->getCategoryID();
80 } else {
82 $id = 0;
83 }
84
85 $hash = $this->createToken($this->user->getId(), $selection, $id);
86 $url = ILIAS_HTTP_PATH . '/calendar.php?client_id=' . CLIENT_ID . '&token=' . $hash;
87 $info->addSection($this->lng->txt("cal_subscription"));
88 $info->addProperty($this->lng->txt('cal_ical_url'), $url, $url);
89
90 $this->tpl->setContent($info->getHTML());
91 }
92
93 private function createToken($user_id, $selection, $id): string
94 {
96 if (strlen($hash)) {
97 return $hash;
98 }
100 $token->setSelectionType($selection);
101 $token->setCalendar($id);
102 return $token->add();
103 }
104
105 protected function getModalForSubscription(): void
106 {
107 $tpl = new ilTemplate(
108 'tpl.subscription_dialog.html',
109 true,
110 true,
111 'components/ILIAS/Calendar'
112 );
113
114 $tpl->setVariable('TXT_SUBSCRIPTION_INFO', $this->lng->txt('cal_subscription_info'));
115
116 if ($this->cal_id > 0) {
119 } elseif ($this->ref_id > 0) {
122 $id = $category->getCategoryID();
123 } else {
125 $id = 0;
126 }
127 $hash = $this->createToken($this->user->getId(), $selection, $id);
128 $url = ILIAS_HTTP_PATH . '/calendar.php?client_id=' . CLIENT_ID . '&token=' . $hash;
129
130 $tpl->setVariable('LINK', $url . '&limited=0');
131 $tpl->setVariable('TXT_PERMA', $this->lng->txt('cal_ical_url'));
132
133 $tpl->setVariable('LINK_LIMITED', $url . '&limited=1');
134 $tpl->setVariable('TXT_PERMA_LIMITED', $this->lng->txt('cal_ical_url_google'));
135
136 $roundtrip = $this->ui_factory->modal()->roundtrip(
137 $this->lng->txt('cal_calendar_subscription_modal_title'),
138 $this->ui_factory->legacy()->content($tpl->get())
139 );
140 echo $this->ui_renderer->render($roundtrip);
141 exit;
142 }
143}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Handles calendar authentication tokens for external calendar subscriptions.
static lookupAuthToken(int $a_user_id, int $a_selection, int $a_calendar=0)
static _getInstanceByObjId(int $a_obj_id)
get instance by obj_id
Show calendar subscription info.
createToken($user_id, $selection, $id)
__construct(int $a_calendar_id, int $a_ref_id=0)
Class ilInfoScreenGUI.
language handling
User class.
static _lookupObjId(int $ref_id)
special template class to simplify handling of ITX/PEAR
const CLIENT_ID
Definition: constants.php:41
exit
$info
Definition: entry_point.php:21
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68
$GLOBALS["DIC"]
Definition: wac.php:54
$token
Definition: xapitoken.php:70