Skip to content

Commit

Permalink
Fix : implement separator extrafield - missing check on update
Browse files Browse the repository at this point in the history
  • Loading branch information
jfefe committed Mar 15, 2013
1 parent 7a16e1b commit ba0963e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
24 changes: 15 additions & 9 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -2138,21 +2138,27 @@ function insertExtraFields()
$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.=")";

Expand Down
9 changes: 6 additions & 3 deletions htdocs/core/class/extrafields.class.php
Expand Up @@ -357,7 +357,6 @@ private function delete_label($attrname, $elementtype='member')
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';
Expand Down Expand Up @@ -385,8 +384,12 @@ function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=
$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)
{
Expand Down

0 comments on commit ba0963e

Please sign in to comment.