19 declare(strict_types=1);
40 protected \ILIAS\HTTP\Wrapper\WrapperFactory
$wrapper;
46 $this->wrapper = $DIC->http()->wrapper();
47 $this->
toolbar = $DIC->toolbar();
60 if (!$this->rbacsystem->checkAccess(
"edit_permission", $this->gui_obj->getObject()->getRefId())) {
61 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
62 $this->
ctrl->redirect($this->gui_obj);
64 $next_class = $this->
ctrl->getNextClass($this);
65 switch ($next_class) {
69 if ($this->
http->wrapper()->query()->has(
'obj_id')) {
70 $role_id = $this->
http->wrapper()->query()->retrieve(
75 $this->
ctrl->setReturn($this,
'perm');
76 $this->gui_obj =
new ilObjRoleGUI(
"", $role_id,
false,
false);
77 $this->
ctrl->forwardCommand($this->gui_obj);
80 case 'ildidactictemplategui':
81 $this->
ctrl->setReturn($this,
'perm');
83 $this->
ctrl->forwardCommand($did);
86 case 'ilrepositorysearchgui':
89 $this->
ctrl->forwardCommand($rep_search);
92 case 'ilobjectpermissionstatusgui':
95 $this->
ctrl->forwardCommand($perm_stat);
99 $cmd = $this->
ctrl->getCmd();
107 return $this->gui_obj->getObject();
115 $this->
ctrl->setReturn($this,
'perm');
116 $this->
ctrl->setCmdClass(
'ildidactictemplategui');
118 $this->
ctrl->forwardCommand($dtpl_gui);
124 if ($dtpl->appendToolbarSwitch(
126 $this->getCurrentObject()->getType(),
129 $this->
toolbar->addSeparator();
132 if ($this->objDefinition->hasLocalRoles($this->getCurrentObject()->getType()) && !$this->
isAdministrationObject()
134 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this));
138 $this->
lng->txt(
'rbac_add_new_local_role'),
139 $this->
ctrl->getLinkTarget($this,
'displayAddRoleForm')
143 $this->
lng->txt(
'rbac_import_role'),
144 $this->
ctrl->getLinkTarget($this,
'displayImportRoleForm')
153 $this->tpl->setContent($table->getHTML());
177 $table->resetOffset();
178 $table->writeFilterToSession();
185 $table->resetOffset();
186 $table->resetFilter();
194 unset($a_roles[SYSTEM_ROLE_ID]);
197 switch ($a_filter_id) {
204 $arr_global_roles = $this->rbacreview->getGlobalRoles();
205 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_global_roles);
206 foreach ($arr_remove_roles as $role_id) {
207 unset($a_roles[$role_id]);
213 $arr_global_roles = $this->rbacreview->getGlobalRoles();
214 foreach ($arr_global_roles as $role_id) {
215 unset($a_roles[$role_id]);
221 $arr_local_roles = $this->rbacreview->getRolesOfObject($this->
getCurrentObject()->getRefId());
222 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_local_roles);
223 foreach ($arr_remove_roles as $role_id) {
224 unset($a_roles[$role_id]);
230 $arr_local_roles = $this->rbacreview->getRolesOfObject($this->
getCurrentObject()->getRefId(),
true);
231 $arr_remove_roles = array_diff(array_keys($a_roles), $arr_local_roles);
232 foreach ($arr_remove_roles as $role_id) {
233 unset($a_roles[$role_id]);
254 (
int) $table->getFilterItemByPostVar(
'role')->getValue()
260 # all possible create permissions 266 # createable (activated) create permissions 272 $post_perm = $this->wrapper->post()->has(
'perm')
273 ? $this->wrapper->post()->retrieve(
275 $this->
refinery->kindlyTo()->dictOf(
276 $this->
refinery->kindlyTo()->dictOf(
283 foreach ($roles as $role => $role_data) {
284 if ($role_data[
'protected']) {
288 $new_ops = array_keys((array) ($post_perm[$role] ?? []));
295 foreach ($possible_ops_ids as $create_ops_id) {
296 if (in_array($create_ops_id, $createable_ops_ids)) {
299 if (in_array($create_ops_id, $old_ops)) {
300 $new_ops[] = $create_ops_id;
311 array_unique($new_ops),
317 $inherit_post = $this->wrapper->post()->has(
'inherit')
318 ? $this->wrapper->post()->retrieve(
320 $this->
refinery->kindlyTo()->dictOf(
326 foreach ($roles as $role) {
327 $obj_id = (
int) $role[
'obj_id'];
328 $parent_id = (
int) $role[
'parent'];
330 if ($parent_id === $this->
getCurrentObject()->getRefId() && $role[
'assign'] ===
'y') {
334 if ($role[
'protected']) {
340 && !isset($inherit_post[$obj_id])
352 && isset($inherit_post[$obj_id])
369 $protected_post = $this->wrapper->post()->has(
'protect')
370 ? $this->wrapper->post()->retrieve(
375 foreach ($roles as $role) {
376 $obj_id = (
int) $role[
'obj_id'];
378 if (isset($protected_post[$obj_id]) &&
381 } elseif (!isset($protected_post[$obj_id]) &&
395 if ($blocked_info[
'num'] > 0) {
399 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
400 $this->
ctrl->redirect($this,
'perm');
407 if ($a_blocked_info[
'new_blocked']) {
408 $info .= $this->
lng->txt(
'role_confirm_block_role_info');
409 if ($a_blocked_info[
'new_unblocked']) {
410 $info .=
'<br /><br />';
413 if ($a_blocked_info[
'new_unblocked']) {
414 $info .= (
'<br />' . $this->
lng->txt(
'role_confirm_unblock_role_info'));
417 $this->tpl->setOnScreenMessage(
'info', $info);
420 $confirm->setFormAction($this->
ctrl->getFormAction($this));
421 $confirm->setHeaderText($this->
lng->txt(
'role_confirm_block_role_header'));
422 $confirm->setConfirm($this->
lng->txt(
'role_confirm_block_role'),
'modifyBlockRoles');
423 $confirm->setCancel($this->
lng->txt(
'cancel'),
'perm');
425 foreach ($a_blocked_info[
'new_blocked'] as $role_id) {
432 foreach ($a_blocked_info[
'new_unblocked'] as $role_id) {
439 $this->tpl->setContent($confirm->getHTML());
445 $this->wrapper->post()->has(
'new_block')
446 ? $this->wrapper->post()->retrieve(
452 $this->
unblockRoles($this->wrapper->post()->has(
'new_unblock')
453 ? $this->wrapper->post()->retrieve(
459 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'settings_saved'));
460 $this->
ctrl->redirect($this,
'perm');
468 foreach (
$roles as $role) {
475 $role_obj->changeExistingObjects(
482 $this->rbacadmin->setBlockedStatus(
492 foreach (
$roles as $role) {
494 $assign = $this->rbacreview->isAssignable($role, $this->
getCurrentObject()->getRefId()) ?
'y' :
'n';
497 $this->rbacadmin->revokeSubtreePermissions($this->
getCurrentObject()->getRefId(), $role);
500 $this->rbacadmin->deleteSubtreeTemplates($this->
getCurrentObject()->getRefId(), $role);
502 $this->rbacadmin->assignRoleToFolder(
509 $this->rbacadmin->setBlockedStatus(
527 $this->
tabs->clearTargets();
532 $this->tpl->setContent($form->getHTML());
538 if ($form->checkInput()) {
543 $imp->getMapping()->addMapping(
544 'Services/AccessControl',
552 $_FILES[
"importfile"][
"tmp_name"],
553 $_FILES[
"importfile"][
"name"],
556 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_role_imported'),
true);
557 $this->
ctrl->redirect($this,
'perm');
560 $this->tpl->setOnScreenMessage(
'failure', $e->getMessage());
561 $form->setValuesByPost();
566 $form->setValuesByPost();
567 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
577 $form->setFormAction($this->
ctrl->getFormAction($this));
578 $form->setTitle($this->
lng->txt(
'rbac_import_role'));
579 $form->addCommandButton(
'doImportRole', $this->
lng->txt(
'import'));
580 $form->addCommandButton(
'perm', $this->
lng->txt(
'cancel'));
584 $zip->setSuffixes([
'zip']);
585 $form->addItem($zip);
593 $form->setFormAction($this->
ctrl->getFormAction($this));
594 $form->setTitle($this->
lng->txt(
'role_new'));
595 $form->addCommandButton(
'addrole', $this->
lng->txt(
'role_new'));
596 $form->addCommandButton(
'perm', $this->
lng->txt(
'cancel'));
599 $title->setValidationRegexp(
'/^(?!il_).*$/');
600 $title->setValidationFailureMessage($this->
lng->txt(
'msg_role_reserved_prefix'));
602 $title->setMaxLength(70);
603 $title->setRequired(
true);
604 $form->addItem($title);
609 $form->addItem($desc);
612 $pro->
setInfo($this->
lng->txt(
'role_protect_permissions_desc'));
614 $form->addItem($pro);
621 $this->
lng->txt(
'rbac_add_recommended_content_info')
624 $pd->setValue((
string) 1);
629 $option =
new ilRadioOption($this->
lng->txt(
"rbac_role_rights_copy_empty"), (string) 0);
630 $rights->addOption($option);
632 $parent_role_ids = $this->rbacreview->getParentRoleIds($this->gui_obj->getObject()->getRefId(),
true);
634 foreach (array_keys($parent_role_ids) as
$id) {
639 $sorted_ids =
ilUtil::_sortIds($ids,
'object_data',
'type DESC,title',
'obj_id');
642 foreach ($sorted_ids as
$id) {
643 $par = $parent_role_ids[
$id];
646 ($par[
"type"] ==
'role' ? $this->
lng->txt(
'obj_role') : $this->
lng->txt(
649 (string) $par[
"obj_id"]
651 $option->
setInfo($par[
"desc"] ??
'');
652 $rights->addOption($option);
656 $form->addItem($rights);
660 if ($this->objDefinition->isContainer($this->getCurrentObject()->getType())) {
661 $check =
new ilCheckboxInputGui($this->
lng->txt(
"rbac_role_rights_copy_change_existing"),
'existing');
662 $check->setInfo($this->
lng->txt(
'rbac_change_existing_objects_desc_new_role'));
673 $this->
tabs->clearTargets();
675 $this->tpl->setContent($form->getHTML());
687 if ($form->checkInput()) {
688 $new_title = $form->getInput(
"title");
691 $role->setTitle($new_title);
692 $role->setDescription($form->getInput(
'desc'));
695 $this->rbacadmin->assignRoleToFolder($role->getId(), $this->
getCurrentObject()->getRefId());
698 $this->rbacadmin->setProtected(
701 $form->getInput(
'pro') ?
'y' :
'n' 705 $right_id_to_copy = (
int) $form->getInput(
"rights");
706 if ($right_id_to_copy) {
707 $parentRoles = $this->rbacreview->getParentRoleIds($this->
getCurrentObject()->getRefId(),
true);
708 $this->rbacadmin->copyRoleTemplatePermissions(
710 $parentRoles[$right_id_to_copy][
"parent"],
716 if ($form->getInput(
'existing')) {
717 if ($form->getInput(
'pro')) {
718 $role->changeExistingObjects(
724 $role->changeExistingObjects(
734 if ($form->getInput(
"desktop")) {
735 $this->recommended_content_manager->addRoleRecommendation(
741 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"role_added"),
true);
742 $this->
ctrl->redirect($this,
'perm');
744 $form->setValuesByPost();
745 $this->tpl->setContent($form->getHTML());
755 $blocked_info[
'new_blocked'] = [];
756 $blocked_info[
'new_unblocked'] = [];
757 $blocked_info[
'num'] = 0;
758 $visible_block = $this->wrapper->post()->has(
'visible_block')
759 ? $this->wrapper->post()->retrieve(
764 $block_post = $this->wrapper->post()->has(
'block')
765 ? $this->wrapper->post()->retrieve(
772 foreach ($visible_block as $role => $one) {
774 if (isset($block_post[$role]) && !$blocked) {
775 $blocked_info[
'new_blocked'][] = $role;
776 $blocked_info[
'num']++;
778 if (!isset($block_post[$role]) && $blocked) {
779 $blocked_info[
'new_unblocked'][] = $role;
780 $blocked_info[
'num']++;
783 return $blocked_info;
792 $perm = self::CMD_PERM_POSITIONS;
797 $table->collectData();
798 $this->tpl->setContent($table->getHTML());
809 $local_post = $this->wrapper->post()->has(
'local')
810 ? $this->wrapper->post()->retrieve(
816 foreach ($positions as $position_id) {
817 if (isset($local_post[$position_id])) {
818 ilOrgUnitPermissionQueries::findOrCreateSetForRefId(
$ref_id, (
int) $position_id);
820 ilOrgUnitPermissionQueries::removeLocalSetForRefId(
$ref_id, (
int) $position_id);
824 $position_perm_post = $this->wrapper->post()->has(
'position_perm')
825 ? $this->wrapper->post()->retrieve(
827 $this->
refinery->kindlyTo()->dictOf(
828 $this->
refinery->kindlyTo()->dictOf(
835 if ($position_perm_post) {
836 foreach ($position_perm_post as $position_id => $ops) {
837 if (!isset($local_post[$position_id])) {
840 $ilOrgUnitPermission = ilOrgUnitPermissionQueries::getSetForRefId(
$ref_id, (
int) $position_id);
842 foreach ($ops as $op_id => $op) {
845 $ilOrgUnitPermission->setOperations($new_ops);
846 $ilOrgUnitPermission->save();
849 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
850 $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 getArray(?string $key=null, $values=null)
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' ...)
isInAdministration()
Check if node is subobject of administration folder.
showConfirmBlockRole(array $a_blocked_info)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
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...
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
static findById(int $operation_id)
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
__construct(object $a_gui_obj)
const ROLE_FILTER_LOCAL_POLICY
const ROLE_FILTER_LOCAL_OBJECT
initImportForm()
init import form
__construct(Container $dic, ilPlugin $plugin)
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...
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.