From 0a968baf1d4cb6f97114daab2bc77c567e808999 Mon Sep 17 00:00:00 2001 From: David Bogner Date: Sun, 15 Oct 2023 22:49:18 +0200 Subject: [PATCH] WIP: Finishing file import --- rule/ftpsyncfiles/rule_class.php | 16 +++++++++------- rule/ftpsyncfiles/rule_form.php | 32 +++++++++++++++++--------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/rule/ftpsyncfiles/rule_class.php b/rule/ftpsyncfiles/rule_class.php index c6dc45c6..bd32fef4 100644 --- a/rule/ftpsyncfiles/rule_class.php +++ b/rule/ftpsyncfiles/rule_class.php @@ -75,7 +75,7 @@ class datalynx_rule_ftpsyncfiles extends datalynx_rule_base { * @var mixed */ private array $sftpsetting; - private int $filefieldid; + private ?int $filefieldid; private array $files; /** @@ -86,12 +86,14 @@ class datalynx_rule_ftpsyncfiles extends datalynx_rule_base { */ public function __construct($df = 0, $rule = 0) { parent::__construct($df, $rule); - $this->sftpsetting = unserialize($this->rule->param2); - $this->sftpserver = $this->sftpsetting['sftpserver']; - $this->sftpport = $this->sftpsetting['sftpport']; - $this->sftpusername = $this->sftpsetting['sftpusername']; - $this->sftppassword = $this->sftpsetting['sftppassword']; - $this->sftppath = $this->sftpsetting['sftppath']; + if (isset($this->rule->param2)) { + $this->sftpsetting = unserialize($this->rule->param2); + $this->sftpserver = $this->sftpsetting['sftpserver']; + $this->sftpport = $this->sftpsetting['sftpport']; + $this->sftpusername = $this->sftpsetting['sftpusername']; + $this->sftppassword = $this->sftpsetting['sftppassword']; + $this->sftppath = $this->sftpsetting['sftppath']; + } $this->matchingfield = $this->rule->param7; $this->teammemberfieldid = $this->rule->param8; $this->authorid = $this->rule->param9; diff --git a/rule/ftpsyncfiles/rule_form.php b/rule/ftpsyncfiles/rule_form.php index 867811dc..76ded2e4 100644 --- a/rule/ftpsyncfiles/rule_form.php +++ b/rule/ftpsyncfiles/rule_form.php @@ -116,21 +116,23 @@ public function data_preprocessing(&$data) { /** */ public function set_data($data) { - $sftpsetting = unserialize($data->param2); - if (isset($sftpsetting['sftpserver'])) { - $data->sftpserver = $sftpsetting['sftpserver']; - } - if (isset($sftpsetting['sftpport'])) { - $data->sftpport = $sftpsetting['sftpport']; - } - if (isset($sftpsetting['sftpusername'])) { - $data->sftpusername = $sftpsetting['sftpusername']; - } - if (isset($sftpsetting['sftppassword'])) { - $data->sftppassword = $sftpsetting['sftppassword']; - } - if (isset($sftpsetting['sftppath'])) { - $data->sftppath = $sftpsetting['sftppath']; + if (!empty($data->param2)) { + $sftpsetting = unserialize($data->param2); + if (isset($sftpsetting['sftpserver'])) { + $data->sftpserver = $sftpsetting['sftpserver']; + } + if (isset($sftpsetting['sftpport'])) { + $data->sftpport = $sftpsetting['sftpport']; + } + if (isset($sftpsetting['sftpusername'])) { + $data->sftpusername = $sftpsetting['sftpusername']; + } + if (isset($sftpsetting['sftppassword'])) { + $data->sftppassword = $sftpsetting['sftppassword']; + } + if (isset($sftpsetting['sftppath'])) { + $data->sftppath = $sftpsetting['sftppath']; + } } parent::set_data($data); }