N°454 - Check data validity during CSV import

* Added additional checks for external keys (including hierarchical ones)

SVN:trunk[4999]
This commit is contained in:
Eric Espié
2017-10-10 10:00:05 +00:00
parent ee53c3a71e
commit d504fb209f
3 changed files with 55 additions and 38 deletions

View File

@@ -1207,13 +1207,14 @@ abstract class DBObject implements iDisplay
{
return "Target object not found ($sTargetClass::$toCheck)";
}
}
if ($oAtt->IsHierarchicalKey())
{
// This check cannot be deactivated since otherwise the user may break things by a CSV import of a bulk modify
if ($toCheck == $this->GetKey())
// Check allowed values
$aValues = $oAtt->GetAllowedValues($this->ToArgsForQuery());
if (count($aValues) > 0)
{
return "An object can not be its own parent in a hierarchy (".$oAtt->Getlabel()." = $toCheck)";
if (!array_key_exists($toCheck, $aValues))
{
return "Value not allowed [$toCheck]";
}
}
}
}