From fba22c8883c4440620c02167c3469772ec606c6f Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 14 Mar 2023 15:04:15 +0100 Subject: [PATCH 1/3] add setAsSelectUser --- htdocs/core/class/html.formsetup.class.php | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 40dec1870a4..26e892c1151 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -833,6 +833,8 @@ class FormSetupItem $out.= $this->generateInputFieldMultiSelect(); } elseif ($this->type == 'select') { $out.= $this->generateInputFieldSelect(); + } elseif ($this->type == 'selectUser') { + $out.= $this->generateInputFieldSelectUser(); } elseif ($this->type == 'textarea') { $out.= $this->generateInputFieldTextarea(); } elseif ($this->type== 'html') { @@ -992,6 +994,14 @@ class FormSetupItem return $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue); } + /** + * @return string + */ + public function generateInputFieldSelectUser() + { + return $this->form->select_dolusers($this->fieldValue, $this->confKey); + } + /** * get the type : used for old module builder setup conf style conversion and tests * because this two class will quickly evolve it's important to not set or get directly $this->type (will be protected) so this method exist @@ -1066,6 +1076,8 @@ class FormSetupItem $out.= $this->generateOutputFieldMultiSelect(); } elseif ($this->type == 'select') { $out.= $this->generateOutputFieldSelect(); + } elseif ($this->type == 'selectUser') { + $out.= $this->generateOutputFieldSelectUser(); } elseif ($this->type== 'html') { $out.= $this->fieldValue; } elseif ($this->type== 'color') { @@ -1185,6 +1197,17 @@ class FormSetupItem return $outPut; } + /** + * @return string + */ + public function generateOutputFieldSelectUser() + { + $outPut = ''; + $user = new User($this->db); + $user->fetch($this->fieldValue); + $outPut = $user->firstname . " " . $user->lastname; + return $outPut; + } /* * METHODS FOR SETTING DISPLAY TYPE */ @@ -1335,4 +1358,16 @@ class FormSetupItem $this->type = 'select'; return $this; } + + /** + * Set type of input as a simple title + * no data to store + * @param array $fieldOptions A table of field options + * @return self + */ + public function setAsSelectUser() + { + $this->type = 'selectUser'; + return $this; + } } From 2eecef22bc5b81154a943e04d359824136df7494 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 27 Mar 2023 08:54:57 +0200 Subject: [PATCH 2/3] Update html.formsetup.class.php --- htdocs/core/class/html.formsetup.class.php | 38 +++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 26e892c1151..ac79da5b281 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -1147,6 +1147,8 @@ class FormSetupItem /** + * generateOutputFieldMultiSelect + * * @return string */ public function generateOutputFieldMultiSelect() @@ -1168,6 +1170,8 @@ class FormSetupItem } /** + * generateOutputFieldColor + * * @return string */ public function generateOutputFieldColor() @@ -1176,6 +1180,8 @@ class FormSetupItem return $this->generateInputField(); } /** + * generateInputFieldColor + * * @return string */ public function generateInputFieldColor() @@ -1185,6 +1191,8 @@ class FormSetupItem } /** + * generateOutputFieldSelect + * * @return string */ public function generateOutputFieldSelect() @@ -1198,6 +1206,8 @@ class FormSetupItem } /** + * generateOutputFieldSelectUser + * * @return string */ public function generateOutputFieldSelectUser() @@ -1208,12 +1218,14 @@ class FormSetupItem $outPut = $user->firstname . " " . $user->lastname; return $outPut; } + /* * METHODS FOR SETTING DISPLAY TYPE */ /** * Set type of input as string + * * @return self */ public function setAsString() @@ -1224,6 +1236,7 @@ class FormSetupItem /** * Set type of input as color + * * @return self */ public function setAsColor() @@ -1234,6 +1247,7 @@ class FormSetupItem /** * Set type of input as textarea + * * @return self */ public function setAsTextarea() @@ -1244,6 +1258,7 @@ class FormSetupItem /** * Set type of input as html editor + * * @return self */ public function setAsHtml() @@ -1254,6 +1269,7 @@ class FormSetupItem /** * Set type of input as emailtemplate selector + * * @param string $templateType email template type * @return self */ @@ -1265,6 +1281,7 @@ class FormSetupItem /** * Set type of input as thirdparty_type selector + * * @return self */ public function setAsThirdpartyType() @@ -1275,6 +1292,7 @@ class FormSetupItem /** * Set type of input as Yes + * * @return self */ public function setAsYesNo() @@ -1285,6 +1303,7 @@ class FormSetupItem /** * Set type of input as secure key + * * @return self */ public function setAsSecureKey() @@ -1295,6 +1314,7 @@ class FormSetupItem /** * Set type of input as product + * * @return self */ public function setAsProduct() @@ -1306,6 +1326,7 @@ class FormSetupItem /** * Set type of input as a category selector * TODO add default value + * * @param int $catType Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @return self */ @@ -1316,8 +1337,8 @@ class FormSetupItem } /** - * Set type of input as a simple title - * no data to store + * Set type of input as a simple title. No data to store + * * @return self */ public function setAsTitle() @@ -1328,8 +1349,8 @@ class FormSetupItem /** - * Set type of input as a simple title - * no data to store + * Set type of input as a simple title. No data to store + * * @param array $fieldOptions A table of field options * @return self */ @@ -1344,8 +1365,8 @@ class FormSetupItem } /** - * Set type of input as a simple title - * no data to store + * Set type of input as a simple title. No data to store + * * @param array $fieldOptions A table of field options * @return self */ @@ -1360,9 +1381,8 @@ class FormSetupItem } /** - * Set type of input as a simple title - * no data to store - * @param array $fieldOptions A table of field options + * Set type of input as a simple title. No data to store + * * @return self */ public function setAsSelectUser() From d56bcd937b5f4fd38522b6eef983a883b5dceb02 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 27 Mar 2023 06:55:42 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/core/class/html.formsetup.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index ac79da5b281..2cd3adec4f4 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -1148,7 +1148,7 @@ class FormSetupItem /** * generateOutputFieldMultiSelect - * + * * @return string */ public function generateOutputFieldMultiSelect() @@ -1171,7 +1171,7 @@ class FormSetupItem /** * generateOutputFieldColor - * + * * @return string */ public function generateOutputFieldColor() @@ -1181,7 +1181,7 @@ class FormSetupItem } /** * generateInputFieldColor - * + * * @return string */ public function generateInputFieldColor() @@ -1218,7 +1218,7 @@ class FormSetupItem $outPut = $user->firstname . " " . $user->lastname; return $outPut; } - + /* * METHODS FOR SETTING DISPLAY TYPE */