ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_once ('./Services/Table/classes/class.ilTable2GUI.php');
5 include_once './Services/AccessControl/classes/class.ilPermissionGUI.php';
6 require_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;
26 
27  private static $template_permissions = NULL;
28 
29 
34  public function __construct($a_parent_obj,$a_parent_cmd, $a_ref_id,$a_role_id,$a_type,$a_show_admin_permissions = false)
35  {
36  global $ilCtrl,$rbacreview,$tpl;
37 
38  $this->tpl_type = $a_type;
39  $this->show_admin_permissions = $a_show_admin_permissions;
40 
41  parent::__construct($a_parent_obj,$a_parent_cmd);
42 
43  $this->setId('role_template_'.$a_ref_id.'_'.$a_type);
44  $this->setFormName('role_template_permissions');
45  $this->setSelectAllCheckbox('template_perm['.$this->getTemplateType().']');
46 
47 
48  $this->lng->loadLanguageModule('rbac');
49 
50  $this->ref_id = $a_ref_id;
51  $this->role_id = $a_role_id;
52 
53  $this->setRowTemplate("tpl.obj_role_template_perm_row.html", "Services/AccessControl");
54  $this->setLimit(100);
55  $this->setShowRowsSelector(false);
56  $this->setDisableFilterHiding(true);
57  $this->setNoEntriesText($this->lng->txt('msg_no_roles_of_type'));
58 
59  $this->setEnableHeader(false);
60  $this->disable('sort');
61  $this->disable('numinfo');
62  $this->disable('form');
63 
64  $this->addColumn('','','0');
65  $this->addColumn('','','100%');
66 
67  $this->initTemplatePermissions();
68 
69  }
70 
75  protected function initTemplatePermissions()
76  {
77  global $rbacreview;
78 
79  if(self::$template_permissions !== NULL)
80  {
81  return true;
82  }
83  self::$template_permissions = $rbacreview->getAllOperationsOfRole(
84  $this->getRoleId(),
85  $this->getRefId()
86  );
87  }
88 
94  protected function getPermissions($a_type)
95  {
96  return self::$template_permissions[$a_type] ? self::$template_permissions[$a_type] : array();
97  }
98 
104  public function initTemplateType($a_type)
105  {
106  }
107 
112  public function getTemplateType()
113  {
114  return $this->tpl_type;
115  }
116 
121  public function getRoleId()
122  {
123  return $this->role_id;
124  }
125 
130  public function getRefId()
131  {
132  return $this->ref_id;
133  }
134 
139  public function getObjId()
140  {
141  return ilObject::_lookupObjId($this->getRefId());
142  }
143 
148  public function getObjType()
149  {
150  return ilObject::_lookupType($this->getObjId());
151  }
152 
157  public function fillRow($row)
158  {
159  global $objDefinition;
160 
161  if(isset($row['show_ce']))
162  {
163  $this->tpl->setCurrentBlock('ce_td');
164  $this->tpl->setVariable('CE_TYPE',$this->getTemplateType());
165  $this->tpl->parseCurrentBlock();
166 
167  $this->tpl->setCurrentBlock('ce_desc_td');
168  $this->tpl->setVariable('CE_DESC_TYPE',$this->getTemplateType());
169  $this->tpl->setVariable('CE_LONG',$this->lng->txt('change_existing_object_type_desc'));
170 
171  if($objDefinition->isSystemObject($this->getTemplateType()))
172  {
173  $this->tpl->setVariable("TXT_CE",
174  $this->lng->txt("change_existing_prefix_single")." ".
175  $this->lng->txt("obj_".$this->getTemplateType())." ".
176  $this->lng->txt("change_existing_suffix_single")
177  );
178  }
179  else
180  {
181  $pl_txt = ($objDefinition->isPlugin($this->getTemplateType()))
183  "objs_".$this->getTemplateType())
184  : $this->lng->txt('objs_'.$this->getTemplateType());
185 
186  $this->tpl->setVariable('TXT_CE',
187  $this->lng->txt('change_existing_prefix').' '.
188  $pl_txt.' '.
189  $this->lng->txt('change_existing_suffix'));
190  $this->tpl->parseCurrentBlock();
191  }
192  return true;
193  }
194  else
195  {
196  $this->tpl->setCurrentBlock('perm_td');
197  $this->tpl->setVariable('OBJ_TYPE',$this->getTemplateType());
198  $this->tpl->setVariable('PERM_PERM_ID',$row['ops_id']);
199  $this->tpl->setVariable('PERM_CHECKED',$row['set'] ? 'checked="checked"' : '');
200 
201  if($this->getRoleId() == SYSTEM_ROLE_ID)
202  {
203  $this->tpl->setVariable('PERM_DISABLED','disabled="disabled"');
204  }
205 
206  $this->tpl->parseCurrentBlock();
207 
208  $this->tpl->setCurrentBlock('perm_desc_td');
209  $this->tpl->setVariable('DESC_TYPE',$this->getTemplateType());
210  $this->tpl->setVariable('DESC_PERM_ID',$row['ops_id']);
211 
212  if ($row["create_type"] != "" && $objDefinition->isPlugin($row['create_type']))
213  {
214  $this->tpl->setVariable('TXT_PERMISSION',
215  ilObjectPlugin::lookupTxtById($row['create_type'],
216  $this->getTemplateType()."_".$row['name']));
217  }
218  else if ($row["create_type"] == "" && $objDefinition->isPlugin($this->getTemplateType()))
219  {
220  $this->tpl->setVariable('TXT_PERMISSION',
222  $this->getTemplateType()."_".$row['name']));
223  }
224  else
225  {
226  if(substr($row['name'],0,6) == 'create')
227  {
228  #$perm = $this->lng->txt($this->getTemplateType().'_'.$row['name']);
229  $perm = $this->lng->txt('rbac'.'_'.$row['name']);
230  }
231  elseif($this->lng->exists($this->getTemplateType().'_'.$row['name'].'_short'))
232  {
233  $perm = $this->lng->txt($this->getTemplateType().'_'.$row['name'].'_short').': '.
234  $this->lng->txt($this->getTemplateType().'_'.$row['name']);
235  }
236  else
237  {
238  $perm = $this->lng->txt($row['name']).': '.$this->lng->txt($this->getTemplateType().'_'.$row['name']);
239  }
240 
241  $this->tpl->setVariable('TXT_PERMISSION',$perm);
242  }
243  $this->tpl->parseCurrentBlock();
244 
245  return true;
246  }
247  }
248 
253  public function parse()
254  {
255  global $rbacreview, $objDefinition;
256 
257  $operations = $this->getPermissions($this->getTemplateType());
258 
259 
260  // Object permissions
261  $rows = array();
262  foreach($rbacreview->getOperationsByTypeAndClass($this->getTemplateType(), 'object') as $ops_id)
263  {
264  $operations = $this->getPermissions($this->getTemplateType());
265 
266  $operation = $rbacreview->getOperation($ops_id);
267 
268  $perm['ops_id'] = $ops_id;
269  $perm['set'] = (in_array($ops_id,$operations) or $this->getRoleId() == SYSTEM_ROLE_ID);
270  $perm['name'] = $operation['operation'];
271 
272  $rows[] = $perm;
273  }
274 
275  // Get creatable objects
276  $objects = $objDefinition->getCreatableSubObjects($this->getTemplateType());
277  $ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
278 
279  foreach($objects as $type => $info)
280  {
281  $ops_id = $ops_ids[$type];
282 
283  if(!$ops_id)
284  {
285  continue;
286  }
287 
288  $perm['ops_id'] = $ops_id;
289  $perm['set'] = (in_array($ops_id,$operations) or $this->getRoleId() == SYSTEM_ROLE_ID);
290 
291  $perm['name'] = 'create_'.$info['name'];
292  $perm['create_type'] = $info['name'];
293 
294  $rows[] = $perm;
295  }
296 
297  if(!$this->show_admin_permissions)
298  {
299  $rows[] = array('show_ce' => 1);
300  }
301 
302  $this->setData($rows);
303  }
304 
305 
306 
307 }
308 ?>
static lookupTxtById($plugin_id, $lang_var)
__construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_role_id, $a_type, $a_show_admin_permissions=false)
Constructor.
setNoEntriesText($a_text)
Set text for an empty table.
setId($a_val)
Set id.
static lookupCreateOperationIds($a_type_arr)
Lookup operation ids.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:93
$info
Definition: example_052.php:80
Class ilTable2GUI.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
static _lookupObjId($a_id)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
disable($a_module_name)
diesables particular modules of table
initTemplateType($a_type)
Set object type for current template permission table.
setFormName($a_formname="")
Set Form name.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setEnableHeader($a_enableheader)
Set Enable Header.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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.
setLimit($a_limit=0, $a_default_limit=0)