ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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;
27 
28  private static $template_permissions = null;
29 
30 
35  public function __construct($a_parent_obj, $a_parent_cmd, $a_ref_id, $a_role_id, $a_type, $a_show_admin_permissions = false)
36  {
37  global $ilCtrl,$rbacreview,$tpl;
38 
39  $this->tpl_type = $a_type;
40  $this->show_admin_permissions = $a_show_admin_permissions;
41 
42  parent::__construct($a_parent_obj, $a_parent_cmd);
43 
44  $this->setId('role_template_' . $a_ref_id . '_' . $a_type);
45  $this->setFormName('role_template_permissions');
46  $this->setSelectAllCheckbox('template_perm[' . $this->getTemplateType() . ']');
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 
73  public function setShowChangeExistingObjects($a_status)
74  {
75  $this->show_change_existing_objects = $a_status;
76  }
77 
81  public function getShowChangeExistingObjects()
82  {
84  }
85 
90  protected function initTemplatePermissions()
91  {
92  global $rbacreview;
93 
94  if (self::$template_permissions !== null) {
95  return true;
96  }
97  self::$template_permissions = $rbacreview->getAllOperationsOfRole(
98  $this->getRoleId(),
99  $this->getRefId()
100  );
101  }
102 
108  protected function getPermissions($a_type)
109  {
110  return self::$template_permissions[$a_type] ? self::$template_permissions[$a_type] : array();
111  }
112 
118  public function initTemplateType($a_type)
119  {
120  }
121 
126  public function getTemplateType()
127  {
128  return $this->tpl_type;
129  }
130 
135  public function getRoleId()
136  {
137  return $this->role_id;
138  }
139 
144  public function getRefId()
145  {
146  return $this->ref_id;
147  }
148 
153  public function getObjId()
154  {
155  return ilObject::_lookupObjId($this->getRefId());
156  }
157 
162  public function getObjType()
163  {
164  return ilObject::_lookupType($this->getObjId());
165  }
166 
171  public function fillRow($row)
172  {
173  global $objDefinition;
174 
175  if (isset($row['show_ce'])) {
176  $this->tpl->setCurrentBlock('ce_td');
177  $this->tpl->setVariable('CE_TYPE', $this->getTemplateType());
178  $this->tpl->parseCurrentBlock();
179 
180  $this->tpl->setCurrentBlock('ce_desc_td');
181  $this->tpl->setVariable('CE_DESC_TYPE', $this->getTemplateType());
182  $this->tpl->setVariable('CE_LONG', $this->lng->txt('change_existing_object_type_desc'));
183 
184  if ($objDefinition->isSystemObject($this->getTemplateType())) {
185  $this->tpl->setVariable(
186  "TXT_CE",
187  $this->lng->txt("change_existing_prefix_single") . " " .
188  $this->lng->txt("obj_" . $this->getTemplateType()) . " " .
189  $this->lng->txt("change_existing_suffix_single")
190  );
191  } else {
192  $pl_txt = ($objDefinition->isPlugin($this->getTemplateType()))
194  $this->getTemplateType(),
195  "objs_" . $this->getTemplateType()
196  )
197  : $this->lng->txt('objs_' . $this->getTemplateType());
198  $this->tpl->setVariable(
199  'TXT_CE',
200  $this->lng->txt('change_existing_prefix') . ' ' .
201  $pl_txt . ' ' .
202  $this->lng->txt('change_existing_suffix')
203  );
204  $this->tpl->parseCurrentBlock();
205  }
206  return true;
207  } else {
208  $this->tpl->setCurrentBlock('perm_td');
209  $this->tpl->setVariable('OBJ_TYPE', $this->getTemplateType());
210  $this->tpl->setVariable('PERM_PERM_ID', $row['ops_id']);
211  $this->tpl->setVariable('PERM_CHECKED', $row['set'] ? 'checked="checked"' : '');
212 
213  if ($this->getRoleId() == SYSTEM_ROLE_ID) {
214  $this->tpl->setVariable('PERM_DISABLED', 'disabled="disabled"');
215  }
216 
217  $this->tpl->parseCurrentBlock();
218 
219  $this->tpl->setCurrentBlock('perm_desc_td');
220  $this->tpl->setVariable('DESC_TYPE', $this->getTemplateType());
221  $this->tpl->setVariable('DESC_PERM_ID', $row['ops_id']);
222 
223  if ($row["create_type"] != "" && $objDefinition->isPlugin($row['create_type'])) {
224  $this->tpl->setVariable(
225  'TXT_PERMISSION',
227  $row['create_type'],
228  $this->getTemplateType() . "_" . $row['name']
229  )
230  );
231  } elseif ($row["create_type"] == "" && $objDefinition->isPlugin($this->getTemplateType())) {
232  $this->tpl->setVariable(
233  'TXT_PERMISSION',
235  $this->getTemplateType(),
236  $this->getTemplateType() . "_" . $row['name']
237  )
238  );
239  } else {
240  if (substr($row['name'], 0, 6) == 'create') {
241  #$perm = $this->lng->txt($this->getTemplateType().'_'.$row['name']);
242  $perm = $this->lng->txt('rbac' . '_' . $row['name']);
243  } elseif ($this->lng->exists($this->getTemplateType() . '_' . $row['name'] . '_short')) {
244  $perm = $this->lng->txt($this->getTemplateType() . '_' . $row['name'] . '_short') . ': ' .
245  $this->lng->txt($this->getTemplateType() . '_' . $row['name']);
246  } else {
247  $perm = $this->lng->txt($row['name']) . ': ' . $this->lng->txt($this->getTemplateType() . '_' . $row['name']);
248  }
249 
250  $this->tpl->setVariable('TXT_PERMISSION', $perm);
251  }
252  $this->tpl->parseCurrentBlock();
253 
254  return true;
255  }
256  }
257 
262  public function parse()
263  {
264  global $rbacreview, $objDefinition;
265 
266  $operations = $this->getPermissions($this->getTemplateType());
267 
268 
269  // Object permissions
270  $rows = array();
271  foreach ($rbacreview->getOperationsByTypeAndClass($this->getTemplateType(), 'object') as $ops_id) {
272  $operations = $this->getPermissions($this->getTemplateType());
273 
274  $operation = $rbacreview->getOperation($ops_id);
275 
276  $perm['ops_id'] = $ops_id;
277  $perm['set'] = (in_array($ops_id, $operations) or $this->getRoleId() == SYSTEM_ROLE_ID);
278  $perm['name'] = $operation['operation'];
279 
280  $rows[] = $perm;
281  }
282 
283  // Get creatable objects
284  $objects = $objDefinition->getCreatableSubObjects($this->getTemplateType());
285  $ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
286 
287  foreach ($objects as $type => $info) {
288  $ops_id = $ops_ids[$type];
289 
290  if (!$ops_id) {
291  continue;
292  }
293 
294  $perm['ops_id'] = $ops_id;
295  $perm['set'] = (in_array($ops_id, $operations) or $this->getRoleId() == SYSTEM_ROLE_ID);
296 
297  $perm['name'] = 'create_' . $info['name'];
298  $perm['create_type'] = $info['name'];
299 
300  $rows[] = $perm;
301  }
302 
303  if (
304  !$this->show_admin_permissions &&
306  ) {
307  $rows[] = array('show_ce' => 1);
308  }
309 
310  $this->setData($rows);
311  }
312 }
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.
$type
setNoEntriesText($a_text)
Set text for an empty table.
setId($a_val)
Set id.
static lookupCreateOperationIds($a_type_arr)
Lookup operation ids.
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:92
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
$rows
Definition: xhr_table.php:10
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.
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.
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.
$info
Definition: index.php:5
setLimit($a_limit=0, $a_default_limit=0)