ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
ilAuthLogoutBehaviourGUI Class Reference

@ilCtrl_isCalledBy ilAuthLogoutBehaviourGUI: ilObjAuthSettingsGUI @ilCtrl_Calls ilAuthLogoutBehaviourGUI: ilLoginPageGUI More...

+ Collaboration diagram for ilAuthLogoutBehaviourGUI:

Public Member Functions

 __construct (private readonly int $ref_id)
 
 executeCommand ()
 
 getForm (?ServerRequestInterface $request=null, array $errors=[])
 
 showForm ()
 
 saveForm ()
 

Private Attributes

ilCtrl $ctrl
 
ilLanguage $lng
 
HttpService $http
 
Refinery $refinery
 
ilSetting $settings
 
UIFactory $ui_factory
 
ilErrorHandling $ilErr
 
UIRenderer $ui_renderer
 
ilRbacSystem $rbac_system
 
ilGlobalTemplateInterface $tpl
 
ConfigurableLogoutTarget $configurable_logout_target
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAuthLogoutBehaviourGUI::__construct ( private readonly int  $ref_id)

Definition at line 48 of file class.ilAuthLogoutBehaviourGUI.php.

49 {
50 global $DIC;
51 $this->ctrl = $DIC->ctrl();
52 $this->http = $DIC->http();
53 $this->lng = $DIC->language();
54 $this->refinery = $DIC->refinery();
55 $this->tpl = $DIC->ui()->mainTemplate();
56 $this->ui_factory = $DIC->ui()->factory();
57 $this->rbac_system = $DIC->rbac()->system();
58 $this->ui_renderer = $DIC->ui()->renderer();
59 $this->ilErr = $DIC->error();
60 $this->lng->loadLanguageModule('auth');
61 $this->settings = new ilSetting('auth');
62 $this->configurable_logout_target = new ConfigurableLogoutTarget(
63 $this->ctrl,
64 $this->settings,
65 $DIC->access()
66 );
67 }
ILIAS Setting Class.
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilAuthLogoutBehaviourGUI::executeCommand ( )

Definition at line 69 of file class.ilAuthLogoutBehaviourGUI.php.

69 : void
70 {
71 $cmd = $this->ctrl->getCmd();
72 if (method_exists($this, $cmd)) {
73 $this->$cmd();
74 }
75 $this->showForm();
76 }

References ILIAS\Repository\ctrl(), and showForm().

+ Here is the call graph for this function:

◆ getForm()

ilAuthLogoutBehaviourGUI::getForm ( ?ServerRequestInterface  $request = null,
array  $errors = [] 
)

Definition at line 78 of file class.ilAuthLogoutBehaviourGUI.php.

81 : StandardForm {
82 $logout_group = $this->ui_factory->input()->field()
83 ->group(
84 [],
85 $this->lng->txt('destination_logout_screen')
86 );
87
88 $login_group = $this->ui_factory->input()->field()
89 ->group(
90 [],
91 $this->lng->txt('destination_login_screen'),
92 $this->lng->txt('destination_login_screen_info')
93 );
94
95 $ref_id = $this->ui_factory->input()->field()
96 ->numeric($this->lng->txt('destination_internal_ressource_ref_id'))
97 ->withAdditionalTransformation(
98 $this->refinery->custom()->constraint(
99 fn($value) => $this->configurable_logout_target->isInRepository($value),
100 fn(callable $txt, $value) => $txt('logout_behaviour_invalid_ref_id', $value)
101 )
102 )
103 ->withAdditionalTransformation(
104 $this->refinery->custom()->constraint(
105 fn($value) => $this->configurable_logout_target->isAnonymousAccessible(
106 $value
107 ),
108 fn(callable $txt, $value) => $txt(
109 'logout_behaviour_ref_id_no_access',
110 $value
111 )
112 )
113 )
114 ->withValue($this->settings->get('logout_behaviour_ref_id', ''));
115 if (isset($errors['ref_id'])) {
116 $ref_id = $ref_id->withError($errors['ref_id']);
117 }
118
119 $internal_group = $this->ui_factory->input()->field()
120 ->group(
121 ['ref_id' => $ref_id],
122 $this->lng->txt('destination_internal_ressource')
123 );
124
125 $url = $this->settings->get('logout_behaviour_url', '');
126 $html = $this->ui_factory->input()->field()
127 ->url($this->lng->txt('destination_external_ressource_url'))
128 ->withAdditionalTransformation(
129 $this->refinery->custom()->constraint(
130 fn($value) => $this->configurable_logout_target->isValidExternalResource(
131 (string) $value
132 ),
133 fn(callable $txt, $value) => $txt('logout_behaviour_invalid_url', $value)
134 )
135 )
136 ->withValue($url);
137 if (isset($errors['url'])) {
138 $html = $html->withError($errors['url']);
139 }
140
141 $external_group = $this->ui_factory->input()->field()
142 ->group(
143 ['url' => $html],
144 $this->lng->txt('destination_external_ressource')
145 );
146
147 $logout_behaviour_switchable_group = $this->ui_factory->input()->field()
148 ->switchableGroup(
149 [
150 LogoutDestinations::LOGOUT_SCREEN->value => $logout_group,
151 LogoutDestinations::LOGIN_SCREEN->value => $login_group,
152 ConfigurableLogoutTarget::INTERNAL_RESSOURCE => $internal_group,
153 ConfigurableLogoutTarget::EXTERNAL_RESSOURCE => $external_group
154 ],
155 $this->lng->txt('destination_after_logout')
156 )
157 ->withValue(
158 $this->settings->get(
159 'logout_behaviour',
160 LogoutDestinations::LOGOUT_SCREEN->value
161 )
162 );
163
164 $access = $this->rbac_system->checkAccess('write', $this->ref_id);
165 if (!$access) {
166 $logout_behaviour_switchable_group = $logout_behaviour_switchable_group->withDisabled(true);
167 }
168
169 $section = $this->ui_factory->input()->field()
170 ->section(
171 ['logout_behaviour_settings' => $logout_behaviour_switchable_group],
172 $this->lng->txt('logout_behaviour_settings')
173 );
174
175 $form = $this->ui_factory->input()->container()->form()
176 ->standard(
177 $access ?
178 $this->ctrl->getFormAction($this, 'saveForm') :
179 $this->ctrl->getFormAction($this, 'showForm'),
180 ['logout_behaviour' => $section]
181 );
182 if ($request) {
183 $form = $form->withRequest($request);
184 }
185
186 if (!$access) {
187 $form = $form->withSubmitLabel($this->lng->txt('refresh'));
188 }
189
190 return $form;
191 }
$ref_id
Definition: ltiauth.php:66
$url
Definition: shib_logout.php:70

References $ref_id.

◆ saveForm()

ilAuthLogoutBehaviourGUI::saveForm ( )

Definition at line 211 of file class.ilAuthLogoutBehaviourGUI.php.

211 : void
212 {
213 if (!$this->rbac_system->checkAccess('write', $this->ref_id)) {
214 $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->WARNING);
215 return;
216 }
217
218 $form = $this->getForm();
219 $form = $form->withRequest($this->http->request());
220 $section = $form->getInputs()['logout_behaviour'];
221 $group = $section->getInputs()['logout_behaviour_settings'];
222 $ref_id = $group->getInputs()[ConfigurableLogoutTarget::INTERNAL_RESSOURCE]->getInputs()['ref_id'];
223 $url = $group->getInputs()[ConfigurableLogoutTarget::EXTERNAL_RESSOURCE]->getInputs()['url'];
224
225 $data = $form->getData();
226 if (!$data || $form->getError() || $ref_id->getError() || $url->getError()) {
227 $errors = [];
228 if ($ref_id->getError()) {
229 $errors['ref_id'] = $ref_id->getError();
230 }
231 if ($url->getError()) {
232 $errors['url'] = $url->getError();
233 }
234 $this->tpl->setContent($this->ui_renderer->render($this->getForm($this->http->request(), $errors)));
235 $this->tpl->printToStdout();
236
237 $this->http->close();
238 }
239 if (isset($data['logout_behaviour']['logout_behaviour_settings'][0])) {
240 $mode = $data['logout_behaviour']['logout_behaviour_settings'][0];
241
242 switch ($mode) {
243 case LogoutDestinations::LOGIN_SCREEN->value:
244 case LogoutDestinations::LOGOUT_SCREEN->value:
245 break;
246
247 case ConfigurableLogoutTarget::INTERNAL_RESSOURCE:
248 $this->settings->set(
249 'logout_behaviour_ref_id',
250 (string) ($data['logout_behaviour']['logout_behaviour_settings'][1]['ref_id'] ?? '')
251 );
252 break;
253 case ConfigurableLogoutTarget::EXTERNAL_RESSOURCE:
254
255 $url = $data['logout_behaviour']['logout_behaviour_settings'][1]['url'] ?? '';
256 $this->settings->set('logout_behaviour_url', (string) $url);
257 break;
258 }
259 $this->settings->set('logout_behaviour', $mode);
260 }
261 $this->ctrl->redirect($this, 'showForm');
262 }
getForm(?ServerRequestInterface $request=null, array $errors=[])

References $data, $ref_id, $url, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ showForm()

ilAuthLogoutBehaviourGUI::showForm ( )

Definition at line 193 of file class.ilAuthLogoutBehaviourGUI.php.

193 : void
194 {
195 $mode = $this->settings->get('logout_behaviour', LogoutDestinations::LOGOUT_SCREEN->value);
196 $ref_id = (int) $this->settings->get('logout_behaviour_ref_id', '');
197 $content = '';
198 if ($mode === ConfigurableLogoutTarget::INTERNAL_RESSOURCE &&
199 !$this->configurable_logout_target->isValidInternalResource($ref_id)) {
200 $content .= $this->ui_renderer->render(
201 $this->ui_factory->messageBox()->failure(
202 $this->lng->txt('logout_behaviour_ref_id_valid_status_changed')
203 )
204 );
205 }
206 $content .= $this->ui_renderer->render($this->getForm());
207
208 $this->tpl->setContent($content);
209 }

References $ref_id, ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $configurable_logout_target

ConfigurableLogoutTarget ilAuthLogoutBehaviourGUI::$configurable_logout_target
private

Definition at line 46 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $ctrl

ilCtrl ilAuthLogoutBehaviourGUI::$ctrl
private

Definition at line 36 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $http

HttpService ilAuthLogoutBehaviourGUI::$http
private

Definition at line 38 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $ilErr

ilErrorHandling ilAuthLogoutBehaviourGUI::$ilErr
private

Definition at line 42 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $lng

ilLanguage ilAuthLogoutBehaviourGUI::$lng
private

Definition at line 37 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $rbac_system

ilRbacSystem ilAuthLogoutBehaviourGUI::$rbac_system
private

Definition at line 44 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $refinery

Refinery ilAuthLogoutBehaviourGUI::$refinery
private

Definition at line 39 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $settings

ilSetting ilAuthLogoutBehaviourGUI::$settings
private

Definition at line 40 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilAuthLogoutBehaviourGUI::$tpl
private

Definition at line 45 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $ui_factory

UIFactory ilAuthLogoutBehaviourGUI::$ui_factory
private

Definition at line 41 of file class.ilAuthLogoutBehaviourGUI.php.

◆ $ui_renderer

UIRenderer ilAuthLogoutBehaviourGUI::$ui_renderer
private

Definition at line 43 of file class.ilAuthLogoutBehaviourGUI.php.


The documentation for this class was generated from the following file: