19 declare(strict_types=1);
47 public function __construct($a_data,
int $a_id,
bool $a_call_by_reference)
51 $this->
logger = $DIC->logger()->ac();
52 $this->rbacadmin = $DIC[
'rbacadmin'];
54 $this->ui_factory = $DIC[
'ui.factory'];
58 $this->
lng->loadLanguageModule(
'rbac');
63 $next_class = $this->
ctrl->getNextClass($this);
64 $cmd = $this->
ctrl->getCmd();
67 switch ($next_class) {
68 case 'ilpermissiongui':
70 $ret = $this->
ctrl->forwardCommand($perm_gui);
74 $this->
ctrl->setReturn($this,
"view");
87 if ($this->
http->wrapper()->query()->has(
'csource')) {
88 return $this->
http->wrapper()->query()->retrieve(
101 if ($this->
http->wrapper()->post()->has(
'roles')) {
102 return $this->
http->wrapper()->post()->retrieve(
105 $this->refinery->kindlyTo()->listOf(
109 $this->
refinery->custom()->transformation(
function ($v) {
110 return explode(
',', $v);
112 $this->
refinery->kindlyTo()->listOf(
131 if ($targets === []) {
132 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'rbac_copy_no_targets'),
true);
133 $this->
ctrl->redirect($this,
'roleSearchList');
136 if (count($targets) > 3) {
140 if (count($targets) > 1) {
142 foreach ($targets as $target) {
145 return $target_names .
'</strong>';
154 $this->tabs_gui->activateTab(
'view');
156 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
157 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
160 if ($this->rbac_system->checkAccess(
'create_role', $this->object->getRefId())) {
161 $this->
ctrl->setParameter($this,
'new_type',
'role');
163 $this->ui_factory->link()->standard(
164 $this->
lng->txt(
'rolf_create_role'),
165 $this->
ctrl->getLinkTargetByClass(ilObjRoleGUI::class,
'create')
169 if ($this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId())) {
170 $this->
ctrl->setParameter($this,
'new_type',
'rolt');
172 $this->ui_factory->link()->standard(
173 $this->
lng->txt(
'rolf_create_rolt'),
174 $this->
ctrl->getLinkTargetByClass(ilObjRoleTemplateGUI::class,
'create')
177 $this->
ctrl->clearParameters($this);
181 $this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId()) ||
182 $this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId())
185 $this->ui_factory->link()->standard(
186 $this->
lng->txt(
'rbac_import_role'),
187 $this->
ctrl->getLinkTargetByClass(
'ilPermissionGUI',
'displayImportRoleForm')
194 $table->parse($this->
object->getId());
196 $this->tpl->setContent($table->getHTML());
204 $this->tabs_gui->clearTargets();
205 $this->tabs_gui->setBackTarget(
206 $this->
lng->txt(
'rbac_back_to_overview'),
207 $this->
ctrl->getLinkTarget($this,
'view')
210 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
211 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
215 $this->tpl->setOnScreenMessage(
218 $this->
lng->txt(
'rbac_choose_copy_targets'),
224 $this->tpl->setContent($form->getHTML());
233 $form->setTitle($this->
lng->txt(
'rbac_role_title'));
234 $form->setFormAction($this->
ctrl->getFormAction($this,
'view'));
237 $search->setRequired(
true);
238 $search->setSize(30);
239 $search->setMaxLength(255);
240 $form->addItem($search);
242 $form->addCommandButton(
'roleSearchForm', $this->
lng->txt(
'search'));
255 if ($form->checkInput()) {
261 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_search_string'),
true);
262 $form->setValuesByPost();
263 $this->
ctrl->redirect($this,
'roleSearch');
271 $this->tabs_gui->clearTargets();
272 $this->tabs_gui->setBackTarget(
273 $this->
lng->txt(
'rbac_back_to_overview'),
274 $this->
ctrl->getLinkTarget($this,
'view')
280 $this->tpl->setOnScreenMessage(
283 $this->
lng->txt(
'rbac_select_copy_targets'),
291 $table->parse($this->
object->getId());
292 $this->tpl->setContent($table->getHTML());
296 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_search_string'),
true);
297 $this->
ctrl->redirect($this,
'roleSearch');
307 $this->
ctrl->saveParameter($this,
'csource');
308 $this->tabs_gui->clearTargets();
309 $this->tabs_gui->setBackTarget(
310 $this->
lng->txt(
'rbac_back_to_overview'),
311 $this->
ctrl->getLinkTarget($this,
'view')
316 $this->tpl->setContent($form->getHTML());
325 $full_featured =
true;
327 $this->tpl->setOnScreenMessage(
330 $this->
lng->txt(
'rbac_copy_behaviour_info'),
338 $form->setTitle($this->
lng->txt(
'rbac_copy_behaviour'));
339 $form->setFormAction($this->
ctrl->getFormAction($this,
'chooseCopyBehaviour'));
341 $copy_type = new \ilRadioGroupInputGUI(
342 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type'),
345 $copy_type->setRequired(
true);
346 $copy_type->setValue((
string) self::COPY_CLONE_PERMISSIONS);
348 if ($full_featured) {
349 $add = new \ilRadioOption(
350 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_add'),
351 (string) self::COPY_ADD_PERMISSIONS,
352 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_add_info')
354 $copy_type->addOption($add);
356 $ce_type_add = new \ilRadioGroupInputGUI(
360 $ce_type_add->setRequired(
true);
361 $ce_add_yes = new \ilRadioOption(
362 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_yes'),
363 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
364 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_yes_info')
366 $ce_type_add->addOption($ce_add_yes);
367 $ce_add_no = new \ilRadioOption(
368 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_no'),
370 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_no_info')
372 $ce_type_add->addOption($ce_add_no);
373 $add->addSubItem($ce_type_add);
375 $clone = new \ilRadioOption(
376 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_clone'),
377 (string) self::COPY_CLONE_PERMISSIONS,
378 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_clone_info')
380 $copy_type->addOption($clone);
382 $ce_type_clone = new \ilRadioGroupInputGUI(
386 $ce_type_clone->setRequired(
true);
387 $ce_clone_yes = new \ilRadioOption(
388 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_yes'),
389 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
390 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_yes_info')
392 $ce_type_clone->addOption($ce_clone_yes);
393 $ce_clone_no = new \ilRadioOption(
394 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_no'),
396 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_no_info')
398 $ce_type_clone->addOption($ce_clone_no);
399 $clone->addSubItem($ce_type_clone);
401 if ($full_featured) {
402 $remove = new \ilRadioOption(
403 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_remove'),
404 (string) self::COPY_REMOVE_PERMISSIONS,
405 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_remove_info')
407 $copy_type->addOption($remove);
408 $ce_type_remove = new \ilRadioGroupInputGUI(
412 $ce_type_remove->setRequired(
true);
413 $ce_remove_yes = new \ilRadioOption(
414 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_yes'),
415 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
416 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_yes_info')
418 $ce_type_remove->addOption($ce_remove_yes);
419 $ce_remove_no = new \ilRadioOption(
420 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_no'),
422 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_no_info')
424 $ce_type_remove->addOption($ce_remove_no);
425 $remove->addSubItem($ce_type_remove);
428 $form->addItem($copy_type);
432 $form->addItem($roles);
434 $form->addCommandButton(
'roleSearchList', $this->
lng->txt(
'back'));
435 $form->addCommandButton(
'adjustRole', $this->
lng->txt(
'rbac_form_copy_roles_adjust_button'));
450 if (!$form->checkInput()) {
451 $form->setValuesByPost();
456 $adjustment_type = $form->getInput(
'type');
457 foreach ((array) $roles as $role_id) {
458 if ($role_id !== $source) {
459 $start_obj = $this->rbac_review->getRoleFolderOfRole($role_id);
460 $this->
logger->debug(
'Start object: ' . $start_obj);
462 switch ($adjustment_type) {
463 case self::COPY_ADD_PERMISSIONS:
464 $change_existing = (bool) $form->getInput(
'add_ce_type');
469 if ($change_existing) {
478 case self::COPY_CLONE_PERMISSIONS:
479 $change_existing = (bool) $form->getInput(
'clone_ce_type');
484 if ($change_existing) {
493 case self::COPY_REMOVE_PERMISSIONS:
494 $change_existing = (bool) $form->getInput(
'remove_ce_type');
499 if ($change_existing) {
511 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_copy_finished'),
true);
512 $this->
ctrl->redirect($this,
'view');
521 $source_definition = $this->rbac_review->getRoleFolderOfRole($source);
522 $this->rbacadmin->copyRolePermissionUnion(
526 $this->rbac_review->getRoleFolderOfRole($target),
528 $this->rbac_review->getRoleFolderOfRole($target)
542 if ($form->checkInput()) {
543 foreach ((array) $roles as $role_id) {
544 if ($role_id !== $source) {
548 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_copy_finished'),
true);
549 $this->
ctrl->redirect($this,
'view');
558 $this->
logger->debug(
'Remove permission source: ' . $source);
559 $this->
logger->debug(
'Remove permission target: ' . $target);
560 $source_obj = $this->rbac_review->getRoleFolderOfRole($source);
561 $this->rbacadmin->copyRolePermissionSubtract(
565 $this->rbac_review->getRoleFolderOfRole($target)
572 protected function doCopyRole(
int $source,
int $target): void
574 $target_obj = $this->rbac_review->getRoleFolderOfRole($target);
575 $source_obj = $this->rbac_review->getRoleFolderOfRole($source);
577 $this->rbacadmin->copyRoleTemplatePermissions(
591 int $a_operation_mode,
595 $this->
logger->warning(
'Missing parameter start object.');
600 $target_ref_id = $this->rbac_review->getRoleFolderOfRole($a_target_role);
601 if ($this->rbac_review->isProtected($target_ref_id, $a_target_role)) {
606 $operation_stack = [];
608 $operation_stack[] = $this->rbac_review->getAllOperationsOfRole($a_source_role, $this->ref_id);
610 $this->
logger->debug(
'Current operation stack');
614 $role->changeExistingObjects(
631 $table->resetOffset();
632 $table->writeFilterToSession();
644 $table->resetOffset();
645 $table->resetFilter();
657 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
658 $this->
ctrl->redirect($this,
'view');
661 $question = $this->
lng->txt(
'rbac_role_delete_qst');
664 $confirm->setHeaderText($question);
665 $confirm->setFormAction($this->
ctrl->getFormAction($this));
666 $confirm->setHeaderText($this->
lng->txt(
"info_delete_sure"));
667 $confirm->setConfirm($this->
lng->txt(
'delete'),
'deleteRole');
668 $confirm->setCancel($this->
lng->txt(
'cancel'),
'cancel');
670 foreach ($roles as $role_id) {
677 $this->tpl->setContent($confirm->getHTML());
685 if (!$this->rbac_system->checkAccess(
'delete', $this->object->getRefId())) {
686 $this->error->raiseError(
687 $this->
lng->txt(
'msg_no_perm_delete'),
688 $this->error->MESSAGE
696 if ($obj->getType() ==
"role") {
697 $rolf_arr = $this->rbac_review->getFoldersAssignedToRole($obj->getId(),
true);
698 $obj->setParent($rolf_arr[0]);
705 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_deleted_roles_rolts"),
true);
706 $this->
ctrl->redirect($this,
'view');
718 $this->tabs_gui->addTarget(
720 $this->
ctrl->getLinkTarget($this,
"view"),
725 $this->tabs_gui->addTarget(
727 $this->
ctrl->getLinkTarget($this,
"editSettings"),
734 $this->tabs_gui->addTarget(
736 $this->
ctrl->getLinkTargetByClass(
737 [get_class($this),
'ilpermissiongui'],
748 if ($a_form ===
null) {
752 $this->tpl->setContent($a_form->getHTML());
759 $user = $DIC->user();
762 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
766 if ($form->checkInput()) {
768 $privacy->enableRbacLog((
bool) $form->getInput(
'rbac_log'));
769 $privacy->setRbacLogAge((
int) $form->getInput(
'rbac_log_age'));
774 $security->protectedAdminRole((
bool) $form->getInput(
'admin_role'));
777 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"settings_saved"),
true);
778 $this->
ctrl->redirect($this,
"editSettings");
781 $form->setValuesByPost();
789 $user = $DIC->user();
791 $this->
lng->loadLanguageModule(
'ps');
797 $form->setFormAction($this->
ctrl->getFormAction($this,
"saveSettings"));
798 $form->setTitle($this->
lng->txt(
'settings'));
803 $admin->setInfo($this->
lng->txt(
'adm_adm_role_protect_info'));
804 $admin->setChecked($security->isAdminRoleProtected());
805 $admin->setValue((
string) 1);
806 $form->addItem($admin);
809 $check->setInfo($this->
lng->txt(
'rbac_log_info'));
810 $check->setChecked($privacy->enabledRbacLog());
814 $age->
setInfo($this->
lng->txt(
'rbac_log_age_info'));
815 $age->setValue((
string) $privacy->getRbacLogAge());
816 $age->setMinValue(1);
817 $age->setMaxValue(24);
819 $age->setMaxLength(2);
822 $form->addCommandButton(
'saveSettings', $this->
lng->txt(
'save'));
829 switch ($a_form_id) {
834 $fields = [
'adm_adm_role_protect' => [$security->isAdminRoleProtected(),
839 return [[
"editSettings", $fields]];
846 if ($privacy->enabledRbacLog()) {
847 $subitems = [
'rbac_log_age' => $privacy->getRbacLogAge()];
849 $fields = [
'rbac_log' => [$privacy->enabledRbacLog(),
855 return [[
"editSettings", $fields]];
static get(string $a_var)
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)
editSettingsObject(?ilPropertyFormGUI $a_form=null)
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
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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.