mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
#439 Record and display changes in the link sets (ex: Members of a team)
#439 Make sure that changes made by a plugin get recorded + simplified the change tracking for the plugins. Simply call DBObject::DBInsert (resp. Update and Delete) and the change will be recorded for the current page. This is compatible with the old (not mandatory anymore) way that was requiring DBInsertTracked APIs (resp. Update, Delete). SVN:trunk[2236]
This commit is contained in:
@@ -303,13 +303,6 @@ try
|
||||
$aPredefinedObjects = call_user_func(array($sClass, 'GetPredefinedObjects'));
|
||||
if ($aPredefinedObjects != null)
|
||||
{
|
||||
// Temporary... until this get really encapsulated as the default and transparent behavior
|
||||
$oMyChange = MetaModel::NewObject("CMDBChange");
|
||||
$oMyChange->Set("date", time());
|
||||
$sUserString = CMDBChange::GetCurrentUserName();
|
||||
$oMyChange->Set("userinfo", $sUserString);
|
||||
$iChangeId = $oMyChange->DBInsert();
|
||||
|
||||
// Create/Delete/Update objects of this class,
|
||||
// according to the given constant values
|
||||
//
|
||||
@@ -324,12 +317,12 @@ try
|
||||
{
|
||||
$oObj->Set($sAttCode, $value);
|
||||
}
|
||||
$oObj->DBUpdateTracked($oMyChange);
|
||||
$oObj->DBUpdate();
|
||||
$aDBIds[$oObj->GetKey()] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$oObj->DBDeleteTracked($oMyChange);
|
||||
$oObj->DBDelete();
|
||||
}
|
||||
}
|
||||
foreach ($aPredefinedObjects as $iRefId => $aObjValues)
|
||||
@@ -342,7 +335,7 @@ try
|
||||
{
|
||||
$oNewObj->Set($sAttCode, $value);
|
||||
}
|
||||
$oNewObj->DBInsertTracked($oMyChange);
|
||||
$oNewObj->DBInsert();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,13 +516,6 @@ class ApplicationInstaller
|
||||
if ($aPredefinedObjects != null)
|
||||
{
|
||||
SetupPage::log_info("$sClass::GetPredefinedObjects() returned ".count($aPredefinedObjects)." elements.");
|
||||
|
||||
// Temporary... until this get really encapsulated as the default and transparent behavior
|
||||
$oMyChange = MetaModel::NewObject("CMDBChange");
|
||||
$oMyChange->Set("date", time());
|
||||
$sUserString = CMDBChange::GetCurrentUserName();
|
||||
$oMyChange->Set("userinfo", $sUserString);
|
||||
$iChangeId = $oMyChange->DBInsert();
|
||||
|
||||
// Create/Delete/Update objects of this class,
|
||||
// according to the given constant values
|
||||
@@ -538,12 +531,12 @@ class ApplicationInstaller
|
||||
{
|
||||
$oObj->Set($sAttCode, $value);
|
||||
}
|
||||
$oObj->DBUpdateTracked($oMyChange);
|
||||
$oObj->DBUpdate();
|
||||
$aDBIds[$oObj->GetKey()] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$oObj->DBDeleteTracked($oMyChange);
|
||||
$oObj->DBDelete();
|
||||
}
|
||||
}
|
||||
foreach ($aPredefinedObjects as $iRefId => $aObjValues)
|
||||
@@ -556,7 +549,7 @@ class ApplicationInstaller
|
||||
{
|
||||
$oNewObj->Set($sAttCode, $value);
|
||||
}
|
||||
$oNewObj->DBInsertTracked($oMyChange);
|
||||
$oNewObj->DBInsert();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -622,12 +615,12 @@ class ApplicationInstaller
|
||||
|
||||
|
||||
$oDataLoader = new XMLDataLoader();
|
||||
$oChange = MetaModel::NewObject("CMDBChange");
|
||||
$oChange->Set("date", time());
|
||||
$oChange->Set("userinfo", "Initialization");
|
||||
$iChangeId = $oChange->DBInsert();
|
||||
|
||||
CMDBObject::SetTrackInfo("Initialization");
|
||||
$oMyChange = CMDBObject::GetCurrentChange();
|
||||
|
||||
SetupPage::log_info("starting data load session");
|
||||
$oDataLoader->StartSession($oChange);
|
||||
$oDataLoader->StartSession($oMyChange);
|
||||
|
||||
$aFiles = array();
|
||||
$oProductionEnv = new RunTimeEnvironment();
|
||||
|
||||
@@ -288,6 +288,27 @@ EOF;
|
||||
return $sRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to format the tracking level for linkset (direct or indirect attributes)
|
||||
* @param string $sTrackingLevel Value set from within the XML
|
||||
* Returns string PHP flag
|
||||
*/
|
||||
protected function TrackingLevelToPHP($sTrackingLevel)
|
||||
{
|
||||
static $aXmlToPHP = array(
|
||||
'none' => 'LINKSET_TRACKING_NONE',
|
||||
'list' => 'LINKSET_TRACKING_LIST',
|
||||
'details' => 'LINKSET_TRACKING_DETAILS',
|
||||
'all' => 'LINKSET_TRACKING_ALL',
|
||||
);
|
||||
|
||||
if (!array_key_exists($sTrackingLevel, $aXmlToPHP))
|
||||
{
|
||||
throw new exception("Tracking level: unknown value '$sTrackingLevel'");
|
||||
}
|
||||
return $aXmlToPHP[$sTrackingLevel];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format a path (file or url) as an absolute path or relative to the module or the app
|
||||
@@ -542,21 +563,29 @@ EOF;
|
||||
$aParameters['linked_class'] = $this->GetPropString($oField, 'linked_class', '');
|
||||
$aParameters['ext_key_to_me'] = $this->GetPropString($oField, 'ext_key_to_me', '');
|
||||
$aParameters['ext_key_to_remote'] = $this->GetPropString($oField, 'ext_key_to_remote', '');
|
||||
// todo - utile ?
|
||||
$aParameters['allowed_values'] = 'null';
|
||||
$aParameters['count_min'] = $this->GetPropNumber($oField, 'count_min', 0);
|
||||
$aParameters['count_max'] = $this->GetPropNumber($oField, 'count_max', 0);
|
||||
$aParameters['duplicates'] = $this->GetPropBoolean($oField, 'duplicates', false);
|
||||
$sTrackingLevel = $oField->GetChildText('tracking_level');
|
||||
if (!is_null($sTrackingLevel))
|
||||
{
|
||||
$aParameters['tracking_level'] = $this->TrackingLevelToPHP($sTrackingLevel);
|
||||
}
|
||||
$aParameters['depends_on'] = $sDependencies;
|
||||
}
|
||||
elseif ($sAttType == 'AttributeLinkedSet')
|
||||
{
|
||||
$aParameters['linked_class'] = $this->GetPropString($oField, 'linked_class', '');
|
||||
$aParameters['ext_key_to_me'] = $this->GetPropString($oField, 'ext_key_to_me', '');
|
||||
// todo - utile ?
|
||||
$aParameters['allowed_values'] = 'null';
|
||||
$aParameters['count_min'] = $this->GetPropNumber($oField, 'count_min', 0);
|
||||
$aParameters['count_max'] = $this->GetPropNumber($oField, 'count_max', 0);
|
||||
$sTrackingLevel = $oField->GetChildText('tracking_level');
|
||||
if (!is_null($sTrackingLevel))
|
||||
{
|
||||
$aParameters['tracking_level'] = $this->TrackingLevelToPHP($sTrackingLevel);
|
||||
}
|
||||
$aParameters['depends_on'] = $sDependencies;
|
||||
}
|
||||
elseif ($sAttType == 'AttributeExternalKey')
|
||||
|
||||
Reference in New Issue
Block a user