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(
130 if ($targets === []) {
131 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'rbac_copy_no_targets'),
true);
132 $this->
ctrl->redirect($this,
'roleSearchList');
135 if (count($targets) > 3) {
139 if (count($targets) > 1) {
141 foreach ($targets as $target) {
144 return $target_names .
'</strong>';
153 $this->tabs_gui->activateTab(
'view');
155 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
156 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
159 if ($this->rbac_system->checkAccess(
'create_role', $this->object->getRefId())) {
160 $this->
ctrl->setParameter($this,
'new_type',
'role');
162 $this->ui_factory->link()->standard(
163 $this->
lng->txt(
'rolf_create_role'),
164 $this->
ctrl->getLinkTarget($this,
'create')
168 if ($this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId())) {
169 $this->
ctrl->setParameter($this,
'new_type',
'rolt');
171 $this->ui_factory->link()->standard(
172 $this->
lng->txt(
'rolf_create_rolt'),
173 $this->
ctrl->getLinkTarget($this,
'create')
176 $this->
ctrl->clearParameters($this);
180 $this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId()) ||
181 $this->rbac_system->checkAccess(
'create_rolt', $this->object->getRefId())
184 $this->ui_factory->link()->standard(
185 $this->
lng->txt(
'rbac_import_role'),
186 $this->
ctrl->getLinkTargetByClass(
'ilPermissionGUI',
'displayImportRoleForm')
193 $table->parse($this->
object->getId());
195 $this->tpl->setContent($table->getHTML());
203 $this->tabs_gui->clearTargets();
204 $this->tabs_gui->setBackTarget(
205 $this->
lng->txt(
'rbac_back_to_overview'),
206 $this->
ctrl->getLinkTarget($this,
'view')
209 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
210 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
214 $this->tpl->setOnScreenMessage(
217 $this->
lng->txt(
'rbac_choose_copy_targets'),
223 $this->tpl->setContent($form->getHTML());
232 $form->setTitle($this->
lng->txt(
'rbac_role_title'));
233 $form->setFormAction($this->
ctrl->getFormAction($this,
'view'));
236 $search->setRequired(
true);
237 $search->setSize(30);
238 $search->setMaxLength(255);
239 $form->addItem($search);
241 $form->addCommandButton(
'roleSearchForm', $this->
lng->txt(
'search'));
254 if ($form->checkInput()) {
260 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_search_string'),
true);
261 $form->setValuesByPost();
262 $this->
ctrl->redirect($this,
'roleSearch');
270 $this->tabs_gui->clearTargets();
271 $this->tabs_gui->setBackTarget(
272 $this->
lng->txt(
'rbac_back_to_overview'),
273 $this->
ctrl->getLinkTarget($this,
'view')
279 $this->tpl->setOnScreenMessage(
282 $this->
lng->txt(
'rbac_select_copy_targets'),
290 $table->parse($this->
object->getId());
291 $this->tpl->setContent($table->getHTML());
295 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_search_string'),
true);
296 $this->
ctrl->redirect($this,
'roleSearch');
306 $this->
ctrl->saveParameter($this,
'csource');
307 $this->tabs_gui->clearTargets();
308 $this->tabs_gui->setBackTarget(
309 $this->
lng->txt(
'rbac_back_to_overview'),
310 $this->
ctrl->getLinkTarget($this,
'view')
315 $this->tpl->setContent($form->getHTML());
324 $full_featured =
true;
326 $this->tpl->setOnScreenMessage(
329 $this->
lng->txt(
'rbac_copy_behaviour_info'),
337 $form->setTitle($this->
lng->txt(
'rbac_copy_behaviour'));
338 $form->setFormAction($this->
ctrl->getFormAction($this,
'chooseCopyBehaviour'));
340 $copy_type = new \ilRadioGroupInputGUI(
341 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type'),
344 $copy_type->setRequired(
true);
345 $copy_type->setValue((
string) self::COPY_CLONE_PERMISSIONS);
347 if ($full_featured) {
348 $add = new \ilRadioOption(
349 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_add'),
350 (string) self::COPY_ADD_PERMISSIONS,
351 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_add_info')
353 $copy_type->addOption($add);
355 $ce_type_add = new \ilRadioGroupInputGUI(
359 $ce_type_add->setRequired(
true);
360 $ce_add_yes = new \ilRadioOption(
361 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_yes'),
362 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
363 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_yes_info')
365 $ce_type_add->addOption($ce_add_yes);
366 $ce_add_no = new \ilRadioOption(
367 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_no'),
369 $this->
lng->txt(
'rbac_form_copy_roles_ce_add_no_info')
371 $ce_type_add->addOption($ce_add_no);
372 $add->addSubItem($ce_type_add);
374 $clone = new \ilRadioOption(
375 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_clone'),
376 (string) self::COPY_CLONE_PERMISSIONS,
377 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_clone_info')
379 $copy_type->addOption($clone);
381 $ce_type_clone = new \ilRadioGroupInputGUI(
385 $ce_type_clone->setRequired(
true);
386 $ce_clone_yes = new \ilRadioOption(
387 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_yes'),
388 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
389 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_yes_info')
391 $ce_type_clone->addOption($ce_clone_yes);
392 $ce_clone_no = new \ilRadioOption(
393 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_no'),
395 $this->
lng->txt(
'rbac_form_copy_roles_ce_clone_no_info')
397 $ce_type_clone->addOption($ce_clone_no);
398 $clone->addSubItem($ce_type_clone);
400 if ($full_featured) {
401 $remove = new \ilRadioOption(
402 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_remove'),
403 (string) self::COPY_REMOVE_PERMISSIONS,
404 $this->
lng->txt(
'rbac_form_copy_roles_adjust_type_remove_info')
406 $copy_type->addOption($remove);
407 $ce_type_remove = new \ilRadioGroupInputGUI(
411 $ce_type_remove->setRequired(
true);
412 $ce_remove_yes = new \ilRadioOption(
413 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_yes'),
414 (string) self::COPY_CHANGE_EXISTING_OBJECTS,
415 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_yes_info')
417 $ce_type_remove->addOption($ce_remove_yes);
418 $ce_remove_no = new \ilRadioOption(
419 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_no'),
421 $this->
lng->txt(
'rbac_form_copy_roles_ce_remove_no_info')
423 $ce_type_remove->addOption($ce_remove_no);
424 $remove->addSubItem($ce_type_remove);
427 $form->addItem($copy_type);
431 $form->addItem($roles);
433 $form->addCommandButton(
'roleSearchList', $this->
lng->txt(
'back'));
434 $form->addCommandButton(
'adjustRole', $this->
lng->txt(
'rbac_form_copy_roles_adjust_button'));
449 if (!$form->checkInput()) {
450 $form->setValuesByPost();
455 $adjustment_type = $form->getInput(
'type');
456 foreach ((array) $roles as $role_id) {
457 if ($role_id !== $source) {
458 $start_obj = $this->rbac_review->getRoleFolderOfRole($role_id);
459 $this->
logger->debug(
'Start object: ' . $start_obj);
461 switch ($adjustment_type) {
462 case self::COPY_ADD_PERMISSIONS:
463 $change_existing = (bool) $form->getInput(
'add_ce_type');
468 if ($change_existing) {
477 case self::COPY_CLONE_PERMISSIONS:
478 $change_existing = (bool) $form->getInput(
'clone_ce_type');
483 if ($change_existing) {
492 case self::COPY_REMOVE_PERMISSIONS:
493 $change_existing = (bool) $form->getInput(
'remove_ce_type');
498 if ($change_existing) {
510 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_copy_finished'),
true);
511 $this->
ctrl->redirect($this,
'view');
520 $source_definition = $this->rbac_review->getRoleFolderOfRole($source);
521 $this->rbacadmin->copyRolePermissionUnion(
525 $this->rbac_review->getRoleFolderOfRole($target),
527 $this->rbac_review->getRoleFolderOfRole($target)
541 if ($form->checkInput()) {
542 foreach ((array) $roles as $role_id) {
543 if ($role_id !== $source) {
547 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'rbac_copy_finished'),
true);
548 $this->
ctrl->redirect($this,
'view');
557 $this->
logger->debug(
'Remove permission source: ' . $source);
558 $this->
logger->debug(
'Remove permission target: ' . $target);
559 $source_obj = $this->rbac_review->getRoleFolderOfRole($source);
560 $this->rbacadmin->copyRolePermissionSubtract(
564 $this->rbac_review->getRoleFolderOfRole($target)
571 protected function doCopyRole(
int $source,
int $target): void
573 $target_obj = $this->rbac_review->getRoleFolderOfRole($target);
574 $source_obj = $this->rbac_review->getRoleFolderOfRole($source);
576 $this->rbacadmin->copyRoleTemplatePermissions(
590 int $a_operation_mode,
594 $this->
logger->warning(
'Missing parameter start object.');
599 $target_ref_id = $this->rbac_review->getRoleFolderOfRole($a_target_role);
600 if ($this->rbac_review->isProtected($target_ref_id, $a_target_role)) {
605 $operation_stack = [];
607 $operation_stack[] = $this->rbac_review->getAllOperationsOfRole($a_source_role, $this->ref_id);
609 $this->
logger->debug(
'Current operation stack');
613 $role->changeExistingObjects(
630 $table->resetOffset();
631 $table->writeFilterToSession();
643 $table->resetOffset();
644 $table->resetFilter();
656 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
657 $this->
ctrl->redirect($this,
'view');
660 $question = $this->
lng->txt(
'rbac_role_delete_qst');
663 $confirm->setHeaderText($question);
664 $confirm->setFormAction($this->
ctrl->getFormAction($this));
665 $confirm->setHeaderText($this->
lng->txt(
"info_delete_sure"));
666 $confirm->setConfirm($this->
lng->txt(
'delete'),
'deleteRole');
667 $confirm->setCancel($this->
lng->txt(
'cancel'),
'cancel');
669 foreach ($roles as $role_id) {
676 $this->tpl->setContent($confirm->getHTML());
684 if (!$this->rbac_system->checkAccess(
'delete', $this->object->getRefId())) {
685 $this->error->raiseError(
686 $this->
lng->txt(
'msg_no_perm_delete'),
687 $this->error->MESSAGE
695 if ($obj->getType() ==
"role") {
696 $rolf_arr = $this->rbac_review->getFoldersAssignedToRole($obj->getId(),
true);
697 $obj->setParent($rolf_arr[0]);
704 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_deleted_roles_rolts"),
true);
705 $this->
ctrl->redirect($this,
'view');
717 $this->tabs_gui->addTarget(
719 $this->
ctrl->getLinkTarget($this,
"view"),
724 $this->tabs_gui->addTarget(
726 $this->
ctrl->getLinkTarget($this,
"editSettings"),
733 $this->tabs_gui->addTarget(
735 $this->
ctrl->getLinkTargetByClass(
736 [get_class($this),
'ilpermissiongui'],
747 if ($a_form === null) {
751 $this->tpl->setContent($a_form->getHTML());
758 $user = $DIC->user();
761 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
765 if ($form->checkInput()) {
767 $privacy->enableRbacLog((
bool) $form->getInput(
'rbac_log'));
768 $privacy->setRbacLogAge((
int) $form->getInput(
'rbac_log_age'));
773 $security->protectedAdminRole((
bool) $form->getInput(
'admin_role'));
776 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"settings_saved"),
true);
777 $this->
ctrl->redirect($this,
"editSettings");
780 $form->setValuesByPost();
788 $user = $DIC->user();
790 $this->
lng->loadLanguageModule(
'ps');
796 $form->setFormAction($this->
ctrl->getFormAction($this,
"saveSettings"));
797 $form->setTitle($this->
lng->txt(
'settings'));
802 $admin->setInfo($this->
lng->txt(
'adm_adm_role_protect_info'));
803 $admin->setChecked($security->isAdminRoleProtected());
804 $admin->setValue((
string) 1);
805 $form->addItem($admin);
807 $check =
new ilCheckboxInputGui($this->
lng->txt(
'rbac_log'),
'rbac_log');
808 $check->setInfo($this->
lng->txt(
'rbac_log_info'));
809 $check->setChecked($privacy->enabledRbacLog());
813 $age->setInfo($this->
lng->txt(
'rbac_log_age_info'));
814 $age->setValue((
string) $privacy->getRbacLogAge());
815 $age->setMinValue(1);
816 $age->setMaxValue(24);
818 $age->setMaxLength(2);
821 $form->addCommandButton(
'saveSettings', $this->
lng->txt(
'save'));
828 switch ($a_form_id) {
833 $fields = [
'adm_adm_role_protect' => [$security->isAdminRoleProtected(),
838 return [[
"editSettings", $fields]];
845 if ($privacy->enabledRbacLog()) {
846 $subitems = [
'rbac_log_age' => $privacy->getRbacLogAge()];
848 $fields = [
'rbac_log' => [$privacy->enabledRbacLog(),
854 return [[
"editSettings", $fields]];
Interface GlobalHttpState.
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
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
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
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.