From efe99b4c37bb00e82b0cf36d188a0336776ec205 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 26 Jan 2023 09:21:13 +0100 Subject: [PATCH] wip #5700 @0.5 --- src/app/Magic/Fields/ExternalPath.php | 8 ++++ src/app/Magic/Models/ExternalServer.php | 58 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/app/Magic/Fields/ExternalPath.php create mode 100644 src/app/Magic/Models/ExternalServer.php diff --git a/src/app/Magic/Fields/ExternalPath.php b/src/app/Magic/Fields/ExternalPath.php new file mode 100644 index 0000000..f55eae7 --- /dev/null +++ b/src/app/Magic/Fields/ExternalPath.php @@ -0,0 +1,8 @@ +addField('name', Text::class, __('Nom'), ['column' => true]); + $this->addField('protocol', SelectFromArray::class, __('Protocole'), ['options' => $this->getProtocols(), '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' => $this->getPasswordProtocols()], 'allows_null' => false,]); + $this->addField('host', Text::class, __('Hôte'), ['default' => '', 'column' => true, 'when' => ['protocol' => $this->getHostProtocols()]]); + $this->addField('port', Integer::class, __('Port'), ['hint' => __('Laisser vide pour utiliser le port par défaut'), 'default' => '', 'min' => 1, 'max' => 65536, 'when' => ['protocol' => $this->getPortProtocols()]]); + $this->addField('username', Text::class, __('Nom d\'utilisateur'), ['when' => ['protocol' => $this->getUsernameProtocols()]]); + $this->addField('password', Password::class, __('Mot de passe'), ['when' => ['protocol' => $this->getPasswordProtocols()]]); + $this->addField('base_path', Text::class, __('Chemin de base'), ['default' => '/']); + $this->addField('base_url', URL::class, __('URL de base'), ['default' => 'https://']); + } + + public function getProtocols() + { + return ['FTP' => __('FTP non sécurisé'), 'FTPS' => __('FTP sécurisé explicite sur TLS'), 'FTPES' => __('FTP sécurisé implicite sur TLS'), 'SFTP' => 'SFTP']; + } + + public function getFTPProtocols() + { + return ['FTP', 'FTPS', 'FTPES']; + } + + public function getHostProtocols() + { + return ['FTP', 'FTPS', 'FTPES', 'SFTP']; + } + + public function getPortProtocols() + { + return $this->getHostProtocols(); + } + + public function getUsernameProtocols() + { + return $this->getHostProtocols(); + } + + public function getPasswordProtocols() + { + return $this->getUsernameProtocols(); + } +} -- 2.39.5