]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5700 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 26 Jan 2023 08:21:30 +0000 (09:21 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 26 Jan 2023 08:21:30 +0000 (09:21 +0100)
app/Fluidbook/Packager/Download.php
app/Models/FluidbookExternalInstallServer.php [new file with mode: 0644]
app/Models/Traits/PublicationSettings.php
resources/views/vendor/backpack/base/inc/sidebar_content.blade.php

index 5dca3e4ebbdc712e61cb6d140804d63b4c56be61..70636d6e2c1c97902abf77ad78ae3469deb38801 100644 (file)
@@ -19,6 +19,8 @@ class Download extends DownloadBase
     protected $_subject = 'Fluidbook ":title" (#:nb) prêt au téléchargement';
     // __('Fluidbook ":title" (#:nb) installé sur hosting')
     protected $_installHostingSubject = 'Fluidbook ":title" (#:nb) installé sur hosting';
+    // __('Fluidbook ":title" (#:nb) installé sur un serveur FTP')
+    protected $_installFTPSubject = 'Fluidbook ":title" (#:nb) installé sur hosting';
 
     public function __construct($entry, $version, $action, $user)
     {
@@ -97,7 +99,14 @@ class Download extends DownloadBase
                 $actions = ['Voir sur hosting' => 'https://hosting.fluidbook.com/' . $dest . '/'];
 
             } else if ($this->action === 'install_ftp') {
+                $dest = self::_cleanInstallDir($this->entry->install_online_ftp);
+                if (!$dest) {
+                    throw new \Exception('No path defined for ftp installation');
+                }
+                $subject = __($this->_installFTPSubject, ['title' => $this->_title(), 'nb' => $this->_id()]);
+                $path = $this->_compileandpackage(false);
 
+                $actions = [];
             }
         } catch (\Exception $e) {
             $subject = __('Erreur lors de la compilation du :type :nb', ['nb' => $this->_id(), 'type' => $this->type]);
diff --git a/app/Models/FluidbookExternalInstallServer.php b/app/Models/FluidbookExternalInstallServer.php
new file mode 100644 (file)
index 0000000..6cecf05
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Models;
+
+use Cubist\Backpack\Magic\Fields\Checkbox;
+use Cubist\Backpack\Magic\Fields\Integer;
+use Cubist\Backpack\Magic\Fields\Password;
+use Cubist\Backpack\Magic\Fields\SelectFromArray;
+use Cubist\Backpack\Magic\Fields\Text;
+use Cubist\Backpack\Magic\Fields\URL;
+use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
+
+class FluidbookExternalInstallServer extends CubistMagicAbstractModel
+{
+    protected $table = 'fluidbook_external_install_server';
+    protected $_options = ['name' => 'fluidbook-external-install-server',
+        'singular' => 'serveur',
+        'plural' => 'serveurs'];
+
+    protected static $_permissionBase = 'fluidbook-external-install-server';
+
+    public function setFields()
+    {
+        parent::setFields();
+
+        $ftpProtocols = ['FTP', 'FTPS', 'FTPES'];
+        $hostProtocols = ['FTP', 'FTPS', 'FTPES', 'SFTP'];
+        $portProtocols = $hostProtocols;
+        $userProtocols = $hostProtocols;
+        $passwordProtocols = $hostProtocols;
+
+        $this->addField('name', Text::class, __('Nom'), ['column' => true]);
+        $this->addField('protocol', SelectFromArray::class, __('Protocole'), ['options' => ['FTP' => __('FTP non sécurisé'), 'FTPS' => __('FTP sécurisé explicite sur TLS'), 'FTPES' => __('FTP sécurisé implicite sur TLS'), 'SFTP' => 'SFTP', 'hosting' => 'Hosting'], 'default' => 'FTP', 'column' => true, 'allows_null' => false]);
+        $this->addField('ftp_mode', SelectFromArray::class, __('Mode de transfert'), ['options' => ['0' => __('Mode passif'), '1' => __('Mode actif')], 'default' => '1', 'when' => ['protocol' => $ftpProtocols], 'allows_null' => false,]);
+        $this->addField('host', Text::class, __('Hôte'), ['default' => '', 'column' => true, 'when' => ['protocol' => $hostProtocols]]);
+        $this->addField('port', Integer::class, __('Port'), ['hint' => __('Laisser vide pour utiliser le port par défaut'), 'default' => '', 'min' => 1, 'max' => 65536, 'when' => ['protocol' => $portProtocols]]);
+        $this->addField('username', Text::class, __('Nom d\'utilisateur'), ['when' => ['protocol' => $userProtocols]]);
+        $this->addField('password', Password::class, __('Mot de passe'), ['when' => ['protocol' => $passwordProtocols]]);
+        $this->addField('base_path', Text::class, __('Chemin de base'), ['default' => '/']);
+        $this->addField('base_url', URL::class, __('URL de base'), ['default' => 'https://']);
+    }
+}
index e40fec30fd2cca5df8e2465d7e60fb8004908f72..872cd8bcca8c074877758391ed2b4cca90663f38 100644 (file)
@@ -5,6 +5,7 @@ namespace App\Models\Traits;
 use App\Fields\FluidbookDevelopmentVersion;
 use App\Fields\FluidbookSignature;
 use App\Fields\SCORMVersion;
+use App\Models\FluidbookExternalInstallServer;
 use Cubist\Backpack\Magic\Fields\Checkbox;
 use Cubist\Backpack\Magic\Fields\FilesOrURL;
 use Cubist\Backpack\Magic\Fields\FormSection;
@@ -2983,14 +2984,7 @@ L,index',
                 'translatable' => false,
             ]);
             if ($downloadVersion['install']) {
-                $installFields = [
-                    'hosting' => ['prefix' => 'https://hosting.fluidbook.com/', 'label' => __('Chemin sur le serveur hosting'), 'hint' => null],
-                    'ftp' => ['prefix' => 'ftp://', 'label' => __('Chemin de connexion au serveur FTP'), 'hint' => __('username:password@host/path/to/install/folder')],
-                ];
-                foreach ($installFields as $iname => $installField) {
-                    $this->addField('install_' . $name . '_' . $iname, Text::class, $installField['label'], ['default' => '', 'fake' => true, 'translatable' => false, 'store_in' => 'settings', 'prefix' => $installField['prefix'], 'hint' => $installField['hint'], 'when' => ['download_' . $name => 1]]);
-                }
-
+                $this->addField('install_' . $name, ExternalPath::class, $installField['label'], ['default' => '', 'fake' => true, 'translatable' => false, 'store_in' => 'settings', 'servers_model' => FluidbookExternalInstallServer::class, 'when' => ['download_' . $name => 1]]);
             }
         }
 
index 116edc77f05d02286842cf15d0384a6c4bc5a0d0..7d43311ad2af9fa29424f369f2afc3bbbb629d8b 100644 (file)
                 <li class="nav-item"><a class="nav-link" href="{{ backpack_url('signature') }}"><i
                             class="la la-signature nav-icon"></i> {{__('Signatures')}}</a></li>
             @endcan
+            @can('fluidbook-external-install-server:read')
+                <li class="nav-item"><a class="nav-link" href="{{ backpack_url('fluidbook-external-install-server') }}"><i
+                            class="la las la-server"></i> {{__('Serveurs externes')}}</a></li>
+            @endcan
             @can('fluidbook-quote:read')
                 <li class="nav-item"><a class="nav-link" href="{{ backpack_url('fluidbook-quote') }}"><i
                             class="la la-wpforms nav-icon"></i> {{__('Demandes de devis')}}</a></li>
             @endcan
             @can('team-pay:read')
                 <li class="nav-item"><a class="nav-link"
-                                        href='{{ backpack_url('team-pay') }}'><i class="nav-icon las la-file-invoice-dollar"></i>
+                                        href='{{ backpack_url('team-pay') }}'><i
+                            class="nav-icon las la-file-invoice-dollar"></i>
                         <span>{{__('Bulletins de salaire')}}</span></a>
                 </li>
             @endcan
             @endcan
             @can('team-overtime:read')
                 <li class="nav-item"><a class="nav-link"
-                                        href='{{ backpack_url('team-overtime') }}'><i class="nav-icon las la-stopwatch"></i>
+                                        href='{{ backpack_url('team-overtime') }}'><i
+                            class="nav-icon las la-stopwatch"></i>
                         <span>{{__('Heures supp')}}</span></a>
                 </li>
             @endcan