From: Vincent Vanwaelscappel Date: Tue, 21 Nov 2023 17:13:02 +0000 (+0100) Subject: wait #6501 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=71b4b6233a6019b2700b368c221c3aecf526036a;p=fluidbook-toolbox.git wait #6501 @1.5 --- diff --git a/app/Fluidbook/Compiler/Accessibility.php b/app/Fluidbook/Compiler/Accessibility.php index a5ab4183d..9dec14be5 100644 --- a/app/Fluidbook/Compiler/Accessibility.php +++ b/app/Fluidbook/Compiler/Accessibility.php @@ -67,7 +67,7 @@ trait Accessibility $hash = hash('sha256', $engine . ':' . $voice . '_^_' . $text); $fname = $hash . '.mp3'; - $dir = Files::mkdir(protected_path('audiodescription')); + $dir = Files::mkdir($this->getFluidbook()->protected_path('audiodescription')); $file = $dir . $fname; diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index 806e8da6f..a2eb7b09f 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -290,11 +290,10 @@ class Compiler extends Base implements CompilerInterface function __construct(FluidbookPublication $book, $scormVariant = false, $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, FluidbookTheme $theme = null, $hybrid = false, Command $command = null) { - ExcelToArray::setCache(protected_path('fluidbookpublication/cache/exceltoarray')); + ExcelToArray::setCache($book->protected_path('fluidbookpublication/cache/exceltoarray')); parent::__construct(); - $this->setFluidbook($book); $this->setCommand($command); @@ -1596,7 +1595,7 @@ class Compiler extends Base implements CompilerInterface public function getCacheDir($path): string { - return Files::mkdir(protected_path('fluidbookpublication/cache/' . $path)); + return Files::mkdir($this->getFluidbook()->protected_path('fluidbookpublication/cache/' . $path)); } @@ -2335,7 +2334,7 @@ class Compiler extends Base implements CompilerInterface $fdir = is_null($baseDir) ? 'data/links/' . str_replace('.', '_', $file) : $baseDir; $zipPath = $this->wdir . '/' . $file; - $dir = protected_path('fluidbookpublication/cache/unzip') . '/' . Files::hashFileAttributes($zipPath) . '_' . ($moveAssets ? '1' : '0') . '_' . ($junkPaths ? '1' : '0'); + $dir = $this->getFluidbook()->protected_path('fluidbookpublication/cache/unzip') . '/' . Files::hashFileAttributes($zipPath) . '_' . ($moveAssets ? '1' : '0') . '_' . ($junkPaths ? '1' : '0'); if (!file_exists($dir)) { Files::mkdir($dir); diff --git a/app/Fluidbook/Compiler/Search.php b/app/Fluidbook/Compiler/Search.php index 996613754..f6dd7d102 100644 --- a/app/Fluidbook/Compiler/Search.php +++ b/app/Fluidbook/Compiler/Search.php @@ -21,7 +21,7 @@ trait Search $doIndex = $this->fluidbookSettings->search_mode !== 'robust'; - $cacheDir = Files::mkdir(protected_path('fluidbookpublication/index/' . $this->book_id . '/' . $cache . '/')); + $cacheDir = Files::mkdir($this->getFluidbook()->protected_path('fluidbookpublication/index/' . $this->book_id . '/' . $cache . '/')); if ($doIndex) { $indexFile = $cacheDir . '/search.index.js'; } diff --git a/app/Fluidbook/PDF.php b/app/Fluidbook/PDF.php index 0b0a752b1..a9f8a6159 100644 --- a/app/Fluidbook/PDF.php +++ b/app/Fluidbook/PDF.php @@ -23,7 +23,7 @@ class PDF return false; } - $cacheDir = Files::mkdir(protected_path('fluidbookpublication/pdf/' . $fluidbook->id)); + $cacheDir = Files::mkdir($fluidbook->protected_path('fluidbookpublication/pdf/' . $fluidbook->id)); $normalPDF = $cacheDir . 'normal.pdf'; $originalPDF = $cacheDir . 'original.pdf'; diff --git a/app/Fluidbook/Packager/Download.php b/app/Fluidbook/Packager/Download.php index c9b1ef2c1..683a52ad8 100644 --- a/app/Fluidbook/Packager/Download.php +++ b/app/Fluidbook/Packager/Download.php @@ -139,7 +139,7 @@ class Download extends DownloadBase $res[] = $url; } else if ($this->action === 'loadbalancer') { $path = $this->_compileandpackage(false); - $dest = protected_path('fluidbookpublication/loadbalancer/' . $this->entry->id . '_' . $this->entry->hash . '/'); + $dest = $this->entry->protected_path('fluidbookpublication/loadbalancer/' . $this->entry->id . '_' . $this->entry->hash . '/'); $rsync = new Rsync($path, $dest, true); $rsync->execute(); diff --git a/app/Fluidbook/Packager/Packager.php b/app/Fluidbook/Packager/Packager.php index 6549e42ee..304807549 100644 --- a/app/Fluidbook/Packager/Packager.php +++ b/app/Fluidbook/Packager/Packager.php @@ -156,7 +156,7 @@ class Packager extends \App\Jobs\Base protected function packager_path($path = '') { - return protected_path('fluidbookpublication/packager/' . ltrim($path, '/')); + return $this->book->protected_path('fluidbookpublication/packager/' . ltrim($path, '/')); } diff --git a/app/Fluidbook/Packager/WindowsZIP.php b/app/Fluidbook/Packager/WindowsZIP.php index bb40508a1..138304797 100644 --- a/app/Fluidbook/Packager/WindowsZIP.php +++ b/app/Fluidbook/Packager/WindowsZIP.php @@ -136,7 +136,7 @@ class WindowsZIP extends Packager { $rand = 'sign-' . hash_file('sha256', $source) . '.exe'; $remote = 'C:/Sign/' . $rand; - $local = protected_path('signedexe/' . $rand); + $local = $this->book->protected_path('signedexe/' . $rand); if (!file_exists($local)) { $ssh = new SSH2('paris.cubedesigners.com', 'vince', 'Y@mUC9mY2DOYWXkN', '22422'); $ssh->send($source, $remote); diff --git a/app/Models/FluidbookDocument.php b/app/Models/FluidbookDocument.php index e3a257a71..b9cdac7c2 100644 --- a/app/Models/FluidbookDocument.php +++ b/app/Models/FluidbookDocument.php @@ -215,11 +215,9 @@ class FluidbookDocument extends ToolboxModel } } - $res = rtrim(self::WS_DOCS . $this->id . ($path ? DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR) : $path), DIRECTORY_SEPARATOR); - if (!$path) { - $res .= DIRECTORY_SEPARATOR; - } - $res = Files::mkdir($res); + $base = 'fluidbookpublication/docs'; + $res = Files::mkdir($this->region == 'UE' ? protected_path($base) : us_protected_path($base)); + if ($fname) { $res .= $fname; } diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 910718b51..03d73cf0b 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -527,6 +527,15 @@ class FluidbookPublication extends ToolboxStatusModel return (float)$this->getDocumentSize($page)[1]; } + public function protected_path($path) + { + if ($this->region === 'UE') { + return protected_path($path); + } else { + return us_protected_path($path); + } + } + public function getFinalPath($theme = null, $scormVariant = false) { $dir = $this->id; @@ -540,18 +549,18 @@ class FluidbookPublication extends ToolboxStatusModel if (null !== $theme && ($themeId != $this->theme)) { $dir .= '-' . $themeId; } - return protected_path('fluidbookpublication/final/' . $dir . '/' . ($scormVariant ? 'scorm' : 'online')); + return $this->protected_path('fluidbookpublication/final/' . $dir . '/' . ($scormVariant ? 'scorm' : 'online')); } public function getAssetDir() { - return Files::mkdir(protected_path('fluidbookpublication/working/' . $this->getAssetDirId())); + return Files::mkdir($this->protected_path('fluidbookpublication/working/' . $this->getAssetDirId())); } public function getPDFDir() { - return Files::mkdir(protected_path('fluidbookpublication/pdf/' . $this->id)); + return Files::mkdir($this->protected_path('fluidbookpublication/pdf/' . $this->id)); } public function asset_path($path) @@ -902,7 +911,7 @@ class FluidbookPublication extends ToolboxStatusModel return $res; } - ExcelToArray::setCache(protected_path('fluidbookpublication/cache/exceltoarray')); + ExcelToArray::setCache($this->protected_path('fluidbookpublication/cache/exceltoarray')); $contents = ExcelToArray::excelToArrayFirstSheet($file); foreach ($contents as $row) { @@ -1028,7 +1037,7 @@ class FluidbookPublication extends ToolboxStatusModel public function getPDFArchivesPath() { - return Files::mkdir(protected_path('fluidbookpublication/pdf/' . $this->id)); + return Files::mkdir($this->protected_path('fluidbookpublication/pdf/' . $this->id)); } public function getPDFArchivesList() @@ -1053,4 +1062,11 @@ class FluidbookPublication extends ToolboxStatusModel { return parent::allowsPreview() && $this->getPagesNumber() > 0; } + + public static function getProtectedPath($id, $path) + { + return cache()->tags([FluidbookPublication::class])->rememberForever("fluidbook_protectedpath_" . $id . '_' . $path, function () use ($id, $path) { + return FluidbookPublication::withoutGlobalScopes()->find($id)->protected_path($id); + }); + } } diff --git a/app/helpers.php b/app/helpers.php index 6d99ebcfa..0336658b2 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -10,3 +10,18 @@ if (!function_exists('dddd')) { return call_user_func_array('dd', func_get_args()); } } + + +if (!function_exists('us_path')) { + function us_path($path = '') + { + return base_path('/usstorage/' . $path); + } +} + +if (!function_exists('us_protected_path')) { + function us_protected_path($path) + { + return us_path('/protected/' . $path); + } +}