ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjCmiXapiAdministrationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
33 {
34  public const TAB_ID_LRS_TYPES = 'tab_lrs_types';
35  public const TAB_ID_PERMISSIONS = 'perm_settings';
36 
37  public const CMD_SHOW_LRS_TYPES_LIST = 'showLrsTypesList';
38  public const CMD_SHOW_LRS_TYPE_FORM = 'showLrsTypeForm';
39  public const CMD_SAVE_LRS_TYPE_FORM = 'saveLrsTypeForm';
40 
41  public const DEFAULT_CMD = self::CMD_SHOW_LRS_TYPES_LIST;
42 
43  public function getAdminTabs(): void
44  {
45  // lrs types tab
46 
47  $this->tabs_gui->addTab(
48  self::TAB_ID_LRS_TYPES,
49  $this->lng->txt(self::TAB_ID_LRS_TYPES),
50  $this->ctrl->getLinkTargetByClass(self::class)
51  );
52 
53  // permissions tab
54 
55  $this->tabs_gui->addTab(
56  self::TAB_ID_PERMISSIONS,
57  $this->lng->txt(self::TAB_ID_PERMISSIONS),
58  $this->ctrl->getLinkTargetByClass(ilPermissionGUI::class, 'perm')
59  );
60  }
61 
62  public function executeCommand(): void
63  {
64  $this->lng->loadLanguageModule('cmix');
65 
66  $this->prepareOutput();
67 
68  switch ($this->ctrl->getNextClass()) {
69  case 'ilpermissiongui':
70 
71  $this->tabs_gui->activateTab(self::TAB_ID_PERMISSIONS);
72  $gui = new ilPermissionGUI($this);
73  $this->ctrl->forwardCommand($gui);
74  break;
75 
76  default:
77 
78  $command = $this->ctrl->getCmd(self::DEFAULT_CMD) . 'Cmd';
79  $this->{$command}();
80  }
81  }
82 
83  protected function viewCmd(): void
84  {
85  $this->showLrsTypesListCmd();
86  }
87 
88  protected function showLrsTypesListCmd(): void
89  {
90  $this->tabs_gui->activateTab(self::TAB_ID_LRS_TYPES);
91 
93 
94  $table = $this->buildLrsTypesTableGUI();
95 
96  $table->setData(ilCmiXapiLrsTypeList::getTypesData(true));
97  $this->tpl->setContent($toolbar->getHTML() . $table->getHTML());
98  }
99 
101  {
102  return new ilCmiXapiLrsTypesTableGUI($this, self::CMD_SHOW_LRS_TYPES_LIST);
103  }
104 
105  protected function buildLrsTypesToolbarGUI(): \ilToolbarGUI
106  {
107  //todo
108  $createTypeButton = ilLinkButton::getInstance();
109  $createTypeButton->setCaption('btn_create_lrs_type');
110  $createTypeButton->setUrl($this->ctrl->getLinkTarget($this, self::CMD_SHOW_LRS_TYPE_FORM));
111 
112  $toolbar = new ilToolbarGUI();
113  $toolbar->addButtonInstance($createTypeButton);
114 
115  return $toolbar;
116  }
117 
118  protected function showLrsTypeFormCmd(ilPropertyFormGUI $form = null): void
119  {
120  $this->tabs_gui->activateTab(self::TAB_ID_LRS_TYPES);
121 
122  if ($form === null) {
123  $lrsType = $this->initLrsType();
124 
125  $form = $this->buildLrsTypeForm($lrsType);
126  }
127 
128  $this->tpl->setContent($form->getHTML());
129  }
130 
131  protected function initLrsType(): \ilCmiXapiLrsType
132  {
133  if ($this->post_wrapper->has('lrs_type_id')) {
134  if (is_int($this->post_wrapper->retrieve('lrs_type_id', $this->refinery->kindlyTo()->int()))) {
135  return new ilCmiXapiLrsType($this->post_wrapper->retrieve('lrs_type_id', $this->refinery->kindlyTo()->int()));
136  }
137  }
138 
139  if ($this->request_wrapper->has('lrs_type_id')) {
140  if (is_int($this->request_wrapper->retrieve('lrs_type_id', $this->refinery->kindlyTo()->int()))) {
141  return new ilCmiXapiLrsType($this->request_wrapper->retrieve('lrs_type_id', $this->refinery->kindlyTo()->int()));
142  }
143  }
144 
145  return new ilCmiXapiLrsType();
146  }
147 
148  protected function buildLrsTypeForm(ilCmiXapiLrsType $lrsType): \ilPropertyFormGUI
149  {
150  global $DIC; /* @var \ILIAS\DI\Container $DIC */
151 
152  $form = new ilPropertyFormGUI();
153  $form->setFormAction($DIC->ctrl()->getFormAction($this));
154 
155  if ($lrsType->getTypeId()) {
156  $form->setTitle($DIC->language()->txt('edit_lrs_type_form'));
157  $form->addCommandButton(self::CMD_SAVE_LRS_TYPE_FORM, $DIC->language()->txt('save'));
158  } else {
159  $form->setTitle($DIC->language()->txt('create_lrs_type_form'));
160  $form->addCommandButton(self::CMD_SAVE_LRS_TYPE_FORM, $DIC->language()->txt('create'));
161  }
162 
163  $form->addCommandButton(self::CMD_SHOW_LRS_TYPES_LIST, $DIC->language()->txt('cancel'));
164 
165  $hiddenId = new ilHiddenInputGUI('lrs_type_id');
166  $hiddenId->setValue((string) $lrsType->getTypeId());
167  $form->addItem($hiddenId);
168 
169 
170  $item = new ilTextInputGUI($DIC->language()->txt('conf_title'), 'title');
171  $item->setValue($lrsType->getTitle());
172  $item->setInfo($DIC->language()->txt('info_title'));
173  $item->setRequired(true);
174  $item->setMaxLength(255);
175  $form->addItem($item);
176 
177  $item = new ilTextInputGUI($DIC->language()->txt('conf_description'), 'description');
178  $item->setValue($lrsType->getDescription());
179  $item->setInfo($DIC->language()->txt('info_description'));
180  $form->addItem($item);
181 
182  $item = new ilRadioGroupInputGUI($DIC->language()->txt('conf_availability'), 'availability');
183  $optionCreate = new ilRadioOption(
184  $DIC->language()->txt('conf_availability_' . ilCmiXapiLrsType::AVAILABILITY_CREATE),
186  );
187  $item->addOption($optionCreate);
188  $optionCreate = new ilRadioOption(
189  $DIC->language()->txt('conf_availability_' . ilCmiXapiLrsType::AVAILABILITY_EXISTING),
191  );
192  $item->addOption($optionCreate);
193  $optionCreate = new ilRadioOption(
194  $DIC->language()->txt('conf_availability_' . ilCmiXapiLrsType::AVAILABILITY_NONE),
196  );
197  $item->addOption($optionCreate);
198  $item->setValue((string) $lrsType->getAvailability());
199  $item->setInfo($DIC->language()->txt('info_availability'));
200  $item->setRequired(true);
201  $form->addItem($item);
202 
203  $sectionHeader = new ilFormSectionHeaderGUI();
204  $sectionHeader->setTitle($DIC->language()->txt('lrs_authentication'));
205  $form->addItem($sectionHeader);
206 
207  $item = new ilTextInputGUI($DIC->language()->txt('conf_lrs_endpoint'), 'lrs_endpoint');
208  $item->setValue($lrsType->getLrsEndpoint());
209  $item->setInfo($DIC->language()->txt('info_lrs_endpoint'));
210  $item->setRequired(true);
211  $item->setMaxLength(255);
212  $form->addItem($item);
213 
214  $item = new ilTextInputGUI($DIC->language()->txt('conf_lrs_key'), 'lrs_key');
215  $item->setValue($lrsType->getLrsKey());
216  $item->setInfo($DIC->language()->txt('info_lrs_key'));
217  $item->setRequired(true);
218  $item->setMaxLength(128);
219  $form->addItem($item);
220 
221  $item = new ilTextInputGUI($DIC->language()->txt('conf_lrs_secret'), 'lrs_secret');
222  $item->setValue($lrsType->getLrsSecret());
223  $item->setInfo($DIC->language()->txt('info_lrs_secret'));
224  $item->setRequired(true);
225  $item->setMaxLength(128);
226  $form->addItem($item);
227 
228  $sectionHeader = new ilFormSectionHeaderGUI();
229  $sectionHeader->setTitle($DIC->language()->txt('sect_learning_progress_options'));
230  $form->addItem($sectionHeader);
231 
232  $cronjob = new ilCheckboxInputGUI($DIC->language()->txt('conf_cronjob_neccessary'), 'cronjob_neccessary');
233  $cronjob->setInfo($DIC->language()->txt('conf_cronjob_neccessary_info'));
234  $cronjob->setChecked($lrsType->isBypassProxyEnabled());
235  $form->addItem($cronjob);
236 
237  $sectionHeader = new ilFormSectionHeaderGUI();
238  $sectionHeader->setTitle('Privacy Settings');
239  $form->addItem($sectionHeader);
240 
241  $item = new ilRadioGroupInputGUI($DIC->language()->txt('conf_privacy_ident'), 'privacy_ident');
242  $op = new ilRadioOption(
243  $DIC->language()->txt('conf_privacy_ident_il_uuid_user_id'),
245  );
246  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_user_id_info'));
247  $item->addOption($op);
248  $op = new ilRadioOption(
249  $DIC->language()->txt('conf_privacy_ident_il_uuid_login'),
251  );
252  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_login_info'));
253  $item->addOption($op);
254  $op = new ilRadioOption(
255  $DIC->language()->txt('conf_privacy_ident_il_uuid_ext_account'),
257  );
258  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_ext_account_info'));
259  $item->addOption($op);
260  $op = new ilRadioOption(
261  $DIC->language()->txt('conf_privacy_ident_il_uuid_sha256'),
263  );
264  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_sha256_info'));
265  $item->addOption($op);
266  $op = new ilRadioOption(
267  $DIC->language()->txt('conf_privacy_ident_il_uuid_sha256url'),
269  );
270  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_sha256url_info'));
271  $item->addOption($op);
272 
273  $op = new ilRadioOption(
274  $DIC->language()->txt('conf_privacy_ident_il_uuid_random'),
276  );
277  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_random_info'));
278  $item->addOption($op);
279  $op = new ilRadioOption(
280  $DIC->language()->txt('conf_privacy_ident_real_email'),
282  );
283  $op->setInfo($DIC->language()->txt('conf_privacy_ident_real_email_info'));
284  $item->addOption($op);
285  $item->setValue((string) $lrsType->getPrivacyIdent());
286  $item->setInfo(
287  $DIC->language()->txt('conf_privacy_ident_info') . ' ' . ilCmiXapiUser::getIliasUuid()
288  );
289  $item->setRequired(false);
290  $form->addItem($item);
291 
292  $item = new ilRadioGroupInputGUI($DIC->language()->txt('conf_privacy_name'), 'privacy_name');
293  $op = new ilRadioOption(
294  $DIC->language()->txt('conf_privacy_name_none'),
296  );
297  $op->setInfo($DIC->language()->txt('conf_privacy_name_none_info'));
298  $item->addOption($op);
299  $op = new ilRadioOption(
300  $DIC->language()->txt('conf_privacy_name_firstname'),
302  );
303  $op->setInfo($DIC->language()->txt('conf_privacy_name_firstname_info'));
304  $item->addOption($op);
305  $op = new ilRadioOption(
306  $DIC->language()->txt('conf_privacy_name_lastname'),
308  );
309  $op->setInfo($DIC->language()->txt('conf_privacy_name_lastname_info'));
310  $item->addOption($op);
311  $op = new ilRadioOption(
312  $DIC->language()->txt('conf_privacy_name_fullname'),
314  );
315  $op->setInfo($DIC->language()->txt('conf_privacy_name_fullname_info'));
316  $item->addOption($op);
317  $item->setValue((string) $lrsType->getPrivacyName());
318  $item->setInfo($DIC->language()->txt('conf_privacy_name_info'));
319  $item->setRequired(false);
320  $form->addItem($item);
321 
322  $item = new ilCheckboxInputGUI($DIC->language()->txt('only_moveon_label'), 'only_moveon');
323  $item->setInfo($DIC->language()->txt('only_moveon_info'));
324  $item->setChecked($lrsType->getOnlyMoveon());
325 
326  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('achieved_label'), 'achieved');
327  $subitem->setInfo($DIC->language()->txt('achieved_info'));
328  $subitem->setChecked($lrsType->getAchieved());
329  $item->addSubItem($subitem);
330 
331  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('answered_label'), 'answered');
332  $subitem->setInfo($DIC->language()->txt('answered_info'));
333  $subitem->setChecked($lrsType->getAnswered());
334  $item->addSubItem($subitem);
335 
336  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('completed_label'), 'completed');
337  $subitem->setInfo($DIC->language()->txt('completed_info'));
338  $subitem->setChecked($lrsType->getCompleted());
339  $item->addSubItem($subitem);
340 
341  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('failed_label'), 'failed');
342  $subitem->setInfo($DIC->language()->txt('failed_info'));
343  $subitem->setChecked($lrsType->getFailed());
344  $item->addSubItem($subitem);
345 
346  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('initialized_label'), 'initialized');
347  $subitem->setInfo($DIC->language()->txt('initialized_info'));
348  $subitem->setChecked($lrsType->getInitialized());
349  $item->addSubItem($subitem);
350 
351  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('passed_label'), 'passed');
352  $subitem->setInfo($DIC->language()->txt('passed_info'));
353  $subitem->setChecked($lrsType->getPassed());
354  $item->addSubItem($subitem);
355 
356  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('progressed_label'), 'progressed');
357  $subitem->setInfo($DIC->language()->txt('progressed_info'));
358  $subitem->setChecked($lrsType->getProgressed());
359  $item->addSubItem($subitem);
360 
361  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('satisfied_label'), 'satisfied');
362  $subitem->setInfo($DIC->language()->txt('satisfied_info'));
363  $subitem->setChecked($lrsType->getSatisfied());
364  $item->addSubItem($subitem);
365 
366  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('terminated_label'), 'terminated');
367  $subitem->setInfo($DIC->language()->txt('terminated_info'));
368  $subitem->setChecked($lrsType->getTerminated());
369  $item->addSubItem($subitem);
370 
371  $form->addItem($item);
372 
373  $item = new ilCheckboxInputGUI($DIC->language()->txt('hide_data_label'), 'hide_data');
374  $item->setInfo($DIC->language()->txt('hide_data_info'));
375  $item->setChecked($lrsType->getHideData());
376 
377  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('timestamp_label'), 'timestamp');
378  $subitem->setInfo($DIC->language()->txt('timestamp_info'));
379  $subitem->setChecked($lrsType->getTimestamp());
380  $item->addSubItem($subitem);
381 
382  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('duration_label'), 'duration');
383  $subitem->setInfo($DIC->language()->txt('duration_info'));
384  $subitem->setChecked($lrsType->getDuration());
385  $item->addSubItem($subitem);
386 
387  $form->addItem($item);
388 
389  $item = new ilCheckboxInputGUI($DIC->language()->txt('no_substatements_label'), 'no_substatements');
390  $item->setInfo($DIC->language()->txt('no_substatements_info'));
391  $item->setChecked($lrsType->getNoSubstatements());
392  $form->addItem($item);
393 
394  $item = new ilRadioGroupInputGUI($DIC->language()->txt('conf_privacy_setting_conf'), 'force_privacy_setting');
395  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_setting_default'), "0");
396  $item->addOption($op);
397  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_setting_force'), "1");
398  $item->addOption($op);
399  $item->setValue((string) ((int) $lrsType->getForcePrivacySettings()));
400  $form->addItem($item);
401 
402  $sectionHeader = new ilFormSectionHeaderGUI();
403  $sectionHeader->setTitle('Hints');
404  $form->addItem($sectionHeader);
405 
406  $item = new ilCheckboxInputGUI($DIC->language()->txt('conf_external_lrs'), 'external_lrs');
407  $item->setChecked($lrsType->getExternalLrs());
408  $item->setInfo($DIC->language()->txt('info_external_lrs'));
409  $form->addItem($item);
410 
411  $item = new ilTextAreaInputGUI($DIC->language()->txt('conf_privacy_comment_default'), 'privacy_comment_default');
412  $item->setInfo($DIC->language()->txt('info_privacy_comment_default'));
413  $item->setValue($lrsType->getPrivacyCommentDefault());
414  $item->setRows(5);
415  $form->addItem($item);
416 
417  $item = new ilTextAreaInputGUI($DIC->language()->txt('conf_remarks'), 'remarks');
418  $item->setInfo($DIC->language()->txt('info_remarks'));
419  $item->setValue($lrsType->getRemarks());
420  $item->setRows(5);
421  $form->addItem($item);
422 
423  return $form;
424  }
425 
426  protected function saveLrsTypeFormCmd(): void
427  {
428  global $DIC; /* @var \ILIAS\DI\Container $DIC */
429 
430  $lrsType = $this->initLrsType();
431 
432  $form = $this->buildLrsTypeForm($lrsType);
433 
434  if (!$form->checkInput()) {
435  $this->showLrsTypeFormCmd($form);
436  return;
437  }
438 
439  $lrsType->setTitle($form->getInput("title"));
440  $lrsType->setDescription($form->getInput("description"));
441  $lrsType->setAvailability((int) $form->getInput("availability"));
442 
443  $lrsType->setLrsEndpoint(
444  ilFileUtils::removeTrailingPathSeparators($form->getInput("lrs_endpoint"))
445  );
446 
447  $lrsType->setLrsKey($form->getInput("lrs_key"));
448  $lrsType->setLrsSecret($form->getInput("lrs_secret"));
449  $lrsType->setExternalLrs((bool) $form->getInput("external_lrs"));
450  $lrsType->setPrivacyIdent((int) $form->getInput("privacy_ident"));
451  $lrsType->setPrivacyName((int) $form->getInput("privacy_name"));
452  $lrsType->setPrivacyCommentDefault($form->getInput("privacy_comment_default"));
453  $lrsType->setRemarks($form->getInput("remarks"));
454 
455  $oldBypassProxyEnabled = $lrsType->isBypassProxyEnabled();
456  $newBypassProxyEnabled = (bool) $form->getInput("cronjob_neccessary");
457  $lrsType->setBypassProxyEnabled($newBypassProxyEnabled);
458  if ($newBypassProxyEnabled && $newBypassProxyEnabled != $oldBypassProxyEnabled) {
460  }
461 
462  $lrsType->setOnlyMoveon((bool) $form->getInput("only_moveon"));
463  $lrsType->setAchieved((bool) $form->getInput("achieved"));
464  $lrsType->setAnswered((bool) $form->getInput("answered"));
465  $lrsType->setCompleted((bool) $form->getInput("completed"));
466  $lrsType->setFailed((bool) $form->getInput("failed"));
467  $lrsType->setInitialized((bool) $form->getInput("initialized"));
468  $lrsType->setPassed((bool) $form->getInput("passed"));
469  $lrsType->setProgressed((bool) $form->getInput("progressed"));
470  $lrsType->setSatisfied((bool) $form->getInput("satisfied"));
471  $lrsType->setTerminated((bool) $form->getInput("terminated"));
472  $lrsType->setHideData((bool) $form->getInput("hide_data"));
473  $lrsType->setTimestamp((bool) $form->getInput("timestamp"));
474  $lrsType->setDuration((bool) $form->getInput("duration"));
475  $lrsType->setNoSubstatements((bool) $form->getInput("no_substatements"));
476 
477  $lrsType->setForcePrivacySettings((bool) $form->getInput("force_privacy_setting"));
478  if ($lrsType->getForcePrivacySettings()) {
480  }
481 
482  $lrsType->save();
483 
484  $DIC->ctrl()->redirect($this, self::CMD_SHOW_LRS_TYPES_LIST);
485  }
486 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
prepareOutput(bool $show_sub_objects=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
addButtonInstance(ilButtonBase $a_button)
Add button instance.
static updatePrivacySettingsFromLrsType(ilCmiXapiLrsType $lrsType)
static removeTrailingPathSeparators(string $path)
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
setValue(string $a_value)
ilToolbarGUI $toolbar
This class represents a text area property in a property form.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static updateByPassProxyFromLrsType(ilCmiXapiLrsType $lrsType)
static getTypesData(bool $a_extended=false, ?int $a_availability=null)
Get basic data array of all types (without field definitions)