18 declare(strict_types=1);
74 $this->object_definition = $DIC[
'objDefinition'];
75 $this->ui_service = $DIC->uiService();
77 $this->tpl = $DIC[
'tpl'];
78 $this->
lng = $DIC[
'lng'];
79 $this->
ctrl = $DIC[
'ilCtrl'];
80 $this->rbacsystem = $DIC[
'rbacsystem'];
81 $this->rbacreview = $DIC[
'rbacreview'];
82 $this->rbacadmin = $DIC[
'rbacadmin'];
83 $this->
tabs = $DIC[
'ilTabs'];
84 $this->ilErr = $DIC[
'ilErr'];
85 $this->
http = $DIC[
'http'];
87 $this->
toolbar = $DIC[
'ilToolbar'];
88 $this->ui_factory = $DIC[
'ui.factory'];
89 $this->ui_renderer = $DIC[
'ui.renderer'];
90 $this->db = $DIC[
'ilDB'];
91 $this->
user = $DIC[
'ilUser'];
92 $this->tree = $DIC[
'tree'];
97 $this->
lng->loadLanguageModule(
'rbac');
98 $this->gui_obj = $a_gui_obj;
99 $this->
tabs->activateTab(
'perm_settings');
104 if (!isset($this->positionRepo)) {
106 $this->positionRepo =
$dic[
"repo.Positions"];
114 if (!isset($this->permissionRepo)) {
116 $this->permissionRepo =
$dic[
"repo.Permissions"];
124 if (!isset($this->operationRepo)) {
126 $this->operationRepo =
$dic[
"repo.Operations"];
140 if (!$this->rbacsystem->checkAccess(
"edit_permission", $this->gui_obj->getObject()->getRefId())) {
141 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
142 $this->
ctrl->redirect($this->gui_obj);
144 $next_class = $this->
ctrl->getNextClass($this);
145 switch ($next_class) {
149 if ($this->
http->wrapper()->query()->has(
'obj_id')) {
150 $role_id = $this->
http->wrapper()->query()->retrieve(
155 $this->
ctrl->setReturn($this,
'perm');
156 $this->gui_obj =
new ilObjRoleGUI(
"", $role_id,
false,
false);
157 $this->
ctrl->forwardCommand($this->gui_obj);
160 case 'ildidactictemplategui':
161 $this->
ctrl->setReturn($this,
'perm');
163 $this->
ctrl->forwardCommand($did);
166 case 'ilrepositorysearchgui':
169 $this->
ctrl->forwardCommand($rep_search);
172 case 'ilobjectpermissionstatusgui':
175 $this->
ctrl->forwardCommand($perm_stat);
179 $cmd = $this->
ctrl->getCmd();
187 return $this->gui_obj->getObject();
193 if ($dtpl->appendToolbarSwitch(
195 $this->getCurrentObject()->getType(),
198 $this->
toolbar->addSeparator();
201 if ($this->object_definition->hasLocalRoles($this->getCurrentObject()->getType()) && !$this->
isAdministrationObject()
203 $this->
toolbar->setFormAction($this->
ctrl->getFormActionByClass(ilDidacticTemplateGUI::class));
207 $this->ui_factory->link()->standard(
208 $this->
lng->txt(
'rbac_add_new_local_role'),
209 $this->
ctrl->getLinkTarget($this,
'displayAddRoleForm')
214 $this->ui_factory->link()->standard(
215 $this->
lng->txt(
'rbac_import_role'),
216 $this->
ctrl->getLinkTarget($this,
'displayImportRoleForm')
226 $this->tpl->setContent($table->getHTML());
250 $table->resetOffset();
251 $table->writeFilterToSession();
258 $table->resetOffset();
259 $table->resetFilter();
267 unset($a_roles[SYSTEM_ROLE_ID]);
270 switch ($a_filter_id) {
277 $arr_global_roles = $this->rbacreview->getGlobalRoles();
278 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_global_roles);
279 foreach ($arr_remove_roles as $role_id) {
280 unset($a_roles[$role_id]);
286 $arr_global_roles = $this->rbacreview->getGlobalRoles();
287 foreach ($arr_global_roles as $role_id) {
288 unset($a_roles[$role_id]);
294 $arr_local_roles = $this->rbacreview->getRolesOfObject($this->
getCurrentObject()->getRefId());
295 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_local_roles);
296 foreach ($arr_remove_roles as $role_id) {
297 unset($a_roles[$role_id]);
303 $arr_local_roles = $this->rbacreview->getRolesOfObject($this->
getCurrentObject()->getRefId(),
true);
304 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_local_roles);
305 foreach ($arr_remove_roles as $role_id) {
306 unset($a_roles[$role_id]);
320 $this->rbacreview->getParentRoleIds($this->getCurrentObject()->getRefId()),
321 (
int) $table->getFilterItemByPostVar(
'role')->getValue()
327 # all possible create permissions 328 $possible_ops_ids = $this->rbacreview->getOperationsByTypeAndClass(
333 # createable (activated) create permissions 334 $create_types = $this->object_definition->getCreatableSubObjects(
339 $post_perm = $this->
http->wrapper()->post()->has(
'perm')
340 ? $this->
http->wrapper()->post()->retrieve(
342 $this->
refinery->kindlyTo()->dictOf(
343 $this->
refinery->kindlyTo()->dictOf(
350 foreach ($roles as $role => $role_data) {
351 if ($role_data[
'protected']) {
355 $new_ops = array_keys((array) ($post_perm[$role] ?? []));
356 $old_ops = $this->rbacreview->getRoleOperationsOnObject(
362 foreach ($possible_ops_ids as $create_ops_id) {
363 if (in_array($create_ops_id, $createable_ops_ids)) {
366 if (in_array($create_ops_id, $old_ops)) {
367 $new_ops[] = $create_ops_id;
371 $this->rbacadmin->revokePermission(
376 $this->rbacadmin->grantPermission(
378 array_unique($new_ops),
384 $inherit_post = $this->
http->wrapper()->post()->has(
'inherit')
385 ? $this->
http->wrapper()->post()->retrieve(
387 $this->
refinery->kindlyTo()->dictOf(
393 foreach ($roles as $role) {
394 $obj_id = (
int) $role[
'obj_id'];
395 $parent_id = (
int) $role[
'parent'];
397 if ($parent_id === $this->
getCurrentObject()->getRefId() && $role[
'assign'] ===
'y') {
401 if ($role[
'protected']) {
407 && !isset($inherit_post[$obj_id])
408 && !$this->rbacreview->isBlockedAtPosition($obj_id, $this->
getCurrentObject()->getRefId())
419 && isset($inherit_post[$obj_id])
422 $this->rbacadmin->copyRoleTemplatePermissions(
429 $this->rbacadmin->assignRoleToFolder($obj_id, $this->
getCurrentObject()->getRefId(),
'n');
436 $protected_post = $this->
http->wrapper()->post()->has(
'protect')
437 ? $this->
http->wrapper()->post()->retrieve(
442 foreach ($roles as $role) {
443 $obj_id = (
int) $role[
'obj_id'];
444 if ($this->rbacreview->isAssignable($obj_id, $this->getCurrentObject()->getRefId())) {
445 if (isset($protected_post[$obj_id]) &&
446 !$this->rbacreview->isProtected($this->
getCurrentObject()->getRefId(), $obj_id)) {
447 $this->rbacadmin->setProtected($this->
getCurrentObject()->getRefId(), $obj_id,
'y');
448 } elseif (!isset($protected_post[$obj_id]) &&
449 $this->rbacreview->isProtected($this->getCurrentObject()->getRefId(), $obj_id)) {
450 $this->rbacadmin->setProtected($this->
getCurrentObject()->getRefId(), $obj_id,
'n');
462 if ($blocked_info[
'num'] > 0) {
466 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
467 $this->
ctrl->redirect($this,
'perm');
473 if ($a_blocked_info[
'new_blocked']) {
474 $info .= $this->
lng->txt(
'role_confirm_block_role_info');
475 if ($a_blocked_info[
'new_unblocked']) {
476 $info .=
'<br /><br />';
479 if ($a_blocked_info[
'new_unblocked']) {
480 $info .= (
'<br />' . $this->
lng->txt(
'role_confirm_unblock_role_info'));
483 $this->tpl->setOnScreenMessage(
'info', $info);
486 $confirm->setFormAction($this->
ctrl->getFormAction($this));
487 $confirm->setHeaderText($this->
lng->txt(
'role_confirm_block_role_header'));
488 $confirm->setConfirm($this->
lng->txt(
'role_confirm_block_role'),
'modifyBlockRoles');
489 $confirm->setCancel($this->
lng->txt(
'cancel'),
'perm');
491 foreach ($a_blocked_info[
'new_blocked'] as $role_id) {
498 foreach ($a_blocked_info[
'new_unblocked'] as $role_id) {
505 $this->tpl->setContent($confirm->getHTML());
511 $this->
http->wrapper()->post()->has(
'new_block')
512 ? $this->
http->wrapper()->post()->retrieve(
519 ? $this->
http->wrapper()->post()->retrieve(
525 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'settings_saved'));
526 $this->
ctrl->redirect($this,
'perm');
531 foreach ($roles as $role) {
538 $role_obj->changeExistingObjects(
545 $this->rbacadmin->setBlockedStatus(
555 foreach ($roles as $role) {
557 $assign = $this->rbacreview->isAssignable($role, $this->
getCurrentObject()->getRefId()) ?
'y' :
'n';
560 $this->rbacadmin->revokeSubtreePermissions($this->
getCurrentObject()->getRefId(), $role);
563 $this->rbacadmin->deleteSubtreeTemplates($this->
getCurrentObject()->getRefId(), $role);
565 $this->rbacadmin->assignRoleToFolder(
572 $this->rbacadmin->setBlockedStatus(
584 $objDefinition = $DIC[
'objDefinition'];
585 return $objDefinition->isContainer($a_type) && $a_type !=
'root' && $a_type !=
'adm' && $a_type !=
'rolf';
590 $this->
tabs->clearTargets();
595 $this->tpl->setContent($form->getHTML());
601 if ($form->checkInput()) {
605 $imp->getMapping()->addMapping(
606 'components/ILIAS/AccessControl',
614 $_FILES[
"importfile"][
"tmp_name"],
615 $_FILES[
"importfile"][
"name"],
618 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_role_imported'),
true);
619 $this->
ctrl->redirect($this,
'perm');
622 $this->tpl->setOnScreenMessage(
'failure', $e->getMessage());
623 $form->setValuesByPost();
628 $form->setValuesByPost();
629 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
636 $form->setFormAction($this->
ctrl->getFormAction($this));
637 $form->setTitle($this->
lng->txt(
'rbac_import_role'));
638 $form->addCommandButton(
'doImportRole', $this->
lng->txt(
'import'));
639 $form->addCommandButton(
'perm', $this->
lng->txt(
'cancel'));
643 $zip->setSuffixes([
'zip']);
644 $form->addItem($zip);
652 $form->setFormAction($this->
ctrl->getFormAction($this));
653 $form->setTitle($this->
lng->txt(
'role_new'));
654 $form->addCommandButton(
'addrole', $this->
lng->txt(
'role_new'));
655 $form->addCommandButton(
'perm', $this->
lng->txt(
'cancel'));
658 $title->setValidationRegexp(
'/^(?!il_).*$/');
659 $title->setValidationFailureMessage($this->
lng->txt(
'msg_role_reserved_prefix'));
661 $title->setMaxLength(70);
662 $title->setRequired(
true);
663 $form->addItem($title);
668 $form->addItem($desc);
671 $pro->setInfo($this->
lng->txt(
'role_protect_permissions_desc'));
673 $form->addItem($pro);
680 $this->
lng->txt(
'rbac_add_recommended_content_info')
683 $pd->setValue((
string) 1);
688 $option =
new ilRadioOption($this->
lng->txt(
"rbac_role_rights_copy_empty"), (string) 0);
691 $parent_role_ids = $this->rbacreview->getParentRoleIds($this->gui_obj->getObject()->getRefId(),
true);
693 foreach (array_keys($parent_role_ids) as
$id) {
698 $sorted_ids =
ilUtil::_sortIds($ids,
'object_data',
'type DESC,title',
'obj_id');
701 foreach ($sorted_ids as
$id) {
702 $par = $parent_role_ids[
$id];
705 ($par[
"type"] ==
'role' ? $this->
lng->txt(
'obj_role') : $this->
lng->txt(
708 (string) $par[
"obj_id"]
710 $option->
setInfo($par[
"desc"] ??
'');
719 if ($this->object_definition->isContainer($this->getCurrentObject()->getType())) {
721 $check->setInfo($this->
lng->txt(
'rbac_change_existing_objects_desc_new_role'));
729 $this->
tabs->clearTargets();
731 $this->tpl->setContent($form->getHTML());
743 if ($form->checkInput()) {
744 $new_title = $form->getInput(
"title");
747 $role->setTitle($new_title);
748 $role->setDescription($form->getInput(
'desc'));
751 $this->rbacadmin->assignRoleToFolder($role->getId(), $this->
getCurrentObject()->getRefId());
754 $this->rbacadmin->setProtected(
757 $form->getInput(
'pro') ?
'y' :
'n' 761 $right_id_to_copy = (
int) $form->getInput(
"rights");
762 if ($right_id_to_copy) {
763 $parentRoles = $this->rbacreview->getParentRoleIds($this->
getCurrentObject()->getRefId(),
true);
764 $this->rbacadmin->copyRoleTemplatePermissions(
766 $parentRoles[$right_id_to_copy][
"parent"],
772 if ($form->getInput(
'existing')) {
773 if ($form->getInput(
'pro')) {
774 $role->changeExistingObjects(
780 $role->changeExistingObjects(
790 if ($form->getInput(
"desktop")) {
791 $this->recommended_content_manager->addRoleRecommendation(
797 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"role_added"),
true);
798 $this->
ctrl->redirect($this,
'perm');
800 $form->setValuesByPost();
801 $this->tpl->setContent($form->getHTML());
807 $blocked_info[
'new_blocked'] = [];
808 $blocked_info[
'new_unblocked'] = [];
809 $blocked_info[
'num'] = 0;
810 $visible_block = $this->
http->wrapper()->post()->has(
'visible_block')
811 ? $this->
http->wrapper()->post()->retrieve(
816 $block_post = $this->
http->wrapper()->post()->has(
'block')
817 ? $this->
http->wrapper()->post()->retrieve(
824 foreach ($visible_block as $role => $one) {
825 $blocked = $this->rbacreview->isBlockedAtPosition($role, $this->
getCurrentObject()->getRefId());
826 if (isset($block_post[$role]) && !$blocked) {
827 $blocked_info[
'new_blocked'][] = $role;
828 $blocked_info[
'num']++;
830 if (!isset($block_post[$role]) && $blocked) {
831 $blocked_info[
'new_unblocked'][] = $role;
832 $blocked_info[
'num']++;
835 return $blocked_info;
840 $perm = self::CMD_PERM_POSITIONS;
845 $table->collectData();
846 $this->tpl->setContent($table->getHTML());
857 $local_post = $this->
http->wrapper()->post()->has(
'local')
858 ? $this->
http->wrapper()->post()->retrieve(
864 foreach ($positions as $position_id) {
865 if (isset($local_post[$position_id])) {
872 $position_perm_post = $this->
http->wrapper()->post()->has(
'position_perm')
873 ? $this->
http->wrapper()->post()->retrieve(
875 $this->
refinery->kindlyTo()->dictOf(
876 $this->
refinery->kindlyTo()->dictOf(
883 if ($position_perm_post) {
884 foreach ($position_perm_post as $position_id => $ops) {
885 if (!isset($local_post[$position_id])) {
889 if (!$ilOrgUnitPermission->isTemplate()) {
891 foreach ($ops as $op_id => $op) {
894 $ilOrgUnitPermission = $ilOrgUnitPermission->withOperations($new_ops);
899 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
900 $this->
ctrl->redirect($this, self::CMD_PERM_POSITIONS);
908 $form->setFormAction($this->
ctrl->getFormAction($this,
"owner"));
909 $form->setTitle($this->
lng->txt(
"info_owner_of_object"));
912 $login->setDataSource($this->
ctrl->getLinkTargetByClass([get_class($this),
913 'ilRepositorySearchGUI' 914 ],
'doUserAutoComplete',
'',
true));
915 $login->setRequired(
true);
917 $login->setInfo($this->
lng->txt(
"chown_warning"));
919 $form->addItem($login);
920 $form->addCommandButton(
"changeOwner", $this->
lng->txt(
"change_owner"));
921 $this->tpl->setContent($form->getHTML());
927 if ($this->
http->wrapper()->post()->has(
'owner')) {
928 $owner = $this->
http->wrapper()->post()->retrieve(
930 $this->
refinery->kindlyTo()->string()
934 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'user_not_known'));
940 if (
$user_id != $this->gui_obj->getObject()->getOwner()) {
941 $this->gui_obj->getObject()->setOwner(
$user_id);
942 $this->gui_obj->getObject()->updateOwner();
943 $this->
objectDataCache->deleteCachedEntry($this->gui_obj->getObject()->getId());
950 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'owner_updated'),
true);
952 if (!$this->rbacsystem->checkAccess(
"edit_permission", $this->gui_obj->getObject()->getRefId())) {
953 $this->
ctrl->redirect($this->gui_obj);
956 $this->
ctrl->redirect($this,
'owner');
961 $perm = $a_cmd ===
'perm';
963 $info = $a_cmd ===
'perminfo';
964 $owner = $a_cmd ===
'owner';
965 $log = $a_cmd ===
'log';
967 $this->
tabs->addSubTabTarget(
968 "permission_settings",
969 $this->
ctrl->getLinkTarget($this,
"perm"),
977 $this->
tabs->addSubTabTarget(
978 self::TAB_POSITION_PERMISSION_SETTINGS,
987 $this->
tabs->addSubTabTarget(
989 $this->
ctrl->getLinkTargetByClass([get_class($this),
"ilobjectpermissionstatusgui"],
"perminfo"),
995 $this->
tabs->addSubTabTarget(
997 $this->
ctrl->getLinkTarget($this,
"owner"),
1005 $this->
tabs->addSubTabTarget(
1007 $this->
ctrl->getLinkTarget($this,
'log'),
1019 $this->
ctrl->redirect($this,
'perm');
1027 $this->data_factory,
1031 $this->object_definition,
1032 $this->
http->request(),
1037 $this->tpl->setContent($this->ui_renderer->render(
1038 $table->getTableAndFilter()
displayImportRoleForm(?ilPropertyFormGUI $form=null)
This class represents an option in a radio group.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjectDefinition $object_definition
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
perm(?ilTable2GUI $table=null)
addRole()
adds a local role This method is only called when choose the option 'you may add local roles'...
__initSubTabs(string $a_cmd)
ilOrgUnitPositionDBRepository $positionRepo
isInAdministration()
Check if node is subobject of administration folder.
showConfirmBlockRole(array $a_blocked_info)
static _lookupId($a_user_str)
ilOrgUnitOperationDBRepository $operationRepo
const MODE_PROTECTED_KEEP_LOCAL_POLICIES
ilOrgUnitPermissionDBRepository $permissionRepo
ilRecommendedContentManager $recommended_content_manager
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static lookupCreateOperationIds(array $a_type_arr)
Lookup operation ids.
static gatherFaPa(int $ref_id, array $role_ids, bool $add_action=false)
ilObjectDataCache $objectDataCache
static http()
Fetches the global http state from ILIAS.
getModifiedBlockedSettings()
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getTranslation(string $a_role_title)
Class ilObjectGUI Basic methods of all Output classes.
static hasContainerCommands(string $a_type)
unblockRoles(array $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.
static add(int $action, int $ref_id, array $diff, bool $source_ref_id=false)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static diffFaPa(array $old, array $new)
const ROLE_FILTER_LOCAL_POLICY
const ROLE_FILTER_LOCAL_OBJECT
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
const MODE_UNPROTECTED_KEEP_LOCAL_POLICIES
DataFactory $data_factory
executeCommand()
Execute command.
ilGlobalTemplateInterface $tpl
applyRoleFilter(array $a_roles, int $a_filter_id)
Class ilRbacAdmin Core functions for role based access control.
savePositionsPermissions()
Table for object role permissions.
const CMD_SAVE_POSITIONS_PERMISSIONS
class ilRbacLog Log changes in Rbac-related settings
This class displays the permission status of a user concerning a specific object. ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TAB_POSITION_PERMISSION_SETTINGS
static _lookupLogin(int $a_user_id)