From 8e01ef1e63de06abc04b9685f9f588362a528925 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 14 Feb 2023 11:29:35 +0100 Subject: [PATCH] wait #5397 @0.75 --- app/Fluidbook/Packager/Packager.php | 2 +- .../FluidbookPublication/DownloadOperation.php | 10 ++++++---- .../fluidbook_publication/download.blade.php | 13 +++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/Fluidbook/Packager/Packager.php b/app/Fluidbook/Packager/Packager.php index f298d5a58..e8bfd1b93 100644 --- a/app/Fluidbook/Packager/Packager.php +++ b/app/Fluidbook/Packager/Packager.php @@ -195,7 +195,7 @@ class Packager extends \App\Jobs\Base if ($ext != '') { $res .= '.' . $ext; } - return url('fluidbook-publication/' . $this->book_id . '/download/' . $res); + return url('fluidbook-publication/' . $this->book_id . '_' . $this->book->hash . '/download/' . $res); } protected function escapeTitle() diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php index f7f2da6d2..cba35d8d0 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Admin\Operations\FluidbookPublication; use App\Fluidbook\Packager\Download; +use App\Http\Middleware\CheckIfAdmin; use App\Models\FluidbookPublication; use Cubist\Backpack\Http\Controllers\Base\XSendFileController; use Illuminate\Support\Facades\Route; @@ -14,7 +15,7 @@ trait DownloadOperation { Route::match(['get'], $segment . '/{id}/delivery', $controller . '@delivery'); Route::match(['get'], $segment . '/{id}/package/{action}/{version}', $controller . '@package'); - Route::match(['get'], $segment . '/{id}/download/{file}', $controller . '@download'); + Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@download')->withoutMiddleware([CheckIfAdmin::class]);; } protected function setupDownloadDefaults() @@ -29,14 +30,15 @@ trait DownloadOperation } } - protected function download($id, $file) + protected function download($id, $hash, $file) { $e = explode('-', $file); if ($e[1] != $id) { abort(404, __('Erreur de correspondance du fichier')); } - if (!FluidbookPublication::hasPermission($id)) { - abort(401, __('Ce fichier ne peut pas être téléchargée')); + $fluidbook = FluidbookPublication::where('id', $id)->where('hash', $hash)->first(); + if (null === $fluidbook) { + abort(404, __('Ce fichier est indisponible')); } $path = protected_path('fluidbookpublication/packager/download/' . $file); if (!file_exists($path)) { diff --git a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php index 852bc5e52..3fef46eb5 100644 --- a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php @@ -21,11 +21,13 @@ } } if(can('fluibook-publication:download:install-hosting') && ($entry->install_online || $entry->scorm_enable)){ - $actions['sep_install']='---------'; - if($entry->install_online && $entry->install_online->server){ + + $installActions['sep_install']='---------'; + if($entry->install_online && $entry->install_online->server && isset($servers[$entry->install_online->server])){ + $server=$servers[$entry->install_online->server]; if($entry->install_online->path || $server['allows_root']){ - $actions['install_online']=[ + $installActions['install_online']=[ 'label'=>__('Installer sur le serveur :server',['server'=>''.$server['name'].'']).' '.$server['base_url'].''.$entry->install_online->path.'', 'url'=> $basePackage.'/install/online', ]; @@ -33,10 +35,13 @@ } if($entry->scorm_enable){ - $actions['scormcloud']=['label'=>__('Tester sur SCORM Cloud'), + $installActions['scormcloud']=['label'=>__('Tester sur SCORM Cloud'), 'url'=> $basePackage.'/scormcloud/scorm' ]; } + if(count($installActions)>1){ + $actions=array_merge($actions,$installActions); + } } @endphp -- 2.39.5