From da875dd945893a527e9224310f83a3f7f369754f Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Thu, 29 Mar 2012 13:32:35 +0000 Subject: [PATCH] #540 Data synchro: the option "write if empty" was not implemented SVN:1.2[1933] --- synchro/synchrodatasource.class.inc.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index 4bfa73dd20..88022d3dfa 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -1736,8 +1736,21 @@ class SynchroReplica extends DBObject implements iDisplay $value = $this->GetValueFromExtData($sAttCode, $oSyncAtt, $oStatLog); if (!is_null($value)) { - $oDestObj->Set($sAttCode, $value); - $aValueTrace[] = "$sAttCode: $value"; + if ($oSyncAtt->Get('update_policy') == 'write_if_empty') + { + $oAttDef = MetaModel::GetAttributeDef(get_class($oDestObj), $sAttCode); + if ($oAttDef->IsNull($oDestObj->Get($sAttCode))) + { + // The value is still "empty" in the target object, we are allowed to write the new value + $oDestObj->Set($sAttCode, $value); + $aValueTrace[] = "$sAttCode: $value"; + } + } + else + { + $oDestObj->Set($sAttCode, $value); + $aValueTrace[] = "$sAttCode: $value"; + } } } // Really modified ?