From f3e1e81219916363936e09e79da8a7c4f61dc286 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 16:11:25 +0100 Subject: [PATCH] Fix update of extrafield password that are crypted --- htdocs/core/class/commonobject.class.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 60d7f4a8c5e..990d158af56 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4673,10 +4673,26 @@ abstract class CommonObject $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); if ($algo != '') { - $new_array_options[$key] = dol_hash($this->array_options[$key], $algo); - /*var_dump($algo); - var_dump($this->array_options[$key]); - var_dump($new_array_options[$key]);*/ + if (is_object($this->oldcopy)) // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value + { + //global $action; // $action may be 'create', 'update', 'update_extras'... + //var_dump($action); + //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); + if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same thaan submited new value, it means we don't change it, so we don't update. + { + $new_array_options[$key] = $this->array_options[$key]; // Value is kept + } + else + { + // var_dump($algo); + $newvalue = dol_hash($this->array_options[$key], $algo); + $new_array_options[$key] = $newvalue; + } + } + else + { + $new_array_options[$key] = $this->array_options[$key]; // Value is kept + } } } else // Common usage