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