]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5397 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 16 Jan 2023 17:58:49 +0000 (18:58 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 16 Jan 2023 17:58:49 +0000 (18:58 +0100)
15 files changed:
app/Console/Commands/FluidbookPackage.php
app/Fluidbook/Packager/Base.php [deleted file]
app/Fluidbook/Packager/Download.php [new file with mode: 0644]
app/Fluidbook/Packager/Online.php
app/Fluidbook/Packager/Packager.php [new file with mode: 0644]
app/Fluidbook/Packager/USBKey.php
app/Fluidbook/Packager/WindowsZIP.php
app/Http/Controllers/Admin/CrudController.php
app/Http/Controllers/Admin/FluidbookPublicationCrudController.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php
app/Http/Controllers/Admin/TeamLeaveCrudController.php
app/Http/Controllers/Admin/UsersCrudController.php
public/packages/fluidbook/toolbox/js/contextdownload.js
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php
routes/backpack/custom.php

index 135a5f637263d73253905a23a01d94807c6e7849..441631da3e2cc593578b38fa3ec14aab96031dd0 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace App\Console\Commands;
 
-use App\Fluidbook\Packager\Base;
+use App\Fluidbook\Packager\Packager;
 use Cubist\Backpack\Console\Commands\CubistCommand;
 
 class FluidbookPackage extends CubistCommand
@@ -15,7 +15,7 @@ class FluidbookPackage extends CubistCommand
      */
     public function handle()
     {
-        $packager = Base::package($this->argument('id'), $this->argument('type'), $this->option('zip', false));
+        $packager = Packager::package($this->argument('id'), $this->argument('type'), $this->option('zip', false));
         $packager->handle();
     }
 }
diff --git a/app/Fluidbook/Packager/Base.php b/app/Fluidbook/Packager/Base.php
deleted file mode 100644 (file)
index cc0e68b..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-<?php
-
-namespace App\Fluidbook\Packager;
-
-use App\Jobs\FluidbookCompiler;
-use App\Models\FluidbookPublication;
-use App\Models\FluidbookTheme;
-use Cubist\Util\CommandLine;
-use Cubist\Util\Files\Files;
-use Cubist\Util\PHP;
-use Cubist\Util\Text;
-use Exception;
-
-class Base extends \App\Jobs\Base
-{
-
-    protected $dir;
-    protected $vdir;
-
-    /**
-     * @var FluidbookPublication
-     */
-    public $book;
-    /** @var FluidbookTheme */
-    protected $theme;
-    protected $scormVariant = false;
-    protected $book_id;
-    protected $themeRoot;
-    protected $zip;
-    protected $workingDir;
-    protected $_clean = true;
-    /**
-     * @var int
-     */
-    protected $_time = 0;
-    protected $_compileOnConstruct = false;
-    public $cleanOnDestruct = true;
-
-    public $zipPackage = true;
-
-    public $downloadExt='zip';
-
-
-    public static function package($book_id, $type, $zipPackage = true, $cleanOnDestruct = true, $options = [])
-    {
-        $type = str_replace('-', '_', $type);
-        switch ($type) {
-            case 'html':
-            case 'online':
-                $packager = new Online($book_id, null, $options);
-                break;
-            case 'scorm':
-                $packager = new SCORM($book_id, null, $options);
-                break;
-            case 'sharepoint':
-                $packager = new Sharepoint($book_id, null, $options);
-                break;
-            case 'win_html':
-                $packager = new OfflineHTML($book_id, null, $options);
-                break;
-            case 'win_exe_html':
-            case 'win_zip':
-                $packager = new WindowsZIP($book_id, null, $options);
-                break;
-            case 'mac_exe_html':
-            case 'mac_exe':
-                $packager = new MacOS($book_id, null, $options);
-                break;
-            case 'win_ins_html':
-            case 'win_ins':
-                $packager = new WindowsInstaller($book_id, null, $options);
-                break;
-            case 'win_inss_html':
-            case 'win_inss':
-            case 'win_exe':
-                $packager = new WindowsEXE($book_id, null, $options);
-                break;
-            case 'win_cd_html':
-            case 'usbkey':
-                $packager = new USBKey($book_id, null, $options);
-                break;
-            case 'precompiled':
-                $packager = new Precompiled($book_id, null, $options);
-                break;
-            case 'chromeos':
-                $packager = new ChromeOS($book_id, null, $options);
-                break;
-            default:
-                throw new Exception('Package type ' . $type . ' not exists');
-        }
-        $packager->cleanOnDestruct = $packager->cleanOnDestruct && $cleanOnDestruct;
-        $packager->zipPackage = $zipPackage;
-
-        return $packager;
-    }
-
-
-    public function __construct($book_id, $vdir = null, $options = [])
-    {
-
-        $this->_time = time();
-        $this->_clean = (null === $vdir);
-
-        $this->book_id = $book_id;
-
-        $this->vdir = $vdir;
-        $this->dir = Files::mkdir($this->packager_path('/' . $book_id));
-
-        $this->book = FluidbookPublication::find($book_id);
-        $forceCompile = false;
-        if (count($options)) {
-            $options['forceCompileOnDownload'] = true;
-        }
-        foreach ($options as $k => $v) {
-            $this->book->getSettings()->set($k, $v);
-        }
-
-        $this->theme = $this->book->getTheme();
-
-        $this->workingDir = $this->book->getAssetDir();
-
-        if ($this->_compileOnConstruct) {
-            $this->compile($forceCompile);
-        }
-    }
-
-    public function handle()
-    {
-        PHP::neverStop();
-        $this->makePackage($this->zipPackage);
-    }
-
-    protected function packager_path($path = '')
-    {
-        return protected_path('fluidbookpublication/packager/' . ltrim($path, '/'));
-    }
-
-
-    protected function resource_path($path)
-    {
-        return resource_path('fluidbookpublication/packager/' . ltrim($path, '/'));
-    }
-
-    /**
-     * @throws Exception
-     */
-    protected function compile($forceCompile = false)
-    {
-        $compiler = new FluidbookCompiler($this->book, $this->scormVariant);
-        $compiler->handle();
-    }
-
-    protected function preparePackage()
-    {
-        $this->initTempDir();
-    }
-
-    public function makePackage($zip)
-    {
-        return $this->preparePackage();
-    }
-
-    protected function replaceContents($str, $toReplace)
-    {
-        $res = $str;
-        foreach ($toReplace as $k => $v) {
-            if (is_null($v)) {
-                return;
-            }
-            $res = str_replace('$' . $k, $v, $res);
-        }
-        return $res;
-    }
-
-
-    protected function getBaseFile()
-    {
-        return $this->type . '-' . date('Ymdhis', $this->_time) . '-' . $this->escapeTitle();
-    }
-
-    protected function getDownloadURL($ext = '')
-    {
-        $res = '/download/' . $this->getBaseFile();
-        if ($ext != '') {
-            $res .= '.' . $ext;
-        }
-        return url('packager' . $res);
-    }
-
-    protected function escapeTitle()
-    {
-        $res = Text::str2URL($this->book->title);
-        if ($res == '') {
-            $res = 'fluidbook';
-        }
-        return $res;
-    }
-
-
-    protected function getPathBase($ext = '')
-    {
-        $res = '/download/' . $this->getBaseFile();
-        if ($ext != '') {
-            $res .= '.' . $ext;
-        }
-
-        return $this->packager_path($res);
-    }
-
-    protected function zip($zipfile = null)
-    {
-        Files::mkdir($this->packager_path('download'));
-        $final = $this->getPathBase('zip');
-        $rename = false;
-        if (is_null($zipfile)) {
-            $zipfile = $final;
-        } else {
-            $rename = true;
-        }
-
-        $dir = $this->getFinalPackageDir();
-        if (file_exists($dir)) {
-            $zip = new CommandLine('zip');
-            $zip->cd($dir);
-            $zip->setArg(null, $zipfile);
-            $zip->setArg('symlinks');
-            $zip->setArg('0');
-            $zip->setArg('r');
-            $zip->setArg('u');
-            $zip->setArg(null, '.');
-            $zip->setManualArg('-x "*/\.*"');
-            $zip->execute();
-        }
-
-        if ($rename) {
-            rename($zipfile, $final);
-        }
-        return $final;
-    }
-
-    public function getFinalPackageDir()
-    {
-        return $this->vdir;
-    }
-
-    protected function initTempDir()
-    {
-        if (is_null($this->vdir)) {
-            $this->vdir = $this->dir . $this->type . '/';
-        }
-    }
-
-
-    protected function postPackage()
-    {
-
-    }
-
-    public function copy($source, $dest)
-    {
-        if (!file_exists($source)) {
-            return;
-        }
-        copy($source, $dest);
-        touch($dest, filemtime($source));
-    }
-
-    /**
-     * @throws Exception
-     */
-    protected function _compileFluidbook($book, $dest = null, $hybrid = false)
-    {
-        if (null === $dest) {
-            $dest = $this->vdir;
-        }
-
-        $compiler = new FluidbookCompiler($book, $this->scormVariant, false, "latest", null, false, false, false, null, $hybrid);
-        $compiler->handle();
-
-        $rsync = new CommandLine\Rsync(rtrim($compiler->getFinalPath(), '/'), $dest, true);
-        $rsync->execute();
-
-        $htmlFiles = array('index');
-        $filesToDelete = [];
-
-        foreach ($htmlFiles as $name) {
-            $html = $book->getSettings()->get('htmlPrepend') . file_get_contents($dest . $name . '.html');
-            file_put_contents($dest . '/' . $name . '.' . $this->_ext, $html);
-            if ($this->_ext != 'html') {
-                $filesToDelete[] = $name . '.html';
-            }
-        }
-
-        $rm = new CommandLine('rm');
-        foreach ($filesToDelete as $f) {
-            $rm->setArg(null, $dest . '/' . $f);
-        }
-        $rm->execute();
-
-        if ($this->_ext !== 'html') {
-            $e = $this->_ext;
-            `find $dest -type f -name "*.html" -exec rename 's/\.html$/.$e/' '{}' \;`;
-        }
-    }
-}
diff --git a/app/Fluidbook/Packager/Download.php b/app/Fluidbook/Packager/Download.php
new file mode 100644 (file)
index 0000000..c5d6d2e
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+
+namespace App\Fluidbook\Packager;
+
+use App\Jobs\DownloadBase;
+use App\Services\ScormCloud;
+use Cubist\Util\Files\Files;
+
+class Download extends DownloadBase
+{
+
+    protected $version = 'online';
+
+    protected $type = 'Fluidbook';
+    // __('Fluidbppl ":title" (#:nb) prêt au téléchargement')
+    protected $_subject = 'Fluidbook ":title" (#:nb) prêt au téléchargement';
+
+    public function __construct($entry, $version, $action, $user)
+    {
+        parent::__construct($entry, $action, $user);
+        $this->setVersion($version);
+    }
+
+    /**
+     * @return string
+     */
+    public function getVersion(): string
+    {
+        return $this->version;
+    }
+
+    /**
+     * @param string $version
+     */
+    public function setVersion(string $version): void
+    {
+        $this->version = $version;
+    }
+
+    protected function _dest($fname)
+    {
+        return Files::mkdir(storage_path('app/public/' . $this->type . '/download/')) . $fname;
+    }
+
+    protected function _url($fname)
+    {
+        return url('storage/' . $this->type . '/download/' . $fname);
+    }
+
+    protected function _title()
+    {
+        return $this->entry->title;
+    }
+
+    protected function _compile()
+    {
+
+    }
+
+    public function handle()
+    {
+        try {
+            $url = $this->_compileandpackage();
+            $subject = __($this->_subject, ['title' => $this->_title(), 'nb' => $this->_id()]);
+            $text = '';
+            $actions = ['Télécharger' => $url];
+
+            if ($this->action === 'scormcloud') {
+                try {
+                    $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->_id());
+                    $actions[__('Tester sur SCORM Cloud')] = $scormURL;
+                } catch (\Exception $e) {
+
+                }
+                $text = __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID')]);
+            }
+        } catch (\Exception $e) {
+            $subject = __('Erreur lors de la compilation du :type :nb', ['nb' => $this->_id(), 'type' => $this->type]);
+            $text = __('Détails de l\'erreur :message', ['message' => $e->getMessage() . ' at line ' . $e->getLine() . ' of ' . $e->getFile()]);
+            $actions = [];
+        }
+
+        $this->sendNotification($subject, $text, $actions);
+    }
+
+    protected function _compileandpackage()
+    {
+        if($this->action==='download' || $this->action===''){
+            $zip=true;
+        }
+        Packager::package($this->entry->id, $this->version);
+    }
+}
index 7d5c61e11fa45b029dea99ddec4a98c2d60fc585..57b7b59a3f188b4f8fa74a7383b3a969c6968700 100644 (file)
@@ -6,7 +6,7 @@ use App\Jobs\FluidbookCompiler;
 use App\Models\FluidbookPublication;
 use Cubist\Util\CommandLine;
 
-class Online extends Base
+class Online extends Packager
 {
     protected $origHTML;
     protected $_labels = array();
diff --git a/app/Fluidbook/Packager/Packager.php b/app/Fluidbook/Packager/Packager.php
new file mode 100644 (file)
index 0000000..a351fc5
--- /dev/null
@@ -0,0 +1,305 @@
+<?php
+
+namespace App\Fluidbook\Packager;
+
+use App\Jobs\FluidbookCompiler;
+use App\Models\FluidbookPublication;
+use App\Models\FluidbookTheme;
+use Cubist\Util\CommandLine;
+use Cubist\Util\Files\Files;
+use Cubist\Util\PHP;
+use Cubist\Util\Text;
+use Exception;
+
+class Packager extends \App\Jobs\Base
+{
+
+    protected $dir;
+    protected $vdir;
+
+    /**
+     * @var FluidbookPublication
+     */
+    public $book;
+    /** @var FluidbookTheme */
+    protected $theme;
+    protected $scormVariant = false;
+    protected $book_id;
+    protected $themeRoot;
+    protected $zip;
+    protected $workingDir;
+    protected $_clean = true;
+    /**
+     * @var int
+     */
+    protected $_time = 0;
+    protected $_compileOnConstruct = false;
+    public $cleanOnDestruct = true;
+
+    public $zipPackage = true;
+
+    public $downloadExt='zip';
+
+
+    public static function package($book_id, $type, $zipPackage = true, $cleanOnDestruct = true, $options = [])
+    {
+        $type = str_replace('-', '_', $type);
+        switch ($type) {
+            case 'html':
+            case 'online':
+                $packager = new Online($book_id, null, $options);
+                break;
+            case 'scorm':
+                $packager = new SCORM($book_id, null, $options);
+                break;
+            case 'sharepoint':
+                $packager = new Sharepoint($book_id, null, $options);
+                break;
+            case 'win_html':
+                $packager = new OfflineHTML($book_id, null, $options);
+                break;
+            case 'win_exe_html':
+            case 'win_zip':
+                $packager = new WindowsZIP($book_id, null, $options);
+                break;
+            case 'mac_exe_html':
+            case 'mac_exe':
+                $packager = new MacOS($book_id, null, $options);
+                break;
+            case 'win_ins_html':
+            case 'win_ins':
+                $packager = new WindowsInstaller($book_id, null, $options);
+                break;
+            case 'win_inss_html':
+            case 'win_inss':
+            case 'win_exe':
+                $packager = new WindowsEXE($book_id, null, $options);
+                break;
+            case 'win_cd_html':
+            case 'usbkey':
+                $packager = new USBKey($book_id, null, $options);
+                break;
+            case 'precompiled':
+                $packager = new Precompiled($book_id, null, $options);
+                break;
+            case 'chromeos':
+                $packager = new ChromeOS($book_id, null, $options);
+                break;
+            default:
+                throw new Exception('Package type ' . $type . ' not exists');
+        }
+        $packager->cleanOnDestruct = $packager->cleanOnDestruct && $cleanOnDestruct;
+        $packager->zipPackage = $zipPackage;
+
+        return $packager;
+    }
+
+
+    public function __construct($book_id, $vdir = null, $options = [])
+    {
+
+        $this->_time = time();
+        $this->_clean = (null === $vdir);
+
+        $this->book_id = $book_id;
+
+        $this->vdir = $vdir;
+        $this->dir = Files::mkdir($this->packager_path('/' . $book_id));
+
+        $this->book = FluidbookPublication::find($book_id);
+        $forceCompile = false;
+        if (count($options)) {
+            $options['forceCompileOnDownload'] = true;
+        }
+        foreach ($options as $k => $v) {
+            $this->book->getSettings()->set($k, $v);
+        }
+
+        $this->theme = $this->book->getTheme();
+
+        $this->workingDir = $this->book->getAssetDir();
+
+        if ($this->_compileOnConstruct) {
+            $this->compile($forceCompile);
+        }
+    }
+
+    public function handle()
+    {
+        PHP::neverStop();
+        $this->makePackage($this->zipPackage);
+    }
+
+    protected function packager_path($path = '')
+    {
+        return protected_path('fluidbookpublication/packager/' . ltrim($path, '/'));
+    }
+
+
+    protected function resource_path($path)
+    {
+        return resource_path('fluidbookpublication/packager/' . ltrim($path, '/'));
+    }
+
+    /**
+     * @throws Exception
+     */
+    protected function compile($forceCompile = false)
+    {
+        $compiler = new FluidbookCompiler($this->book, $this->scormVariant);
+        $compiler->handle();
+    }
+
+    protected function preparePackage()
+    {
+        $this->initTempDir();
+    }
+
+    public function makePackage($zip)
+    {
+        return $this->preparePackage();
+    }
+
+    protected function replaceContents($str, $toReplace)
+    {
+        $res = $str;
+        foreach ($toReplace as $k => $v) {
+            if (is_null($v)) {
+                return;
+            }
+            $res = str_replace('$' . $k, $v, $res);
+        }
+        return $res;
+    }
+
+
+    protected function getBaseFile()
+    {
+        return $this->type . '-' . date('Ymdhis', $this->_time) . '-' . $this->escapeTitle();
+    }
+
+    protected function getDownloadURL($ext = '')
+    {
+        $res = '/download/' . $this->getBaseFile();
+        if ($ext != '') {
+            $res .= '.' . $ext;
+        }
+        return url('packager' . $res);
+    }
+
+    protected function escapeTitle()
+    {
+        $res = Text::str2URL($this->book->title);
+        if ($res == '') {
+            $res = 'fluidbook';
+        }
+        return $res;
+    }
+
+
+    protected function getPathBase($ext = '')
+    {
+        $res = '/download/' . $this->getBaseFile();
+        if ($ext != '') {
+            $res .= '.' . $ext;
+        }
+
+        return $this->packager_path($res);
+    }
+
+    protected function zip($zipfile = null)
+    {
+        Files::mkdir($this->packager_path('download'));
+        $final = $this->getPathBase('zip');
+        $rename = false;
+        if (is_null($zipfile)) {
+            $zipfile = $final;
+        } else {
+            $rename = true;
+        }
+
+        $dir = $this->getFinalPackageDir();
+        if (file_exists($dir)) {
+            $zip = new CommandLine('zip');
+            $zip->cd($dir);
+            $zip->setArg(null, $zipfile);
+            $zip->setArg('symlinks');
+            $zip->setArg('0');
+            $zip->setArg('r');
+            $zip->setArg('u');
+            $zip->setArg(null, '.');
+            $zip->setManualArg('-x "*/\.*"');
+            $zip->execute();
+        }
+
+        if ($rename) {
+            rename($zipfile, $final);
+        }
+        return $final;
+    }
+
+    public function getFinalPackageDir()
+    {
+        return $this->vdir;
+    }
+
+    protected function initTempDir()
+    {
+        if (is_null($this->vdir)) {
+            $this->vdir = $this->dir . $this->type . '/';
+        }
+    }
+
+
+    protected function postPackage()
+    {
+
+    }
+
+    public function copy($source, $dest)
+    {
+        if (!file_exists($source)) {
+            return;
+        }
+        copy($source, $dest);
+        touch($dest, filemtime($source));
+    }
+
+    /**
+     * @throws Exception
+     */
+    protected function _compileFluidbook($book, $dest = null, $hybrid = false)
+    {
+        if (null === $dest) {
+            $dest = $this->vdir;
+        }
+
+        $compiler = new FluidbookCompiler($book, $this->scormVariant, false, "latest", null, false, false, false, null, $hybrid);
+        $compiler->handle();
+
+        $rsync = new CommandLine\Rsync(rtrim($compiler->getFinalPath(), '/'), $dest, true);
+        $rsync->execute();
+
+        $htmlFiles = array('index');
+        $filesToDelete = [];
+
+        foreach ($htmlFiles as $name) {
+            $html = $book->getSettings()->get('htmlPrepend') . file_get_contents($dest . $name . '.html');
+            file_put_contents($dest . '/' . $name . '.' . $this->_ext, $html);
+            if ($this->_ext != 'html') {
+                $filesToDelete[] = $name . '.html';
+            }
+        }
+
+        $rm = new CommandLine('rm');
+        foreach ($filesToDelete as $f) {
+            $rm->setArg(null, $dest . '/' . $f);
+        }
+        $rm->execute();
+
+        if ($this->_ext !== 'html') {
+            $e = $this->_ext;
+            `find $dest -type f -name "*.html" -exec rename 's/\.html$/.$e/' '{}' \;`;
+        }
+    }
+}
index 91082f9495b444677ad3ae07cc2c1d51bd716253..78e855e10b2589a4e84321c8897bca500dc442dd 100644 (file)
@@ -10,7 +10,7 @@ class USBKey extends MacOS
                $this->replaceAutorun();
 
                // Package mac app
-               $win = ROOT . Base::package($this->book_id, 'win_inss_html', false, false);
+               $win = ROOT . Packager::package($this->book_id, 'win_inss_html', false, false);
 
                $dest = $this->getFinalPackageDir() . "/" . $this->exeName . '.exe';
                $cp = "cp $win $dest";
index 386a9d5b49edf267840fd7c2b5263c87f65dc9e4..512fdd332f784fbccad3278a722b28fc1c7ba2c4 100644 (file)
@@ -7,7 +7,7 @@ use Cubist\Util\CommandLine;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Text;
 
-class WindowsZIP extends Base
+class WindowsZIP extends Packager
 {
     protected $exeName;
     protected $appName;
index 560a9461f494d9a41e18dc8d16e10f35e24f32b9..bed63b7f768215171fc3636192d59f88ecb15db3 100644 (file)
@@ -19,7 +19,7 @@ class CrudController extends \Cubist\Backpack\Magic\Controllers\CubistMagicContr
     /*
        */
 
-    protected $_modelNamespace = 'App\Models\Base\ToolboxSettingsModel';
+    protected $_modelNamespace = 'App\Models\Base\ToolboxHRModel';
     protected $_routeURL = '';
     protected $_singular = '';
     protected $_plural = '';
index 70fe82f9bf9819770d4271167f16e25bfac43ff5..0520381fb05c9739043e830f000e76aeb302c544 100644 (file)
@@ -4,17 +4,16 @@ namespace App\Http\Controllers\Admin;
 
 class FluidbookPublicationCrudController extends \Cubist\Backpack\Magic\Controllers\CubistMagicController
 {
-    use \Cubist\Backpack\Magic\Operations\CreateOperation;
-       use \Cubist\Backpack\Http\Controllers\Operations\CloneEditOperation;
-       use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
-       use \Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
-       use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
+    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
        use \Cubist\Backpack\Http\Controllers\Operations\ReviseOperation;
+       use \Cubist\Backpack\Magic\Operations\CreateOperation;
        use \App\Http\Controllers\Admin\Operations\FluidbookPublication\PreviewOperation;
        use \App\Http\Controllers\Admin\Operations\FluidbookPublication\EditOperation;
        use \App\Http\Controllers\Admin\Operations\FluidbookPublication\CompositionOperation;
        use \App\Http\Controllers\Admin\Operations\FluidbookPublication\StatsOperation;
        use \App\Http\Controllers\Admin\Operations\FluidbookPublication\DownloadOperation;
+       use \Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
+       use \App\Http\Controllers\Admin\Operations\FluidbookPublication\DeletefbOperation;
        
 
 
index 1b9ea01a8ef30bd0ea14bb0d51bd3abc604d517f..d95eeb8131669d385167a134d2cd53ec7b23c1b2 100644 (file)
@@ -2,8 +2,8 @@
 
 namespace App\Http\Controllers\Admin\Operations\FluidbookPublication;
 
-use App\Jobs\ElearningPackageDownload;
-use App\Models\ELearningPackage;
+use App\Fluidbook\Packager\Download;
+use App\Models\FluidbookPublication;
 use Illuminate\Support\Facades\Route;
 use Prologue\Alerts\Facades\Alert;
 
@@ -11,7 +11,8 @@ trait DownloadOperation
 {
     protected function setupDownloadRoutes($segment, $routeName, $controller)
     {
-        Route::match(['get'], $segment . '/delivery/{id}_{hash}', $controller . '@delivery');
+        Route::match(['get'], $segment . '/{id}/delivery', $controller . '@delivery');
+        Route::match(['get'], $segment . '/{id}/{action}/{version}', $controller . '@download');
     }
 
     protected function setupDownloadDefaults()
@@ -19,8 +20,31 @@ trait DownloadOperation
         $this->crud->addButtonFromView('line', 'download', 'fluidbook_publication.download', 'end');
     }
 
-    protected function delivery($id, $hash)
+    protected function delivery($id)
     {
+        if (!FluidbookPublication::hasPermission($id)) {
+            abort(401);
+        }
+    }
+
+    /**
+     * @throws \Exception
+     */
+    protected function download($id, $action, $version)
+    {
+        if (!in_array($action, ['download', 'install_hosting', 'install_ftp', 'scormcloud'])) {
+            abort(404, __('Cette action n\'est pas disponible'));
+        }
+        if (!FluidbookPublication::hasPermission($id)) {
+            abort(401, __('Cette publication ne peut pas être téléchargée'));
+        }
+        $fluidbook = FluidbookPublication::find($id);
+        if (!$fluidbook->{'download_' . $version} && !can('fluidbook-publication:download:all-versions')) {
+            abort(401, __('Cette version n\'est pas disponible au téléchargement'));
+        }
 
+        Download::dispatch($fluidbook, $version, $action, backpack_user())->onQueue('download');;
+        Alert::add('success', __('La compilation a été placée en file d\'attente. Vous recevrez un email lorsqu\'elle sera terminée.'))->flash();
+        return redirect(backpack_url('fluidbook-publication'));
     }
 }
index ef983bd132cb2debd15dca61facbffb41a03713c..1ea8207f29a717c24d4f1af67b4f36c5e8e797e8 100644 (file)
@@ -11,6 +11,7 @@ class TeamLeaveCrudController extends \Cubist\Backpack\Magic\Controllers\CubistM
        use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
        use \Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
        use \Cubist\Backpack\Http\Controllers\Operations\ReviseOperation;
+       use \App\Http\Controllers\Admin\Operations\TeamLeave\ICSOperation;
        
 
 
index c32f5f1a10aea0f089ded802399fa1c1b324c58d..63ffb0d9f625957d96ac06be18f8ccdd3b96d120 100644 (file)
@@ -18,7 +18,7 @@ class UsersCrudController extends \Cubist\Backpack\Magic\Controllers\CubistMagic
        __('utilisateurs')
        */
 
-    protected $_modelNamespace = 'App\Models\AuthUser';
+    protected $_modelNamespace = 'App\Models\CubedesignersTeamMember';
     protected $_routeURL = 'users';
     protected $_singular = 'utilisateur';
     protected $_plural = 'utilisateurs';
index 0c3f32b3f440833e6cdae1a64b0716ced5c468b2..e030de7090dde88bd6fd36fce04802a9f8c56193 100644 (file)
@@ -9,21 +9,27 @@ $(function () {
 
             var actions = {};
             $.each(rawActions, function (key, action) {
-                if (typeof action === 'string') {
-                    action = {'label': action};
-                }
-                if (action.url === undefined) {
-                    action.url = route;
-                }
-                action.url = replaceVariables(action.url, key);
-                if (action.target === undefined) {
-                    action.target = '_self';
+                if (action != '---------') {
+                    if (typeof action === 'string') {
+                        action = {'label': action};
+                    }
+                    if (action.url === undefined) {
+                        action.url = route;
+                    }
+                    action.url = replaceVariables(action.url, key);
+                    if (action.target === undefined) {
+                        action.target = '_self';
+                    }
                 }
                 actions[key] = action;
             });
 
             $.each(actions, function (key, action) {
-                items[key] = {name: action.label};
+                if(action!=='---------') {
+                    items[key] = {name: action.label};
+                }else{
+                    items[key]=action;
+                }
             });
 
             function replaceVariables(template, action) {
index 33e1e9fe3c7ae31feabcba12a043bad82ce15e5f..4913a9951236fc2a35875b6d47549e7aba588953 100644 (file)
@@ -1,14 +1,37 @@
 @php
+    $allVersions=can('fluidbook-publication:download:all-versions');
     $actions=[
         'delivery'=>
             [
                 'label'=>__('Page de téléchargement'),
-                'url'=>$crud->route.'/delivery/'.$entry->id.'_'.$entry->hash,
+                'url'=>$crud->route.'/'.$entry->id.'/delivery',
                 ],
         ];
     foreach (\App\Models\FluidbookPublication::getDownloadVersions() as $k=>$v) {
-        if(can('fluidbook-publication:download:all-versions') || $entry->{'download_'.$k}){
-            $actions['download_'.$k]=['label'=>$v['label'],'url'=>$crud->route.'/download/'.$entry->id.'/'.$k];
+        $actions['sep_download']='---------';
+        if($allVersions || $entry->{'download_'.$k}){
+            $actions['download_'.$k]=[
+                'label'=>$v['label'],
+                'url'=>$crud->route.'/'.$entry->id.'/download/'.$k
+                ];
+        }
+    }
+    if(can('fluibook-publication:download:install-hosting')){
+        $actions['sep_install']='---------';
+        $actions['install_hosting']=[
+            'label'=>__('Installer sur le serveur d\'hébergement'),
+            'url'=>$crud->route.'/'.$entry->id.'/install_hosting/online',
+            ];
+
+        $actions['install_ftp']=[
+            'label'=>__('Installer sur un serveur FTP'),
+            'url'=>$crud->route.'/'.$entry->id.'/install_ftp/online',
+            ];
+
+        if($entry->scorm_enable){
+            $actions['scormcloud']=['label'=>__('Tester sur SCORM Cloud'),
+            'url'=>$crud->route.'/'.$entry->id.'/scormcloud/scorm'
+            ];
         }
     }
 
@@ -18,6 +41,6 @@
    data-toggle="tooltip"
    title="{{__('Télécharger la publication')}}"
    data-context-actions="{{json_encode($actions)}}"
-   data-context-route="{{$crud->route}}/$id/edit/$action"
+   data-context-route="{{$crud->route}}/$id/download/$action"
    data-context-id="{{$entry->getKey()}}"
 ><i class="la la-arrow-circle-down"></i> {{__('Télécharger')}}</a>
index a0931c777e9b14088fcc1b999bf458f5e3535fa8..36d28313e73bbd6e795d1112b5b9ced4b81d29be 100644 (file)
@@ -4,17 +4,29 @@ Route::group([
     'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
     'namespace'  => 'App\Http\Controllers\Admin',
 ], function () { // custom admin routes
-    try {
-         Route::crud('users', 'UsersCrudController');
+     Route::crud('elearning-media', 'ElearningMediaCrudController');
+     Route::crud('toolbox-translate', 'ToolboxTranslateCrudController');
+     Route::crud('quiztranslation', 'QuiztranslationCrudController');
+     Route::crud('team-emails', 'TeamEmailsCrudController');
+     Route::crud('fluidbook-quote', 'FluidbookQuoteCrudController');
      Route::crud('locale', 'LocaleCrudController');
+     Route::crud('tool-sprite', 'ToolSpriteCrudController');
+     Route::crud('users', 'UsersCrudController');
+     Route::crud('users', 'UsersCrudController');
+     Route::crud('quiz', 'QuizCrudController');
      Route::crud('page', 'PageCrudController');
-     Route::crud('quizatttempt', 'QuizatttemptCrudController');
-     Route::crud('quiztranslation', 'QuiztranslationCrudController');
      Route::crud('settings', 'SettingsCrudController');
+     Route::crud('team-leave', 'TeamLeaveCrudController');
+     Route::crud('team-overtime', 'TeamOvertimeCrudController');
+     Route::crud('fluidbook-collection', 'FluidbookCollectionCrudController');
+     Route::crud('fluidbook-document', 'FluidbookDocumentCrudController');
+     Route::crud('fluidbook-publication', 'FluidbookPublicationCrudController');
+     Route::crud('quizatttempt', 'QuizatttemptCrudController');
+     Route::crud('elearning-package', 'ElearningPackageCrudController');
+     Route::crud('fluidbook-theme', 'FluidbookThemeCrudController');
+     Route::crud('company', 'CompanyCrudController');
      Route::crud('signature', 'SignatureCrudController');
-     Route::crud('team-emails', 'TeamEmailsCrudController');
-     Route::crud('toolbox-translate', 'ToolboxTranslateCrudController');
-    } catch(\Throwable $e) {
-
-    }
+     Route::crud('fluidbook-iconset', 'FluidbookIconsetCrudController');
+     Route::crud('users', 'UsersCrudController');
+     Route::crud('fluidbook-translate', 'FluidbookTranslateCrudController');
 });