Data synchro: if the object is deleted from within iTop, do cleanup sync table and replica as well

SVN:trunk[1223]
This commit is contained in:
Romain Quetiez
2011-04-21 09:04:34 +00:00
parent 69f21b9b79
commit b7bd1a5943
3 changed files with 26 additions and 14 deletions

View File

@@ -1300,13 +1300,20 @@ class SynchroReplica extends DBObject implements iDisplay
// Overload the deletion -> the replica has been created by the mean of a trigger,
// it will be deleted by the mean of a trigger too
public function DBDelete(&$oDeletionPlan = null)
protected function DBDeleteSingleObject()
{
$oDataSource = MetaModel::GetObject('SynchroDataSource', $this->Get('sync_source_id'));
$sTable = $oDataSource->GetDataTable();
$this->OnDelete();
$sSQL = "DELETE FROM `$sTable` WHERE id = '{$this->GetKey()}'";
CMDBSource::Query($sSQL);
if (!MetaModel::DBIsReadOnly())
{
$oDataSource = MetaModel::GetObject('SynchroDataSource', $this->Get('sync_source_id'));
$sTable = $oDataSource->GetDataTable();
$sSQL = "DELETE FROM `$sTable` WHERE id = '{$this->GetKey()}'";
CMDBSource::Query($sSQL);
}
$this->AfterDelete();
$this->m_bIsInDB = false;
$this->m_iKey = null;