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:
Romain Quetiez
2009-09-18 09:35:21 +00:00
parent e176e2090c
commit 637993e7eb
6 changed files with 53 additions and 30 deletions

View File

@@ -847,6 +847,29 @@ abstract class DBObject
}
return $aResults;
}
public function GetReferencingObjects()
{
$aDependentObjects = array();
$aRererencingMe = MetaModel::EnumReferencingClasses(get_class($this));
foreach($aRererencingMe as $sRemoteClass => $aExtKeys)
{
foreach($aExtKeys as $sExtKeyAttCode => $oExtKeyAttDef)
{
//$oAttDef = MetaModel::GetAttributeDef($sClass, $sExtKeyAttCode);
$oSearch = new DBObjectSearch($sRemoteClass);
$oSearch->AddCondition($sExtKeyAttCode, $this->GetKey());
$oSet = new CMDBObjectSet($oSearch);
//if ($oSet->Count() > 0)
while ($oDependentObj = $oSet->fetch())
{
$aDependentObjects[$sRemoteClass][] = $oDependentObj;
}
}
}
return $aDependentObjects;
}
}