ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjectRoleTemplatePermissionTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
27{
28 private int $ref_id = 0;
29 private int $role_id = 0;
30 private int $role_folder_id = 0;
31
32 private string $tpl_type = '';
33
34 private bool $show_admin_permissions = false;
35 private bool $show_change_existing_objects = true;
36
37 private static ?array $template_permissions = null;
40
41 public function __construct(
42 object $a_parent_obj,
43 string $a_parent_cmd,
44 int $a_ref_id,
45 int $a_role_id,
46 string $a_type,
47 bool $a_show_admin_permissions = false
48 ) {
49 global $DIC;
50
51 $this->review = $DIC->rbac()->review();
52 $this->objDefinition = $DIC['objDefinition'];
53
54 $this->tpl_type = $a_type;
55 $this->show_admin_permissions = $a_show_admin_permissions;
56
57 $this->setId('role_template_' . $a_ref_id . '_' . $a_type);
58 parent::__construct($a_parent_obj, $a_parent_cmd);
59 $this->setFormName('role_template_permissions');
60 $this->setSelectAllCheckbox('template_perm[' . $this->getTemplateType() . ']');
61
62 $this->lng->loadLanguageModule('rbac');
63
64 $this->ref_id = $a_ref_id;
65 $this->role_id = $a_role_id;
66
67 $this->setRowTemplate("tpl.obj_role_template_perm_row.html", "components/ILIAS/AccessControl");
68 $this->setLimit(100);
69 $this->setShowRowsSelector(false);
70 $this->setDisableFilterHiding(true);
71 $this->setNoEntriesText($this->lng->txt('msg_no_roles_of_type'));
72
73 $this->setEnableHeader(false);
74 $this->disable('sort');
75 $this->disable('numinfo');
76 $this->disable('form');
77
78 $this->addColumn('', '', '0');
79 $this->addColumn('', '', '100%');
80
82 }
83
84 public function setShowChangeExistingObjects(bool $a_status): void
85 {
86 $this->show_change_existing_objects = $a_status;
87 }
88
89 public function getShowChangeExistingObjects(): bool
90 {
92 }
93
94 protected function initTemplatePermissions(): void
95 {
96 if (self::$template_permissions !== null) {
97 return;
98 }
99 self::$template_permissions = $this->review->getAllOperationsOfRole(
100 $this->getRoleId(),
101 $this->getRefId()
102 );
103 }
104
108 protected function getPermissions(string $a_type): array
109 {
110 return !isset(self::$template_permissions[$a_type]) ? [] : self::$template_permissions[$a_type];
111 }
112
113 public function getTemplateType(): string
114 {
115 return $this->tpl_type;
116 }
117
118 public function getRoleId(): int
119 {
120 return $this->role_id;
121 }
122
123 public function getRefId(): int
124 {
125 return $this->ref_id;
126 }
127
128 public function getObjId(): int
129 {
130 return ilObject::_lookupObjId($this->getRefId());
131 }
132
133 public function getObjType(): string
134 {
135 return ilObject::_lookupType($this->getObjId());
136 }
137
138 protected function fillRow(array $a_set): void
139 {
140 if (isset($a_set['show_ce'])) {
141 $this->tpl->setCurrentBlock('ce_td');
142 $this->tpl->setVariable('CE_TYPE', $this->getTemplateType());
143 $this->tpl->parseCurrentBlock();
144
145 $this->tpl->setCurrentBlock('ce_desc_td');
146 $this->tpl->setVariable('CE_DESC_TYPE', $this->getTemplateType());
147 $this->tpl->setVariable('CE_LONG', $this->lng->txt('change_existing_object_type_desc'));
148
149 if ($this->objDefinition->isSystemObject($this->getTemplateType())) {
150 $this->tpl->setVariable(
151 "TXT_CE",
152 $this->lng->txt("change_existing_prefix_single") . " " .
153 $this->lng->txt("obj_" . $this->getTemplateType()) . " " .
154 $this->lng->txt("change_existing_suffix_single")
155 );
156 } else {
157 $pl_txt = ($this->objDefinition->isPlugin($this->getTemplateType()))
159 $this->getTemplateType(),
160 "objs_" . $this->getTemplateType()
161 )
162 : $this->lng->txt('objs_' . $this->getTemplateType());
163 $this->tpl->setVariable(
164 'TXT_CE',
165 $this->lng->txt('change_existing_prefix') . ' ' .
166 $pl_txt . ' ' .
167 $this->lng->txt('change_existing_suffix')
168 );
169 $this->tpl->parseCurrentBlock();
170 }
171 } else {
172 $this->tpl->setCurrentBlock('perm_td');
173 $this->tpl->setVariable('OBJ_TYPE', $this->getTemplateType());
174 $this->tpl->setVariable('PERM_PERM_ID', $a_set['ops_id']);
175 $this->tpl->setVariable('PERM_CHECKED', $a_set['set'] ? 'checked="checked"' : '');
176
177 if ($this->getRoleId() == SYSTEM_ROLE_ID) {
178 $this->tpl->setVariable('PERM_DISABLED', 'disabled="disabled"');
179 }
180
181 $this->tpl->parseCurrentBlock();
182
183 $this->tpl->setCurrentBlock('perm_desc_td');
184 $this->tpl->setVariable('DESC_TYPE', $this->getTemplateType());
185 $this->tpl->setVariable('DESC_PERM_ID', $a_set['ops_id']);
186
187 $create_type = $a_set["create_type"] ?? "";
188 if ($create_type != "" && $this->objDefinition->isPlugin($a_set['create_type'])) {
189 $this->tpl->setVariable(
190 'TXT_PERMISSION',
192 $a_set['create_type'],
193 $this->getTemplateType() . "_" . $a_set['name']
194 )
195 );
196 } elseif ($create_type == "" && $this->objDefinition->isPlugin($this->getTemplateType())) {
197 $this->tpl->setVariable(
198 'TXT_PERMISSION',
200 $this->getTemplateType(),
201 $this->getTemplateType() . "_" . $a_set['name']
202 )
203 );
204 } else {
205 if (substr($a_set['name'], 0, 6) == 'create') {
206 #$perm = $this->lng->txt($this->getTemplateType().'_'.$row['name']);
207 $perm = $this->lng->txt('rbac' . '_' . $a_set['name']);
208 } elseif ($this->lng->exists($this->getTemplateType() . '_' . $a_set['name'] . '_short')) {
209 $perm = $this->lng->txt($this->getTemplateType() . '_' . $a_set['name'] . '_short') . ': ' .
210 $this->lng->txt($this->getTemplateType() . '_' . $a_set['name']);
211 } else {
212 $perm = $this->lng->txt($a_set['name']) . ': ' . $this->lng->txt($this->getTemplateType() . '_' . $a_set['name']);
213 }
214
215 $this->tpl->setVariable('TXT_PERMISSION', $perm);
216 }
217 $this->tpl->parseCurrentBlock();
218 }
219 }
220
225 public function parse(): void
226 {
227 $operations = $this->getPermissions($this->getTemplateType());
228
229 // Object permissions
230 $rows = [];
231 foreach ($this->review->getOperationsByTypeAndClass($this->getTemplateType(), 'object') as $ops_id) {
232 $operations = $this->getPermissions($this->getTemplateType());
233
234 $operation = $this->review->getOperation($ops_id);
235
236 $perm['ops_id'] = $ops_id;
237 $perm['set'] = (in_array($ops_id, $operations) || $this->getRoleId() == SYSTEM_ROLE_ID);
238 $perm['name'] = $operation['operation'];
239
240 $rows[] = $perm;
241 }
242
243 // Get creatable objects
244 $objects = $this->objDefinition->getCreatableSubObjects($this->getTemplateType());
245 $ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
246
247 foreach ($objects as $type => $info) {
248 $ops_id = $ops_ids[$type] ?? null;
249
250 if (!$ops_id) {
251 continue;
252 }
253
254 $perm['ops_id'] = $ops_id;
255 $perm['set'] = (in_array($ops_id, $operations) || $this->getRoleId() == SYSTEM_ROLE_ID);
256
257 $perm['name'] = 'create_' . $info['name'];
258 $perm['create_type'] = $info['name'];
259
260 $rows[] = $perm;
261 }
262
263 if (
264 !$this->show_admin_permissions &&
266 ) {
267 $rows[] = ['show_ce' => 1];
268 }
269 $this->setData($rows);
270 }
271}
parses the objects.xml it handles the xml-description of all ilias objects
static lookupTxtById(string $plugin_id, string $lang_var)
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_ref_id, int $a_role_id, string $a_type, bool $a_show_admin_permissions=false)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
class ilRbacReview Contains Review functions of core Rbac.
static lookupCreateOperationIds(array $a_type_arr)
Lookup operation ids.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setFormName(string $a_name="")
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setDisableFilterHiding(bool $a_val=true)
setNoEntriesText(string $a_text)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
disable(string $a_module_name)
const SYSTEM_ROLE_ID
Definition: constants.php:29
$info
Definition: entry_point.php:21
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26