mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
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:code[180]
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -117,7 +117,7 @@ function Page2_ConfigFilters($oPage, $oFilter)
|
||||
//
|
||||
foreach (MetaModel::EnumReferencingClasses($sClass, true) as $sRemoteClass => $aRemoteKeys)
|
||||
{
|
||||
foreach ($aRemoteKeys as $sExtKeyAttCode)
|
||||
foreach ($aRemoteKeys as $sExtKeyAttCode => $oExtKeyAttDef)
|
||||
{
|
||||
// Set its current values
|
||||
$oSubFilter = $oFilter->GetCriteria_ReferencedBy($sRemoteClass, $sExtKeyAttCode);
|
||||
|
||||
@@ -59,7 +59,7 @@ function DisplayReferencingClasses($oPage, $sClass)
|
||||
$oPage->add("<ul>\n");
|
||||
foreach ($aRefs as $sRemoteClass => $aRemoteKeys)
|
||||
{
|
||||
foreach ($aRemoteKeys as $sExtKeyAttCode)
|
||||
foreach ($aRemoteKeys as $sExtKeyAttCode => $oExtKeyAttDef)
|
||||
{
|
||||
$oPage->add("<li>".MakeClassHLink($sRemoteClass)." by <em>$sExtKeyAttCode</em></li>\n");
|
||||
}
|
||||
@@ -117,7 +117,7 @@ function DisplayRelatedClassesBestInClass($oPage, $sClass, $iLevels = 20, &$aVis
|
||||
}
|
||||
foreach (MetaModel::EnumReferencingClasses($sClass) as $sRemoteClass => $aRemoteKeys)
|
||||
{
|
||||
foreach ($aRemoteKeys as $sExtKeyAttCode)
|
||||
foreach ($aRemoteKeys as $sExtKeyAttCode => $oExtKeyAttDef)
|
||||
{
|
||||
$sVisited = (array_key_exists($sRemoteClass, $aVisitedClasses)) ? " ..." : "";
|
||||
$oPage->add("<li>$sClass| <=".MakeClassHLink($sRemoteClass)."::<em>$sExtKeyAttCode</em>$sVisited</li>\n");
|
||||
|
||||
Reference in New Issue
Block a user