ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
106  case self::TYPE_VIEW:
107  $this->setShowRowsSelector(true);
108  $this->setDefaultOrderField('title');
109  $this->setDefaultOrderDirection('asc');
110  //$this->setId('rolf_role_tbl');
111  $this->addColumn($this->lng->txt('search_title_description'),'title','30%');
112  $this->addColumn($this->lng->txt('type'),'rtype','20%');
113  $this->addColumn($this->lng->txt('context'),'','40%');
114  $this->addColumn($this->lng->txt('actions'),'','10%');
115  $this->setTitle($this->lng->txt('objs_role'));
116 
117  if($GLOBALS['rbacsystem']->checkAccess('delete', $this->getParentObject()->object->getRefId()))
118  {
119  $this->addMultiCommand('confirmDelete',$this->lng->txt('delete'));
120  }
121  break;
122 
123  case self::TYPE_SEARCH:
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  {
151  $this->initFilter();
152  }
153  }
154 
158  public function initFilter()
159  {
160  $this->setDisableFilterHiding(true);
161 
162  switch($this->getType())
163  {
164  case self::TYPE_VIEW:
165  $action[ilRbacReview::FILTER_ALL] = $this->lng->txt('all_roles');
166  $action[ilRbacReview::FILTER_ALL_GLOBAL] = $this->lng->txt('all_global_roles');
167  $action[ilRbacReview::FILTER_ALL_LOCAL] = $this->lng->txt('all_local_roles');
168  $action[ilRbacReview::FILTER_INTERNAL] = $this->lng->txt('internal_local_roles_only');
169  $action[ilRbacReview::FILTER_NOT_INTERNAL] = $this->lng->txt('non_internal_local_roles_only');
170  $action[ilRbacReview::FILTER_TEMPLATES] = $this->lng->txt('role_templates_only');
171  break;
172 
173  case self::TYPE_SEARCH:
174  $action[ilRbacReview::FILTER_ALL] = $this->lng->txt('all_roles');
175  $action[ilRbacReview::FILTER_ALL_GLOBAL] = $this->lng->txt('all_global_roles');
176  $action[ilRbacReview::FILTER_ALL_LOCAL] = $this->lng->txt('all_local_roles');
177  $action[ilRbacReview::FILTER_INTERNAL] = $this->lng->txt('internal_local_roles_only');
178  $action[ilRbacReview::FILTER_NOT_INTERNAL] = $this->lng->txt('non_internal_local_roles_only');
179  break;
180  }
181 
182  include_once './Services/Form/classes/class.ilSelectInputGUI.php';
183  $roles = new ilSelectInputGUI($this->lng->txt('rbac_role_selection'), 'role_type');
184 
185  $roles->setOptions($action);
186 
187  $this->addFilterItem($roles);
188 
189  $roles->readFromSession();
190  if(!$roles->getValue())
191  {
192  $roles->setValue(ilRbacReview::FILTER_ALL_GLOBAL);
193  }
194 
195  // title filter
196  include_once './Services/Form/classes/class.ilTextInputGUI.php';
197  $title = new ilTextInputGUI($this->lng->txt('title'), 'role_title');
198  $title->setSize(16);
199  $title->setMaxLength(64);
200 
201  $this->addFilterItem($title);
202  $title->readFromSession();
203 
204  $this->filter['role_type'] = $roles->getValue();
205  $this->filter['role_title'] = $title->getValue();
206  }
207 
212  public function fillRow($set)
213  {
214  global $rbacreview,$tree;
215 
216  if($set['type'] == 'role')
217  {
218  if($set['parent'] != ROLE_FOLDER_ID)
219  {
220  $this->ctrl->setParameterByClass(
221  "ilobjrolegui",
222  "rolf_ref_id",
223  $set['parent']
224  );
225  }
226 
227  $this->ctrl->setParameterByClass("ilobjrolegui", "obj_id", $set["obj_id"]);
228  $link = $this->ctrl->getLinkTargetByClass("ilobjrolegui", "perm");
229  $this->ctrl->setParameterByClass("ilobjrolegui", "rolf_ref_id", "");
230  }
231  else
232  {
233  $this->ctrl->setParameterByClass("ilobjroletemplategui", "obj_id", $set["obj_id"]);
234  $link = $this->ctrl->getLinkTargetByClass("ilobjroletemplategui", "perm");
235  }
236 
237  switch($set['rtype'])
238  {
239  case self::TYPE_GLOBAL_AU:
240  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_global'));
241  break;
242  case self::TYPE_GLOBAL_UD:
243  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_global'));
244  break;
245  case self::TYPE_LOCAL_AU:
246  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_local'));
247  break;
248  case self::TYPE_LOCAL_UD:
249  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_local'));
250  break;
251  case self::TYPE_ROLT_AU:
252  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_auto_rolt'));
253  break;
254  case self::TYPE_ROLT_UD:
255  $this->tpl->setVariable('ROLE_TYPE', $this->lng->txt('rbac_ud_rolt'));
256  break;
257  }
258 
259 
260 
261  if(
262  ($set['obj_id'] != ANONYMOUS_ROLE_ID and
263  $set['obj_id'] != SYSTEM_ROLE_ID and
264  substr($set['title_orig'],0,3) != 'il_') or
265  $this->getType() == self::TYPE_SEARCH)
266  {
267  $this->tpl->setVariable('VAL_ID', $set['obj_id']);
268  }
269  $this->tpl->setVariable('VAL_TITLE_LINKED', $set['title']);
270  $this->tpl->setVariable('VAL_LINK', $link);
271  if(strlen($set['description']))
272  {
273  $this->tpl->setVariable('VAL_DESC', $set['description']);
274  }
275 
283  $ref = $set['parent'];
284  if($ref == ROLE_FOLDER_ID)
285  {
286  $this->tpl->setVariable('CONTEXT', $this->lng->txt('rbac_context_global'));
287  }
288  else
289  {
290  $this->tpl->setVariable(
291  'CONTEXT',
292  (string) $this->getPathGUI()->getPath(ROOT_FOLDER_ID,$ref)
293  );
294  }
295 
296  if($this->getType() == self::TYPE_VIEW and $set['obj_id'] != SYSTEM_ROLE_ID)
297  {
298  if($GLOBALS['rbacsystem']->checkAccess('write',$this->role_folder_id))
299  {
300  // Copy role
301  $this->tpl->setVariable('COPY_TEXT',$this->lng->txt('rbac_role_rights_copy'));
302  $this->ctrl->setParameter($this->getParentObject(), "copy_source", $set["obj_id"]);
303  $link = $this->ctrl->getLinkTarget($this->getParentObject(),'roleSearch');
304  $this->tpl->setVariable(
305  'COPY_LINK',
306  $link
307  );
308  }
309  }
310 
311  }
312 
317  public function parse($role_folder_id)
318  {
319  global $rbacreview,$ilUser;
320 
321  $this->role_folder_id = $role_folder_id;
322 
323  include_once './Services/AccessControl/classes/class.ilObjRole.php';
324 
325  if($this->getType() == self::TYPE_VIEW)
326  {
327  $filter_orig = $filter = $this->getFilterItemByPostVar('role_title')->getValue();
328  $type = $this->getFilterItemByPostVar('role_type')->getValue();
329  }
330  else
331  {
332  $filter_orig = $filter = $this->getRoleTitleFilter();
334  }
335 
336 
337  // the translation must be filtered
339  {
340  // roles like il_crs_... are filtered manually
341  $filter = '';
342  }
343 
344  $role_list = $rbacreview->getRolesByFilter(
345  $type,
346  0,
347  $filter
348  );
349 
350  $counter = 0;
351  $rows = array();
352  foreach((array) $role_list as $role)
353  {
354  if(
355  $role['parent'] and
356  (
357  $GLOBALS['tree']->isDeleted($role['parent']) or
358  !$GLOBALS['tree']->isInTree($role['parent'])
359  )
360  )
361  {
362  continue;
363  }
364 
365  $title = ilObjRole::_getTranslation($role['title']);
367  {
368  if(strlen($filter_orig))
369  {
370  if(stristr($title, $filter_orig) == FALSE)
371  {
372  continue;
373  }
374  }
375  }
376 
377 
378  $rows[$counter]['title_orig'] = $role['title'];
379  $rows[$counter]['title'] = $title;
380  $rows[$counter]['description'] = $role['description'];
381  $rows[$counter]['obj_id'] = $role['obj_id'];
382  $rows[$counter]['parent'] = $role['parent'];
383  $rows[$counter]['type'] = $role['type'];
384 
385  $auto = (substr($role['title'], 0, 3) == 'il_' ? true : false);
386 
387 
388  // Role templates
389  if($role['type'] == 'rolt')
390  {
391  $rows[$counter]['rtype'] = $auto ? self::TYPE_ROLT_AU : self::TYPE_ROLT_UD;
392  }
393  else
394  {
395  // Roles
396  if($role['parent'] == ROLE_FOLDER_ID)
397  {
398  if($role['obj_id'] == ANONYMOUS_ROLE_ID or $role['obj_id'] == SYSTEM_ROLE_ID)
399  {
400  $rows[$counter]['rtype'] = self::TYPE_GLOBAL_AU;
401  }
402  else
403  {
404  $rows[$counter]['rtype'] = self::TYPE_GLOBAL_UD;
405  }
406  }
407  else
408  {
409  $rows[$counter]['rtype'] = $auto ? self::TYPE_LOCAL_AU : self::TYPE_LOCAL_UD;
410  }
411  }
412 
413  ++$counter;
414  }
415  $this->setMaxCount(count($rows));
416  $this->setData($rows);
417  }
418 }
419 
420 ?>
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.
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:93
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.
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
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.
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.
getPathGUI()
Get path gui.