19 declare(strict_types=1);
49 $this->
ctrl = $DIC->ctrl();
50 $this->
http = $DIC->http();
51 $this->
lng = $DIC->language();
53 $this->tpl = $DIC->ui()->mainTemplate();
54 $this->ui_factory = $DIC->ui()->factory();
55 $this->ui_renderer = $DIC->ui()->renderer();
56 $this->
lng->loadLanguageModule(
'auth');
67 $cmd = $this->
ctrl->getCmd();
68 if (method_exists($this, $cmd)) {
78 $logout_group = $this->ui_factory->input()->field()
81 $this->
lng->txt(
'destination_logout_screen')
84 $login_group = $this->ui_factory->input()->field()
87 $this->
lng->txt(
'destination_login_screen'),
88 $this->
lng->txt(
'destination_login_screen_info')
91 $ref_id = $this->ui_factory->input()->field()
92 ->numeric($this->
lng->txt(
'destination_internal_ressource_ref_id'))
94 $this->
refinery->custom()->constraint(
95 fn($value) => $this->configurable_logout_target->isInRepository($value),
96 fn(callable
$txt, $value) =>
$txt(
'logout_behaviour_invalid_ref_id', $value)
99 ->withAdditionalTransformation(
100 $this->
refinery->custom()->constraint(
101 fn($value) => $this->configurable_logout_target->isAnonymousAccessible(
104 fn(callable $txt, $value) =>
$txt(
105 'logout_behaviour_ref_id_no_access',
110 ->withValue($this->
settings->get(
'logout_behaviour_ref_id',
''));
111 if (isset($errors[
'ref_id'])) {
115 $internal_group = $this->ui_factory->input()->field()
118 $this->
lng->txt(
'destination_internal_ressource')
121 $url = $this->
settings->get(
'logout_behaviour_url',
'');
122 $html = $this->ui_factory->input()->field()
123 ->url($this->
lng->txt(
'destination_external_ressource_url'))
125 $this->
refinery->custom()->constraint(
126 fn($value) => $this->configurable_logout_target->isValidExternalResource(
129 fn(callable $txt, $value) =>
$txt(
'logout_behaviour_invalid_url', $value)
133 if (isset($errors[
'url'])) {
134 $html = $html->withError($errors[
'url']);
137 $external_group = $this->ui_factory->input()->field()
140 $this->
lng->txt(
'destination_external_ressource')
143 $logout_behaviour_switchable_group = $this->ui_factory->input()->field()
146 LogoutDestinations::LOGOUT_SCREEN->value => $logout_group,
147 LogoutDestinations::LOGIN_SCREEN->value => $login_group,
148 ConfigurableLogoutTarget::INTERNAL_RESSOURCE => $internal_group,
149 ConfigurableLogoutTarget::EXTERNAL_RESSOURCE => $external_group
151 $this->
lng->txt(
'destination_after_logout')
156 LogoutDestinations::LOGOUT_SCREEN->value
160 $section = $this->ui_factory->input()->field()
162 [
'logout_behaviour_settings' => $logout_behaviour_switchable_group],
163 $this->
lng->txt(
'logout_behaviour_settings')
166 $form = $this->ui_factory->input()->container()->form()
168 $this->
ctrl->getFormAction($this,
'saveForm'),
169 [
'logout_behaviour' => $section]
172 $form = $form->withRequest($request);
180 $mode = $this->
settings->get(
'logout_behaviour', LogoutDestinations::LOGOUT_SCREEN->value);
183 if ($mode === ConfigurableLogoutTarget::INTERNAL_RESSOURCE &&
184 !$this->configurable_logout_target->isValidInternalResource(
$ref_id)) {
185 $content .= $this->ui_renderer->render(
186 $this->ui_factory->messageBox()->failure(
187 $this->
lng->txt(
'logout_behaviour_ref_id_valid_status_changed')
191 $content .= $this->ui_renderer->render($this->
getForm());
193 $this->tpl->setContent($content);
199 $form = $form->withRequest($this->
http->request());
200 $section = $form->getInputs()[
'logout_behaviour'];
201 $group = $section->getInputs()[
'logout_behaviour_settings'];
202 $ref_id = $group->getInputs()[ConfigurableLogoutTarget::INTERNAL_RESSOURCE]->getInputs()[
'ref_id'];
203 $url = $group->getInputs()[ConfigurableLogoutTarget::EXTERNAL_RESSOURCE]->getInputs()[
'url'];
205 $data = $form->getData();
206 if (!
$data || $form->getError() ||
$ref_id->getError() ||
$url->getError()) {
209 $errors[
'ref_id'] =
$ref_id->getError();
211 if (
$url->getError()) {
212 $errors[
'url'] =
$url->getError();
214 $this->tpl->setContent($this->ui_renderer->render($this->getForm($this->http->request(), $errors)));
215 $this->tpl->printToStdout();
217 $this->
http->close();
219 if (isset(
$data[
'logout_behaviour'][
'logout_behaviour_settings'][0])) {
220 $mode =
$data[
'logout_behaviour'][
'logout_behaviour_settings'][0];
223 case LogoutDestinations::LOGIN_SCREEN->value:
224 case LogoutDestinations::LOGOUT_SCREEN->value:
227 case ConfigurableLogoutTarget::INTERNAL_RESSOURCE:
229 'logout_behaviour_ref_id',
230 (
string) (
$data[
'logout_behaviour'][
'logout_behaviour_settings'][1][
'ref_id'] ??
'')
233 case ConfigurableLogoutTarget::EXTERNAL_RESSOURCE:
235 $url =
$data[
'logout_behaviour'][
'logout_behaviour_settings'][1][
'url'] ??
'';
236 $this->
settings->set(
'logout_behaviour_url', (
string)
$url);
239 $this->
settings->set(
'logout_behaviour', $mode);
241 $this->
ctrl->redirect($this,
'showForm');
ilGlobalTemplateInterface $tpl
ConfigurableLogoutTarget $configurable_logout_target
ilAuthLogoutBehaviourGUI: ilObjAuthSettingsGUI ilAuthLogoutBehaviourGUI: ilLoginPageGUI ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
getForm(?ServerRequestInterface $request=null, array $errors=[])