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

Class ilShibbolethSettingsForm. More...

+ Collaboration diagram for ilShibbolethSettingsForm:

Public Member Functions

 __construct (protected ilShibbolethSettings $settings, protected string $action)
 
 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
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilShibbolethSettingsForm::__construct ( protected ilShibbolethSettings  $settings,
protected string  $action 
)

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

43 {
44 global $DIC;
45 $this->ctrl = $DIC->ctrl();
46 $this->lng = $DIC->language();
47 $this->rbac_review = $DIC->rbac()->review();
48 $this->refinery = $DIC->refinery();
49 $this->renderer = $DIC->ui()->renderer();
50 $this->request = $DIC->http()->request();
51 $this->ui = $DIC->ui()->factory();
52
53 $this->initForm();
54 }
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 226 of file class.ilShibbolethSettingsForm.php.

226 : bool
227 {
228 return $this->form->getData() !== null;
229 }
form( $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 66 of file class.ilShibbolethSettingsForm.php.

66 : string
67 {
68 return $this->renderer->render($this->form);
69 }

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 243 of file class.ilShibbolethSettingsForm.php.

243 : array
244 {
245 $opt = [];
246 foreach ($this->rbac_review->getRolesByFilter($filter) as $role) {
247 $opt[$role['obj_id']] = $role['title'] . ' (' . $role['obj_id'] . ')';
248 }
249
250 return $opt;
251 }

Referenced by initForm().

+ Here is the caller graph for this function:

◆ infoTxt()

ilShibbolethSettingsForm::infoTxt ( string  $var)
protected

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

61 : string
62 {
63 return $this->txt($var . '_info');
64 }

References txt().

+ Here is the call graph for this function:

◆ initForm()

ilShibbolethSettingsForm::initForm ( )

@noRector

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

71 : void
72 {
73 $field = $this->ui->input()->field();
74 $custom_trafo = fn(callable $c): Transformation => $this->refinery->custom()->transformation($c);
76 $active = $field->checkbox($this->txt('shib_active'), $this->lng->txt("auth_shib_instructions"))
77 ->withValue($this->settings->isActive())
78 ->withAdditionalTransformation($custom_trafo(function ($v): void {
79 $this->settings->setActive((bool) $v);
80 }));
81
82 $auth_allow_local = $field->checkbox($this->txt('auth_allow_local'))
83 ->withValue($this->settings->isLocalAuthAllowed())
84 ->withAdditionalTransformation($custom_trafo(function ($v): void {
85 $this->settings->setAllowLocalAuth((bool) $v);
86 }));
87
88 $account_creation = $field->switchableGroup(
89 [
91 [],
92 $this->lng->txt("shib_account_creation_enabled"),
93 $this->lng->txt("shib_account_creation_enabled_info")
94 ),
96 [],
97 $this->lng->txt("shib_account_creation_with_approval"),
98 $this->lng->txt("shib_account_creation_with_approval_info")
99 ),
101 [],
102 $this->lng->txt("shib_account_creation_disabled"),
103 $this->lng->txt("shib_account_creation_disabled_info")
104 )
105 ],
106 $this->lng->txt("shib_account_creation"),
107 $this->lng->txt("shib_account_creation_info")
108 )->withValue(
109 $this->settings->getAccountCreation()
110 )->withRequired(
111 true
112 )->withAdditionalTransformation($custom_trafo(function ($v): void {
113 $this->settings->setAccountCreation((string) $v[0]);
114 }));
115
116 $default_user_role = $field->select($this->txt('shib_user_default_role'), $this->getRoles())
117 ->withRequired(true)
118 ->withValue($this->settings->getDefaultRole())
119 ->withAdditionalTransformation($custom_trafo(function ($v): void {
120 $this->settings->setDefaultRole((int) $v);
121 }));
122
123 $basic_section = $field->section([
124 $active,
125 $auth_allow_local,
126 $account_creation,
127 $default_user_role,
128 ], $this->txt('shib'));
129
130 // Federation
131 $federation_name = $field->text($this->txt('shib_federation_name'))
132 ->withRequired(true)
133 ->withValue($this->settings->getFederationName())
134 ->withAdditionalTransformation($custom_trafo(function ($v): void {
135 $this->settings->setFederationName((string) $v);
136 }));
137
138 $login_type = $field->switchableGroup([
139 'internal_wayf' => $field->group([
140 $field->textarea('', $this->txt('shib_idp_list'))
141 ->withValue($this->settings->getIdPList())
142 ->withAdditionalTransformation($custom_trafo(function ($v): void {
143 $this->settings->setIdPList((string) $v);
144 }))
145 ], $this->txt('shib_login_internal_wayf')),
146 'external_wayf' => $field->group([
147 $field->text('', $this->txt('shib_login_button'))
148 ->withValue($this->settings->getLoginButton())
149 ->withAdditionalTransformation($custom_trafo(function ($v): void {
150 $this->settings->setLoginButton((string) $v);
151 }))
152 ], $this->txt('shib_login_external_wayf')),
153 'embedded_wayf' => $field->group([], $this->txt('shib_login_embedded_wayf'))
154 ->withByline($this->txt('shib_login_embedded_wayf_description')),
155 ], $this->txt('shib_login_type'))
156 ->withRequired(true)
157 ->withValue($this->settings->getOrganisationSelectionType())
158 ->withAdditionalTransformation($custom_trafo(function ($v): void {
159 $this->settings->setOrganisationSelectionType($v[0]);
160 }));
161
162 $instructions = $field->textarea($this->txt('auth_login_instructions'))
163 ->withValue($this->settings->get('login_instructions', ''))
164 ->withAdditionalTransformation($custom_trafo(function ($v): void {
165 $this->settings->set('login_instructions', htmlspecialchars_decode($v));
166 }));
167
168 $data_manipulation = $field->text($this->txt('shib_data_conv'))
169 ->withValue($this->settings->get('data_conv'))
170 ->withAdditionalTransformation($custom_trafo(function ($v): void {
171 $this->settings->set('data_conv', (string) $v);
172 }));
173
174 $federation_section = $field->section([
175 $federation_name,
176 $login_type,
177 $instructions,
178 $data_manipulation
179 ], '');
180
181 // User Fields
182 $fields = [];
183 $fields[] = $field->text($this->txt('shib_login'))
184 ->withValue($this->settings->get('shib_login'))
185 ->withRequired(true)
186 ->withAdditionalTransformation($custom_trafo(function ($v): void {
187 $this->settings->set('shib_login', (string) $v);
188 }));
189 foreach ($this->settings->getUserFields() as $field_name => $required) {
190 $fields[] = $field->text($this->txt($field_name))
191 ->withValue($this->settings->get($field_name))
192 ->withRequired($required)
193 ->withAdditionalTransformation($custom_trafo(function ($v) use ($field_name): void {
194 $this->settings->set($field_name, (string) $v);
195 }));
196 $fields[] = $field->checkbox($this->txt('shib_update'))
197 ->withValue((bool) $this->settings->get('update_' . $field_name))
198 ->withAdditionalTransformation($custom_trafo(function ($v) use ($field_name): void {
199 $this->settings->set('update_' . $field_name, (string) $v);
200 }));
201 }
202
203 $user_fields = $field->section(
204 $fields,
205 ''
206 );
207
208 // COMPLETE FORM
209
210 $this->form = $this->ui->input()->container()->form()->standard(
211 $this->action,
212 [
213 $basic_section,
214 $federation_section,
215 $user_fields
216 ]
217 );
218 }
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\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 231 of file class.ilShibbolethSettingsForm.php.

231 : bool
232 {
233 if (!$this->fillObject()) {
234 return false;
235 }
236 $this->settings->store();
237 return true;
238 }

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

+ Here is the call graph for this function:

◆ setValuesByPost()

ilShibbolethSettingsForm::setValuesByPost ( )

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

220 : void
221 {
222 $request = $this->request->withParsedBody(array_map('htmlspecialchars', $this->request->getParsedBody()));
223 $this->form = $this->form->withRequest($request);
224 }

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

+ Here is the call graph for this function:

◆ txt()

ilShibbolethSettingsForm::txt ( string  $var)
protected

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

56 : string
57 {
58 return $this->lng->txt($var);
59 }

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.

◆ $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: