From: Vincent Vanwaelscappel Date: Thu, 26 Jan 2023 08:21:30 +0000 (+0100) Subject: wip #5700 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f0a6e895a69773bef418ec14075d4e5293bdd33e;p=fluidbook-toolbox.git wip #5700 @2 --- diff --git a/app/Fluidbook/Packager/Download.php b/app/Fluidbook/Packager/Download.php index 5dca3e4eb..70636d6e2 100644 --- a/app/Fluidbook/Packager/Download.php +++ b/app/Fluidbook/Packager/Download.php @@ -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 index 000000000..6cecf05c5 --- /dev/null +++ b/app/Models/FluidbookExternalInstallServer.php @@ -0,0 +1,42 @@ + '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://']); + } +} diff --git a/app/Models/Traits/PublicationSettings.php b/app/Models/Traits/PublicationSettings.php index e40fec30f..872cd8bcc 100644 --- a/app/Models/Traits/PublicationSettings.php +++ b/app/Models/Traits/PublicationSettings.php @@ -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]]); } } diff --git a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php index 116edc77f..7d43311ad 100644 --- a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php +++ b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php @@ -87,6 +87,10 @@ @endcan + @can('fluidbook-external-install-server:read') + + @endcan @can('fluidbook-quote:read') @@ -136,7 +140,8 @@ @endcan @can('team-pay:read') @endcan @@ -149,7 +154,8 @@ @endcan @can('team-overtime:read') @endcan