ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilShibbolethSettingsForm Class Reference

Class ilShibbolethSettingsForm. More...

+ Collaboration diagram for ilShibbolethSettingsForm:

Public Member Functions

 __construct (private readonly int $ref_id, private readonly object $parentObject, protected ilShibbolethSettings $settings, protected readonly string $action, protected readonly string $show_command='')
 
 getHTML ()
 
 initForm ()
 
 setValuesByPost ()
 
 saveObject ()
 

Protected Member Functions

 txt (string $var)
 
 infoTxt (string $var)
 
 fillObject ()
 
 getRoles (int $filter=ilRbacReview::FILTER_ALL_GLOBAL)
 

Protected Attributes

ilCtrl $ctrl
 
StandardForm $form = null
 
ilLanguage $lng
 
ilRbacReview $rbac_review
 
Refinery $refinery
 
Renderer $renderer
 
RequestInterface $request
 
UIFactory $ui
 
ilRbacSystem $rbac_system
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilShibbolethSettingsForm::__construct ( private readonly int  $ref_id,
private readonly object  $parentObject,
protected ilShibbolethSettings  $settings,
protected readonly string  $action,
protected readonly string  $show_command = '' 
)

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

49 {
50 global $DIC;
51 $this->ctrl = $DIC->ctrl();
52 $this->lng = $DIC->language();
53 $this->rbac_review = $DIC->rbac()->review();
54 $this->refinery = $DIC->refinery();
55 $this->renderer = $DIC->ui()->renderer();
56 $this->request = $DIC->http()->request();
57 $this->ui = $DIC->ui()->factory();
58 $this->rbac_system = $DIC->rbac()->system();
59
60 $this->initForm();
61 }
renderer()
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), initForm(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), renderer(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

Member Function Documentation

◆ fillObject()

ilShibbolethSettingsForm::fillObject ( )
protected

Definition at line 243 of file class.ilShibbolethSettingsForm.php.

243 : bool
244 {
245 return $this->form->getData() !== null;
246 }
form(?array $class_path, string $cmd, string $submit_caption="")

References ILIAS\Repository\form().

Referenced by saveObject().

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

◆ getHTML()

ilShibbolethSettingsForm::getHTML ( )

Definition at line 73 of file class.ilShibbolethSettingsForm.php.

73 : string
74 {
75 return $this->renderer->render($this->form);
76 }

References ILIAS\Repository\form(), and renderer().

+ Here is the call graph for this function:

◆ getRoles()

ilShibbolethSettingsForm::getRoles ( int  $filter = ilRbacReview::FILTER_ALL_GLOBAL)
protected
Returns
array<int|string, string>

Definition at line 260 of file class.ilShibbolethSettingsForm.php.

260 : array
261 {
262 $opt = [];
263 foreach ($this->rbac_review->getRolesByFilter($filter) as $role) {
264 $opt[$role['obj_id']] = $role['title'] . ' (' . $role['obj_id'] . ')';
265 }
266
267 return $opt;
268 }

Referenced by initForm().

+ Here is the caller graph for this function:

◆ infoTxt()

ilShibbolethSettingsForm::infoTxt ( string  $var)
protected

Definition at line 68 of file class.ilShibbolethSettingsForm.php.

68 : string
69 {
70 return $this->txt($var . '_info');
71 }

References txt().

+ Here is the call graph for this function:

◆ initForm()

ilShibbolethSettingsForm::initForm ( )

@noRector

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

78 : void
79 {
80 $field = $this->ui->input()->field();
81 $custom_trafo = fn(callable $c): Transformation => $this->refinery->custom()->transformation($c);
83 $active = $field->checkbox($this->txt('shib_active'), $this->lng->txt("auth_shib_instructions"))
84 ->withValue($this->settings->isActive())
85 ->withAdditionalTransformation($custom_trafo(function ($v): void {
86 $this->settings->setActive((bool) $v);
87 }));
88
89 $auth_allow_local = $field->checkbox($this->txt('auth_allow_local'))
90 ->withValue($this->settings->isLocalAuthAllowed())
91 ->withAdditionalTransformation($custom_trafo(function ($v): void {
92 $this->settings->setAllowLocalAuth((bool) $v);
93 }));
94
95 $account_creation = $field->switchableGroup(
96 [
98 [],
99 $this->lng->txt("shib_account_creation_enabled"),
100 $this->lng->txt("shib_account_creation_enabled_info")
101 ),
103 [],
104 $this->lng->txt("shib_account_creation_with_approval"),
105 $this->lng->txt("shib_account_creation_with_approval_info")
106 ),
108 [],
109 $this->lng->txt("shib_account_creation_disabled"),
110 $this->lng->txt("shib_account_creation_disabled_info")
111 )
112 ],
113 $this->lng->txt("shib_account_creation"),
114 $this->lng->txt("shib_account_creation_info")
115 )->withValue(
116 $this->settings->getAccountCreation()
117 )->withRequired(
118 true
119 )->withAdditionalTransformation($custom_trafo(function ($v): void {
120 $this->settings->setAccountCreation((string) $v[0]);
121 }));
122
123 $default_user_role = $field->select($this->txt('shib_user_default_role'), $this->getRoles())
124 ->withRequired(true)
125 ->withValue($this->settings->getDefaultRole())
126 ->withAdditionalTransformation($custom_trafo(function ($v): void {
127 $this->settings->setDefaultRole((int) $v);
128 }));
129
130 $basic_section = $field->section([
131 $active,
132 $auth_allow_local,
133 $account_creation,
134 $default_user_role,
135 ], $this->txt('shib'));
136
137 // Federation
138 $federation_name = $field->text($this->txt('shib_federation_name'))
139 ->withRequired(true)
140 ->withValue($this->settings->getFederationName())
141 ->withAdditionalTransformation($custom_trafo(function ($v): void {
142 $this->settings->setFederationName((string) $v);
143 }));
144
145 $login_type = $field->switchableGroup([
146 'internal_wayf' => $field->group([
147 $field->textarea('', $this->txt('shib_idp_list'))
148 ->withValue($this->settings->getIdPList())
149 ->withAdditionalTransformation($custom_trafo(function ($v): void {
150 $this->settings->setIdPList((string) $v);
151 }))
152 ], $this->txt('shib_login_internal_wayf')),
153 'external_wayf' => $field->group([
154 $field->text('', $this->txt('shib_login_button'))
155 ->withValue($this->settings->getLoginButton())
156 ->withAdditionalTransformation($custom_trafo(function ($v): void {
157 $this->settings->setLoginButton((string) $v);
158 }))
159 ], $this->txt('shib_login_external_wayf')),
160 'embedded_wayf' => $field->group([], $this->txt('shib_login_embedded_wayf'))
161 ->withByline($this->txt('shib_login_embedded_wayf_description')),
162 ], $this->txt('shib_login_type'))
163 ->withRequired(true)
164 ->withValue($this->settings->getOrganisationSelectionType())
165 ->withAdditionalTransformation($custom_trafo(function ($v): void {
166 $this->settings->setOrganisationSelectionType($v[0]);
167 }));
168
169 $instructions = $field->textarea($this->txt('auth_login_instructions'))
170 ->withValue($this->settings->get('login_instructions', ''))
171 ->withAdditionalTransformation($custom_trafo(function ($v): void {
172 $this->settings->set('login_instructions', htmlspecialchars_decode($v));
173 }));
174
175 $data_manipulation = $field->text($this->txt('shib_data_conv'))
176 ->withValue($this->settings->get('data_conv'))
177 ->withAdditionalTransformation($custom_trafo(function ($v): void {
178 $this->settings->set('data_conv', (string) $v);
179 }));
180
181 $federation_section = $field->section([
182 $federation_name,
183 $login_type,
184 $instructions,
185 $data_manipulation
186 ], '');
187
188 // User Fields
189 $fields = [];
190 $fields[] = $field->text($this->txt('shib_login'))
191 ->withValue($this->settings->get('shib_login'))
192 ->withRequired(true)
193 ->withAdditionalTransformation($custom_trafo(function ($v): void {
194 $this->settings->set('shib_login', (string) $v);
195 }));
196 foreach ($this->settings->getUserFields() as $field_name => $required) {
197 $fields[] = $field->text($this->txt($field_name))
198 ->withValue($this->settings->get($field_name))
199 ->withRequired($required)
200 ->withAdditionalTransformation($custom_trafo(function ($v) use ($field_name): void {
201 $this->settings->set($field_name, (string) $v);
202 }));
203 $fields[] = $field->checkbox($this->txt('shib_update'))
204 ->withValue((bool) $this->settings->get('update_' . $field_name))
205 ->withAdditionalTransformation($custom_trafo(function ($v) use ($field_name): void {
206 $this->settings->set('update_' . $field_name, (string) $v);
207 }));
208 }
209
210 $user_fields = $field->section(
211 $fields,
212 ''
213 );
214
215 // COMPLETE FORM
216 $access = $this->rbac_system->checkAccess('write', $this->ref_id);
217 if (!$access) {
218 $basic_section = $basic_section->withDisabled(true);
219 $federation_section = $federation_section->withDisabled(true);
220 $user_fields = $user_fields->withDisabled(true);
221 }
222
223 $this->form = $this->ui->input()->container()->form()->standard(
224 $this->ctrl->getFormAction($this->parentObject, $access ? $this->action : $this->show_command),
225 [
226 $basic_section,
227 $federation_section,
228 $user_fields
229 ]
230 );
231
232 if (!$access) {
233 $this->form = $this->form->withSubmitLabel($this->lng->txt('refresh'));
234 }
235 }
getRoles(int $filter=ilRbacReview::FILTER_ALL_GLOBAL)
$c
Definition: deliver.php:25
A transformation is a function from one datatype to another.

References $c, ilShibbolethSettings\ACCOUNT_CREATION_DISABLED, ilShibbolethSettings\ACCOUNT_CREATION_ENABLED, ilShibbolethSettings\ACCOUNT_CREATION_WITH_APPROVAL, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), getRoles(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\settings(), txt(), and ILIAS\Repository\ui().

Referenced by __construct().

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

◆ saveObject()

ilShibbolethSettingsForm::saveObject ( )

Definition at line 248 of file class.ilShibbolethSettingsForm.php.

248 : bool
249 {
250 if (!$this->fillObject()) {
251 return false;
252 }
253 $this->settings->store();
254 return true;
255 }

References fillObject(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ setValuesByPost()

ilShibbolethSettingsForm::setValuesByPost ( )

Definition at line 237 of file class.ilShibbolethSettingsForm.php.

237 : void
238 {
239 $request = $this->request->withParsedBody(array_map('htmlspecialchars', $this->request->getParsedBody()));
240 $this->form = $this->form->withRequest($request);
241 }

References $request, and ILIAS\Repository\form().

+ Here is the call graph for this function:

◆ txt()

ilShibbolethSettingsForm::txt ( string  $var)
protected

Definition at line 63 of file class.ilShibbolethSettingsForm.php.

63 : string
64 {
65 return $this->lng->txt($var);
66 }

References ILIAS\Repository\lng().

Referenced by infoTxt(), and initForm().

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

Field Documentation

◆ $ctrl

ilCtrl ilShibbolethSettingsForm::$ctrl
protected

Definition at line 33 of file class.ilShibbolethSettingsForm.php.

◆ $form

StandardForm ilShibbolethSettingsForm::$form = null
protected

Definition at line 34 of file class.ilShibbolethSettingsForm.php.

◆ $lng

ilLanguage ilShibbolethSettingsForm::$lng
protected

Definition at line 35 of file class.ilShibbolethSettingsForm.php.

◆ $rbac_review

ilRbacReview ilShibbolethSettingsForm::$rbac_review
protected

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

◆ $rbac_system

ilRbacSystem ilShibbolethSettingsForm::$rbac_system
protected

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

◆ $refinery

Refinery ilShibbolethSettingsForm::$refinery
protected

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

◆ $renderer

Renderer ilShibbolethSettingsForm::$renderer
protected

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

◆ $request

RequestInterface ilShibbolethSettingsForm::$request
protected

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

Referenced by setValuesByPost().

◆ $ui

UIFactory ilShibbolethSettingsForm::$ui
protected

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


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