N°6040 - Booking: Add prerequisites in iTop core - Compilation extensibility for new attributes

This commit is contained in:
Eric Espie
2023-03-06 15:22:16 +01:00
parent 5da76096cf
commit 4bd66ac0fe
3 changed files with 641 additions and 460 deletions

View File

@@ -6975,6 +6975,23 @@ class AttributeExternalKey extends AttributeDBFieldVoid
return $oRet;
}
/**
* Return the deletion option for the target attribute
* i.e. should the target object be deleted when the host object is deleted
*
* @return int DEL_AUTO (yes explicit), DEL_SILENT (yes implicit), DEL_MANUAL (no = default)
*
* @since 3.1.0
*/
public function GetDeletionOptionForTargetObject()
{
if ($this->IsParam('on_host_delete')) {
return $this->Get('on_host_delete');
}
return $this->GetOptional('on_host_delete', DEL_MANUAL);
}
public static function GetFormFieldClass()
{
return '\\Combodo\\iTop\\Form\\Field\\SelectObjectField';

View File

@@ -4876,6 +4876,18 @@ abstract class DBObject implements iDisplay
}
$aVisited[$sClass] = $iThisId;
// Delete possible target objects
foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
if ($oAttDef instanceof AttributeExternalKey && $oAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) {
$iOption = $oAttDef->GetDeletionOptionForTargetObject();
if ($iOption == DEL_SILENT || $iOption == DEL_AUTO) {
// Delete target object
$oTargetObject = MetaModel::GetObject($oAttDef->GetTargetClass(), $this->Get($sAttCode));
$oTargetObject->MakeDeletionPlan($oDeletionPlan, $aVisited, $iOption);
}
}
}
if ($iDeleteOption == DEL_MANUAL)
{
// Stop the recursion here
@@ -4889,13 +4901,13 @@ abstract class DBObject implements iDisplay
$aDependentObjects = $this->GetReferencingObjects(true /* allow all data */);
// Getting and setting time limit are not symetric:
// Getting and setting time limit are not symmetric:
// www.php.net/manual/fr/function.set-time-limit.php#72305
$iPreviousTimeLimit = ini_get('max_execution_time');
foreach ($aDependentObjects as $sRemoteClass => $aPotentialDeletes)
foreach ($aDependentObjects as $aPotentialDeletes)
{
foreach ($aPotentialDeletes as $sRemoteExtKey => $aData)
foreach ($aPotentialDeletes as $aData)
{
set_time_limit(intval($iLoopTimeLimit));

File diff suppressed because it is too large Load Diff