ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilShibbolethSettingsForm Class Reference

Class ilShibbolethSettingsForm. More...

+ Collaboration diagram for ilShibbolethSettingsForm:

Public Member Functions

 __construct (ilShibbolethSettings $settings, 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

string $action
 
ilCtrl $ctrl
 
StandardForm $form = null
 
ilLanguage $lng
 
ilRbacReview $rbac_review
 
Refinery $refinery
 
Renderer $renderer
 
RequestInterface $request
 
ilShibbolethSettings $settings
 
UIFactory $ui
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

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

44  {
45  global $DIC;
46 
47  $this->action = $action;
48  $this->ctrl = $DIC->ctrl();
49  $this->lng = $DIC->language();
50  $this->rbac_review = $DIC->rbac()->review();
51  $this->refinery = $DIC->refinery();
52  $this->renderer = $DIC->ui()->renderer();
53  $this->request = $DIC->http()->request();
54  $this->settings = $settings;
55  $this->ui = $DIC->ui()->factory();
56 
57  $this->initForm();
58  }
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ fillObject()

ilShibbolethSettingsForm::fillObject ( )
protected

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

References ILIAS\Repository\form().

Referenced by saveObject().

230  : bool
231  {
232  return $this->form->getData() !== null;
233  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilShibbolethSettingsForm::getHTML ( )

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

References ILIAS\Repository\form().

70  : string
71  {
72  return $this->renderer->render($this->form);
73  }
form( $class_path, string $cmd, string $submit_caption="")
+ 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 247 of file class.ilShibbolethSettingsForm.php.

Referenced by initForm().

247  : array
248  {
249  $opt = [];
250  foreach ($this->rbac_review->getRolesByFilter($filter) as $role) {
251  $opt[$role['obj_id']] = $role['title'] . ' (' . $role['obj_id'] . ')';
252  }
253 
254  return $opt;
255  }
+ Here is the caller graph for this function:

◆ infoTxt()

ilShibbolethSettingsForm::infoTxt ( string  $var)
protected

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

References txt().

65  : string
66  {
67  return $this->txt($var . '_info');
68  }
+ Here is the call graph for this function:

◆ initForm()

ilShibbolethSettingsForm::initForm ( )

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

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(), ILIAS\Repository\ui(), ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by __construct().

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

◆ saveObject()

ilShibbolethSettingsForm::saveObject ( )

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

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

235  : bool
236  {
237  if (!$this->fillObject()) {
238  return false;
239  }
240  $this->settings->store();
241  return true;
242  }
+ Here is the call graph for this function:

◆ setValuesByPost()

ilShibbolethSettingsForm::setValuesByPost ( )

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

References ILIAS\Repository\form().

224  : void
225  {
226  $request = $this->request->withParsedBody(array_map('htmlspecialchars', $this->request->getParsedBody()));
227  $this->form = $this->form->withRequest($request);
228  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ txt()

ilShibbolethSettingsForm::txt ( string  $var)
protected

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

References ILIAS\Repository\lng().

Referenced by infoTxt(), and initForm().

60  : string
61  {
62  return $this->lng->txt($var);
63  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $action

string ilShibbolethSettingsForm::$action
protected

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

Referenced by __construct().

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

◆ $settings

ilShibbolethSettings ilShibbolethSettingsForm::$settings
protected

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

Referenced by __construct().

◆ $ui

UIFactory ilShibbolethSettingsForm::$ui
protected

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


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