19 declare(strict_types=1);
50 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference)
54 $this->
logger = $DIC->logger()->ac();
55 $this->rbacadmin = $DIC[
'rbacadmin'];
56 $this->
http = $DIC->http();
58 $this->ui_factory = $DIC[
'ui.factory'];
62 $this->
lng->loadLanguageModule(
'rbac');
67 $next_class = $this->
ctrl->getNextClass($this);
68 $cmd = $this->
ctrl->getCmd();
71 switch ($next_class) {
72 case 'ilpermissiongui':
74 $ret = $this->
ctrl->forwardCommand($perm_gui);
78 $this->
ctrl->setReturn($this,
"view");
91 if ($this->
http->wrapper()->query()->has(
'csource')) {
92 return $this->
http->wrapper()->query()->retrieve(
105 if ($this->
http->wrapper()->post()->has(
'roles')) {
106 return $this->
http->wrapper()->post()->retrieve(
109 $this->refinery->kindlyTo()->listOf(
113 $this->
refinery->custom()->transformation(
function ($v) {
114 return explode(
',', $v);
116 $this->
refinery->kindlyTo()->listOf(
135 if ($targets === []) {
136 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'rbac_copy_no_targets'),
true);
137 $this->
ctrl->redirect($this,
'roleSearchList');
140 if (count($targets) > 3) {
144 if (count($targets) > 1) {
146 foreach ($targets as $target) {
149 return $target_names .
'</strong>';
158 $this->tabs_gui->activateTab(
'view');
160 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
161 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
164 if ($this->rbac_system->checkAccess(
'create_role', $this->object->getRefId())) {
165 $this->
ctrl->setParameter($this,
'new_type',
'role');
167 $this->ui_factory->link()->standard(
168 $this->
lng->txt(
'rolf_create_role'),
169 $this->
ctrl->getLinkTargetByClass(ilObjRoleGUI::class,
'create')
173 if ($this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId())) {
174 $this->
ctrl->setParameter($this,
'new_type',
'rolt');
176 $this->ui_factory->link()->standard(
177 $this->
lng->txt(
'rolf_create_rolt'),
178 $this->
ctrl->getLinkTargetByClass(ilObjRoleTemplateGUI::class,
'create')
181 $this->
ctrl->clearParameters($this);
185 $this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId()) ||
186 $this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId())
189 $this->ui_factory->link()->standard(
190 $this->
lng->txt(
'rbac_import_role'),
191 $this->
ctrl->getLinkTargetByClass(
'ilPermissionGUI',
'displayImportRoleForm')
198 $table->parse($this->
object->getId());
200 $this->tpl->setContent($table->getHTML());
208 $this->tabs_gui->clearTargets();
209 $this->tabs_gui->setBackTarget(
210 $this->
lng->txt(
'rbac_back_to_overview'),
211 $this->
ctrl->getLinkTarget($this,
'view')
214 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
215 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
219 $this->tpl->setOnScreenMessage(
222 $this->
lng->txt(
'rbac_choose_copy_targets'),
228 $this->tpl->setContent($form->getHTML());
237 $form->setTitle($this->
lng->txt(
'rbac_role_title'));
238 $form->setFormAction($this->
ctrl->getFormAction($this,
'view'));
241 $search->setRequired(
true);
242 $search->setSize(30);
243 $search->setMaxLength(255);
244 $form->addItem($search);
246 $form->addCommandButton(
'roleSearchForm', $this->
lng->txt(
'search'));
259 if ($form->checkInput()) {
265 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_search_string'),
true);
266 $form->setValuesByPost();
267 $this->
ctrl->redirect($this,
'roleSearch');
275 $this->tabs_gui->clearTargets();
276 $this->tabs_gui->setBackTarget(
277 $this->
lng->txt(
'rbac_back_to_overview'),
278 $this->
ctrl->getLinkTarget($this,
'view')
284 $this->tpl->setOnScreenMessage(
287 $this->
lng->txt(
'rbac_select_copy_targets'),
295 $table->parse($this->
object->getId());
296 $this->tpl->setContent($table->getHTML());
300 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_search_string'),
true);
301 $this->
ctrl->redirect($this,
'roleSearch');
311 $this->
ctrl->saveParameter($this,
'csource');
312 $this->tabs_gui->clearTargets();
313 $this->tabs_gui->setBackTarget(
314 $this->
lng->txt(
'rbac_back_to_overview'),
315 $this->
ctrl->getLinkTarget($this,
'view')
320 $this->tpl->setContent($form->getHTML());
329 $full_featured =
true;
331 $this->tpl->setOnScreenMessage(
334 $this->
lng->txt(
'rbac_copy_behaviour_info'),
342 $form->setTitle($this->
lng->txt(
'rbac_copy_behaviour'));
343 $form->setFormAction($this->
ctrl->getFormAction($this,
'chooseCopyBehaviour'));
345 $copy_type = new \ilRadioGroupInputGUI(
346 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type'),
349 $copy_type->setRequired(
true);
350 $copy_type->setValue((
string) self::COPY_CLONE_PERMISSIONS);
352 if ($full_featured) {
353 $add = new \ilRadioOption(
354 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_add'),
355 (string) self::COPY_ADD_PERMISSIONS,
356 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_add_info')
358 $copy_type->addOption($add);
360 $ce_type_add = new \ilRadioGroupInputGUI(
364 $ce_type_add->setRequired(
true);
365 $ce_add_yes = new \ilRadioOption(
366 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_yes'),
367 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
368 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_yes_info')
370 $ce_type_add->addOption($ce_add_yes);
371 $ce_add_no = new \ilRadioOption(
372 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_no'),
374 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_no_info')
376 $ce_type_add->addOption($ce_add_no);
377 $add->addSubItem($ce_type_add);
379 $clone = new \ilRadioOption(
380 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_clone'),
381 (string) self::COPY_CLONE_PERMISSIONS,
382 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_clone_info')
384 $copy_type->addOption($clone);
386 $ce_type_clone = new \ilRadioGroupInputGUI(
390 $ce_type_clone->setRequired(
true);
391 $ce_clone_yes = new \ilRadioOption(
392 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_yes'),
393 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
394 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_yes_info')
396 $ce_type_clone->addOption($ce_clone_yes);
397 $ce_clone_no = new \ilRadioOption(
398 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_no'),
400 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_no_info')
402 $ce_type_clone->addOption($ce_clone_no);
403 $clone->addSubItem($ce_type_clone);
405 if ($full_featured) {
406 $remove = new \ilRadioOption(
407 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_remove'),
408 (string) self::COPY_REMOVE_PERMISSIONS,
409 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_remove_info')
411 $copy_type->addOption($remove);
412 $ce_type_remove = new \ilRadioGroupInputGUI(
416 $ce_type_remove->setRequired(
true);
417 $ce_remove_yes = new \ilRadioOption(
418 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_yes'),
419 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
420 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_yes_info')
422 $ce_type_remove->addOption($ce_remove_yes);
423 $ce_remove_no = new \ilRadioOption(
424 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_no'),
426 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_no_info')
428 $ce_type_remove->addOption($ce_remove_no);
429 $remove->addSubItem($ce_type_remove);
432 $form->addItem($copy_type);
436 $form->addItem($roles);
438 $form->addCommandButton(
'roleSearchList', $this->
lng->txt(
'back'));
439 $form->addCommandButton(
'adjustRole', $this->
lng->txt(
'rbac_form_copy_roles_adjust_button'));
454 if (!$form->checkInput()) {
455 $form->setValuesByPost();
460 $adjustment_type = $form->getInput(
'type');
461 foreach ((array) $roles as $role_id) {
462 if ($role_id !== $source) {
463 $start_obj = $this->rbac_review->getRoleFolderOfRole($role_id);
464 $this->
logger->debug(
'Start object: ' . $start_obj);
466 switch ($adjustment_type) {
467 case self::COPY_ADD_PERMISSIONS:
468 $change_existing = (bool) $form->getInput(
'add_ce_type');
473 if ($change_existing) {
482 case self::COPY_CLONE_PERMISSIONS:
483 $change_existing = (bool) $form->getInput(
'clone_ce_type');
488 if ($change_existing) {
497 case self::COPY_REMOVE_PERMISSIONS:
498 $change_existing = (bool) $form->getInput(
'remove_ce_type');
503 if ($change_existing) {
515 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_copy_finished'),
true);
516 $this->
ctrl->redirect($this,
'view');
525 $source_definition = $this->rbac_review->getRoleFolderOfRole($source);
526 $this->rbacadmin->copyRolePermissionUnion(
530 $this->rbac_review->getRoleFolderOfRole($target),
532 $this->rbac_review->getRoleFolderOfRole($target)
546 if ($form->checkInput()) {
547 foreach ((array) $roles as $role_id) {
548 if ($role_id !== $source) {
552 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_copy_finished'),
true);
553 $this->
ctrl->redirect($this,
'view');
562 $this->
logger->debug(
'Remove permission source: ' . $source);
563 $this->
logger->debug(
'Remove permission target: ' . $target);
564 $source_obj = $this->rbac_review->getRoleFolderOfRole($source);
565 $this->rbacadmin->copyRolePermissionSubtract(
569 $this->rbac_review->getRoleFolderOfRole($target)
576 protected function doCopyRole(
int $source,
int $target): void
578 $target_obj = $this->rbac_review->getRoleFolderOfRole($target);
579 $source_obj = $this->rbac_review->getRoleFolderOfRole($source);
581 $this->rbacadmin->copyRoleTemplatePermissions(
595 int $a_operation_mode,
599 $this->
logger->warning(
'Missing parameter start object.');
604 $target_ref_id = $this->rbac_review->getRoleFolderOfRole($a_target_role);
605 if ($this->rbac_review->isProtected($target_ref_id, $a_target_role)) {
610 $operation_stack = [];
612 $operation_stack[] = $this->rbac_review->getAllOperationsOfRole($a_source_role, $this->ref_id);
614 $this->
logger->debug(
'Current operation stack');
618 $role->changeExistingObjects(
635 $table->resetOffset();
636 $table->writeFilterToSession();
648 $table->resetOffset();
649 $table->resetFilter();
661 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
662 $this->
ctrl->redirect($this,
'view');
665 $question = $this->
lng->txt(
'rbac_role_delete_qst');
668 $confirm->setHeaderText($question);
669 $confirm->setFormAction($this->
ctrl->getFormAction($this));
670 $confirm->setHeaderText($this->
lng->txt(
"info_delete_sure"));
671 $confirm->setConfirm($this->
lng->txt(
'delete'),
'deleteRole');
672 $confirm->setCancel($this->
lng->txt(
'cancel'),
'cancel');
674 foreach ($roles as $role_id) {
681 $this->tpl->setContent($confirm->getHTML());
689 if (!$this->rbac_system->checkAccess(
'delete', $this->object->getRefId())) {
690 $this->error->raiseError(
691 $this->
lng->txt(
'msg_no_perm_delete'),
692 $this->error->MESSAGE
700 if ($obj->getType() ==
"role") {
701 $rolf_arr = $this->rbac_review->getFoldersAssignedToRole($obj->getId(),
true);
702 $obj->setParent($rolf_arr[0]);
709 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_deleted_roles_rolts"),
true);
710 $this->
ctrl->redirect($this,
'view');
722 $this->tabs_gui->addTarget(
724 $this->
ctrl->getLinkTarget($this,
"view"),
729 $this->tabs_gui->addTarget(
731 $this->
ctrl->getLinkTarget($this,
"editSettings"),
738 $this->tabs_gui->addTarget(
740 $this->
ctrl->getLinkTargetByClass(
741 [get_class($this),
'ilpermissiongui'],
752 if ($a_form === null) {
756 $this->tpl->setContent($a_form->getHTML());
763 $user = $DIC->user();
766 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
770 if ($form->checkInput()) {
772 $privacy->enableRbacLog((
bool) $form->getInput(
'rbac_log'));
773 $privacy->setRbacLogAge((
int) $form->getInput(
'rbac_log_age'));
778 $security->protectedAdminRole((
bool) $form->getInput(
'admin_role'));
781 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"settings_saved"),
true);
782 $this->
ctrl->redirect($this,
"editSettings");
785 $form->setValuesByPost();
793 $user = $DIC->user();
795 $this->
lng->loadLanguageModule(
'ps');
801 $form->setFormAction($this->
ctrl->getFormAction($this,
"saveSettings"));
802 $form->setTitle($this->
lng->txt(
'settings'));
807 $admin->setInfo($this->
lng->txt(
'adm_adm_role_protect_info'));
808 $admin->setChecked($security->isAdminRoleProtected());
809 $admin->setValue((
string) 1);
810 $form->addItem($admin);
813 $check->setInfo($this->
lng->txt(
'rbac_log_info'));
814 $check->setChecked($privacy->enabledRbacLog());
818 $age->setInfo($this->
lng->txt(
'rbac_log_age_info'));
819 $age->setValue((
string) $privacy->getRbacLogAge());
820 $age->setMinValue(1);
821 $age->setMaxValue(24);
823 $age->setMaxLength(2);
826 $form->addCommandButton(
'saveSettings', $this->
lng->txt(
'save'));
833 switch ($a_form_id) {
838 $fields = [
'adm_adm_role_protect' => [$security->isAdminRoleProtected(),
843 return [[
"editSettings", $fields]];
850 if ($privacy->enabledRbacLog()) {
851 $subitems = [
'rbac_log_age' => $privacy->getRbacLogAge()];
853 $fields = [
'rbac_log' => [$privacy->enabledRbacLog(),
859 return [[
"editSettings", $fields]];
static get(string $a_var)
editSettingsObject(ilPropertyFormGUI $a_form=null)
confirmDeleteObject()
Confirm deletion of roles.
prepareOutput(bool $show_sub_objects=true)
getAdminTabs()
Add role folder tabs.
adjustRoleObject()
Copy role.
__construct($a_data, int $a_id, bool $a_call_by_reference)
Constructor public.
addToExternalSettingsForm(int $a_form_id)
deleteRoleObject()
Delete roles.
roleSearchListObject()
List roles.
const MODE_REMOVE_OPERATIONS
Class ilObjRoleFolderGUI.
TableGUI for the presentation og roles and role templates.
const MODE_PROTECTED_KEEP_LOCAL_POLICIES
const MODE_READ_OPERATIONS
doRemoveRolePermissions(int $source, int $target)
do add role permission
static http()
Fetches the global http state from ILIAS.
static _lookupTitle(int $obj_id)
const COPY_ADD_PERMISSIONS
static _getTranslation(string $a_role_title)
Class ilObjectGUI Basic methods of all Output classes.
initRoleSearchForm()
Init role search form.
removeRolePermissionsObject()
Remove role permissions.
applyFilterObject()
Apply role filter.
const COPY_CLONE_PERMISSIONS
doCopyRole(int $source, int $target)
Perform copy of role.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
const MODE_ADD_OPERATIONS
const COPY_CHANGE_EXISTING_OBJECTS
const COPY_REMOVE_PERMISSIONS
resetFilterObject()
Reset role filter.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
__construct(Container $dic, ilPlugin $plugin)
chooseCopyBehaviourObject(?ilPropertyFormGUI $form=null)
Choose option for copying roles/role templates.
const MODE_UNPROTECTED_KEEP_LOCAL_POLICIES
doAddRolePermissions(int $source, int $target)
do add role permission
Class ilRbacAdmin Core functions for role based access control.
roleSearchFormObject()
Parse search query.
static _getInstance()
Get instance of ilSecuritySettings.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static set(string $a_var, $a_val)
Set a value.
doChangeExistingObjects(int $a_start_obj, int $a_target_role, int $a_operation_mode, int $a_source_role)
Do change existing objects.
initCopyBehaviourForm()
Show copy behaviour form.
roleSearchObject()
Search target roles.