]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6247 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Sep 2023 17:52:17 +0000 (19:52 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Sep 2023 17:52:17 +0000 (19:52 +0200)
app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php

index 50171a2efadc2d919445439db8491e00e7d8c3d6..21db71aac31f58a78e0e5a3207e1c1265ba9fd04 100644 (file)
@@ -33,7 +33,11 @@ trait DownloadOperation
         if (!FluidbookPublication::hasPermission($id, 'read')) {
             abort(401);
         }
-        return view('fluidbook_publication.delivery.index', ['fluidbook' => FluidbookPublication::where('id', $id)->first()]);
+        $fluidbook = FluidbookPublication::withoutGlobalScopes()->where('id', $id)->first();
+        if ($fluidbook->getPagesNumber() === 0) {
+            abort(404, __('Cette publication ne comporte aucune page'));
+        }
+        return view('fluidbook_publication.delivery.index', ['fluidbook' => $fluidbook]);
     }
 
     protected function deliveryThumb($id, $type)
@@ -66,6 +70,9 @@ trait DownloadOperation
         if (null === $fluidbook) {
             abort(404, __('Ce fichier est indisponible'));
         }
+        if ($fluidbook->getPagesNumber() === 0) {
+            abort(404, __('Cette publication ne comporte aucune page'));
+        }
         $path = protected_path('fluidbookpublication/packager/download/' . $file);
         if (!file_exists($path)) {
             abort(404, __('Le fichier n\'existe pas'));
@@ -90,6 +97,10 @@ trait DownloadOperation
             abort(401, __('Cette version n\'est pas disponible au tĂ©lĂ©chargement'));
         }
 
+        if ($fluidbook->getPagesNumber() === 0) {
+            abort(404, __('Cette publication ne comporte aucune page'));
+        }
+
         // Mark the fluidbook as downloaded when status is ready and user is not an admin
         if ($fluidbook->status == 1 && !can('fluidbook-publication:admin')) {
             $fluidbook->status = 2;
index 0dfa1ab661656249305272e3c43e12d9cfe43289..912605331c0e8a709d73958b37576136769786e7 100644 (file)
@@ -67,7 +67,7 @@
 
 @endphp
 
-@if($entry->allowsDownload())
+@if($entry->getPagesNumber()>0 && $entry->allowsDownload())
 
     <a class="btn btn-sm btn-link" href="#"
        data-toggle="tooltip"