ILIAS  release_8 Revision v8.23
class.ilTermsOfServiceUserHasGlobalRoleCriterionGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
29 {
32  protected ilLanguage $lng;
34 
35  public function __construct(
37  ilLanguage $lng,
38  ilRbacReview $rbacReview,
39  ilObjectDataCache $objectCache
40  ) {
41  $this->type = $type;
42  $this->lng = $lng;
43  $this->rbacReview = $rbacReview;
44  $this->objectCache = $objectCache;
45 
46  $this->lng->loadLanguageModule('rbac');
47  }
48 
50  {
51  $option = new ilRadioOption($this->getIdentPresentation(), $this->type->getTypeIdent());
52  $option->setInfo($this->lng->txt('tos_crit_type_usr_global_role_info'));
53 
54  $roleSelection = new ilSelectInputGUI(
55  $this->lng->txt('perm_global_role'),
56  $this->type->getTypeIdent() . '_role_id'
57  );
58  $roleSelection->setRequired(true);
59 
60  $options = [];
61  foreach ($this->rbacReview->getGlobalRoles() as $roleId) {
62  $options[$roleId] = $this->objectCache->lookupTitle($roleId);
63  }
64 
65  natcasesort($options);
66 
67  $roleSelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
68  $roleSelection->setValue((string) ((int) ($config['role_id'] ?? 0)));
69 
70  $option->addSubItem($roleSelection);
71 
72  $group->addOption($option);
73  }
74 
76  {
78  'role_id' => (int) $form->getInput($this->type->getTypeIdent() . '_role_id')
79  ]);
80 
81  return $config;
82  }
83 
84  public function getIdentPresentation(): string
85  {
86  return $this->lng->txt('tos_crit_type_usr_global_role');
87  }
88 
90  {
91  $roleId = $config['role_id'] ?? 0;
92 
93  if (!is_numeric($roleId) || $roleId < 1 || $roleId > PHP_INT_MAX || is_float($roleId)) {
94  return $uiFactory->legacy('');
95  }
96 
97  $roleId = (int) $roleId;
98  if (!in_array($roleId, $this->rbacReview->getGlobalRoles(), true)) {
99  return $uiFactory->legacy($this->lng->txt('deleted'));
100  }
101 
102  return $uiFactory->legacy($this->objectCache->lookupTitle($roleId));
103  }
104 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilTermsOfServiceCriterionTypeGUI.
setInfo(string $a_info)
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addOption(ilRadioOption $a_option)
legacy(string $content)
description: purpose: > This component is used to wrap an existing ILIAS UI element into a UI compon...
Class ilTermsOfServiceCriterionConfig.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
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.
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
__construct(ilTermsOfServiceUserHasGlobalRoleCriterion $type, ilLanguage $lng, ilRbacReview $rbacReview, ilObjectDataCache $objectCache)
getValuePresentation(ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)