19declare(strict_types=1);
25use Psr\Http\Message\ServerRequestInterface;
51 $this->
ctrl = $DIC->ctrl();
52 $this->
http = $DIC->http();
53 $this->
lng = $DIC->language();
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');
71 $cmd = $this->
ctrl->getCmd();
72 if (method_exists($this, $cmd)) {
79 ?ServerRequestInterface $request =
null,
82 $logout_group = $this->ui_factory->input()->field()
85 $this->
lng->txt(
'destination_logout_screen')
88 $login_group = $this->ui_factory->input()->field()
91 $this->
lng->txt(
'destination_login_screen'),
92 $this->lng->txt(
'destination_login_screen_info')
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)
103 ->withAdditionalTransformation(
104 $this->
refinery->custom()->constraint(
105 fn($value) => $this->configurable_logout_target->isAnonymousAccessible(
108 fn(callable $txt, $value) => $txt(
109 'logout_behaviour_ref_id_no_access',
114 ->withValue($this->
settings->get(
'logout_behaviour_ref_id',
''));
115 if (isset($errors[
'ref_id'])) {
119 $internal_group = $this->ui_factory->input()->field()
122 $this->
lng->txt(
'destination_internal_ressource')
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(
133 fn(callable $txt, $value) => $txt(
'logout_behaviour_invalid_url', $value)
137 if (isset($errors[
'url'])) {
138 $html = $html->withError($errors[
'url']);
141 $external_group = $this->ui_factory->input()->field()
144 $this->
lng->txt(
'destination_external_ressource')
147 $logout_behaviour_switchable_group = $this->ui_factory->input()->field()
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
155 $this->
lng->txt(
'destination_after_logout')
160 LogoutDestinations::LOGOUT_SCREEN->value
164 $access = $this->rbac_system->checkAccess(
'write', $this->ref_id);
166 $logout_behaviour_switchable_group = $logout_behaviour_switchable_group->withDisabled(
true);
169 $section = $this->ui_factory->input()->field()
171 [
'logout_behaviour_settings' => $logout_behaviour_switchable_group],
172 $this->
lng->txt(
'logout_behaviour_settings')
175 $form = $this->ui_factory->input()->container()->form()
178 $this->
ctrl->getFormAction($this,
'saveForm') :
179 $this->ctrl->getFormAction($this,
'showForm'),
180 [
'logout_behaviour' => $section]
183 $form = $form->withRequest($request);
187 $form = $form->withSubmitLabel($this->
lng->txt(
'refresh'));
195 $mode = $this->
settings->get(
'logout_behaviour', LogoutDestinations::LOGOUT_SCREEN->value);
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')
206 $content .= $this->ui_renderer->render($this->getForm());
208 $this->tpl->setContent($content);
213 if (!$this->rbac_system->checkAccess(
'write', $this->ref_id)) {
214 $this->ilErr->raiseError($this->
lng->txt(
'permission_denied'), $this->ilErr->WARNING);
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'];
225 $data = $form->getData();
226 if (!
$data || $form->getError() ||
$ref_id->getError() ||
$url->getError()) {
229 $errors[
'ref_id'] =
$ref_id->getError();
231 if (
$url->getError()) {
232 $errors[
'url'] =
$url->getError();
234 $this->tpl->setContent($this->ui_renderer->render($this->getForm($this->http->request(), $errors)));
235 $this->tpl->printToStdout();
237 $this->
http->close();
239 if (isset(
$data[
'logout_behaviour'][
'logout_behaviour_settings'][0])) {
240 $mode =
$data[
'logout_behaviour'][
'logout_behaviour_settings'][0];
243 case LogoutDestinations::LOGIN_SCREEN->value:
244 case LogoutDestinations::LOGOUT_SCREEN->value:
247 case ConfigurableLogoutTarget::INTERNAL_RESSOURCE:
249 'logout_behaviour_ref_id',
250 (
string) (
$data[
'logout_behaviour'][
'logout_behaviour_settings'][1][
'ref_id'] ??
'')
253 case ConfigurableLogoutTarget::EXTERNAL_RESSOURCE:
255 $url =
$data[
'logout_behaviour'][
'logout_behaviour_settings'][1][
'url'] ??
'';
256 $this->
settings->set(
'logout_behaviour_url', (
string)
$url);
259 $this->
settings->set(
'logout_behaviour', $mode);
261 $this->
ctrl->redirect($this,
'showForm');
Builds a Color from either hex- or rgb values.
@ilCtrl_isCalledBy ilAuthLogoutBehaviourGUI: ilObjAuthSettingsGUI @ilCtrl_Calls ilAuthLogoutBehaviour...
ilRbacSystem $rbac_system
getForm(?ServerRequestInterface $request=null, array $errors=[])
__construct(private readonly int $ref_id)
ilGlobalTemplateInterface $tpl
ConfigurableLogoutTarget $configurable_logout_target
Class ilCtrl provides processing control methods.
Error Handling & global info handling.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.