ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTermsOfServiceUserHasGlobalRoleCriterionGUI.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
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 {
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.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
This class represents a property in a property form.
addOption($a_option)
Add Option.
This class represents an option in a radio group.
class ilRbacReview Contains Review functions of core Rbac.
This class represents a selection list property in a property form.
Class ilTermsOfServiceCriterionConfig.
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
__construct(ilTermsOfServiceUserHasGlobalRoleCriterion $type, ilLanguage $lng, ilRbacReview $rbacReview, ilObjectDataCache $objectCache)
ilTermsOfServiceUserHasGlobalRoleCriterionGUI constructor.
getConfigByForm(ilPropertyFormGUI $form)
ilTermsOfServiceCriterionConfig
getValuePresentation(ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)
Component
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:18
legacy($content)
Interface ilTermsOfServiceCriterionTypeGUI.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68