ILIAS  eassessment Revision 61809
 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  $this->tpl->parseCurrentBlock();
211 
212  $this->tpl->setCurrentBlock('perm_desc_td');
213  $this->tpl->setVariable('DESC_TYPE',$this->getTemplateType());
214  $this->tpl->setVariable('DESC_PERM_ID',$row['ops_id']);
215 
216  if ($row["create_type"] != "" && $objDefinition->isPlugin($row['create_type']))
217  {
218  $this->tpl->setVariable('TXT_PERMISSION',
219  ilPlugin::lookupTxt("rep_robj", $row['create_type'],
220  $this->getTemplateType()."_".$row['name']));
221  }
222  else if ($row["create_type"] == "" && $objDefinition->isPlugin($this->getTemplateType()))
223  {
224  $this->tpl->setVariable('TXT_PERMISSION',
225  ilPlugin::lookupTxt("rep_robj", $this->getTemplateType(),
226  $this->getTemplateType()."_".$row['name']));
227  }
228  else
229  {
230  $this->tpl->setVariable('TXT_PERMISSION',$this->lng->txt($this->getTemplateType().'_'.$row['name']));
231  }
232  $this->tpl->parseCurrentBlock();
233 
234  return true;
235  }
236  }
237 
242  public function parse()
243  {
244  global $rbacreview, $objDefinition;
245 
246  $operations = $this->getPermissions($this->getTemplateType());
247 
248 
249  // Object permissions
250  $rows = array();
251  foreach($rbacreview->getOperationsByTypeAndClass($this->getTemplateType(), 'object') as $ops_id)
252  {
253  $operations = $this->getPermissions($this->getTemplateType());
254 
255  $operation = $rbacreview->getOperation($ops_id);
256 
257  $perm['ops_id'] = $ops_id;
258  $perm['set'] = in_array($ops_id,$operations);
259  $perm['name'] = $operation['operation'];
260 
261  $rows[] = $perm;
262  }
263 
264  // Get creatable objects
265  $objects = $objDefinition->getCreatableSubObjects($this->getTemplateType());
266  $ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
267 
268  foreach($objects as $type => $info)
269  {
270  $ops_id = $ops_ids[$type];
271 
272  if(!$ops_id)
273  {
274  continue;
275  }
276 
277  $perm['ops_id'] = $ops_id;
278  $perm['set'] = in_array($ops_id,$operations);
279 
280  $perm['name'] = 'create_'.$info['name'];
281  $perm['create_type'] = $info['name'];
282 
283  $rows[] = $perm;
284  }
285 
286  if(!$this->show_admin_permissions)
287  {
288  $rows[] = array('show_ce' => 1);
289  }
290 
291  $this->setData($rows);
292  }
293 
294 
295 
296 }
297 ?>