]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7868 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 27 Feb 2026 14:49:11 +0000 (15:49 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 27 Feb 2026 14:49:11 +0000 (15:49 +0100)
.docker/fluidbook-workshop/html/.htaccess
app/Console/Commands/HemsleyEnableLinkShortener.php [new file with mode: 0644]
app/Http/Controllers/Admin/Operations/FluidbookCollection/AuditLinksOperation.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php
app/Jobs/AuditLinkRegister.php

index bfc83ca5eb0e01985bf5ea37ecf8db780e4d5feb..8e28dcf44fa5ee10c567ee022327710fb215d93d 100644 (file)
@@ -5,6 +5,7 @@ Options +FollowSymlinks
        RewriteBase /
 
     RewriteRule ^viewerh/(.+)$ https://toolbox.fluidbook.com/fluidbook-publication/preview/$1 [R=308,L]
+    RewriteRule ^viewer/(.+)$ https://toolbox.fluidbook.com/fluidbook-publication/preview/$1 [R=308,L]
     RewriteRule ^viewers/(.+)$ https://toolbox.fluidbook.com/fluidbook-publication/preview/scorm/$1 [R=308,L]
 
     RewriteRule ^publications$ https://toolbox.fluidbook.com/fluidbook-publication/ [R=308,L]
diff --git a/app/Console/Commands/HemsleyEnableLinkShortener.php b/app/Console/Commands/HemsleyEnableLinkShortener.php
new file mode 100644 (file)
index 0000000..d98cb4b
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Jobs\AuditLinkRegister;
+use App\Models\FluidbookPublication;
+use Illuminate\Console\Command;
+
+class HemsleyEnableLinkShortener extends Command
+{
+    protected $signature = 'hemsleyfraser:enablelinkshortener';
+
+    public function handle()
+    {
+        /** @var FluidbookPublication[] $fluidbooks */
+        $fluidbooks = \App\Models\FluidbookPublication::where('invoicable_company', 1880)->orderBy('id', 'ASC')->get();
+        foreach ($fluidbooks as $fb) {
+            $fb->linkShortener = 3;
+            $fb->saveQuietly();
+        }
+
+        AuditLinkRegister::dispatchSync();
+    }
+}
index 60e64c1e1b47fa98af154a2ae1bc97c54fe89d78..0ca3755bb61e64edce988b51860f3469eae3ce08 100644 (file)
@@ -269,6 +269,7 @@ trait AuditLinksOperation
             500 => __('There is a problem on the server. This should be temporary'),
             502 => __('There is a problem on the server. This should be temporary'),
             503 => __('There is a problem on the server. This should be temporary'),
+            601 => __('There was too many redirection. This could be due a redirection infinite loop'),
             628 => __('The auditing tool was blocked by CloudFlare DDOS Protection. Please check manually'),
             603 => __('The auditing tool was blocked by CloudFlare DDOS Protection. Please check manually'),
             695 => __('There is a problem with the SSL certificate. The auditing tool could not check if the URL is valid or not. Please check manually'),
index 40e897d5387c2ebe0f327e6992ddb9f815d1e333..a5b39066a3406945fdb09f569cd015dcdc56f7eb 100644 (file)
@@ -28,7 +28,9 @@ trait DownloadOperation
 
     protected function setupDownloadDefaults()
     {
-        $this->crud->addButtonFromView('line', 'download', 'fluidbook_publication.download', 'end');
+        if (backpack_user() !== null && backpack_user()->company != 1880) {
+            $this->crud->addButtonFromView('line', 'download', 'fluidbook_publication.download', 'end');
+        }
     }
 
     protected function delivery($id)
index eaa1adafb7aca7a2382b1b436f90234cfd0366c3..941ca5c850fad88be627979376118722850b6716 100644 (file)
@@ -6,6 +6,7 @@ use App\Fluidbook\Link\LinksData;
 use App\Models\FluidbookAuditLink;
 use App\Models\FluidbookPublication;
 use App\Models\FluidbookCollection;
+use App\Models\LinkShortener;
 use App\Models\ShortLink;
 use Fluidbook\Tools\Links\Link as LinkAlias;
 use Illuminate\Support\Arr;
@@ -28,11 +29,14 @@ class AuditLinkRegister extends Base
             $publications = array_merge($publications, $collection->getFluidbooksID());
         }
 
+        $linkShortenerPublications = [];
+
         // Add fluidbooks that have enabled linkShortener
         foreach (DB::table('fluidbook_publication')->get() as $p) {
             $s = json_decode($p->settings);
             if (isset($s->linkShortener) && $s->linkShortener && $s->linkShortener !== 'none') {
                 $publications[] = $p->id;
+                $linkShortenerPublications[$p->id] = $s->linkShortener;
             }
         }
 
@@ -64,6 +68,8 @@ class AuditLinkRegister extends Base
                 return (preg_match('/^https?:\/\//', trim($n['to']))) || $n['type'] == LinkAlias::WEBVIDEO;
             });
 
+            $ls = $linkShortenerPublications[$publication] ?? false;
+
             foreach ($links as $link) {
                 $seen[] = $publication . '_' . $link['uid'];
                 $link['to'] = trim($link['to']);
@@ -73,6 +79,10 @@ class AuditLinkRegister extends Base
                     }
                 }
 
+                if ($ls) {
+                    LinkShortener::shorturl($link['to'], $ls);
+                }
+
                 if (isset($existing[$publication . '_' . $link['uid']])) {
                     $l = $existing[$publication . '_' . $link['uid']];
                     if ($l['url'] == $link['to'] && $l['page'] == $link['page']) {