]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5397 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 14 Feb 2023 10:29:35 +0000 (11:29 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 14 Feb 2023 10:29:35 +0000 (11:29 +0100)
app/Fluidbook/Packager/Packager.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php

index f298d5a585b5534b33c331215f79ac4c44b20739..e8bfd1b933ab1434d27aaf47494ef05a83b1c344 100644 (file)
@@ -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()
index f7f2da6d29686ae7ccd1d554b79c5db09b3c9d07..cba35d8d0b5066b023bd06246e2cd59ade228982 100644 (file)
@@ -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)) {
index 852bc5e52e766627422ab64a00170df7f6cc951d..3fef46eb55fe567528553b110588547dd8a4422d 100644 (file)
         }
     }
     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'=>'<strong>'.$server['name'].'</strong>']).' <span class="small"><span class="grey">'.$server['base_url'].'</span>'.$entry->install_online->path.'</span>',
                     'url'=> $basePackage.'/install/online',
                     ];
         }
 
         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