4 include_once (
'./Services/Table/classes/class.ilTable2GUI.php');
5 include_once
'./Services/AccessControl/classes/class.ilPermissionGUI.php';
36 public function __construct($a_parent_obj,$a_parent_cmd, $a_ref_id)
42 $this->lng->loadLanguageModule(
'rbac');
44 $this->ref_id = $a_ref_id;
45 $this->tree_path_ids = $tree->getPathId($this->ref_id);
47 $this->
setId(
'objroleperm_'.$this->ref_id);
49 $tpl->addJavaScript(
'./Services/AccessControl/js/ilPermSelect.js');
51 $this->
setTitle($this->lng->txt(
'permission_settings'));
54 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
56 $this->
setRowTemplate(
"tpl.obj_role_perm_row.html",
"Services/AccessControl");
111 $this->activeOperations[] = $a_ops_id;
130 $this->visible_roles = $a_ar;
158 if ($tree->checkForParentType($this->getRefId(),
'crs') or
159 $tree->checkForParentType($this->getRefId(),
'grp'))
161 $roles->setValue(self::ROLE_FILTER_LOCAL);
165 $roles->setValue(self::ROLE_FILTER_ALL);
172 self::ROLE_FILTER_ALL => $this->lng->txt(
'filter_all_roles'),
173 self::ROLE_FILTER_GLOBAL => $this->lng->txt(
'filter_global_roles'),
174 self::ROLE_FILTER_LOCAL => $this->lng->txt(
'filter_local_roles'),
175 self::ROLE_FILTER_LOCAL_POLICY => $this->lng->txt(
'filter_roles_local_policy'),
176 self::ROLE_FILTER_LOCAL_OBJECT => $this->lng->txt(
'filter_local_roles_object')
189 global $objDefinition;
193 if(isset(
$row[
'show_local_policy_row']))
195 foreach(
$row[
'roles'] as $role_id => $role_info)
197 $this->tpl->setCurrentBlock(
'role_option');
198 $this->tpl->setVariable(
'INHERIT_ROLE_ID',$role_id);
199 $this->tpl->setVariable(
'INHERIT_CHECKED',$role_info[
'local_policy'] ?
'checked=checked' :
'');
200 $this->tpl->setVariable(
'INHERIT_DISABLED',($role_info[
'protected'] or $role_info[
'isLocal']) ?
'disabled="disabled"' :
'');
201 $this->tpl->setVariable(
'TXT_INHERIT',$this->lng->txt(
'rbac_local_policy'));
202 $this->tpl->setVariable(
'INHERIT_LONG',$this->lng->txt(
'perm_use_local_policy_desc'));
203 $this->tpl->parseCurrentBlock();
208 if(isset(
$row[
'show_protected_row']))
210 foreach(
$row[
'roles'] as $role_id => $role_info)
212 $this->tpl->setCurrentBlock(
'role_protect');
213 $this->tpl->setVariable(
'PROTECT_ROLE_ID',$role_id);
214 $this->tpl->setVariable(
'PROTECT_CHECKED',$role_info[
'protected_status'] ?
'checked=checked' :
'');
215 $this->tpl->setVariable(
'PROTECT_DISABLED',$role_info[
'protected_allowed'] ?
'' :
'disabled="disabled"');
216 $this->tpl->setVariable(
'TXT_PROTECT',$this->lng->txt(
'role_protect_permissions'));
217 $this->tpl->setVariable(
'PROTECT_LONG',$this->lng->txt(
'role_protect_permissions_desc'));
218 $this->tpl->parseCurrentBlock();
224 if(isset(
$row[
'show_block_row']))
228 $this->tpl->setCurrentBlock(
'role_block');
229 $this->tpl->setVariable(
'BLOCK_ROLE_ID',$role_info[
'obj_id']);
230 $this->tpl->setVariable(
'TXT_BLOCK',$this->lng->txt(
'role_block_role'));
231 $this->tpl->setVariable(
'BLOCK_LONG',$this->lng->txt(
'role_block_role_desc'));
232 if($role_info[
'protected'] ==
'y')
234 $this->tpl->setVariable(
'BLOCK_DISABLED',
'disabled="disabled');
237 $this->tpl->parseCurrentBlock();
243 if(isset(
$row[
'show_select_all']))
247 $this->tpl->setCurrentBlock(
'role_select_all');
248 $this->tpl->setVariable(
'JS_ROLE_ID',$role[
'obj_id']);
249 $this->tpl->setVariable(
'JS_SUBID',
$row[
'subtype']);
250 $this->tpl->setVariable(
'JS_ALL_PERMS',
"['".implode(
"','",
$row[
'ops']).
"']");
251 $this->tpl->setVariable(
'JS_FORM_NAME',$this->
getFormName());
252 $this->tpl->setVariable(
'TXT_SEL_ALL',$this->lng->txt(
'select_all'));
253 $this->tpl->parseCurrentBlock();
259 if(isset(
$row[
'show_start_info']))
261 $this->tpl->setCurrentBlock(
'section_info');
262 $this->tpl->setVariable(
'SECTION_TITLE',$this->lng->txt(
'perm_class_object'));
263 $this->tpl->setVariable(
'SECTION_DESC',$this->lng->txt(
'perm_class_object_desc'));
264 $this->tpl->parseCurrentBlock();
269 if(isset(
$row[
'show_create_info']))
271 $this->tpl->setCurrentBlock(
'section_info');
272 $this->tpl->setVariable(
'SECTION_TITLE',$this->lng->txt(
'perm_class_create'));
273 $this->tpl->setVariable(
'SECTION_DESC',$this->lng->txt(
'perm_class_create_desc'));
274 $this->tpl->parseCurrentBlock();
279 foreach((array)
$row[
'roles'] as $role_id => $role_info)
281 $this->tpl->setCurrentBlock(
'role_td');
282 $this->tpl->setVariable(
'PERM_ROLE_ID',$role_id);
283 $this->tpl->setVariable(
'PERM_PERM_ID',
$row[
'perm'][
'ops_id']);
286 if(substr(
$row[
'perm'][
'operation'],0,6) ==
'create')
288 if ($objDefinition->isPlugin(substr(
$row[
'perm'][
'operation'],7)))
291 "obj_".substr(
$row[
'perm'][
'operation'],7));
295 $perm = $this->lng->txt(
'obj_'.substr(
$row[
'perm'][
'operation'],7));
300 if($this->lng->exists($this->getObjType().
'_'.
$row[
'perm'][
'operation'].
'_short'))
302 $perm = $this->lng->txt($this->
getObjType().
'_'.
$row[
'perm'][
'operation'].
'_short');
306 $perm = $this->lng->txt(
$row[
'perm'][
'operation']);
310 $this->tpl->setVariable(
'TXT_PERM',$perm);
312 if ($objDefinition->isPlugin($this->getObjType()))
317 elseif(substr(
$row[
'perm'][
'operation'],0,6) ==
'create')
319 $this->tpl->setVariable(
'PERM_LONG',$this->lng->txt(
'rbac_'.$row[
'perm'][
'operation']));
323 $this->tpl->setVariable(
'PERM_LONG',$this->lng->txt($this->getObjType().
'_'.
$row[
'perm'][
'operation']));
326 if($role_info[
'protected'])
328 $this->tpl->setVariable(
'PERM_DISABLED',$role_info[
'protected'] ?
'disabled="disabled"' :
'');
330 if($role_info[
'permission_set'])
332 $this->tpl->setVariable(
'PERM_CHECKED',
'checked="checked"');
335 $this->tpl->parseCurrentBlock();
346 global $rbacreview,$objDefinition;
355 return $this->
setData(array());
359 $operations = array();
362 $operations[$role_data[
'obj_id']] = $rbacreview->getActiveOperationsOfRole($this->
getRefId(), $role_data[
'obj_id']);
371 $local_roles = $rbacreview->getRolesOfObject($this->
getRefId());
374 $roles[$role_data[
'obj_id']] = array(
375 'protected' => $role_data[
'protected'],
376 'local_policy' => in_array($role_data[
'obj_id'],$local_roles),
377 'isLocal' => ($this->
getRefId() == $role_data[
'parent']) && $role_data[
'assign'] ==
'y'
380 $perms[$counter][
'roles'] =
$roles;
381 $perms[$counter][
'show_local_policy_row'] = 1;
392 $roles[$role_data[
'obj_id']] = array(
393 'protected_allowed' => $rbacreview->isAssignable($role_data[
'obj_id'],$this->getRefId()),
394 'protected_status' => $rbacreview->isProtected($role_data[
'parent'], $role_data[
'obj_id'])
397 $perms[$counter][
'roles'] =
$roles;
398 $perms[$counter][
'show_protected_row'] = 1;
405 $perms[$counter++][
'show_block_row'] = 1;
411 $perms[$counter++][
'show_start_info'] =
true;
415 $no_creation_operations = array();
416 foreach($rbacreview->getOperationsByTypeAndClass($this->getObjType(),
'object') as $operation)
419 $no_creation_operations[] = $operation;
425 $roles[$role_data[
'obj_id']] =
427 'protected' => $role_data[
'protected'],
428 'permission_set' => in_array($operation,(array) $operations[$role_data[
'obj_id']])
432 $op = $rbacreview->getOperation($operation);
434 $perms[$counter][
'roles'] =
$roles;
435 $perms[$counter][
'perm'] = $op;
443 if($no_creation_operations)
445 $perms[$counter][
'show_select_all'] = 1;
446 $perms[$counter][
'ops'] = $no_creation_operations;
447 $perms[$counter][
'subtype'] =
'nocreation';
452 if($objDefinition->isContainer($this->getObjType()))
454 $perms[$counter++][
'show_create_info'] =
true;
458 $objects = $objDefinition->getCreatableSubObjects($this->
getObjType());
460 $creation_operations = array();
461 foreach($objects as $type => $info)
463 $ops_id = $ops_ids[$type];
471 $creation_operations[] = $ops_id;
476 $roles[$role_data[
'obj_id']] =
478 'protected' => $role_data[
'protected'],
479 'permission_set' => in_array($ops_id,(array) $operations[$role_data[
'obj_id']])
483 $op = $rbacreview->getOperation($ops_id);
485 $perms[$counter][
'roles'] =
$roles;
486 $perms[$counter][
'perm'] = $op;
494 if(count($creation_operations))
496 $perms[$counter][
'show_select_all'] = 1;
497 $perms[$counter][
'ops'] = $creation_operations;
498 $perms[$counter][
'subtype'] =
'creation';
526 $column_widht =
"0%";
529 $all_roles = array();
532 if($role[
'obj_id'] == SYSTEM_ROLE_ID)
537 $role[
'role_type'] = $rbacreview->isGlobalRole($role[
'obj_id']) ?
'global' :
'local';
548 $all_roles[] = $role;
562 global $rbacreview,$tree;
565 $protected_status = $rbacreview->isProtected($role[
'parent'], $role[
'obj_id']) ?
'protected_' :
'';
566 if($role[
'role_type'] ==
'global')
568 $tp = $this->lng->txt(
'perm_'.$protected_status.
'global_role');
572 $tp = $this->lng->txt(
'perm_'.$protected_status.
'local_role');
575 $inheritance_seperator =
': ';
579 ($role[
'assign'] ==
'y' and $role[
'role_type'] !=
'global') or
580 ($role[
'assign'] ==
'n' and $role[
'role_type'] !=
'global')
585 $obj = $rbacreview->getObjectOfRole($role[
'obj_id']);
589 $this->lng->txt(
'perm_role_path_info_created'),
592 $inheritance_seperator =
', ';
596 $path_hierarchy = $rbacreview->getObjectsWithStopedInheritance(
598 $tree->getPathId($this->getRefId())
601 $reduced_path_hierarchy = (array) array_diff(
605 $rbacreview->getObjectReferenceOfRole($role[
'obj_id'])
611 if($role[
'assign'] ==
'n' and count($reduced_path_hierarchy))
613 $tp .= $inheritance_seperator;
615 $parent = end($reduced_path_hierarchy);
618 $tp .= sprintf($this->lng->txt(
'perm_role_path_info_inheritance'),$this->lng->txt(
'obj_'.$p_type),$p_title);
633 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
637 if($role[
'parent'] != $this->
getRefId())
639 return $role[
'title'];
641 $ilCtrl->setParameterByClass(
'ilobjrolegui',
'obj_id', $role[
'obj_id']);
643 return '<a class="tblheader" href="'.$ilCtrl->getLinkTargetByClass(
'ilobjrolegui',
'').
'" >'.$role[
'title'].
'</a>';