diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a959a7f585d..2f1a56c5595 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4424,7 +4424,7 @@ abstract class CommonObject //Eliminate copied source object extra_fields that do not exist in target object $new_array_options=array(); foreach ($this->array_options as $key => $value) { - if (in_array(substr($key,8), array_keys($target_extrafields))) + if (in_array(substr($key,8), array_keys($target_extrafields))) // We remove the 'options_' from $key $new_array_options[$key] = $value; } @@ -4510,6 +4510,7 @@ abstract class CommonObject $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; + foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c637155e48b..ae1cd2848be 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1336,7 +1336,7 @@ class ExtraFields $list=$this->attribute_list[$key]; $hidden=(abs($list)!=1 ? 1 : 0); - if ($hidden) return ''; + if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. // If field is a computed field, value must become result of compute if ($computed) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index c4120552b80..15bfd51f83b 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -42,6 +42,9 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][ { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { + // Discard if extrafield is a hidden field + if (abs($extrafields->attributes[$object->table_element]['list'][$key]) != 1) continue; + // Load language if required if (! empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 0a4d5f0ea1d..c0cf82c3899 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -163,7 +163,8 @@ class User extends CommonObject } /** - * Load a user from database with its id or ref (login) + * Load a user from database with its id or ref (login). + * This function does not load permissions, only user properties. Use getrights() for this just after the fetch. * * @param int $id If defined, id to used for search * @param string $login If defined, login to used for search