From 0b915bf90ca616f8310c9046ca13007d74829863 Mon Sep 17 00:00:00 2001 From: Stephan Kergomard Date: Fri, 9 Aug 2024 13:19:07 +0200 Subject: [PATCH] RBAC: Fix Deleteion Confirmation Modal --- .../classes/class.ilObjRoleGUI.php | 27 ++++++++++--------- .../tpl.rbac_template_permissions.html | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/components/ILIAS/AccessControl/classes/class.ilObjRoleGUI.php b/components/ILIAS/AccessControl/classes/class.ilObjRoleGUI.php index c4b1cb96d73c..91ac2f12d722 100755 --- a/components/ILIAS/AccessControl/classes/class.ilObjRoleGUI.php +++ b/components/ILIAS/AccessControl/classes/class.ilObjRoleGUI.php @@ -448,8 +448,14 @@ protected function permObject(bool $a_show_admin_permissions = false): void $this->tabs_gui->setSubTabActive('rbac_repository_permissions'); } - $additional_content = ''; - if ($this->object->getId() != SYSTEM_ROLE_ID) { + $this->tpl->addBlockFile( + 'ADM_CONTENT', + 'adm_content', + 'tpl.rbac_template_permissions.html', + 'components/ILIAS/AccessControl' + ); + + if ($this->object->getId() !== SYSTEM_ROLE_ID) { $this->toolbar->setFormAction($this->ctrl->getFormAction($this)); $this->toolbar->addComponent( $this->ui_factory->link()->standard( @@ -465,17 +471,10 @@ protected function permObject(bool $a_show_admin_permissions = false): void $modal->getShowSignal() ) ); - $additional_content = $this->ui_renderer->render($modal); + $this->tpl->setVariable('DELETION_MODAL', $this->ui_renderer->render($modal)); } } - $this->tpl->addBlockFile( - 'ADM_CONTENT', - 'adm_content', - 'tpl.rbac_template_permissions.html', - 'components/ILIAS/AccessControl' - ); - $this->tpl->setVariable('PERM_ACTION', $this->ctrl->getFormAction($this)); $acc = new ilAccordionGUI(); @@ -524,7 +523,7 @@ protected function permObject(bool $a_show_admin_permissions = false): void } $options->parse(); - $this->tpl->setVariable('OPTIONS_TABLE', $options->getHTML() . $additional_content); + $this->tpl->setVariable('OPTIONS_TABLE', $options->getHTML()); } protected function adminPermObject(): void @@ -1316,9 +1315,13 @@ protected function ensureRoleAccessForContext(): bool private function buildConfirmationModal(): InterruptiveModal { + $message = $this->lng->txt('rbac_role_delete_qst'); + if ($this->rbac_review->isAssigned($this->user->getId(), $this->object->getId())) { + $message .= ('
' . $this->lng->txt('rbac_role_delete_self')); + } return $this->ui_factory->modal()->interruptive( $this->lng->txt('confirm'), - $this->lng->txt('rbac_role_delete_self'), + $message, $this->ctrl->getFormActionByClass(self::class, 'performDeleteRole') )->withAffectedItems([ $this->ui_factory->modal()->interruptiveItem()->standard( diff --git a/components/ILIAS/AccessControl/templates/default/tpl.rbac_template_permissions.html b/components/ILIAS/AccessControl/templates/default/tpl.rbac_template_permissions.html index 0177731c2f0a..485526f70918 100755 --- a/components/ILIAS/AccessControl/templates/default/tpl.rbac_template_permissions.html +++ b/components/ILIAS/AccessControl/templates/default/tpl.rbac_template_permissions.html @@ -3,3 +3,4 @@
{OPTIONS_TABLE} +{DELETION_MODAL}