From ba0963ea7dbfd3241637c7e5e79cf27ac27ed5c3 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 16 Mar 2013 00:00:57 +0100 Subject: [PATCH] Fix : implement separator extrafield - missing check on update --- htdocs/core/class/commonobject.class.php | 24 +++++++++++++++--------- htdocs/core/class/extrafields.class.php | 9 ++++++--- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 50bd564e8d9..26b8a0c5826 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2138,21 +2138,27 @@ abstract class CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; foreach($this->array_options as $key => $value) { + $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut - $sql.=",".substr($key,8); // Remove 'options_' prefix + if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; foreach($this->array_options as $key => $value) { + $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field o fattribut - if ($this->array_options[$key] != '') - { - $sql.=",'".$this->array_options[$key]."'"; - } - else - { - $sql.=",null"; - } + if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + { + if ($this->array_options[$key] != '') + { + $sql.=",'".$this->array_options[$key]."'"; + } + else + { + $sql.=",null"; + } + } } $sql.=")"; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d917d6283ce..5b12672f6ce 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -357,7 +357,6 @@ class ExtraFields function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos,$param='') { $table=$elementtype.'_extrafields'; - // Special case for not normalized table names if ($elementtype == 'member') $table='adherent_extrafields'; elseif ($elementtype == 'company') $table='societe_extrafields'; @@ -385,8 +384,12 @@ class ExtraFields $lengthdb=$length; } $field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL')); - $result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); - if ($result > 0) + + if ($type != 'separate') // No table update when separate type + { + $result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); + } + if ($result > 0 || $type == 'separate') { if ($label) {