From 157d9e4ebbe8a7bbbbfed5b94469867232d337fe Mon Sep 17 00:00:00 2001 From: Tetrachloromethane250 <79449630+Tetrachloromethane250@users.noreply.github.com> Date: Tue, 6 Apr 2021 05:51:47 +0100 Subject: [PATCH] Added #5977: Add permission to view files attached to licenses (#9264) * Add permission to view and modify files for licenses * Actually use the permission --- app/Policies/LicensePolicy.php | 10 ++++++++++ config/permissions.php | 6 ++++++ resources/views/licenses/view.blade.php | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/app/Policies/LicensePolicy.php b/app/Policies/LicensePolicy.php index 0fc097e4d8..9d1ec815c6 100644 --- a/app/Policies/LicensePolicy.php +++ b/app/Policies/LicensePolicy.php @@ -35,4 +35,14 @@ class LicensePolicy extends CheckoutablePermissionsPolicy return false; } + /** + * Determine whether the user can access files associated with licenses. + * + * @param \App\Models\User $user + * @return mixed + */ + public function files(User $user) + { + return $user->hasAccess($this->columnName().'.files'); + } } diff --git a/config/permissions.php b/config/permissions.php index a17857161e..0176dc13ba 100644 --- a/config/permissions.php +++ b/config/permissions.php @@ -218,6 +218,12 @@ return array( 'note' => '', 'display' => true, ), + array( + 'permission' => 'licenses.files', + 'label' => 'View and Modify License Files', + 'note' => '', + 'display' => true, + ), ), diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php index 80de54d956..96b426d3dd 100755 --- a/resources/views/licenses/view.blade.php +++ b/resources/views/licenses/view.blade.php @@ -31,7 +31,9 @@
@@ -364,6 +366,7 @@ + @can('files', $license)