From 9107e8f9864a3cf9a63bae897cb86fb227cecef5 Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Tue, 12 Jul 2022 18:40:36 +0200 Subject: [PATCH 1/9] Add pdf export for user-audit refs #4862 --- application/controllers/RoleController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index a1b0730df0..5129e03d68 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -18,6 +18,7 @@ use Icinga\Web\Controller\AuthBackendController; use Icinga\Web\View\PrivilegeAudit; use Icinga\Web\Widget\SingleValueSearchControl; +use Icinga\Web\Widget\Tabextension\OutputFormat; use ipl\Html\Html; use ipl\Html\HtmlString; use ipl\Web\Url; @@ -143,6 +144,7 @@ public function removeAction() public function auditAction() { + $this->getTabs()->extend(new OutputFormat(["csv","json"])); $this->assertPermission('config/access-control/roles'); $this->createListTabs()->activate('role/audit'); $this->view->title = t('Audit'); @@ -244,11 +246,13 @@ public function auditAction() ] )); - $this->addControl($header); - $this->addContent( + $wrapper = Html::tag('div'); + $wrapper->addHtml($header); + $wrapper->addHtml( (new PrivilegeAudit($chosenRole !== null ? [$chosenRole] : $assignedRoles)) - ->addAttributes(['id' => 'role-audit']) - ); + ->addAttributes(['id' => 'role-audit'])); + + $this->addContent($wrapper); } public function suggestRoleMemberAction() From 31f845a1a94f6ac2b9a7714fe08e0aa2085aedff Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Tue, 12 Jul 2022 19:24:56 +0200 Subject: [PATCH 2/9] Fix PSR2 issues --- application/controllers/RoleController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index 5129e03d68..fc9065fa09 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -250,7 +250,8 @@ public function auditAction() $wrapper->addHtml($header); $wrapper->addHtml( (new PrivilegeAudit($chosenRole !== null ? [$chosenRole] : $assignedRoles)) - ->addAttributes(['id' => 'role-audit'])); + ->addAttributes(['id' => 'role-audit']) + ); $this->addContent($wrapper); } From b25b8ad87c3e15ca12feb12911e5008a4328bbd5 Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Wed, 13 Jul 2022 10:03:46 +0200 Subject: [PATCH 3/9] Fix Space after comma in array --- application/controllers/RoleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index fc9065fa09..0f59e1c386 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -144,7 +144,7 @@ public function removeAction() public function auditAction() { - $this->getTabs()->extend(new OutputFormat(["csv","json"])); + $this->getTabs()->extend(new OutputFormat(["csv", "json"])); $this->assertPermission('config/access-control/roles'); $this->createListTabs()->activate('role/audit'); $this->view->title = t('Audit'); From 481117d2f3f968e6bfb00c3350ccab6f9abf8eb8 Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Wed, 13 Jul 2022 10:20:52 +0200 Subject: [PATCH 4/9] Fix Added header text as title --- application/controllers/RoleController.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index 0f59e1c386..abd6753ffc 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -144,7 +144,7 @@ public function removeAction() public function auditAction() { - $this->getTabs()->extend(new OutputFormat(["csv", "json"])); + $this->getTabs()->extend(new OutputFormat(["csv","json"])); $this->assertPermission('config/access-control/roles'); $this->createListTabs()->activate('role/audit'); $this->view->title = t('Audit'); @@ -194,13 +194,13 @@ public function auditAction() } if ($type === 'user') { - $header = Html::tag('h2', sprintf(t('Privilege Audit for User "%s"'), $name)); + $title = sprintf(t('Privilege Audit for User "%s"'), $name); $user = new User($name); $user->setAdditional('backend_name', $backend); Auth::getInstance()->setupUser($user); } else { - $header = Html::tag('h2', sprintf(t('Privilege Audit for Group "%s"'), $name)); + $title = sprintf(t('Privilege Audit for Group "%s"'), $name); $user = new User((string) time()); $user->setGroups([$name]); @@ -246,14 +246,13 @@ public function auditAction() ] )); - $wrapper = Html::tag('div'); - $wrapper->addHtml($header); - $wrapper->addHtml( - (new PrivilegeAudit($chosenRole !== null ? [$chosenRole] : $assignedRoles)) - ->addAttributes(['id' => 'role-audit']) - ); + $this->view->title = $title; - $this->addContent($wrapper); + $header = Html::tag('h2', $title); + $this->addControl($header); + $this->addContent( + (new PrivilegeAudit($chosenRole !== null ? [$chosenRole] : $assignedRoles)) + ->addAttributes(['id' => 'role-audit'])); } public function suggestRoleMemberAction() From 6a88eae821ec928261ed0b48a5d697fc65ba68b0 Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Wed, 13 Jul 2022 10:26:06 +0200 Subject: [PATCH 5/9] Fix codestyle issues --- application/controllers/RoleController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index abd6753ffc..f093c9418c 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -252,7 +252,8 @@ public function auditAction() $this->addControl($header); $this->addContent( (new PrivilegeAudit($chosenRole !== null ? [$chosenRole] : $assignedRoles)) - ->addAttributes(['id' => 'role-audit'])); + ->addAttributes(['id' => 'role-audit']) + ); } public function suggestRoleMemberAction() From 7e8b7522898e36c972c960555a19ae42dcbf4068 Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Thu, 14 Jul 2022 10:14:13 +0200 Subject: [PATCH 6/9] Fix Space after comma in array Co-authored-by: Johannes Meyer --- application/controllers/RoleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index f093c9418c..9e1df20efb 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -144,7 +144,7 @@ public function removeAction() public function auditAction() { - $this->getTabs()->extend(new OutputFormat(["csv","json"])); + $this->getTabs()->extend(new OutputFormat(["csv", "json"])); $this->assertPermission('config/access-control/roles'); $this->createListTabs()->activate('role/audit'); $this->view->title = t('Audit'); From 145e320d43aefdb5f7c43a81332a59465a62063b Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Thu, 14 Jul 2022 10:14:57 +0200 Subject: [PATCH 7/9] Fix Use setTitleFunction Co-authored-by: Johannes Meyer --- application/controllers/RoleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index 9e1df20efb..4531ef43cb 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -246,7 +246,7 @@ public function auditAction() ] )); - $this->view->title = $title; + $this->setTitle($title); $header = Html::tag('h2', $title); $this->addControl($header); From 79b2f0249b385e726f817bc2516c15d7bc8ef3f3 Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Thu, 14 Jul 2022 10:18:38 +0200 Subject: [PATCH 8/9] Fix Codestyle combine two lines --- application/controllers/RoleController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index 4531ef43cb..60dd6c0c45 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -247,9 +247,7 @@ public function auditAction() )); $this->setTitle($title); - - $header = Html::tag('h2', $title); - $this->addControl($header); + $this->addControl(Html::tag('h2', $title); $this->addContent( (new PrivilegeAudit($chosenRole !== null ? [$chosenRole] : $assignedRoles)) ->addAttributes(['id' => 'role-audit']) From b4cabbbbf7628f36d6f9244689ea696b062823e8 Mon Sep 17 00:00:00 2001 From: moreamazingnick Date: Thu, 14 Jul 2022 10:23:34 +0200 Subject: [PATCH 9/9] Fix missing bracket after last commit --- application/controllers/RoleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php index 60dd6c0c45..94a4afaf1c 100644 --- a/application/controllers/RoleController.php +++ b/application/controllers/RoleController.php @@ -247,7 +247,7 @@ public function auditAction() )); $this->setTitle($title); - $this->addControl(Html::tag('h2', $title); + $this->addControl(Html::tag('h2', $title)); $this->addContent( (new PrivilegeAudit($chosenRole !== null ? [$chosenRole] : $assignedRoles)) ->addAttributes(['id' => 'role-audit'])