Merge branch '3.2' of git+ssh://git@github.com/Dolibarr/dolibarr.git into 3.2.1

This commit is contained in:
Regis Houssin 2012-06-29 10:10:18 +02:00
commit 123b45aa4b

View File

@ -39,7 +39,8 @@ function checkElementExist($id, $table)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) return true; if ($num > 0) return true;
else return false; else return false;
} }
else return true; // for security
} }
/** /**
@ -56,6 +57,9 @@ function checkLinkedElements($sourcetype, $targettype)
$elements=array(); $elements=array();
$deleted=0; $deleted=0;
$sourcetable=$sourcetype;
$targettable=$targettype;
if ($sourcetype == 'shipping') $sourcetable = 'expedition'; if ($sourcetype == 'shipping') $sourcetable = 'expedition';
else if ($targettype == 'shipping') $targettable = 'expedition'; else if ($targettype == 'shipping') $targettable = 'expedition';
if ($sourcetype == 'delivery') $sourcetable = 'livraison'; if ($sourcetype == 'delivery') $sourcetable = 'livraison';
@ -88,7 +92,7 @@ function checkLinkedElements($sourcetype, $targettype)
if (! empty($elements)) if (! empty($elements))
{ {
foreach($elements as $key => $element) foreach($elements as $key => $element)
{ {
if (! checkElementExist($element[$sourcetype], $sourcetable) || ! checkElementExist($element[$targettype], $targettable)) if (! checkElementExist($element[$sourcetype], $sourcetable) || ! checkElementExist($element[$targettype], $targettable))
{ {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX .'element_element'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX .'element_element';