Selaa lähdekoodia

Model factory: introduced a new variation of attribute _delta: delete_if_exists. Use this flag to delete a branch from the data model being hacked, without caring if it is already deleted (or non existing). This eases the burden of coping with different installation combinations.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4306 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 9 vuotta sitten
vanhempi
commit
8f179b8e11
1 muutettua tiedostoa jossa 11 lisäystä ja 1 poistoa
  1. 11 1
      setup/modelfactory.class.inc.php

+ 11 - 1
setup/modelfactory.class.inc.php

@@ -490,7 +490,17 @@ class ModelFactory
 			$oTargetParentNode->RedefineChildNode($oTargetNode, $sSearchId);
 			break;
 
-		case 'delete':
+		case 'delete_if_exists':
+			$oTargetNode = $oTargetParentNode->_FindChildNode($oSourceNode);
+			if (($oTargetNode !== null) && ($oTargetNode->getAttribute('_alteration') !== 'removed'))
+			{
+				// Delete the node if it actually exists and is not already marked as deleted
+				$oTargetNode->Delete();
+			}
+			// otherwise fail silently
+			break;
+			
+		case 'delete':			
 			$oTargetNode = $oTargetParentNode->_FindChildNode($oSourceNode);
 			if ($oTargetNode == null)
 			{