From d24f5538f9cf1c5e0ce8b0eb7a559111f9b50963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 5 Oct 2015 20:25:55 +0200 Subject: [PATCH 1/4] Fix: wrong parameters order --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 99ec23c6a73..40ba0e666ae 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1155,7 +1155,7 @@ class ExtraFields else if (in_array($key_type,array('checkbox'))) { $value_arr=GETPOST("options_".$key.$keyprefix); - $value_key=implode($value_arr,','); + $value_key=implode(',', $value_arr); } else if (in_array($key_type,array('price','double'))) { From 41354ca00d63888f46de15c3ae6c657b3824856d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 5 Oct 2015 20:30:55 +0200 Subject: [PATCH 2/4] Added type hinting to extrafields object --- htdocs/core/class/commonobject.class.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f9eeffbb018..a812ccc7bf7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3564,16 +3564,16 @@ abstract class CommonObject else return 0; } - /** - * Function to show lines of extrafields with output datas - * - * @param object $extrafields Extrafield Object - * @param string $mode Show output (view) or input (edit) for extrafield - * @param array $params Optionnal parameters - * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * - * @return string - */ + /** + * Function to show lines of extrafields with output datas + * + * @param Extrafields $extrafields Extrafield Object + * @param string $mode Show output (view) or input (edit) for extrafield + * @param array $params Optional parameters + * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * + * @return string + */ function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='') { global $_POST, $conf; From 3fdd59bf0a06798476566b6fc173ebb3540ef5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 5 Oct 2015 20:39:14 +0200 Subject: [PATCH 3/4] Fix #3666 checkbox extrafields on edit --- htdocs/core/class/commonobject.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a812ccc7bf7..99e497046e0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3601,7 +3601,16 @@ abstract class CommonObject $value=$this->array_options["options_".$key]; break; case "edit": - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); + if (isset($_POST["options_" . $key])) { + if (is_array($_POST["options_" . $key])) { + // $_POST["options"] is an array but following code expects a comma separated string + $value = implode(",", $_POST["options_" . $key]); + } else { + $value = $_POST["options_" . $key]; + } + } else { + $value = $this->array_options["options_" . $key]; + } break; } if ($extrafields->attribute_type[$key] == 'separate') From afbee44993e6c5c6ae80f7e46f5eba72bd523fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 5 Oct 2015 20:51:17 +0200 Subject: [PATCH 4/4] Fix #3667 checkbox extrafields on edit For actions and members. --- htdocs/adherents/type.php | 11 ++++++++++- htdocs/comm/action/card.php | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 14bbcb8e854..1819925e723 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -678,7 +678,16 @@ if ($rowid > 0) print '

'; foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($adht->array_options['options_'.$key])?$adht->array_options['options_'.$key]:'')); + if (isset($_POST["options_" . $key])) { + if (is_array($_POST["options_" . $key])) { + // $_POST["options"] is an array but following code expects a comma separated string + $value = implode(",", $_POST["options_" . $key]); + } else { + $value = $_POST["options_" . $key]; + } + } else { + $value = $adht->array_options["options_" . $key]; + } print '\n"; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 2e35b8004f0..c011717c0cc 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1202,7 +1202,16 @@ if ($id > 0) print '

'.$label.''; print $extrafields->showInputField($key,$value); print "
'; foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); + if (isset($_POST["options_" . $key])) { + if (is_array($_POST["options_" . $key])) { + // $_POST["options"] is an array but following code expects a comma separated string + $value = implode(",", $_POST["options_" . $key]); + } else { + $value = $_POST["options_" . $key]; + } + } else { + $value = $object->array_options["options_" . $key]; + } print '\n";
'.$label.''; print $extrafields->showOutputField($key,$value); print "