ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTermsOfServiceUserHasGlobalRoleCriterionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
6
12{
16 protected $type;
17
21 protected $rbacReview;
22
26 protected $lng;
27
31 protected $objectCache;
32
40 public function __construct(
45 ) {
46 $this->type = $type;
47 $this->lng = $lng;
48 $this->rbacReview = $rbacReview;
49 $this->objectCache = $objectCache;
50
51 $this->lng->loadLanguageModule('rbac');
52 }
53
58 {
59 $option = new \ilRadioOption($this->getIdentPresentation(), $this->type->getTypeIdent());
60 $option->setInfo($this->lng->txt('tos_crit_type_usr_global_role_info'));
61
62 $roleSelection = new \ilSelectInputGUI(
63 $this->lng->txt('perm_global_role'),
64 $this->type->getTypeIdent() . '_role_id'
65 );
66 $roleSelection->setRequired(true);
67
68 $options = [];
69 foreach ($this->rbacReview->getGlobalRoles() as $roleId) {
70 $options[$roleId] = $this->objectCache->lookupTitle($roleId);
71 }
72
73 asort($options);
74
75 $roleSelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
76 $roleSelection->setValue((int) ($config['role_id'] ?? 0));
77
78 $option->addSubItem($roleSelection);
79
80 $group->addOption($option);
81 }
82
87 {
88 $config = new \ilTermsOfServiceCriterionConfig([
89 'role_id' => (int) $form->getInput($this->type->getTypeIdent() . '_role_id')
90 ]);
91
92 return $config;
93 }
94
98 public function getIdentPresentation() : string
99 {
100 return $this->lng->txt('tos_crit_type_usr_global_role');
101 }
102
107 {
108 $roleId = $config['role_id'] ?? 0;
109
110 if (!is_numeric($roleId) || $roleId < 1 || is_float($roleId)) {
111 return $uiFactory->legacy('');
112 }
113
114 return $uiFactory->legacy($this->objectCache->lookupTitle($roleId));
115 }
116}
An exception for terminatinating execution or to throw for unit testing.
language handling
class ilObjectDataCache
This class represents a property form user interface.
This class represents a property in a property form.
addOption($a_option)
Add Option.
class ilRbacReview Contains Review functions of core Rbac.
Class ilTermsOfServiceCriterionConfig.
getValuePresentation(\ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)
Component
getConfigByForm(\ilPropertyFormGUI $form)
\ilTermsOfServiceCriterionConfig
appendOption(\ilRadioGroupInputGUI $group, \ilTermsOfServiceCriterionConfig $config)
__construct(\ilTermsOfServiceUserHasGlobalRoleCriterion $type, \ilLanguage $lng, \ilRbacReview $rbacReview, \ilObjectDataCache $objectCache)
ilTermsOfServiceUserHasGlobalRoleCriterionGUI constructor.
A component is the most general form of an entity in the UI.
Definition: Component.php:14
This is how the factory for UI elements looks.
Definition: Factory.php:16
legacy($content)
Interface ilTermsOfServiceCriterionTypeGUI.
$config
Definition: bootstrap.php:15
if(isset($_POST['submit'])) $form