Improved the change tracking to simplify the development of plugins (1st step... still to be drastically simplified)

SVN:1.2[1847]
This commit is contained in:
Romain Quetiez
2012-02-08 14:24:45 +00:00
parent 7e6d1c2ce4
commit 81145d7b1c
3 changed files with 25 additions and 0 deletions

View File

@@ -93,6 +93,23 @@ abstract class CMDBObject extends DBObject
protected static $m_oCurrChange = null;
public static function SetCurrentChange(CMDBChange $oChange)
{
self::$m_oCurrChange = $oChange;
}
//
// Todo: simplify the APIs and do not pass the current change as an argument anymore
// SetCurrentChange to be invoked in very few cases (UI.php, CSV import, Data synchro)
// GetCurrentChange to be called ONCE (!) by CMDBChangeOp::OnInsert ($this->Set('change', ..GetCurrentChange())
// GetCurrentChange to create a default change if not already done in the current context
//
public static function GetCurrentChange()
{
return self::$m_oCurrChange;
}
private function RecordObjCreation(CMDBChange $oChange)
{
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpCreate");

View File

@@ -1303,6 +1303,11 @@ abstract class DBObject
return $this->DBInsert();
}
public function DBInsertTrackedNoReload(CMDBChange $oVoid)
{
return $this->DBInsertNoReload();
}
// Creates a copy of the current object into the database
// Returns the id of the newly created object
public function DBClone($iNewKey = null)

View File

@@ -304,6 +304,9 @@ try
$sUserString .= ' (CSV)';
$oMyChange->Set("userinfo", $sUserString);
$iChangeId = $oMyChange->DBInsert();
// Todo - simplify that when reworking the change tracking
CMDBObject::SetCurrentChange($oMyChange);
}
$oBulk = new BulkChange(