19declare(strict_types=1);
75 $this->object_definition =
$DIC[
'objDefinition'];
76 $this->ui_service =
$DIC->uiService();
78 $this->tpl =
$DIC[
'tpl'];
79 $this->
lng = $DIC[
'lng'];
80 $this->
ctrl = $DIC[
'ilCtrl'];
81 $this->rbacsystem =
$DIC[
'rbacsystem'];
82 $this->rbacreview =
$DIC[
'rbacreview'];
83 $this->rbacadmin =
$DIC[
'rbacadmin'];
84 $this->
tabs = $DIC[
'ilTabs'];
85 $this->ilErr =
$DIC[
'ilErr'];
86 $this->
http = $DIC[
'http'];
88 $this->
toolbar = $DIC[
'ilToolbar'];
89 $this->ui_factory =
$DIC[
'ui.factory'];
90 $this->ui_renderer =
$DIC[
'ui.renderer'];
91 $this->db =
$DIC[
'ilDB'];
92 $this->
user = $DIC[
'ilUser'];
93 $this->tree =
$DIC[
'tree'];
95 $this->data_factory =
new DataFactory();
98 $this->
lng->loadLanguageModule(
'rbac');
99 $this->gui_obj = $a_gui_obj;
100 $this->
tabs->activateTab(
'perm_settings');
101 if ($this->
tabs->getActiveTab() ===
'') {
102 $this->
tabs->activateTab(
'id_permissions');
108 if (!isset($this->positionRepo)) {
110 $this->positionRepo =
$dic[
"repo.Positions"];
118 if (!isset($this->permissionRepo)) {
120 $this->permissionRepo =
$dic[
"repo.Permissions"];
128 if (!isset($this->operationRepo)) {
130 $this->operationRepo =
$dic[
"repo.Operations"];
144 if (!$this->rbacsystem->checkAccess(
"edit_permission", $this->gui_obj->getObject()->getRefId())) {
145 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
146 $this->
ctrl->redirect($this->gui_obj);
148 $next_class = $this->
ctrl->getNextClass($this);
149 switch ($next_class) {
153 if ($this->
http->wrapper()->query()->has(
'obj_id')) {
154 $role_id = $this->
http->wrapper()->query()->retrieve(
159 $this->
ctrl->setReturn($this,
'perm');
160 $this->gui_obj =
new ilObjRoleGUI(
"", $role_id,
false,
false);
161 $this->
ctrl->forwardCommand($this->gui_obj);
164 case 'ildidactictemplategui':
165 $this->
ctrl->setReturn($this,
'perm');
167 $this->
ctrl->forwardCommand($did);
170 case 'ilrepositorysearchgui':
173 $this->
ctrl->forwardCommand($rep_search);
176 case 'ilobjectpermissionstatusgui':
179 $this->
ctrl->forwardCommand($perm_stat);
183 $cmd = $this->
ctrl->getCmd();
191 return $this->gui_obj->getObject();
197 if ($dtpl->appendToolbarSwitch(
199 $this->getCurrentObject()->getType(),
200 $this->getCurrentObject()->getRefId()
202 $this->
toolbar->addSeparator();
205 if ($this->object_definition->hasLocalRoles($this->getCurrentObject()->getType()) && !$this->isAdministrationObject()
207 $this->
toolbar->setFormAction($this->
ctrl->getFormActionByClass(ilDidacticTemplateGUI::class));
211 $this->ui_factory->link()->standard(
212 $this->lng->txt(
'rbac_add_new_local_role'),
213 $this->ctrl->getLinkTarget($this,
'displayAddRoleForm')
218 $this->ui_factory->link()->standard(
219 $this->lng->txt(
'rbac_import_role'),
220 $this->ctrl->getLinkTarget($this,
'displayImportRoleForm')
230 $this->tpl->setContent($table->getHTML());
254 $table->resetOffset();
255 $table->writeFilterToSession();
262 $table->resetOffset();
263 $table->resetFilter();
274 switch ($a_filter_id) {
281 $arr_global_roles = $this->rbacreview->getGlobalRoles();
282 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_global_roles);
283 foreach ($arr_remove_roles as $role_id) {
284 unset($a_roles[$role_id]);
290 $arr_global_roles = $this->rbacreview->getGlobalRoles();
291 foreach ($arr_global_roles as $role_id) {
292 unset($a_roles[$role_id]);
298 $arr_local_roles = $this->rbacreview->getRolesOfObject($this->
getCurrentObject()->getRefId());
299 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_local_roles);
300 foreach ($arr_remove_roles as $role_id) {
301 unset($a_roles[$role_id]);
307 $arr_local_roles = $this->rbacreview->getRolesOfObject($this->
getCurrentObject()->getRefId(),
true);
308 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_local_roles);
309 foreach ($arr_remove_roles as $role_id) {
310 unset($a_roles[$role_id]);
324 $this->rbacreview->getParentRoleIds($this->getCurrentObject()->getRefId()),
325 (
int) $table->getFilterItemByPostVar(
'role')->getValue()
331 # all possible create permissions
332 $possible_ops_ids = $this->rbacreview->getOperationsByTypeAndClass(
337 # createable (activated) create permissions
338 $create_types = $this->object_definition->getCreatableSubObjects(
343 $post_perm = $this->
http->wrapper()->post()->has(
'perm')
344 ? $this->
http->wrapper()->post()->retrieve(
346 $this->
refinery->kindlyTo()->dictOf(
347 $this->refinery->kindlyTo()->dictOf(
348 $this->refinery->kindlyTo()->int()
354 foreach ($roles as $role => $role_data) {
355 if ($role_data[
'protected']) {
359 $new_ops = array_keys((array) ($post_perm[$role] ?? []));
360 $old_ops = $this->rbacreview->getRoleOperationsOnObject(
366 foreach ($possible_ops_ids as $create_ops_id) {
367 if (in_array($create_ops_id, $createable_ops_ids)) {
370 if (in_array($create_ops_id, $old_ops)) {
371 $new_ops[] = $create_ops_id;
375 $this->rbacadmin->revokePermission(
380 $this->rbacadmin->grantPermission(
382 array_unique($new_ops),
388 $inherit_post = $this->
http->wrapper()->post()->has(
'inherit')
389 ? $this->
http->wrapper()->post()->retrieve(
391 $this->
refinery->kindlyTo()->dictOf(
392 $this->refinery->kindlyTo()->bool()
397 foreach ($roles as $role) {
398 $obj_id = (
int) $role[
'obj_id'];
399 $parent_id = (
int) $role[
'parent'];
401 if ($parent_id === $this->
getCurrentObject()->getRefId() && $role[
'assign'] ===
'y') {
405 if ($role[
'protected']) {
411 && !isset($inherit_post[$obj_id])
412 && !$this->rbacreview->isBlockedAtPosition($obj_id, $this->
getCurrentObject()->getRefId())
423 && isset($inherit_post[$obj_id])
426 $this->rbacadmin->copyRoleTemplatePermissions(
433 $this->rbacadmin->assignRoleToFolder($obj_id, $this->
getCurrentObject()->getRefId(),
'n');
440 $protected_post = $this->
http->wrapper()->post()->has(
'protect')
441 ? $this->
http->wrapper()->post()->retrieve(
443 $this->
refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->int())
446 foreach ($roles as $role) {
447 $obj_id = (
int) $role[
'obj_id'];
448 if ($this->rbacreview->isAssignable($obj_id, $this->getCurrentObject()->getRefId())) {
449 if (isset($protected_post[$obj_id]) &&
450 !$this->rbacreview->isProtected($this->
getCurrentObject()->getRefId(), $obj_id)) {
451 $this->rbacadmin->setProtected($this->
getCurrentObject()->getRefId(), $obj_id,
'y');
452 } elseif (!isset($protected_post[$obj_id]) &&
453 $this->rbacreview->isProtected($this->getCurrentObject()->getRefId(), $obj_id)) {
454 $this->rbacadmin->setProtected($this->
getCurrentObject()->getRefId(), $obj_id,
'n');
466 if ($blocked_info[
'num'] > 0) {
470 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
471 $this->
ctrl->redirect($this,
'perm');
477 if ($a_blocked_info[
'new_blocked']) {
478 $info .= $this->
lng->txt(
'role_confirm_block_role_info');
479 if ($a_blocked_info[
'new_unblocked']) {
480 $info .=
'<br /><br />';
483 if ($a_blocked_info[
'new_unblocked']) {
484 $info .= (
'<br />' . $this->
lng->txt(
'role_confirm_unblock_role_info'));
487 $this->tpl->setOnScreenMessage(
'info',
$info);
490 $confirm->setFormAction($this->
ctrl->getFormAction($this));
491 $confirm->setHeaderText($this->
lng->txt(
'role_confirm_block_role_header'));
492 $confirm->setConfirm($this->
lng->txt(
'role_confirm_block_role'),
'modifyBlockRoles');
493 $confirm->setCancel($this->
lng->txt(
'cancel'),
'perm');
495 foreach ($a_blocked_info[
'new_blocked'] as $role_id) {
502 foreach ($a_blocked_info[
'new_unblocked'] as $role_id) {
509 $this->tpl->setContent($confirm->getHTML());
515 $this->
http->wrapper()->post()->has(
'new_block')
516 ? $this->http->wrapper()->post()->retrieve(
518 $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->int())
523 ? $this->http->wrapper()->post()->retrieve(
525 $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->int())
529 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'settings_saved'));
530 $this->
ctrl->redirect($this,
'perm');
535 foreach ($roles as $role) {
542 $role_obj->changeExistingObjects(
549 $this->rbacadmin->setBlockedStatus(
559 foreach ($roles as $role) {
561 $assign = $this->rbacreview->isAssignable($role, $this->
getCurrentObject()->getRefId()) ?
'y' :
'n';
564 $this->rbacadmin->revokeSubtreePermissions($this->
getCurrentObject()->getRefId(), $role);
567 $this->rbacadmin->deleteSubtreeTemplates($this->
getCurrentObject()->getRefId(), $role);
569 $this->rbacadmin->assignRoleToFolder(
576 $this->rbacadmin->setBlockedStatus(
588 $objDefinition =
$DIC[
'objDefinition'];
589 return $objDefinition->isContainer($a_type) && $a_type !=
'root' && $a_type !=
'adm' && $a_type !=
'rolf';
594 $this->
tabs->clearTargets();
599 $this->tpl->setContent($form->getHTML());
605 if ($form->checkInput()) {
609 $imp->getMapping()->addMapping(
610 'components/ILIAS/AccessControl',
618 $_FILES[
"importfile"][
"tmp_name"],
619 $_FILES[
"importfile"][
"name"],
622 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_role_imported'),
true);
623 $this->
ctrl->redirect($this,
'perm');
625 }
catch (Exception
$e) {
626 $this->tpl->setOnScreenMessage(
'failure',
$e->getMessage());
627 $form->setValuesByPost();
632 $form->setValuesByPost();
633 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
640 $form->setFormAction($this->
ctrl->getFormAction($this));
641 $form->setTitle($this->
lng->txt(
'rbac_import_role'));
642 $form->addCommandButton(
'doImportRole', $this->
lng->txt(
'import'));
643 $form->addCommandButton(
'perm', $this->
lng->txt(
'cancel'));
646 $zip->setRequired(
true);
647 $zip->setSuffixes([
'zip']);
648 $form->addItem($zip);
656 $form->setFormAction($this->
ctrl->getFormAction($this));
657 $form->setTitle($this->
lng->txt(
'role_new'));
658 $form->addCommandButton(
'addrole', $this->
lng->txt(
'role_new'));
659 $form->addCommandButton(
'perm', $this->
lng->txt(
'cancel'));
662 $title->setValidationRegexp(
'/^(?!il_).*$/');
663 $title->setValidationFailureMessage($this->
lng->txt(
'msg_role_reserved_prefix'));
665 $title->setMaxLength(70);
666 $title->setRequired(
true);
667 $form->addItem($title);
672 $form->addItem($desc);
675 $pro->setInfo($this->
lng->txt(
'role_protect_permissions_desc'));
677 $form->addItem($pro);
684 $this->
lng->txt(
'rbac_add_recommended_content_info')
687 $pd->setValue((
string) 1);
692 $option =
new ilRadioOption($this->
lng->txt(
"rbac_role_rights_copy_empty"), (
string) 0);
695 $parent_role_ids = $this->rbacreview->getParentRoleIds($this->gui_obj->getObject()->getRefId(),
true);
697 foreach (array_keys($parent_role_ids) as
$id) {
702 $sorted_ids =
ilUtil::_sortIds($ids,
'object_data',
'type DESC,title',
'obj_id');
705 foreach ($sorted_ids as
$id) {
706 $par = $parent_role_ids[
$id];
709 ($par[
"type"] ==
'role' ? $this->
lng->txt(
'obj_role') : $this->lng->txt(
712 (
string) $par[
"obj_id"]
714 $option->setInfo($par[
"desc"] ??
'');
723 if ($this->object_definition->isContainer($this->getCurrentObject()->getType())) {
725 $check->setInfo($this->
lng->txt(
'rbac_change_existing_objects_desc_new_role'));
733 $this->
tabs->clearTargets();
735 $this->tpl->setContent($form->getHTML());
747 if ($form->checkInput()) {
748 $new_title = $form->getInput(
"title");
751 $role->setTitle($new_title);
752 $role->setDescription($form->getInput(
'desc'));
755 $this->rbacadmin->assignRoleToFolder($role->getId(), $this->getCurrentObject()->getRefId());
758 $this->rbacadmin->setProtected(
761 $form->getInput(
'pro') ?
'y' :
'n'
765 $right_id_to_copy = (
int) $form->getInput(
"rights");
766 if ($right_id_to_copy) {
767 $parentRoles = $this->rbacreview->getParentRoleIds($this->
getCurrentObject()->getRefId(),
true);
768 $this->rbacadmin->copyRoleTemplatePermissions(
770 $parentRoles[$right_id_to_copy][
"parent"],
776 if ($form->getInput(
'existing')) {
777 if ($form->getInput(
'pro')) {
778 $role->changeExistingObjects(
784 $role->changeExistingObjects(
794 if ($form->getInput(
"desktop")) {
795 $this->recommended_content_manager->addRoleRecommendation(
801 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"role_added"),
true);
802 $this->
ctrl->redirect($this,
'perm');
804 $form->setValuesByPost();
805 $this->tpl->setContent($form->getHTML());
811 $blocked_info[
'new_blocked'] = [];
812 $blocked_info[
'new_unblocked'] = [];
813 $blocked_info[
'num'] = 0;
814 $visible_block = $this->
http->wrapper()->post()->has(
'visible_block')
815 ? $this->
http->wrapper()->post()->retrieve(
817 $this->
refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->int())
820 $block_post = $this->
http->wrapper()->post()->has(
'block')
821 ? $this->
http->wrapper()->post()->retrieve(
823 $this->
refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->int())
828 foreach ($visible_block as $role => $one) {
829 $blocked = $this->rbacreview->isBlockedAtPosition($role, $this->
getCurrentObject()->getRefId());
830 if (isset($block_post[$role]) && !$blocked) {
831 $blocked_info[
'new_blocked'][] = $role;
832 $blocked_info[
'num']++;
834 if (!isset($block_post[$role]) && $blocked) {
835 $blocked_info[
'new_unblocked'][] = $role;
836 $blocked_info[
'num']++;
839 return $blocked_info;
849 $table->collectData();
850 $this->tpl->setContent($table->getHTML());
860 $positions_with_local_perms_from_post = $this->
http->wrapper()->post()->has(
'local')
861 ? $this->
http->wrapper()->post()->retrieve(
863 $this->
refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->int())
867 foreach ($positions as $position_id) {
868 if (isset($positions_with_local_perms_from_post[$position_id])) {
875 $position_perm_post = $this->
http->wrapper()->post()->has(
'position_perm')
876 ? $this->
http->wrapper()->post()->retrieve(
878 $this->
refinery->kindlyTo()->dictOf(
879 $this->refinery->kindlyTo()->dictOf(
880 $this->refinery->kindlyTo()->int()
886 foreach ($position_perm_post as $position_id => $ops) {
887 if (!isset($positions_with_local_perms_from_post[$position_id])) {
891 if (!$org_unit_permissions->isTemplate()) {
893 foreach ($ops as $op_id => $op) {
897 $org_unit_permissions->withOperations($new_ops)
902 foreach (array_keys($positions_with_local_perms_from_post) as $position_id_from_post) {
903 if (array_key_exists($position_id_from_post, $position_perm_post)) {
907 if ($org_unit_permissions !==
null && !$org_unit_permissions->isTemplate()) {
912 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
913 $this->
ctrl->redirect($this, self::CMD_PERM_POSITIONS);
920 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'chown_warning'));
923 $form->setFormAction($this->
ctrl->getFormAction($this,
'owner'));
924 $form->setTitle($this->
lng->txt(
'info_owner_of_object'));
927 $login->setDataSource(
928 $this->
ctrl->getLinkTargetByClass(
931 ilRepositorySearchGUI::class
933 'doUserAutoComplete',
938 $login->setRequired(
true);
941 $form->addItem($login);
942 $form->addCommandButton(
"changeOwner", $this->
lng->txt(
"change_owner"));
943 $this->tpl->setContent($form->getHTML());
949 if ($this->
http->wrapper()->post()->has(
'owner')) {
950 $owner = $this->
http->wrapper()->post()->retrieve(
952 $this->
refinery->kindlyTo()->string()
956 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'user_not_known'));
962 if (
$user_id != $this->gui_obj->getObject()->getOwner()) {
963 $this->gui_obj->getObject()->setOwner(
$user_id);
964 $this->gui_obj->getObject()->updateOwner();
965 $this->
objectDataCache->deleteCachedEntry($this->gui_obj->getObject()->getId());
972 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'owner_updated'),
true);
974 if (!$this->rbacsystem->checkAccess(
"edit_permission", $this->gui_obj->getObject()->getRefId())) {
975 $this->
ctrl->redirect($this->gui_obj);
978 $this->
ctrl->redirect($this,
'owner');
983 $perm = $a_cmd ===
'perm';
985 $info = $a_cmd ===
'perminfo';
986 $owner = $a_cmd ===
'owner';
987 $log = $a_cmd ===
'log';
989 $this->
tabs->addSubTabTarget(
990 "permission_settings",
991 $this->
ctrl->getLinkTarget($this,
"perm"),
999 $this->
tabs->addSubTabTarget(
1000 self::TAB_POSITION_PERMISSION_SETTINGS,
1009 $this->
tabs->addSubTabTarget(
1011 $this->
ctrl->getLinkTargetByClass([get_class($this),
"ilobjectpermissionstatusgui"],
"perminfo"),
1017 $this->
tabs->addSubTabTarget(
1019 $this->
ctrl->getLinkTarget($this,
"owner"),
1027 $this->
tabs->addSubTabTarget(
1029 $this->
ctrl->getLinkTarget($this,
'log'),
1041 $this->
ctrl->redirect($this,
'perm');
1049 $this->data_factory,
1053 $this->object_definition,
1054 $this->
http->request(),
1059 $this->tpl->setContent($this->ui_renderer->render(
1060 $table->getTableAndFilter()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
GUI class for didactic template settings inside repository objects.
Error Handling & global info handling.
static getLogger(string $a_component_id)
Get component logger.
const MODE_UNPROTECTED_KEEP_LOCAL_POLICIES
const MODE_PROTECTED_KEEP_LOCAL_POLICIES
static _getTranslation(string $a_role_title)
static _lookupId(string|array $a_user_str)
static _lookupLogin(int $a_user_id)
parses the objects.xml it handles the xml-description of all ilias objects
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjectGUI Basic methods of all Output classes.
This class displays the permission status of a user concerning a specific object.
Table for object role permissions.
const ROLE_FILTER_LOCAL_OBJECT
const ROLE_FILTER_LOCAL_POLICY
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static hasContainerCommands(string $a_type)
unblockRoles(array $roles)
applyRoleFilter(array $a_roles, int $a_filter_id)
ilObjectDefinition $object_definition
ilOrgUnitPositionDBRepository $positionRepo
const CMD_SAVE_POSITIONS_PERMISSIONS
DataFactory $data_factory
savePositionsPermissions()
getModifiedBlockedSettings()
executeCommand()
Execute command.
__initSubTabs(string $a_cmd)
const TAB_POSITION_PERMISSION_SETTINGS
perm(?ilTable2GUI $table=null)
showConfirmBlockRole(array $a_blocked_info)
ilOrgUnitOperationDBRepository $operationRepo
ilGlobalTemplateInterface $tpl
displayImportRoleForm(?ilPropertyFormGUI $form=null)
ilOrgUnitPermissionDBRepository $permissionRepo
isInAdministration()
Check if node is subobject of administration folder.
ilRecommendedContentManager $recommended_content_manager
ilObjectDataCache $objectDataCache
addRole()
adds a local role This method is only called when choose the option 'you may add local roles'.
This class represents an option in a radio group.
Class ilRbacAdmin Core functions for role based access control.
class ilRbacLog Log changes in Rbac-related settings
static add(int $action, int $ref_id, array $diff, bool $source_ref_id=false)
static gatherFaPa(int $ref_id, array $role_ids, bool $add_action=false)
static diffFaPa(array $old, array $new)
class ilRbacReview Contains Review functions of core Rbac.
static lookupCreateOperationIds(array $a_type_arr)
Lookup operation ids.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
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,...
Interface GlobalHttpState.
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc