ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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 
29  private $type = self::TYPE_VIEW;
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 $ilCtrl;
41 
42  $this->ctrl = $ilCtrl;
43 
44  $this->setId('rolf_role_tbl');
45 
46  parent::__construct($a_parent_gui, $a_parent_cmd);
47  $this->lng->loadLanguageModule('rbac');
48  $this->lng->loadLanguageModule('search');
49  }
50 
55  public function setType($a_type)
56  {
57  $this->type = $a_type;
58  }
59 
64  public function setRoleTitleFilter($a_filter)
65  {
66  $this->role_title_filter = $a_filter;
67  }
68 
73  public function getRoleTitleFilter()
74  {
76  }
77 
81  public function getType()
82  {
83  return $this->type;
84  }
85 
90  protected function getPathGUI()
91  {
92  return $this->path_gui;
93  }
94 
95 
96 
100  public function init()
101  {
102  $this->addColumn('', 'f', '1px');
103 
104  switch ($this->getType()) {
105  case self::TYPE_VIEW:
106  $this->setShowRowsSelector(true);
107  $this->setDefaultOrderField('title');
108  $this->setDefaultOrderDirection('asc');
109  //$this->setId('rolf_role_tbl');
110  $this->addColumn($this->lng->txt('search_title_description'), 'title', '30%');
111  $this->addColumn($this->lng->txt('type'), 'rtype', '20%');
112  $this->addColumn($this->lng->txt('context'), '', '40%');
113  $this->addColumn($this->lng->txt('actions'), '', '10%');
114  $this->setTitle($this->lng->txt('objs_role'));
115 
116  if ($GLOBALS['rbacsystem']->checkAccess('delete', $this->getParentObject()->object->getRefId())) {
117  $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
118  }
119  break;
120 
121  case self::TYPE_SEARCH:
122  $this->setShowRowsSelector(true);
123  $this->disable('sort');
124  //$this->setId('rolf_role_search_tbl');
125  $this->addColumn($this->lng->txt('search_title_description'), 'title', '30%');
126  $this->addColumn($this->lng->txt('type'), 'rtype', '20%');
127  $this->addColumn($this->lng->txt('context'), '', '50%');
128  $this->setTitle($this->lng->txt('rbac_role_rights_copy'));
129  $this->addMultiCommand('chooseCopyBehaviour', $this->lng->txt('btn_next'));
130  $this->addCommandButton('roleSearch', $this->lng->txt('btn_previous'));
131  break;
132  }
133 
134 
135  $this->setRowTemplate('tpl.role_row.html', 'Services/AccessControl');
136  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
137  $this->setSelectAllCheckbox('roles');
138 
139  include_once './Services/Tree/classes/class.ilPathGUI.php';
140  $this->path_gui = new ilPathGUI();
141  $this->getPathGUI()->enableTextOnly(false);
142  $this->getPathGUI()->enableHideLeaf(false);
143 
144 
145  // Filter initialisation
146 
147  if ($this->getType() == self::TYPE_VIEW) {
148  $this->initFilter();
149  }
150  }
151 
155  public function initFilter()
156  {
157  $this->setDisableFilterHiding(true);
158 
159  switch ($this->getType()) {
160  case self::TYPE_VIEW:
161  $action[ilRbacReview::FILTER_ALL] = $this->lng->txt('all_roles');
162  $action[ilRbacReview::FILTER_ALL_GLOBAL] = $this->lng->txt('all_global_roles');
163  $action[ilRbacReview::FILTER_ALL_LOCAL] = $this->lng->txt('all_local_roles');
164  $action[ilRbacReview::FILTER_INTERNAL] = $this->lng->txt('internal_local_roles_only');
165  $action[ilRbacReview::FILTER_NOT_INTERNAL] = $this->lng->txt('non_internal_local_roles_only');
166  $action[ilRbacReview::FILTER_TEMPLATES] = $this->lng->txt('role_templates_only');
167  break;
168 
169  case self::TYPE_SEARCH:
170  $action[ilRbacReview::FILTER_ALL] = $this->lng->txt('all_roles');
171  $action[ilRbacReview::FILTER_ALL_GLOBAL] = $this->lng->txt('all_global_roles');
172  $action[ilRbacReview::FILTER_ALL_LOCAL] = $this->lng->txt('all_local_roles');
173  $action[ilRbacReview::FILTER_INTERNAL] = $this->lng->txt('internal_local_roles_only');
174  $action[ilRbacReview::FILTER_NOT_INTERNAL] = $this->lng->txt('non_internal_local_roles_only');
175  break;
176  }
177 
178  include_once './Services/Form/classes/class.ilSelectInputGUI.php';
179  $roles = new ilSelectInputGUI($this->lng->txt('rbac_role_selection'), 'role_type');
180 
181  $roles->setOptions($action);
182 
183  $this->addFilterItem($roles);
184 
185  $roles->readFromSession();
186  if (!$roles->getValue()) {
187  $roles->setValue(ilRbacReview::FILTER_ALL_GLOBAL);
188  }
189 
190  // title filter
191  include_once './Services/Form/classes/class.ilTextInputGUI.php';
192  $title = new ilTextInputGUI($this->lng->txt('title'), 'role_title');
193  $title->setSize(16);
194  $title->setMaxLength(64);
195 
196  $this->addFilterItem($title);
197  $title->readFromSession();
198 
199  $this->filter['role_type'] = $roles->getValue();
200  $this->filter['role_title'] = $title->getValue();
201  }
202 
207  public function fillRow($set)
208  {
209  global $rbacreview,$tree;
210 
211  if ($set['type'] == 'role') {
212  if ($set['parent'] != ROLE_FOLDER_ID) {
213  $this->ctrl->setParameterByClass(
214  "ilobjrolegui",
215  "rolf_ref_id",
216  $set['parent']
217  );
218  }
219 
220  $this->ctrl->setParameterByClass("ilobjrolegui", "obj_id", $set["obj_id"]);
221  $link = $this->ctrl->getLinkTargetByClass("ilobjrolegui", "perm");
222  $this->ctrl->setParameterByClass("ilobjrolegui", "rolf_ref_id", "");
223  } else {
224  $this->ctrl->setParameterByClass("ilobjroletemplategui", "obj_id", $set["obj_id"]);
225  $link = $this->ctrl->getLinkTargetByClass("ilobjroletemplategui", "perm");
226  }
227 
228  switch ($set['rtype']) {
229  case self::TYPE_GLOBAL_AU:
230  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_global'));
231  break;
232  case self::TYPE_GLOBAL_UD:
233  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_global'));
234  break;
235  case self::TYPE_LOCAL_AU:
236  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_local'));
237  break;
238  case self::TYPE_LOCAL_UD:
239  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_local'));
240  break;
241  case self::TYPE_ROLT_AU:
242  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_rolt'));
243  break;
244  case self::TYPE_ROLT_UD:
245  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_rolt'));
246  break;
247  }
248 
249 
250 
251  if (
252  ($set['obj_id'] != ANONYMOUS_ROLE_ID and
253  $set['obj_id'] != SYSTEM_ROLE_ID and
254  substr($set['title_orig'], 0, 3) != 'il_') or
255  $this->getType() == self::TYPE_SEARCH) {
256  $this->tpl->setVariable('VAL_ID', $set['obj_id']);
257  }
258  $this->tpl->setVariable('VAL_TITLE_LINKED', $set['title']);
259  $this->tpl->setVariable('VAL_LINK', $link);
260  if (strlen($set['description'])) {
261  $this->tpl->setVariable('VAL_DESC', $set['description']);
262  }
263 
271  $ref = $set['parent'];
272  if ($ref == ROLE_FOLDER_ID) {
273  $this->tpl->setVariable('CONTEXT', $this->lng->txt('rbac_context_global'));
274  } else {
275  $this->tpl->setVariable(
276  'CONTEXT',
277  (string) $this->getPathGUI()->getPath(ROOT_FOLDER_ID, $ref)
278  );
279  }
280 
281  if ($this->getType() == self::TYPE_VIEW and $set['obj_id'] != SYSTEM_ROLE_ID) {
282  if ($GLOBALS['rbacsystem']->checkAccess('write', $this->role_folder_id)) {
283  // Copy role
284  $this->tpl->setVariable('COPY_TEXT', $this->lng->txt('rbac_role_rights_copy'));
285  $this->ctrl->setParameter($this->getParentObject(), "copy_source", $set["obj_id"]);
286  $link = $this->ctrl->getLinkTarget($this->getParentObject(), 'roleSearch');
287  $this->tpl->setVariable(
288  'COPY_LINK',
289  $link
290  );
291  }
292  }
293  }
294 
299  public function parse($role_folder_id)
300  {
301  global $rbacreview,$ilUser;
302 
303  $this->role_folder_id = $role_folder_id;
304 
305  include_once './Services/AccessControl/classes/class.ilObjRole.php';
306 
307  if ($this->getType() == self::TYPE_VIEW) {
308  $filter_orig = $filter = $this->getFilterItemByPostVar('role_title')->getValue();
309  $type = $this->getFilterItemByPostVar('role_type')->getValue();
310  } else {
311  $filter_orig = $filter = $this->getRoleTitleFilter();
313  }
314 
315 
316  // the translation must be filtered
318  // roles like il_crs_... are filtered manually
319  $filter = '';
320  }
321 
322  $role_list = $rbacreview->getRolesByFilter(
323  $type,
324  0,
325  $filter
326  );
327 
328  $counter = 0;
329  $rows = array();
330  foreach ((array) $role_list as $role) {
331  if (
332  $role['parent'] and
333  (
334  $GLOBALS['tree']->isDeleted($role['parent']) or
335  !$GLOBALS['tree']->isInTree($role['parent'])
336  )
337  ) {
338  continue;
339  }
340 
341  $title = ilObjRole::_getTranslation($role['title']);
343  if (strlen($filter_orig)) {
344  if (stristr($title, $filter_orig) == false) {
345  continue;
346  }
347  }
348  }
349 
350 
351  $rows[$counter]['title_orig'] = $role['title'];
352  $rows[$counter]['title'] = $title;
353  $rows[$counter]['description'] = $role['description'];
354  $rows[$counter]['obj_id'] = $role['obj_id'];
355  $rows[$counter]['parent'] = $role['parent'];
356  $rows[$counter]['type'] = $role['type'];
357 
358  $auto = (substr($role['title'], 0, 3) == 'il_' ? true : false);
359 
360 
361  // Role templates
362  if ($role['type'] == 'rolt') {
363  $rows[$counter]['rtype'] = $auto ? self::TYPE_ROLT_AU : self::TYPE_ROLT_UD;
364  } else {
365  // Roles
366  if ($role['parent'] == ROLE_FOLDER_ID) {
367  if ($role['obj_id'] == ANONYMOUS_ROLE_ID or $role['obj_id'] == SYSTEM_ROLE_ID) {
368  $rows[$counter]['rtype'] = self::TYPE_GLOBAL_AU;
369  } else {
370  $rows[$counter]['rtype'] = self::TYPE_GLOBAL_UD;
371  }
372  } else {
373  $rows[$counter]['rtype'] = $auto ? self::TYPE_LOCAL_AU : self::TYPE_LOCAL_UD;
374  }
375  }
376 
377  ++$counter;
378  }
379  $this->setMaxCount(count($rows));
380  $this->setData($rows);
381  }
382 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
Creates a path for a start and endnode.
setType($a_type)
Set table type.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
getRoleTitleFilter()
Get role title filter.
This class represents a selection list property in a property form.
$action
setRoleTitleFilter($a_filter)
Set role title filter.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
getFilterItemByPostVar($a_post_var)
parse($role_folder_id)
Parse role list.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
getParentObject()
Get parent object.
setId($a_val)
Set id.
TableGUI for the presentation og roles and role templates.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
$counter
$a_type
Definition: workflow.php:92
Class ilTable2GUI.
__construct($a_parent_gui, $a_parent_cmd)
Constructor.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
addMultiCommand($a_cmd, $a_text)
Add Command button.
This class represents a text property in a property form.
$ilUser
Definition: imgupload.php:18
getType()
Get table type.
setOptions($a_options)
Set Options.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _getTranslation($a_role_title)
Create styles array
The data for the language used.
$rows
Definition: xhr_table.php:10
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
initFilter()
Init filter.
Create new PHPExcel object
obj_idprivate
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.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setMaxCount($a_max_count)
set max.
getPathGUI()
Get path gui.