From 1088f56a92912b97992d297c90287a7d0909fc41 Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Wed, 22 Nov 2023 08:31:59 +1100 Subject: [PATCH] =?UTF-8?q?The=20Workflow=20control=20panel=20menu=20item?= =?UTF-8?q?=20now=20will=20only=20show=20if=20the=20user=20has=20=E2=80=9C?= =?UTF-8?q?Overview=E2=80=9D=20permission?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Workflow.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Workflow.php b/src/Workflow.php index 6e38c25..f556327 100644 --- a/src/Workflow.php +++ b/src/Workflow.php @@ -41,7 +41,6 @@ class Workflow extends Plugin // Properties // ========================================================================= - public bool $hasCpSection = true; public bool $hasCpSettings = true; public string $schemaVersion = '2.5.0'; public string $minVersionRequired = '1.7.0'; @@ -73,6 +72,13 @@ public function init(): void if (Craft::$app->getRequest()->getIsCpRequest()) { $this->_registerCpRoutes(); $this->_registerWidgets(); + + // Only show the menu item if user has permission to overview + if ($currentUser = Craft::$app->getUser()->getIdentity()) { + if ($currentUser->can('workflow-overview')) { + $this->hasCpSection = true; + } + } } if (Craft::$app->getRequest()->getIsConsoleRequest()) {