From 02a4d4bae03e85a528af22f10c995b948bc3026b Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Wed, 22 Nov 2023 08:37:55 +1100 Subject: [PATCH] Add read-only state for submission detail pages for editors to view submission detail --- src/controllers/SubmissionsController.php | 12 ++++++ src/templates/submissions/_edit.html | 46 ++++++++++++----------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/controllers/SubmissionsController.php b/src/controllers/SubmissionsController.php index cb1cdb1..7e958c5 100644 --- a/src/controllers/SubmissionsController.php +++ b/src/controllers/SubmissionsController.php @@ -24,6 +24,9 @@ public function actionEdit(?Submission $submission, ?int $submissionId = null): { $this->requireCpRequest(); + $settings = Workflow::$plugin->getSettings(); + $currentUser = Craft::$app->getUser()->getIdentity(); + if ($submission === null) { $submission = Submission::find()->id($submissionId)->siteId('*')->one(); @@ -32,9 +35,18 @@ public function actionEdit(?Submission $submission, ?int $submissionId = null): } } + $canEdit = true; + $editorGroup = $settings->getEditorUserGroup($submission->site); + + if ($editorGroup && $currentUser && $currentUser->isInGroup($editorGroup)) { + $canEdit = false; + } + $variables = [ 'submission' => $submission, 'title' => $submission->title, + 'settings' => $settings, + 'canEdit' => $canEdit, ]; $variables['changesCount'] = Workflow::$plugin->getContent()->getContentChangesTotalCount($submission); diff --git a/src/templates/submissions/_edit.html b/src/templates/submissions/_edit.html index fe7cc24..d6fb79d 100644 --- a/src/templates/submissions/_edit.html +++ b/src/templates/submissions/_edit.html @@ -9,7 +9,7 @@ ] %} {% set isNew = submission.id ? false : true %} -{% set fullPageForm = true %} +{% set fullPageForm = canEdit %} {% set saveShortcutRedirect = '{cpEditUrl}' %} {% set numberReviews = 0 %} @@ -28,30 +28,32 @@ {% block actionButton %} -
-
- - - - +{% endif %} {% endblock %} @@ -112,7 +114,9 @@
  • {{ 'Compare' | t('app') }}
  • {% endif %} -
  • {{ 'Delete' | t('app') }}
  • + {% if canEdit %} +
  • {{ 'Delete' | t('app') }}
  • + {% endif %}