Fix update of extrafield password that are crypted

This commit is contained in:
Laurent Destailleur 2018-02-23 16:11:25 +01:00
parent 0a79550f43
commit f3e1e81219

View File

@ -4673,10 +4673,26 @@ abstract class CommonObject
$algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']));
if ($algo != '') if ($algo != '')
{ {
$new_array_options[$key] = dol_hash($this->array_options[$key], $algo); 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
/*var_dump($algo); {
var_dump($this->array_options[$key]); //global $action; // $action may be 'create', 'update', 'update_extras'...
var_dump($new_array_options[$key]);*/ //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 else // Common usage