4 include_once (
'./Services/Table/classes/class.ilTable2GUI.php');
5 include_once
'./Services/AccessControl/classes/class.ilPermissionGUI.php';
37 public function __construct($a_parent_obj,$a_parent_cmd, $a_ref_id)
43 $this->lng->loadLanguageModule(
'rbac');
45 $this->ref_id = $a_ref_id;
46 $this->tree_path_ids = $tree->getPathId($this->ref_id);
47 $this->role_folder_id = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
49 $this->
setId(
'objroleperm_'.$this->ref_id);
51 $tpl->addJavaScript(
'./Services/AccessControl/js/ilPermSelect.js');
53 $this->
setTitle($this->lng->txt(
'permission_settings'));
56 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
58 $this->
setRowTemplate(
"tpl.obj_role_perm_row.html",
"Services/AccessControl");
121 $this->activeOperations[] = $a_ops_id;
140 $this->visible_roles = $a_ar;
168 if ($tree->checkForParentType($this->getRefId(),
'crs') or
169 $tree->checkForParentType($this->getRefId(),
'grp'))
171 $roles->setValue(self::ROLE_FILTER_LOCAL);
175 $roles->setValue(self::ROLE_FILTER_ALL);
182 self::ROLE_FILTER_ALL => $this->lng->txt(
'filter_all_roles'),
183 self::ROLE_FILTER_GLOBAL => $this->lng->txt(
'filter_global_roles'),
184 self::ROLE_FILTER_LOCAL => $this->lng->txt(
'filter_local_roles'),
185 self::ROLE_FILTER_LOCAL_POLICY => $this->lng->txt(
'filter_roles_local_policy'),
186 self::ROLE_FILTER_LOCAL_OBJECT => $this->lng->txt(
'filter_local_roles_object')
199 global $objDefinition;
203 if(isset(
$row[
'show_local_policy_row']))
205 foreach(
$row[
'roles'] as $role_id => $role_info)
207 $this->tpl->setCurrentBlock(
'role_option');
208 $this->tpl->setVariable(
'INHERIT_ROLE_ID',$role_id);
209 $this->tpl->setVariable(
'INHERIT_CHECKED',$role_info[
'local_policy'] ?
'checked=checked' :
'');
210 $this->tpl->setVariable(
'INHERIT_DISABLED',($role_info[
'protected'] or $role_info[
'isLocal']) ?
'disabled="disabled"' :
'');
211 $this->tpl->setVariable(
'TXT_INHERIT',$this->lng->txt(
'rbac_local_policy'));
212 $this->tpl->setVariable(
'INHERIT_LONG',$this->lng->txt(
'perm_use_local_policy_desc'));
213 $this->tpl->parseCurrentBlock();
218 if(isset(
$row[
'show_protected_row']))
220 foreach(
$row[
'roles'] as $role_id => $role_info)
222 $this->tpl->setCurrentBlock(
'role_protect');
223 $this->tpl->setVariable(
'PROTECT_ROLE_ID',$role_id);
224 $this->tpl->setVariable(
'PROTECT_CHECKED',$role_info[
'protected_status'] ?
'checked=checked' :
'');
225 $this->tpl->setVariable(
'PROTECT_DISABLED',$role_info[
'protected_allowed'] ?
'' :
'disabled="disabled"');
226 $this->tpl->setVariable(
'TXT_PROTECT',$this->lng->txt(
'role_protect_permissions'));
227 $this->tpl->setVariable(
'PROTECT_LONG',$this->lng->txt(
'role_protect_permissions_desc'));
228 $this->tpl->parseCurrentBlock();
234 if(isset(
$row[
'show_block_row']))
238 $this->tpl->setCurrentBlock(
'role_block');
239 $this->tpl->setVariable(
'BLOCK_ROLE_ID',$role_info[
'obj_id']);
240 $this->tpl->setVariable(
'TXT_BLOCK',$this->lng->txt(
'role_block_role'));
241 $this->tpl->setVariable(
'BLOCK_LONG',$this->lng->txt(
'role_block_role_desc'));
242 if($role_info[
'protected'] ==
'y')
244 $this->tpl->setVariable(
'BLOCK_DISABLED',
'disabled="disabled');
247 $this->tpl->parseCurrentBlock();
253 if(isset(
$row[
'show_select_all']))
257 $this->tpl->setCurrentBlock(
'role_select_all');
258 $this->tpl->setVariable(
'JS_ROLE_ID',$role[
'obj_id']);
259 $this->tpl->setVariable(
'JS_SUBID',
$row[
'subtype']);
260 $this->tpl->setVariable(
'JS_ALL_PERMS',
"['".implode(
"','",
$row[
'ops']).
"']");
261 $this->tpl->setVariable(
'JS_FORM_NAME',$this->
getFormName());
262 $this->tpl->setVariable(
'TXT_SEL_ALL',$this->lng->txt(
'select_all'));
263 $this->tpl->parseCurrentBlock();
269 if(isset(
$row[
'show_start_info']))
271 $this->tpl->setCurrentBlock(
'section_info');
272 $this->tpl->setVariable(
'SECTION_TITLE',$this->lng->txt(
'perm_class_object'));
273 $this->tpl->setVariable(
'SECTION_DESC',$this->lng->txt(
'perm_class_object_desc'));
274 $this->tpl->parseCurrentBlock();
279 if(isset(
$row[
'show_create_info']))
281 $this->tpl->setCurrentBlock(
'section_info');
282 $this->tpl->setVariable(
'SECTION_TITLE',$this->lng->txt(
'perm_class_create'));
283 $this->tpl->setVariable(
'SECTION_DESC',$this->lng->txt(
'perm_class_create_desc'));
284 $this->tpl->parseCurrentBlock();
289 foreach((array)
$row[
'roles'] as $role_id => $role_info)
291 $this->tpl->setCurrentBlock(
'role_td');
292 $this->tpl->setVariable(
'PERM_ROLE_ID',$role_id);
293 $this->tpl->setVariable(
'PERM_PERM_ID',
$row[
'perm'][
'ops_id']);
296 if(substr(
$row[
'perm'][
'operation'],0,6) ==
'create')
298 if ($objDefinition->isPlugin(substr(
$row[
'perm'][
'operation'],7)))
301 "obj_".substr(
$row[
'perm'][
'operation'],7));
305 $perm = $this->lng->txt(
'obj_'.substr(
$row[
'perm'][
'operation'],7));
310 if($this->lng->exists($this->getObjType().
'_'.
$row[
'perm'][
'operation'].
'_short'))
312 $perm = $this->lng->txt($this->
getObjType().
'_'.
$row[
'perm'][
'operation'].
'_short');
316 $perm = $this->lng->txt(
$row[
'perm'][
'operation']);
320 $this->tpl->setVariable(
'TXT_PERM',$perm);
322 if ($objDefinition->isPlugin($this->getObjType()))
327 elseif(substr(
$row[
'perm'][
'operation'],0,6) ==
'create')
329 $this->tpl->setVariable(
'PERM_LONG',$this->lng->txt(
'rbac_'.$row[
'perm'][
'operation']));
333 $this->tpl->setVariable(
'PERM_LONG',$this->lng->txt($this->getObjType().
'_'.
$row[
'perm'][
'operation']));
336 if($role_info[
'protected'])
338 $this->tpl->setVariable(
'PERM_DISABLED',$role_info[
'protected'] ?
'disabled="disabled"' :
'');
340 if($role_info[
'permission_set'])
342 $this->tpl->setVariable(
'PERM_CHECKED',
'checked="checked"');
345 $this->tpl->parseCurrentBlock();
356 global $rbacreview,$objDefinition;
365 return $this->
setData(array());
369 $operations = array();
372 $operations[$role_data[
'obj_id']] = $rbacreview->getActiveOperationsOfRole($this->
getRefId(), $role_data[
'obj_id']);
377 $rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
383 $local_roles = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
384 $local_roles = $rbacreview->getRolesOfRoleFolder($local_roles);
387 $roles[$role_data[
'obj_id']] = array(
388 'protected' => $role_data[
'protected'],
389 'local_policy' => in_array($role_data[
'obj_id'],$local_roles),
390 'isLocal' => ($rolf == $role_data[
'parent']) && $role_data[
'assign'] ==
'y'
393 $perms[$counter][
'roles'] =
$roles;
394 $perms[$counter][
'show_local_policy_row'] = 1;
405 $roles[$role_data[
'obj_id']] = array(
406 'protected_allowed' => $rbacreview->isAssignable($role_data[
'obj_id'],$rolf),
407 'protected_status' => $rbacreview->isProtected($role_data[
'parent'], $role_data[
'obj_id'])
410 $perms[$counter][
'roles'] =
$roles;
411 $perms[$counter][
'show_protected_row'] = 1;
418 $perms[$counter++][
'show_block_row'] = 1;
424 $perms[$counter++][
'show_start_info'] =
true;
428 $no_creation_operations = array();
429 foreach($rbacreview->getOperationsByTypeAndClass($this->getObjType(),
'object') as $operation)
432 $no_creation_operations[] = $operation;
438 $roles[$role_data[
'obj_id']] =
440 'protected' => $role_data[
'protected'],
441 'permission_set' => in_array($operation,(array) $operations[$role_data[
'obj_id']])
445 $op = $rbacreview->getOperation($operation);
447 $perms[$counter][
'roles'] =
$roles;
448 $perms[$counter][
'perm'] = $op;
456 if($no_creation_operations)
458 $perms[$counter][
'show_select_all'] = 1;
459 $perms[$counter][
'ops'] = $no_creation_operations;
460 $perms[$counter][
'subtype'] =
'nocreation';
465 if($objDefinition->isContainer($this->getObjType()))
467 $perms[$counter++][
'show_create_info'] =
true;
471 $objects = $objDefinition->getCreatableSubObjects($this->
getObjType());
473 $creation_operations = array();
474 foreach($objects as $type => $info)
476 $ops_id = $ops_ids[$type];
484 $creation_operations[] = $ops_id;
489 $roles[$role_data[
'obj_id']] =
491 'protected' => $role_data[
'protected'],
492 'permission_set' => in_array($ops_id,(array) $operations[$role_data[
'obj_id']])
496 $op = $rbacreview->getOperation($ops_id);
498 $perms[$counter][
'roles'] =
$roles;
499 $perms[$counter][
'perm'] = $op;
507 if(count($creation_operations))
509 $perms[$counter][
'show_select_all'] = 1;
510 $perms[$counter][
'ops'] = $creation_operations;
511 $perms[$counter][
'subtype'] =
'creation';
539 $column_widht =
"0%";
542 $all_roles = array();
545 if($role[
'obj_id'] == SYSTEM_ROLE_ID)
550 $role[
'role_type'] = $rbacreview->isGlobalRole($role[
'obj_id']) ?
'global' :
'local';
561 $all_roles[] = $role;
575 global $rbacreview,$tree;
578 $protected_status = $rbacreview->isProtected($role[
'parent'], $role[
'obj_id']) ?
'protected_' :
'';
579 if($role[
'role_type'] ==
'global')
581 $tp = $this->lng->txt(
'perm_'.$protected_status.
'global_role');
585 $tp = $this->lng->txt(
'perm_'.$protected_status.
'local_role');
588 $inheritance_seperator =
': ';
592 ($role[
'assign'] ==
'y' and $role[
'role_type'] !=
'global') or
593 ($role[
'assign'] ==
'n' and $role[
'role_type'] !=
'global')
598 $obj = $rbacreview->getObjectOfRole($role[
'obj_id']);
602 $this->lng->txt(
'perm_role_path_info_created'),
605 $inheritance_seperator =
', ';
609 $path_hierarchy = $rbacreview->getObjectsWithStopedInheritance(
611 $tree->getPathId($this->getRefId())
614 $reduced_path_hierarchy = (array) array_diff(
618 $rbacreview->getObjectReferenceOfRole($role[
'obj_id'])
624 if($role[
'assign'] ==
'n' and count($reduced_path_hierarchy))
626 $tp .= $inheritance_seperator;
628 $parent = end($reduced_path_hierarchy);
631 $tp .= sprintf($this->lng->txt(
'perm_role_path_info_inheritance'),$this->lng->txt(
'obj_'.$p_type),$p_title);
646 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
652 return $role[
'title'];
654 $ilCtrl->setParameterByClass(
'ilobjrolegui',
'rolf_ref_id', $this->
getRoleFolderId());
655 $ilCtrl->setParameterByClass(
'ilobjrolegui',
'obj_id', $role[
'obj_id']);
657 return '<a class="tblheader" href="'.$ilCtrl->getLinkTargetByClass(
'ilobjrolegui',
'').
'" >'.$role[
'title'].
'</a>';