ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilRoleTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Table/classes/class.ilTable2GUI.php';
5
15{
16 const TYPE_GLOBAL_AU = 1;
17 const TYPE_GLOBAL_UD = 2;
18 const TYPE_LOCAL_AU = 3;
19 const TYPE_LOCAL_UD = 4;
20 const TYPE_ROLT_AU = 5;
21 const TYPE_ROLT_UD = 6;
22
23
24 const TYPE_VIEW = 1;
25 const TYPE_SEARCH = 2;
26
27 private $path_gui = null;
28
30 private $role_title_filter = '';
31 private $role_folder_id = 0;
32
38 public function __construct($a_parent_gui, $a_parent_cmd)
39 {
40 global $DIC;
41
42 $ilCtrl = $DIC['ilCtrl'];
43
44 $this->ctrl = $ilCtrl;
45
46 $this->setId('rolf_role_tbl');
47
48 parent::__construct($a_parent_gui, $a_parent_cmd);
49 $this->lng->loadLanguageModule('rbac');
50 $this->lng->loadLanguageModule('search');
51 }
52
57 public function setType($a_type)
58 {
59 $this->type = $a_type;
60 }
61
66 public function setRoleTitleFilter($a_filter)
67 {
68 $this->role_title_filter = $a_filter;
69 }
70
75 public function getRoleTitleFilter()
76 {
78 }
79
83 public function getType()
84 {
85 return $this->type;
86 }
87
92 protected function getPathGUI()
93 {
94 return $this->path_gui;
95 }
96
97
98
102 public function init()
103 {
104 $this->addColumn('', 'f', '1px');
105
106 switch ($this->getType()) {
107 case self::TYPE_VIEW:
108 $this->setShowRowsSelector(true);
109 $this->setDefaultOrderField('title');
110 $this->setDefaultOrderDirection('asc');
111 //$this->setId('rolf_role_tbl');
112 $this->addColumn($this->lng->txt('search_title_description'), 'title', '30%');
113 $this->addColumn($this->lng->txt('type'), 'rtype', '20%');
114 $this->addColumn($this->lng->txt('context'), '', '40%');
115 $this->addColumn($this->lng->txt('actions'), '', '10%');
116 $this->setTitle($this->lng->txt('objs_role'));
117
118 if ($GLOBALS['DIC']['rbacsystem']->checkAccess('delete', $this->getParentObject()->object->getRefId())) {
119 $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
120 }
121 break;
122
124 $this->setShowRowsSelector(true);
125 $this->disable('sort');
126 //$this->setId('rolf_role_search_tbl');
127 $this->addColumn($this->lng->txt('search_title_description'), 'title', '30%');
128 $this->addColumn($this->lng->txt('type'), 'rtype', '20%');
129 $this->addColumn($this->lng->txt('context'), '', '50%');
130 $this->setTitle($this->lng->txt('rbac_role_rights_copy'));
131 $this->addMultiCommand('chooseCopyBehaviour', $this->lng->txt('btn_next'));
132 $this->addCommandButton('roleSearch', $this->lng->txt('btn_previous'));
133 break;
134 }
135
136
137 $this->setRowTemplate('tpl.role_row.html', 'Services/AccessControl');
138 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
139 $this->setSelectAllCheckbox('roles');
140
141 include_once './Services/Tree/classes/class.ilPathGUI.php';
142 $this->path_gui = new ilPathGUI();
143 $this->getPathGUI()->enableTextOnly(false);
144 $this->getPathGUI()->enableHideLeaf(false);
145
146
147 // Filter initialisation
148
149 if ($this->getType() == self::TYPE_VIEW) {
150 $this->initFilter();
151 }
152 }
153
157 public function initFilter()
158 {
159 $this->setDisableFilterHiding(true);
160
161 switch ($this->getType()) {
162 case self::TYPE_VIEW:
163 $action[ilRbacReview::FILTER_ALL] = $this->lng->txt('all_roles');
164 $action[ilRbacReview::FILTER_ALL_GLOBAL] = $this->lng->txt('all_global_roles');
165 $action[ilRbacReview::FILTER_ALL_LOCAL] = $this->lng->txt('all_local_roles');
166 $action[ilRbacReview::FILTER_INTERNAL] = $this->lng->txt('internal_local_roles_only');
167 $action[ilRbacReview::FILTER_NOT_INTERNAL] = $this->lng->txt('non_internal_local_roles_only');
168 $action[ilRbacReview::FILTER_TEMPLATES] = $this->lng->txt('role_templates_only');
169 break;
170
172 $action[ilRbacReview::FILTER_ALL] = $this->lng->txt('all_roles');
173 $action[ilRbacReview::FILTER_ALL_GLOBAL] = $this->lng->txt('all_global_roles');
174 $action[ilRbacReview::FILTER_ALL_LOCAL] = $this->lng->txt('all_local_roles');
175 $action[ilRbacReview::FILTER_INTERNAL] = $this->lng->txt('internal_local_roles_only');
176 $action[ilRbacReview::FILTER_NOT_INTERNAL] = $this->lng->txt('non_internal_local_roles_only');
177 break;
178 }
179
180 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
181 $roles = new ilSelectInputGUI($this->lng->txt('rbac_role_selection'), 'role_type');
182
183 $roles->setOptions($action);
184
185 $this->addFilterItem($roles);
186
187 $roles->readFromSession();
188 if (!$roles->getValue()) {
189 $roles->setValue(ilRbacReview::FILTER_ALL_GLOBAL);
190 }
191
192 // title filter
193 include_once './Services/Form/classes/class.ilTextInputGUI.php';
194 $title = new ilTextInputGUI($this->lng->txt('title'), 'role_title');
195 $title->setSize(16);
196 $title->setMaxLength(64);
197
198 $this->addFilterItem($title);
199 $title->readFromSession();
200
201 $this->filter['role_type'] = $roles->getValue();
202 $this->filter['role_title'] = $title->getValue();
203 }
204
209 public function fillRow($set)
210 {
211 global $DIC;
212
213 $rbacreview = $DIC['rbacreview'];
214 $tree = $DIC['tree'];
215
216 if ($set['type'] == 'role') {
217 if ($set['parent'] != ROLE_FOLDER_ID) {
218 $this->ctrl->setParameterByClass(
219 "ilobjrolegui",
220 "rolf_ref_id",
221 $set['parent']
222 );
223 }
224
225 $this->ctrl->setParameterByClass("ilobjrolegui", "obj_id", $set["obj_id"]);
226 $link = $this->ctrl->getLinkTargetByClass("ilobjrolegui", "perm");
227 $this->ctrl->setParameterByClass("ilobjrolegui", "rolf_ref_id", "");
228 } else {
229 $this->ctrl->setParameterByClass("ilobjroletemplategui", "obj_id", $set["obj_id"]);
230 $link = $this->ctrl->getLinkTargetByClass("ilobjroletemplategui", "perm");
231 }
232
233 switch ($set['rtype']) {
235 $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_global'));
236 break;
238 $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_global'));
239 break;
241 $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_local'));
242 break;
244 $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_local'));
245 break;
247 $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_rolt'));
248 break;
250 $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_rolt'));
251 break;
252 }
253
254
255
256 if (
257 ($set['obj_id'] != ANONYMOUS_ROLE_ID and
258 $set['obj_id'] != SYSTEM_ROLE_ID and
259 substr($set['title_orig'], 0, 3) != 'il_') or
260 $this->getType() == self::TYPE_SEARCH) {
261 $this->tpl->setVariable('VAL_ID', $set['obj_id']);
262 }
263 $this->tpl->setVariable('VAL_TITLE_LINKED', $set['title']);
264 $this->tpl->setVariable('VAL_LINK', $link);
265 if (strlen($set['description'])) {
266 $this->tpl->setVariable('VAL_DESC', $set['description']);
267 }
268
276 $ref = $set['parent'];
277 if ($ref == ROLE_FOLDER_ID) {
278 $this->tpl->setVariable('CONTEXT', $this->lng->txt('rbac_context_global'));
279 } else {
280 $this->tpl->setVariable(
281 'CONTEXT',
282 (string) $this->getPathGUI()->getPath(ROOT_FOLDER_ID, $ref)
283 );
284 }
285
286 if ($this->getType() == self::TYPE_VIEW and $set['obj_id'] != SYSTEM_ROLE_ID) {
287 if ($GLOBALS['DIC']['rbacsystem']->checkAccess('write', $this->role_folder_id)) {
288 // Copy role
289 $this->tpl->setVariable('COPY_TEXT', $this->lng->txt('rbac_role_rights_copy'));
290 $this->ctrl->setParameter($this->getParentObject(), "csource", $set["obj_id"]);
291 $link = $this->ctrl->getLinkTarget($this->getParentObject(), 'roleSearch');
292 $this->tpl->setVariable(
293 'COPY_LINK',
294 $link
295 );
296 }
297 }
298 }
299
304 public function parse($role_folder_id)
305 {
306 global $DIC;
307
308 $rbacreview = $DIC['rbacreview'];
309 $ilUser = $DIC['ilUser'];
310
311 $this->role_folder_id = $role_folder_id;
312
313 include_once './Services/AccessControl/classes/class.ilObjRole.php';
314
315 if ($this->getType() == self::TYPE_VIEW) {
316 $filter_orig = $filter = $this->getFilterItemByPostVar('role_title')->getValue();
317 $type = $this->getFilterItemByPostVar('role_type')->getValue();
318 } else {
319 $filter_orig = $filter = $this->getRoleTitleFilter();
321 }
322
323
324 // the translation must be filtered
326 // roles like il_crs_... are filtered manually
327 $filter = '';
328 }
329
330 $role_list = $rbacreview->getRolesByFilter(
331 $type,
332 0,
333 $filter
334 );
335
336 $counter = 0;
337 $rows = array();
338 foreach ((array) $role_list as $role) {
339 if (
340 $role['parent'] and
341 (
342 $GLOBALS['DIC']['tree']->isDeleted($role['parent']) or
343 !$GLOBALS['DIC']['tree']->isInTree($role['parent'])
344 )
345 ) {
346 continue;
347 }
348
349 $title = ilObjRole::_getTranslation($role['title']);
351 if (strlen($filter_orig)) {
352 if (stristr($title, $filter_orig) == false) {
353 continue;
354 }
355 }
356 }
357
358
359 $rows[$counter]['title_orig'] = $role['title'];
360 $rows[$counter]['title'] = $title;
361 $rows[$counter]['description'] = $role['description'];
362 $rows[$counter]['obj_id'] = $role['obj_id'];
363 $rows[$counter]['parent'] = $role['parent'];
364 $rows[$counter]['type'] = $role['type'];
365
366 $auto = (substr($role['title'], 0, 3) == 'il_' ? true : false);
367
368
369 // Role templates
370 if ($role['type'] == 'rolt') {
371 $rows[$counter]['rtype'] = $auto ? self::TYPE_ROLT_AU : self::TYPE_ROLT_UD;
372 } else {
373 // Roles
374 if ($role['parent'] == ROLE_FOLDER_ID) {
375 if ($role['obj_id'] == ANONYMOUS_ROLE_ID or $role['obj_id'] == SYSTEM_ROLE_ID) {
376 $rows[$counter]['rtype'] = self::TYPE_GLOBAL_AU;
377 } else {
378 $rows[$counter]['rtype'] = self::TYPE_GLOBAL_UD;
379 }
380 } else {
381 $rows[$counter]['rtype'] = $auto ? self::TYPE_LOCAL_AU : self::TYPE_LOCAL_UD;
382 }
383 }
384
385 ++$counter;
386 }
387 $this->setMaxCount(count($rows));
388 $this->setData($rows);
389 }
390}
An exception for terminatinating execution or to throw for unit testing.
static _getTranslation($a_role_title)
Creates a path for a start and endnode.
TableGUI for the presentation og roles and role templates.
getPathGUI()
Get path gui.
parse($role_folder_id)
Parse role list.
getType()
Get table type.
getRoleTitleFilter()
Get role title filter.
initFilter()
Init filter.
setRoleTitleFilter($a_filter)
Set role title filter.
__construct($a_parent_gui, $a_parent_cmd)
Constructor.
setType($a_type)
Set table type.
This class represents a selection list property in a property form.
Class ilTable2GUI.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
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.
getFilterItemByPostVar($a_post_var)
addMultiCommand($a_cmd, $a_text)
Add Command button.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setMaxCount($a_max_count)
set max.
disable($a_module_name)
diesables particular modules of table
This class represents a text property in a property form.
$action
global $ilCtrl
Definition: ilias.php:18
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$rows
Definition: xhr_table.php:10