19 declare(strict_types=1);
53 $this->wrapper = $DIC->http()->wrapper();
54 $this->
toolbar = $DIC[
'ilToolbar'];
55 $this->ui_factory = $DIC[
'ui.factory'];
62 if (!isset($this->positionRepo)) {
64 $this->positionRepo =
$dic[
"repo.Positions"];
72 if (!isset($this->permissionRepo)) {
74 $this->permissionRepo =
$dic[
"repo.Permissions"];
82 if (!isset($this->operationRepo)) {
84 $this->operationRepo =
$dic[
"repo.Operations"];
98 if (!$this->rbacsystem->checkAccess(
"edit_permission", $this->gui_obj->getObject()->getRefId())) {
99 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
100 $this->
ctrl->redirect($this->gui_obj);
102 $next_class = $this->
ctrl->getNextClass($this);
103 switch ($next_class) {
107 if ($this->
http->wrapper()->query()->has(
'obj_id')) {
108 $role_id = $this->
http->wrapper()->query()->retrieve(
113 $this->
ctrl->setReturn($this,
'perm');
114 $this->gui_obj =
new ilObjRoleGUI(
"", $role_id,
false,
false);
115 $this->
ctrl->forwardCommand($this->gui_obj);
118 case 'ildidactictemplategui':
119 $this->
ctrl->setReturn($this,
'perm');
121 $this->
ctrl->forwardCommand($did);
124 case 'ilrepositorysearchgui':
127 $this->
ctrl->forwardCommand($rep_search);
130 case 'ilobjectpermissionstatusgui':
133 $this->
ctrl->forwardCommand($perm_stat);
137 $cmd = $this->
ctrl->getCmd();
145 return $this->gui_obj->getObject();
153 $this->
ctrl->setReturn($this,
'perm');
154 $this->
ctrl->setCmdClass(
'ildidactictemplategui');
156 $this->
ctrl->forwardCommand($dtpl_gui);
162 if ($dtpl->appendToolbarSwitch(
164 $this->getCurrentObject()->getType(),
167 $this->
toolbar->addSeparator();
170 if ($this->objDefinition->hasLocalRoles($this->getCurrentObject()->getType()) && !$this->
isAdministrationObject()
172 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this));
176 $this->ui_factory->link()->standard(
177 $this->
lng->txt(
'rbac_add_new_local_role'),
178 $this->
ctrl->getLinkTarget($this,
'displayAddRoleForm')
183 $this->ui_factory->link()->standard(
184 $this->
lng->txt(
'rbac_import_role'),
185 $this->
ctrl->getLinkTarget($this,
'displayImportRoleForm')
195 $this->tpl->setContent($table->getHTML());
219 $table->resetOffset();
220 $table->writeFilterToSession();
227 $table->resetOffset();
228 $table->resetFilter();
236 unset($a_roles[SYSTEM_ROLE_ID]);
239 switch ($a_filter_id) {
246 $arr_global_roles = $this->rbacreview->getGlobalRoles();
247 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_global_roles);
248 foreach ($arr_remove_roles as $role_id) {
249 unset($a_roles[$role_id]);
255 $arr_global_roles = $this->rbacreview->getGlobalRoles();
256 foreach ($arr_global_roles as $role_id) {
257 unset($a_roles[$role_id]);
263 $arr_local_roles = $this->rbacreview->getRolesOfObject($this->
getCurrentObject()->getRefId());
264 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_local_roles);
265 foreach ($arr_remove_roles as $role_id) {
266 unset($a_roles[$role_id]);
272 $arr_local_roles = $this->rbacreview->getRolesOfObject($this->
getCurrentObject()->getRefId(),
true);
273 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_local_roles);
274 foreach ($arr_remove_roles as $role_id) {
275 unset($a_roles[$role_id]);
296 (
int) $table->getFilterItemByPostVar(
'role')->getValue()
302 # all possible create permissions 308 # createable (activated) create permissions 314 $post_perm = $this->wrapper->post()->has(
'perm')
315 ? $this->wrapper->post()->retrieve(
317 $this->
refinery->kindlyTo()->dictOf(
318 $this->
refinery->kindlyTo()->dictOf(
325 foreach ($roles as $role => $role_data) {
326 if ($role_data[
'protected']) {
330 $new_ops = array_keys((array) ($post_perm[$role] ?? []));
337 foreach ($possible_ops_ids as $create_ops_id) {
338 if (in_array($create_ops_id, $createable_ops_ids)) {
341 if (in_array($create_ops_id, $old_ops)) {
342 $new_ops[] = $create_ops_id;
353 array_unique($new_ops),
359 $inherit_post = $this->wrapper->post()->has(
'inherit')
360 ? $this->wrapper->post()->retrieve(
362 $this->
refinery->kindlyTo()->dictOf(
368 foreach ($roles as $role) {
369 $obj_id = (
int) $role[
'obj_id'];
370 $parent_id = (
int) $role[
'parent'];
372 if ($parent_id === $this->
getCurrentObject()->getRefId() && $role[
'assign'] ===
'y') {
376 if ($role[
'protected']) {
382 && !isset($inherit_post[$obj_id])
394 && isset($inherit_post[$obj_id])
411 $protected_post = $this->wrapper->post()->has(
'protect')
412 ? $this->wrapper->post()->retrieve(
417 foreach ($roles as $role) {
418 $obj_id = (
int) $role[
'obj_id'];
420 if (isset($protected_post[$obj_id]) &&
423 } elseif (!isset($protected_post[$obj_id]) &&
437 if ($blocked_info[
'num'] > 0) {
441 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
442 $this->
ctrl->redirect($this,
'perm');
449 if ($a_blocked_info[
'new_blocked']) {
450 $info .= $this->
lng->txt(
'role_confirm_block_role_info');
451 if ($a_blocked_info[
'new_unblocked']) {
452 $info .=
'<br /><br />';
455 if ($a_blocked_info[
'new_unblocked']) {
456 $info .= (
'<br />' . $this->
lng->txt(
'role_confirm_unblock_role_info'));
459 $this->tpl->setOnScreenMessage(
'info', $info);
462 $confirm->setFormAction($this->
ctrl->getFormAction($this));
463 $confirm->setHeaderText($this->
lng->txt(
'role_confirm_block_role_header'));
464 $confirm->setConfirm($this->
lng->txt(
'role_confirm_block_role'),
'modifyBlockRoles');
465 $confirm->setCancel($this->
lng->txt(
'cancel'),
'perm');
467 foreach ($a_blocked_info[
'new_blocked'] as $role_id) {
474 foreach ($a_blocked_info[
'new_unblocked'] as $role_id) {
481 $this->tpl->setContent($confirm->getHTML());
487 $this->wrapper->post()->has(
'new_block')
488 ? $this->wrapper->post()->retrieve(
494 $this->
unblockRoles($this->wrapper->post()->has(
'new_unblock')
495 ? $this->wrapper->post()->retrieve(
501 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'settings_saved'));
502 $this->
ctrl->redirect($this,
'perm');
510 foreach (
$roles as $role) {
517 $role_obj->changeExistingObjects(
524 $this->rbacadmin->setBlockedStatus(
534 foreach (
$roles as $role) {
536 $assign = $this->rbacreview->isAssignable($role, $this->
getCurrentObject()->getRefId()) ?
'y' :
'n';
539 $this->rbacadmin->revokeSubtreePermissions($this->
getCurrentObject()->getRefId(), $role);
542 $this->rbacadmin->deleteSubtreeTemplates($this->
getCurrentObject()->getRefId(), $role);
544 $this->rbacadmin->assignRoleToFolder(
551 $this->rbacadmin->setBlockedStatus(
569 $this->
tabs->clearTargets();
574 $this->tpl->setContent($form->getHTML());
580 if ($form->checkInput()) {
584 $imp->getMapping()->addMapping(
585 'Services/AccessControl',
593 $_FILES[
"importfile"][
"tmp_name"],
594 $_FILES[
"importfile"][
"name"],
597 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_role_imported'),
true);
598 $this->
ctrl->redirect($this,
'perm');
601 $this->tpl->setOnScreenMessage(
'failure', $e->getMessage());
602 $form->setValuesByPost();
607 $form->setValuesByPost();
608 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
618 $form->setFormAction($this->
ctrl->getFormAction($this));
619 $form->setTitle($this->
lng->txt(
'rbac_import_role'));
620 $form->addCommandButton(
'doImportRole', $this->
lng->txt(
'import'));
621 $form->addCommandButton(
'perm', $this->
lng->txt(
'cancel'));
625 $zip->setSuffixes([
'zip']);
626 $form->addItem($zip);
634 $form->setFormAction($this->
ctrl->getFormAction($this));
635 $form->setTitle($this->
lng->txt(
'role_new'));
636 $form->addCommandButton(
'addrole', $this->
lng->txt(
'role_new'));
637 $form->addCommandButton(
'perm', $this->
lng->txt(
'cancel'));
640 $title->setValidationRegexp(
'/^(?!il_).*$/');
641 $title->setValidationFailureMessage($this->
lng->txt(
'msg_role_reserved_prefix'));
643 $title->setMaxLength(70);
644 $title->setRequired(
true);
645 $form->addItem($title);
650 $form->addItem($desc);
653 $pro->setInfo($this->
lng->txt(
'role_protect_permissions_desc'));
655 $form->addItem($pro);
662 $this->
lng->txt(
'rbac_add_recommended_content_info')
665 $pd->setValue((
string) 1);
670 $option =
new ilRadioOption($this->
lng->txt(
"rbac_role_rights_copy_empty"), (string) 0);
673 $parent_role_ids = $this->rbacreview->getParentRoleIds($this->gui_obj->getObject()->getRefId(),
true);
675 foreach (array_keys($parent_role_ids) as
$id) {
680 $sorted_ids =
ilUtil::_sortIds($ids,
'object_data',
'type DESC,title',
'obj_id');
683 foreach ($sorted_ids as
$id) {
684 $par = $parent_role_ids[
$id];
687 ($par[
"type"] ==
'role' ? $this->
lng->txt(
'obj_role') : $this->
lng->txt(
690 (string) $par[
"obj_id"]
692 $option->
setInfo($par[
"desc"] ??
'');
701 if ($this->objDefinition->isContainer($this->getCurrentObject()->getType())) {
702 $check =
new ilCheckboxInputGui($this->
lng->txt(
"rbac_role_rights_copy_change_existing"),
'existing');
703 $check->setInfo($this->
lng->txt(
'rbac_change_existing_objects_desc_new_role'));
714 $this->
tabs->clearTargets();
716 $this->tpl->setContent($form->getHTML());
728 if ($form->checkInput()) {
729 $new_title = $form->getInput(
"title");
732 $role->setTitle($new_title);
733 $role->setDescription($form->getInput(
'desc'));
736 $this->rbacadmin->assignRoleToFolder($role->getId(), $this->
getCurrentObject()->getRefId());
739 $this->rbacadmin->setProtected(
742 $form->getInput(
'pro') ?
'y' :
'n' 746 $right_id_to_copy = (
int) $form->getInput(
"rights");
747 if ($right_id_to_copy) {
748 $parentRoles = $this->rbacreview->getParentRoleIds($this->
getCurrentObject()->getRefId(),
true);
749 $this->rbacadmin->copyRoleTemplatePermissions(
751 $parentRoles[$right_id_to_copy][
"parent"],
757 if ($form->getInput(
'existing')) {
758 if ($form->getInput(
'pro')) {
759 $role->changeExistingObjects(
765 $role->changeExistingObjects(
775 if ($form->getInput(
"desktop")) {
776 $this->recommended_content_manager->addRoleRecommendation(
782 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"role_added"),
true);
783 $this->
ctrl->redirect($this,
'perm');
785 $form->setValuesByPost();
786 $this->tpl->setContent($form->getHTML());
796 $blocked_info[
'new_blocked'] = [];
797 $blocked_info[
'new_unblocked'] = [];
798 $blocked_info[
'num'] = 0;
799 $visible_block = $this->wrapper->post()->has(
'visible_block')
800 ? $this->wrapper->post()->retrieve(
805 $block_post = $this->wrapper->post()->has(
'block')
806 ? $this->wrapper->post()->retrieve(
813 foreach ($visible_block as $role => $one) {
815 if (isset($block_post[$role]) && !$blocked) {
816 $blocked_info[
'new_blocked'][] = $role;
817 $blocked_info[
'num']++;
819 if (!isset($block_post[$role]) && $blocked) {
820 $blocked_info[
'new_unblocked'][] = $role;
821 $blocked_info[
'num']++;
824 return $blocked_info;
833 $perm = self::CMD_PERM_POSITIONS;
838 $table->collectData();
839 $this->tpl->setContent($table->getHTML());
850 $positions_with_local_perms_from_post = $this->wrapper->post()->has(
'local')
851 ? $this->wrapper->post()->retrieve(
857 foreach ($positions as $position_id) {
858 if (isset($positions_with_local_perms_from_post[$position_id])) {
865 $position_perm_post = $this->wrapper->post()->has(
'position_perm')
866 ? $this->wrapper->post()->retrieve(
868 $this->
refinery->kindlyTo()->dictOf(
869 $this->
refinery->kindlyTo()->dictOf(
876 foreach ($position_perm_post as $position_id => $ops) {
877 if (!isset($positions_with_local_perms_from_post[$position_id])) {
881 if (!$org_unit_permissions->isTemplate()) {
883 foreach ($ops as $op_id => $op) {
887 $org_unit_permissions->withOperations($new_ops)
892 foreach (array_keys($positions_with_local_perms_from_post) as $position_id_from_post) {
893 if (array_key_exists($position_id_from_post, $position_perm_post)) {
897 if ($org_unit_permissions !== null && !$org_unit_permissions->isTemplate()) {
902 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
903 $this->
ctrl->redirect($this, self::CMD_PERM_POSITIONS);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static gatherFaPa(int $a_ref_id, array $a_role_ids, bool $a_add_action=false)
grantPermission(int $a_rol_id, array $a_ops, int $a_ref_id)
Grants a permission to an object and a specific role.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
getRoleOperationsOnObject(int $a_role_id, int $a_ref_id)
isBlockedAtPosition(int $a_role_id, int $a_ref_id)
copyRoleTemplatePermissions(int $a_source_id, int $a_source_parent, int $a_dest_parent, int $a_dest_id, bool $a_consider_protected=true)
Copies template permissions of one role to another.
addRole()
adds a local role This method is only called when choose the option 'you may add local roles'...
isContainer(string $obj_name)
Check if object type is container ('crs','fold','grp' ...)
ilOrgUnitPositionDBRepository $positionRepo
isInAdministration()
Check if node is subobject of administration folder.
showConfirmBlockRole(array $a_blocked_info)
ilOrgUnitOperationDBRepository $operationRepo
revokePermission(int $a_ref_id, int $a_rol_id=0, bool $a_keep_protected=true)
Revokes permissions of an object of one role.
__initSubTabs(string $a_cmd)
getCreatableSubObjects(string $obj_type, int $context=self::MODE_REPOSITORY, int $parent_ref_id=null)
static diffFaPa(array $a_old, array $a_new)
const MODE_PROTECTED_KEEP_LOCAL_POLICIES
ilOrgUnitPermissionDBRepository $permissionRepo
ilRecommendedContentManager $recommended_content_manager
static lookupCreateOperationIds(array $a_type_arr)
Lookup operation ids.
getOperationsByTypeAndClass(string $a_type, string $a_class)
Get operations by type and class.
displayImportRoleForm(ilPropertyFormGUI $form=null)
static http()
Fetches the global http state from ILIAS.
getModifiedBlockedSettings()
static add(int $a_action, int $a_ref_id, array $a_diff, bool $a_source_ref_id=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
confirmTemplateSwitch()
Called after toolbar action applyTemplateSwitch.
static _getTranslation(string $a_role_title)
static hasContainerCommands(string $a_type)
getParentRoleIds(int $a_endnode_id, bool $a_templates=false)
Get an array of parent role ids of all parent roles, if last parameter is set true you get also all p...
displayAddRoleForm()
Show add role form.
setProtected(int $a_ref_id, int $a_role_id, string $a_value)
Set protected.
assignRoleToFolder(int $a_rol_id, int $a_parent, string $a_assign="y")
Assigns a role to a role folder A role folder is an object to store roles.
static _sortIds(array $a_ids, string $a_table, string $a_field, string $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),'usr_data','lastname','usr_id') => sorts by lastname.
ilObjectDefinition $objDefinition
ILIAS HTTP Wrapper WrapperFactory $wrapper
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_gui_obj)
const ROLE_FILTER_LOCAL_POLICY
const ROLE_FILTER_LOCAL_OBJECT
initImportForm()
init import form
This class represents a text area property in a property form.
const MODE_UNPROTECTED_KEEP_LOCAL_POLICIES
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
executeCommand()
Execute command.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
applyRoleFilter(array $a_roles, int $a_filter_id)
savePositionsPermissions()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isAssignable(int $a_rol_id, int $a_ref_id)
Check if its possible to assign users.
Class ilPermissionGUI RBAC related output.
const CMD_SAVE_POSITIONS_PERMISSIONS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
perm(ilTable2GUI $table=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isProtected(int $a_ref_id, int $a_role_id)
ref_id not used yet.