Skip to content

Commit

Permalink
2nd try to fix better compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 10, 2017
1 parent b6bdd98 commit 209bd0b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -1223,11 +1223,11 @@ function getValueFrom($table, $id, $field)
* @param int $id To force other object id (should not be used)
* @param string $format Data format ('text', 'date'). 'text' is used if not defined
* @param string $id_field To force rowid field name. 'rowid' is used if not defined
* @param User|string $user Update last update fields also if user object provided. If not provided, current user is used.
* @param User|string $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none'
* @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY')
* @return int <0 if KO, >0 if OK
*/
function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $user='', $trigkey='')
function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='')
{
global $user,$langs,$conf;

Expand All @@ -1247,7 +1247,8 @@ function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field
if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'";
else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value);
else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null");
if (empty($user) && is_object($user)) $sql.=", fk_user_modif = ".$user->id;
if (! empty($fuser) && is_object($fuser)) $sql.=", fk_user_modif = ".$fuser->id;
elseif (empty($fuser) || $fuser != 'none') $sql.=", fk_user_modif = ".$user->id;
$sql.= " WHERE ".$id_field." = ".$id;

dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG);
Expand All @@ -1256,7 +1257,7 @@ function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field
{
if ($trigkey)
{
$result=$this->call_trigger($trigkey, $user); // This may set this->errors
$result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors
if ($result < 0) $error++;
}

Expand Down

0 comments on commit 209bd0b

Please sign in to comment.