ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAuthLogoutBehaviourGUI Class Reference

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

+ Collaboration diagram for ilAuthLogoutBehaviourGUI:

Public Member Functions

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

Private Attributes

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAuthLogoutBehaviourGUI::__construct ( )

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

47 {
48 global $DIC;
49 $this->ctrl = $DIC->ctrl();
50 $this->http = $DIC->http();
51 $this->lng = $DIC->language();
52 $this->refinery = $DIC->refinery();
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');
57 $this->settings = new ilSetting('auth');
58 $this->configurable_logout_target = new ConfigurableLogoutTarget(
59 $this->ctrl,
60 $this->settings,
61 $DIC->access()
62 );
63 }
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 65 of file class.ilAuthLogoutBehaviourGUI.php.

65 : void
66 {
67 $cmd = $this->ctrl->getCmd();
68 if (method_exists($this, $cmd)) {
69 $this->$cmd();
70 }
71 $this->showForm();
72 }

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 74 of file class.ilAuthLogoutBehaviourGUI.php.

77 : StandardForm {
78 $logout_group = $this->ui_factory->input()->field()
79 ->group(
80 [],
81 $this->lng->txt('destination_logout_screen')
82 );
83
84 $login_group = $this->ui_factory->input()->field()
85 ->group(
86 [],
87 $this->lng->txt('destination_login_screen'),
88 $this->lng->txt('destination_login_screen_info')
89 );
90
91 $ref_id = $this->ui_factory->input()->field()
92 ->numeric($this->lng->txt('destination_internal_ressource_ref_id'))
93 ->withAdditionalTransformation(
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)
97 )
98 )
99 ->withAdditionalTransformation(
100 $this->refinery->custom()->constraint(
101 fn($value) => $this->configurable_logout_target->isAnonymousAccessible(
102 $value
103 ),
104 fn(callable $txt, $value) => $txt(
105 'logout_behaviour_ref_id_no_access',
106 $value
107 )
108 )
109 )
110 ->withValue($this->settings->get('logout_behaviour_ref_id', ''));
111 if (isset($errors['ref_id'])) {
112 $ref_id = $ref_id->withError($errors['ref_id']);
113 }
114
115 $internal_group = $this->ui_factory->input()->field()
116 ->group(
117 ['ref_id' => $ref_id],
118 $this->lng->txt('destination_internal_ressource')
119 );
120
121 $url = $this->settings->get('logout_behaviour_url', '');
122 $html = $this->ui_factory->input()->field()
123 ->url($this->lng->txt('destination_external_ressource_url'))
124 ->withAdditionalTransformation(
125 $this->refinery->custom()->constraint(
126 fn($value) => $this->configurable_logout_target->isValidExternalResource(
127 (string) $value
128 ),
129 fn(callable $txt, $value) => $txt('logout_behaviour_invalid_url', $value)
130 )
131 )
132 ->withValue($url);
133 if (isset($errors['url'])) {
134 $html = $html->withError($errors['url']);
135 }
136
137 $external_group = $this->ui_factory->input()->field()
138 ->group(
139 ['url' => $html],
140 $this->lng->txt('destination_external_ressource')
141 );
142
143 $logout_behaviour_switchable_group = $this->ui_factory->input()->field()
144 ->switchableGroup(
145 [
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
150 ],
151 $this->lng->txt('destination_after_logout')
152 )
153 ->withValue(
154 $this->settings->get(
155 'logout_behaviour',
156 LogoutDestinations::LOGOUT_SCREEN->value
157 )
158 );
159
160 $section = $this->ui_factory->input()->field()
161 ->section(
162 ['logout_behaviour_settings' => $logout_behaviour_switchable_group],
163 $this->lng->txt('logout_behaviour_settings')
164 );
165
166 $form = $this->ui_factory->input()->container()->form()
167 ->standard(
168 $this->ctrl->getFormAction($this, 'saveForm'),
169 ['logout_behaviour' => $section]
170 );
171 if ($request) {
172 $form = $form->withRequest($request);
173 }
174
175 return $form;
176 }
$txt
Definition: error.php:31
$ref_id
Definition: ltiauth.php:66
$url
Definition: shib_logout.php:68

References $ref_id.

◆ saveForm()

ilAuthLogoutBehaviourGUI::saveForm ( )

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

196 : void
197 {
198 $form = $this->getForm();
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'];
204
205 $data = $form->getData();
206 if (!$data || $form->getError() || $ref_id->getError() || $url->getError()) {
207 $errors = [];
208 if ($ref_id->getError()) {
209 $errors['ref_id'] = $ref_id->getError();
210 }
211 if ($url->getError()) {
212 $errors['url'] = $url->getError();
213 }
214 $this->tpl->setContent($this->ui_renderer->render($this->getForm($this->http->request(), $errors)));
215 $this->tpl->printToStdout();
216
217 $this->http->close();
218 }
219 if (isset($data['logout_behaviour']['logout_behaviour_settings'][0])) {
220 $mode = $data['logout_behaviour']['logout_behaviour_settings'][0];
221
222 switch ($mode) {
223 case LogoutDestinations::LOGIN_SCREEN->value:
224 case LogoutDestinations::LOGOUT_SCREEN->value:
225 break;
226
227 case ConfigurableLogoutTarget::INTERNAL_RESSOURCE:
228 $this->settings->set(
229 'logout_behaviour_ref_id',
230 (string) ($data['logout_behaviour']['logout_behaviour_settings'][1]['ref_id'] ?? '')
231 );
232 break;
233 case ConfigurableLogoutTarget::EXTERNAL_RESSOURCE:
234
235 $url = $data['logout_behaviour']['logout_behaviour_settings'][1]['url'] ?? '';
236 $this->settings->set('logout_behaviour_url', (string) $url);
237 break;
238 }
239 $this->settings->set('logout_behaviour', $mode);
240 }
241 $this->ctrl->redirect($this, 'showForm');
242 }
getForm(?ServerRequestInterface $request=null, array $errors=[])

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

+ Here is the call graph for this function:

◆ showForm()

ilAuthLogoutBehaviourGUI::showForm ( )

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

178 : void
179 {
180 $mode = $this->settings->get('logout_behaviour', LogoutDestinations::LOGOUT_SCREEN->value);
181 $ref_id = (int) $this->settings->get('logout_behaviour_ref_id', '');
182 $content = '';
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')
188 )
189 );
190 }
191 $content .= $this->ui_renderer->render($this->getForm());
192
193 $this->tpl->setContent($content);
194 }

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 44 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.

◆ $lng

ilLanguage ilAuthLogoutBehaviourGUI::$lng
private

Definition at line 37 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 43 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 42 of file class.ilAuthLogoutBehaviourGUI.php.


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