ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
17 {
18  private $ref_id = null;
19  private $role_id = null;
20  private $role_folder_id = 0;
21 
22  private $tpl_type = '';
23 
24  private $show_admin_permissions = false;
25 
26  private static $template_permissions = NULL;
27 
28 
33  public function __construct($a_parent_obj,$a_parent_cmd, $a_ref_id,$a_role_id,$a_type,$a_show_admin_permissions = false)
34  {
35  global $ilCtrl,$rbacreview,$tpl;
36 
37  $this->tpl_type = $a_type;
38  $this->show_admin_permissions = $a_show_admin_permissions;
39 
40  parent::__construct($a_parent_obj,$a_parent_cmd);
41 
42  $this->setId('role_template_'.$a_ref_id.'_'.$a_type);
43  $this->setFormName('role_template_permissions');
44  $this->setSelectAllCheckbox('template_perm['.$this->getTemplateType().']');
45 
46 
47  $this->lng->loadLanguageModule('rbac');
48 
49  $this->ref_id = $a_ref_id;
50  $this->role_id = $a_role_id;
51 
52  $this->role_folder_id = $rbacreview->getRoleFolderIdOfObject($this->getRefId());
53 
54  $this->setRowTemplate("tpl.obj_role_template_perm_row.html", "Services/AccessControl");
55  $this->setLimit(100);
56  $this->setShowRowsSelector(false);
57  $this->setDisableFilterHiding(true);
58  $this->setNoEntriesText($this->lng->txt('msg_no_roles_of_type'));
59 
60  $this->setEnableHeader(false);
61  $this->disable('sort');
62  $this->disable('numinfo');
63  $this->disable('form');
64 
65  $this->addColumn('','','0');
66  $this->addColumn('','','100%');
67 
68  $this->initTemplatePermissions();
69 
70  }
71 
76  protected function initTemplatePermissions()
77  {
78  global $rbacreview;
79 
80  if(self::$template_permissions !== NULL)
81  {
82  return true;
83  }
84  self::$template_permissions = $rbacreview->getAllOperationsOfRole(
85  $this->getRoleId(),
86  $this->getRoleFolderId()
87  );
88  }
89 
95  protected function getPermissions($a_type)
96  {
97  return self::$template_permissions[$a_type] ? self::$template_permissions[$a_type] : array();
98  }
99 
105  public function initTemplateType($a_type)
106  {
107  }
108 
113  public function getTemplateType()
114  {
115  return $this->tpl_type;
116  }
117 
122  public function getRoleFolderId()
123  {
124  return $this->role_folder_id;
125  }
126 
131  public function getRoleId()
132  {
133  return $this->role_id;
134  }
135 
140  public function getRefId()
141  {
142  return $this->ref_id;
143  }
144 
149  public function getObjId()
150  {
151  return ilObject::_lookupObjId($this->getRefId());
152  }
153 
158  public function getObjType()
159  {
160  return ilObject::_lookupType($this->getObjId());
161  }
162 
167  public function fillRow($row)
168  {
169  global $objDefinition;
170 
171  if(isset($row['show_ce']))
172  {
173  $this->tpl->setCurrentBlock('ce_td');
174  $this->tpl->setVariable('CE_TYPE',$this->getTemplateType());
175  $this->tpl->parseCurrentBlock();
176 
177  $this->tpl->setCurrentBlock('ce_desc_td');
178  $this->tpl->setVariable('CE_DESC_TYPE',$this->getTemplateType());
179  $this->tpl->setVariable('CE_LONG',$this->lng->txt('change_existing_object_type_desc'));
180 
181  if($objDefinition->isSystemObject($this->getTemplateType()))
182  {
183  $this->tpl->setVariable("TXT_CE",
184  $this->lng->txt("change_existing_prefix_single")." ".
185  $this->lng->txt("obj_".$this->getTemplateType())." ".
186  $this->lng->txt("change_existing_suffix_single")
187  );
188  }
189  else
190  {
191  $pl_txt = ($objDefinition->isPlugin($this->getTemplateType()))
192  ? ilPlugin::lookupTxt("rep_robj", $this->getTemplateType(),
193  "objs_".$this->getTemplateType())
194  : $this->lng->txt('objs_'.$this->getTemplateType());
195 
196  $this->tpl->setVariable('TXT_CE',
197  $this->lng->txt('change_existing_prefix').' '.
198  $pl_txt.' '.
199  $this->lng->txt('change_existing_suffix'));
200  $this->tpl->parseCurrentBlock();
201  }
202  return true;
203  }
204  else
205  {
206  $this->tpl->setCurrentBlock('perm_td');
207  $this->tpl->setVariable('OBJ_TYPE',$this->getTemplateType());
208  $this->tpl->setVariable('PERM_PERM_ID',$row['ops_id']);
209  $this->tpl->setVariable('PERM_CHECKED',$row['set'] ? 'checked="checked"' : '');
210 
211  if($this->getRoleId() == SYSTEM_ROLE_ID)
212  {
213  $this->tpl->setVariable('PERM_DISABLED','disabled="disabled"');
214  }
215 
216  $this->tpl->parseCurrentBlock();
217 
218  $this->tpl->setCurrentBlock('perm_desc_td');
219  $this->tpl->setVariable('DESC_TYPE',$this->getTemplateType());
220  $this->tpl->setVariable('DESC_PERM_ID',$row['ops_id']);
221 
222  if ($row["create_type"] != "" && $objDefinition->isPlugin($row['create_type']))
223  {
224  $this->tpl->setVariable('TXT_PERMISSION',
225  ilPlugin::lookupTxt("rep_robj", $row['create_type'],
226  $this->getTemplateType()."_".$row['name']));
227  }
228  else if ($row["create_type"] == "" && $objDefinition->isPlugin($this->getTemplateType()))
229  {
230  $this->tpl->setVariable('TXT_PERMISSION',
231  ilPlugin::lookupTxt("rep_robj", $this->getTemplateType(),
232  $this->getTemplateType()."_".$row['name']));
233  }
234  else
235  {
236  if(substr($row['name'],0,6) == 'create')
237  {
238  #$perm = $this->lng->txt($this->getTemplateType().'_'.$row['name']);
239  $perm = $this->lng->txt('rbac'.'_'.$row['name']);
240  }
241  elseif($this->lng->exists($this->getTemplateType().'_'.$row['name'].'_short'))
242  {
243  $perm = $this->lng->txt($this->getTemplateType().'_'.$row['name'].'_short').': '.
244  $this->lng->txt($this->getTemplateType().'_'.$row['name']);
245  }
246  else
247  {
248  $perm = $this->lng->txt($row['name']).': '.$this->lng->txt($this->getTemplateType().'_'.$row['name']);
249  }
250 
251  $this->tpl->setVariable('TXT_PERMISSION',$perm);
252  }
253  $this->tpl->parseCurrentBlock();
254 
255  return true;
256  }
257  }
258 
263  public function parse()
264  {
265  global $rbacreview, $objDefinition;
266 
267  $operations = $this->getPermissions($this->getTemplateType());
268 
269 
270  // Object permissions
271  $rows = array();
272  foreach($rbacreview->getOperationsByTypeAndClass($this->getTemplateType(), 'object') as $ops_id)
273  {
274  $operations = $this->getPermissions($this->getTemplateType());
275 
276  $operation = $rbacreview->getOperation($ops_id);
277 
278  $perm['ops_id'] = $ops_id;
279  $perm['set'] = (in_array($ops_id,$operations) or $this->getRoleId() == SYSTEM_ROLE_ID);
280  $perm['name'] = $operation['operation'];
281 
282  $rows[] = $perm;
283  }
284 
285  // Get creatable objects
286  $objects = $objDefinition->getCreatableSubObjects($this->getTemplateType());
287  $ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
288 
289  foreach($objects as $type => $info)
290  {
291  $ops_id = $ops_ids[$type];
292 
293  if(!$ops_id)
294  {
295  continue;
296  }
297 
298  $perm['ops_id'] = $ops_id;
299  $perm['set'] = (in_array($ops_id,$operations) or $this->getRoleId() == SYSTEM_ROLE_ID);
300 
301  $perm['name'] = 'create_'.$info['name'];
302  $perm['create_type'] = $info['name'];
303 
304  $rows[] = $perm;
305  }
306 
307  if(!$this->show_admin_permissions)
308  {
309  $rows[] = array('show_ce' => 1);
310  }
311 
312  $this->setData($rows);
313  }
314 
315 
316 
317 }
318 ?>