N°9617 - Send events on data export for traceability

This commit is contained in:
Eric Espie
2026-05-18 10:08:20 +02:00
parent 48e6203869
commit 4aa1f8ae18
9 changed files with 54 additions and 1 deletions

View File

@@ -5356,6 +5356,7 @@ JS
/**
* @param array $aChanges
* @param bool $bIsNew
* @param string|null $sStimulusBeingApplied
*
* @return void
* @throws \ArchivedObjectException
@@ -5369,6 +5370,21 @@ JS
$this->FireEvent(EVENT_DB_AFTER_WRITE, ['is_new' => $bIsNew, 'changes' => $aChanges, 'stimulus_applied' => $sStimulusBeingApplied, 'cmdb_change' => self::GetCurrentChange()]);
}
//////////////
/// READ
///
/**
* @return void
* @throws \CoreException
* @since 3.3.0
*/
final public function FireEventReadDetails(): void
{
$this->FireEvent(EVENT_DB_TRACEABILITY);
}
//////////////
/// DELETE
///

View File

@@ -519,6 +519,23 @@ Call $this->AddInitialAttributeFlags($sAttCode, $iFlags) for all the initial att
</event_datum>
</event_data>
</event>
<event id="EVENT_DB_TRACEABILITY" _delta="define">
<name>Object details read from outside iTop</name>
<description><![CDATA[An object details has been read during an export]]></description>
<sources>
<source id="cmdbAbstractObject">cmdbAbstractObject</source>
</sources>
<event_data>
<event_datum id="object">
<description>The object unarchived</description>
<type>DBObject</type>
</event_datum>
<event_datum id="debug_info">
<description>Debug string</description>
<type>string</type>
</event_datum>
</event_data>
</event>
<event id="EVENT_DOWNLOAD_DOCUMENT" _delta="define">
<name>Document downloaded</name>
<description><![CDATA[A document has been downloaded from the GUI]]></description>

View File

@@ -340,6 +340,7 @@ EOF
$sField = '';
$oObj = $aRow[$sAlias];
$oObj->FireEventReadDetails();
if ($oObj != null) {
switch ($sAttCode) {
case 'id':

View File

@@ -6247,7 +6247,9 @@ abstract class DBObject implements iDisplay
}
/**
* @param array $aChanges
* @param bool $bIsNew
* @param string|null $sStimulusBeingApplied
*
* @return void
* @since 3.1.0
@@ -6256,6 +6258,18 @@ abstract class DBObject implements iDisplay
{
}
//////////////
/// READ
///
/**
* @return void
* @since 3.3.0
*/
public function FireEventReadDetails(): void
{
}
//////////////
/// DELETE
///

View File

@@ -293,6 +293,7 @@ EOF
$sAttCode = $aFieldSpec['sAttCode'];
$oObj = $aRow[$sAlias];
$oObj->FireEventReadDetails();
$sField = '';
if ($oObj) {
$sField = $this->GetValue($oObj, $sAttCode);

View File

@@ -144,6 +144,7 @@ class HTMLBulkExport extends TabularBulkExport
$sAttCode = $aFieldSpec['sAttCode'];
$oObj = $aRow[$sAlias];
$oObj->FireEventReadDetails();
$sField = '';
if ($oObj) {
$sField = $this->GetValue($oObj, $sAttCode);

View File

@@ -531,6 +531,7 @@ class CoreServices implements iRestServiceProvider, iRestInputSanitizer
}
while ($oObject = $oObjectSet->Fetch()) {
$oObject->FireEventReadDetails();
$oResult->AddObject(0, '', $oObject, $aShowFields, $bExtendedOutput);
}
$oResult->message = "Found: ".$oObjectSet->Count();
@@ -605,6 +606,7 @@ class CoreServices implements iRestServiceProvider, iRestInputSanitizer
if ($oElement instanceof RelationObjectNode) {
$oObject = $oElement->GetProperty('object');
if ($oObject) {
$oObject->FireEventReadDetails();
if ($bEnableRedundancy && $sDirection == 'down') {
// Add only the "reached" objects
if ($oElement->GetProperty('is_reached')) {

View File

@@ -233,7 +233,6 @@ EOF
public function GetNextChunk(&$aStatus)
{
$sRetCode = 'run';
$iPercentage = 0;
$oSet = new DBObjectSet($this->oSearch);
$oSet->SetLimit($this->iChunkSize, $this->aStatusInfo['position']);
@@ -261,6 +260,7 @@ EOF
$sField = '';
/** @var \DBObject $oObj */
$oObj = $aRow[$sAlias];
$oObj->FireEventReadDetails();
if ($oObj == null) {
$sData .= "<td x:str></td>";
continue;

View File

@@ -146,6 +146,7 @@ class XMLBulkExport extends BulkExport
}
foreach ($aAuthorizedClasses as $sAlias => $sClassName) {
$oObj = $aObjects[$sAlias];
$oObj->FireEventReadDetails();
if (is_null($oObj)) {
$sData .= "<$sClassName alias=\"$sAlias\" id=\"null\">\n";
} else {