Fixed bug on deletion: take the inheritance into account when checking for referencing objects (eg. a ticket linked to a PC was not seen)

SVN:trunk[180]
This commit is contained in:
Romain Quetiez
2009-09-18 09:35:21 +00:00
parent 4ce9d9779a
commit 0454e7fa78
6 changed files with 53 additions and 30 deletions

View File

@@ -504,30 +504,14 @@ switch($operation)
}
else
{
// Evaluate the consequences onto the DB integrity
//
$aDependentObjects = array();
$iTotalThreat = 0;
$aRererencingMe = MetaModel::EnumReferencingClasses($sClass, false /*include N-N links*/, true /*inner joins*/);
foreach($aRererencingMe as $sRemoteClass => $aExtKeys)
{
foreach($aExtKeys as $sExtKeyAttCode)
{
//$oAttDef = MetaModel::GetAttributeDef($sClass, $sExtKeyAttCode);
$oSearch = new DBObjectSearch($sRemoteClass);
$oSearch->AddCondition($sExtKeyAttCode, $id);
$oSet = new CMDBObjectSet($oSearch);
//if ($oSet->Count() > 0)
while ($oDependentObj = $oSet->fetch())
{
$aDependentObjects[$sRemoteClass][] = $oDependentObj;
$iTotalThreat++;
}
}
}
$aDependentObjects = $oObj->GetReferencingObjects();
// Ask for a confirmation, or cancel (back to the object details)
//
$iTotalThreat = 0;
foreach ($aDependentObjects as $sRemoteClass => $aPotentialDeletes)
{
$iTotalThreat += count($aPotentialDeletes);
}
if ($iTotalThreat > 0)
{
$oP->p("Warning: $iTotalThreat object(s) are pointing to the object that you would like to delete");
@@ -550,7 +534,7 @@ switch($operation)
}
else
{
$oP->p("Please confirm that you want to delete this object");
$oP->p("Please confirm that you want to delete ".$oObj->GetHyperLink());
$oP->add("<form method=\"post\">\n");
$oP->add("<input type=\"hidden\" name=\"menu\" value=\"$iActiveNodeId\">\n");
$oP->add("<input type=\"hidden\" name=\"operation\" value=\"delete_confirmed\">\n");