ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjectRoleTemplatePermissionTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Services/Table/classes/class.ilTable2GUI.php');
5include_once './Services/AccessControl/classes/class.ilPermissionGUI.php';
6require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
7
18{
19 private $ref_id = null;
20 private $role_id = null;
21 private $role_folder_id = 0;
22
23 private $tpl_type = '';
24
25 private $show_admin_permissions = false;
27
28 private static $template_permissions = null;
29
30
35 public function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_role_id, $a_type, $a_show_admin_permissions = false)
36 {
37 global $DIC;
38
39 $ilCtrl = $DIC['ilCtrl'];
40 $rbacreview = $DIC['rbacreview'];
41 $tpl = $DIC['tpl'];
42
43 $this->tpl_type = $a_type;
44 $this->show_admin_permissions = $a_show_admin_permissions;
45
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 $this->setId('role_template_' . $a_ref_id . '_' . $a_type);
49 $this->setFormName('role_template_permissions');
50 $this->setSelectAllCheckbox('template_perm[' . $this->getTemplateType() . ']');
51
52 $this->lng->loadLanguageModule('rbac');
53
54 $this->ref_id = $a_ref_id;
55 $this->role_id = $a_role_id;
56
57 $this->setRowTemplate("tpl.obj_role_template_perm_row.html", "Services/AccessControl");
58 $this->setLimit(100);
59 $this->setShowRowsSelector(false);
60 $this->setDisableFilterHiding(true);
61 $this->setNoEntriesText($this->lng->txt('msg_no_roles_of_type'));
62
63 $this->setEnableHeader(false);
64 $this->disable('sort');
65 $this->disable('numinfo');
66 $this->disable('form');
67
68 $this->addColumn('', '', '0');
69 $this->addColumn('', '', '100%');
70
72 }
73
77 public function setShowChangeExistingObjects($a_status)
78 {
79 $this->show_change_existing_objects = $a_status;
80 }
81
86 {
88 }
89
94 protected function initTemplatePermissions()
95 {
96 global $DIC;
97
98 $rbacreview = $DIC['rbacreview'];
99
100 if (self::$template_permissions !== null) {
101 return true;
102 }
103 self::$template_permissions = $rbacreview->getAllOperationsOfRole(
104 $this->getRoleId(),
105 $this->getRefId()
106 );
107 }
108
114 protected function getPermissions($a_type)
115 {
116 return self::$template_permissions[$a_type] ? self::$template_permissions[$a_type] : array();
117 }
118
124 public function initTemplateType($a_type)
125 {
126 }
127
132 public function getTemplateType()
133 {
134 return $this->tpl_type;
135 }
136
141 public function getRoleId()
142 {
143 return $this->role_id;
144 }
145
150 public function getRefId()
151 {
152 return $this->ref_id;
153 }
154
159 public function getObjId()
160 {
161 return ilObject::_lookupObjId($this->getRefId());
162 }
163
168 public function getObjType()
169 {
170 return ilObject::_lookupType($this->getObjId());
171 }
172
177 public function fillRow($row)
178 {
179 global $DIC;
180
181 $objDefinition = $DIC['objDefinition'];
182
183 if (isset($row['show_ce'])) {
184 $this->tpl->setCurrentBlock('ce_td');
185 $this->tpl->setVariable('CE_TYPE', $this->getTemplateType());
186 $this->tpl->parseCurrentBlock();
187
188 $this->tpl->setCurrentBlock('ce_desc_td');
189 $this->tpl->setVariable('CE_DESC_TYPE', $this->getTemplateType());
190 $this->tpl->setVariable('CE_LONG', $this->lng->txt('change_existing_object_type_desc'));
191
192 if ($objDefinition->isSystemObject($this->getTemplateType())) {
193 $this->tpl->setVariable(
194 "TXT_CE",
195 $this->lng->txt("change_existing_prefix_single") . " " .
196 $this->lng->txt("obj_" . $this->getTemplateType()) . " " .
197 $this->lng->txt("change_existing_suffix_single")
198 );
199 } else {
200 $pl_txt = ($objDefinition->isPlugin($this->getTemplateType()))
202 $this->getTemplateType(),
203 "objs_" . $this->getTemplateType()
204 )
205 : $this->lng->txt('objs_' . $this->getTemplateType());
206 $this->tpl->setVariable(
207 'TXT_CE',
208 $this->lng->txt('change_existing_prefix') . ' ' .
209 $pl_txt . ' ' .
210 $this->lng->txt('change_existing_suffix')
211 );
212 $this->tpl->parseCurrentBlock();
213 }
214 return true;
215 } else {
216 $this->tpl->setCurrentBlock('perm_td');
217 $this->tpl->setVariable('OBJ_TYPE', $this->getTemplateType());
218 $this->tpl->setVariable('PERM_PERM_ID', $row['ops_id']);
219 $this->tpl->setVariable('PERM_CHECKED', $row['set'] ? 'checked="checked"' : '');
220
221 if ($this->getRoleId() == SYSTEM_ROLE_ID) {
222 $this->tpl->setVariable('PERM_DISABLED', 'disabled="disabled"');
223 }
224
225 $this->tpl->parseCurrentBlock();
226
227 $this->tpl->setCurrentBlock('perm_desc_td');
228 $this->tpl->setVariable('DESC_TYPE', $this->getTemplateType());
229 $this->tpl->setVariable('DESC_PERM_ID', $row['ops_id']);
230
231 if ($row["create_type"] != "" && $objDefinition->isPlugin($row['create_type'])) {
232 $this->tpl->setVariable(
233 'TXT_PERMISSION',
235 $row['create_type'],
236 $this->getTemplateType() . "_" . $row['name']
237 )
238 );
239 } elseif ($row["create_type"] == "" && $objDefinition->isPlugin($this->getTemplateType())) {
240 $this->tpl->setVariable(
241 'TXT_PERMISSION',
243 $this->getTemplateType(),
244 $this->getTemplateType() . "_" . $row['name']
245 )
246 );
247 } else {
248 if (substr($row['name'], 0, 6) == 'create') {
249 #$perm = $this->lng->txt($this->getTemplateType().'_'.$row['name']);
250 $perm = $this->lng->txt('rbac' . '_' . $row['name']);
251 } elseif ($this->lng->exists($this->getTemplateType() . '_' . $row['name'] . '_short')) {
252 $perm = $this->lng->txt($this->getTemplateType() . '_' . $row['name'] . '_short') . ': ' .
253 $this->lng->txt($this->getTemplateType() . '_' . $row['name']);
254 } else {
255 $perm = $this->lng->txt($row['name']) . ': ' . $this->lng->txt($this->getTemplateType() . '_' . $row['name']);
256 }
257
258 $this->tpl->setVariable('TXT_PERMISSION', $perm);
259 }
260 $this->tpl->parseCurrentBlock();
261
262 return true;
263 }
264 }
265
270 public function parse()
271 {
272 global $DIC;
273
274 $rbacreview = $DIC['rbacreview'];
275 $objDefinition = $DIC['objDefinition'];
276
277 $operations = $this->getPermissions($this->getTemplateType());
278
279
280 // Object permissions
281 $rows = array();
282 foreach ($rbacreview->getOperationsByTypeAndClass($this->getTemplateType(), 'object') as $ops_id) {
283 $operations = $this->getPermissions($this->getTemplateType());
284
285 $operation = $rbacreview->getOperation($ops_id);
286
287 $perm['ops_id'] = $ops_id;
288 $perm['set'] = (in_array($ops_id, $operations) or $this->getRoleId() == SYSTEM_ROLE_ID);
289 $perm['name'] = $operation['operation'];
290
291 $rows[] = $perm;
292 }
293
294 // Get creatable objects
295 $objects = $objDefinition->getCreatableSubObjects($this->getTemplateType());
296 $ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
297
298 foreach ($objects as $type => $info) {
299 $ops_id = $ops_ids[$type];
300
301 if (!$ops_id) {
302 continue;
303 }
304
305 $perm['ops_id'] = $ops_id;
306 $perm['set'] = (in_array($ops_id, $operations) or $this->getRoleId() == SYSTEM_ROLE_ID);
307
308 $perm['name'] = 'create_' . $info['name'];
309 $perm['create_type'] = $info['name'];
310
311 $rows[] = $perm;
312 }
313
314 if (
315 !$this->show_admin_permissions &&
317 ) {
318 $rows[] = array('show_ce' => 1);
319 }
320
321 $this->setData($rows);
322 }
323}
An exception for terminatinating execution or to throw for unit testing.
static lookupTxtById($plugin_id, $lang_var)
initTemplateType($a_type)
Set object type for current template permission table.
__construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_role_id, $a_type, $a_show_admin_permissions=false)
Constructor.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static lookupCreateOperationIds($a_type_arr)
Lookup operation ids.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setNoEntriesText($a_text)
Set text for an empty table.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
disable($a_module_name)
diesables particular modules of table
const SYSTEM_ROLE_ID
Definition: constants.php:27
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$rows
Definition: xhr_table.php:10