#792 Duplicate entries in the parent/child tickets when updating the case log and applying a stimulus (e.g. Close the WO) at the same time.

SVN:trunk[2930]
This commit is contained in:
Romain Quetiez
2013-10-18 15:54:54 +00:00
parent 26dca89b19
commit edce93282b
4 changed files with 41 additions and 96 deletions

View File

@@ -1534,14 +1534,10 @@
{
if (!MetaModel::IsValidClass('UserRequest')) return true; // Do nothing
$sLogPublic = utils::ReadPostedParam('attr_public_log', null,false,'raw_data');
if ( $sLogPublic != null)
$oLog = $this->Get('public_log');
$sLogPublic = $oLog->GetModifiedEntry();
if ($sLogPublic != '')
{
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString."(automatic update)");
$iChangeId = $oMyChange->DBInsert();
$sOQL = "SELECT UserRequest WHERE parent_incident_id=:ticket";
$oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
array(),
@@ -1552,18 +1548,14 @@
while($oRequest = $oChildRequestSet->Fetch())
{
$oRequest->set('public_log',$sLogPublic);
$oRequest->DBUpdateTracked($oMyChange);
$oRequest->DBUpdate();
}
}
$sLogPrivate = utils::ReadPostedParam('attr_private_log', null,false,'raw_data');
if ( $sLogPrivate != null)
$oLog = $this->Get('private_log');
$sLogPrivate = $oLog->GetModifiedEntry();
if ($sLogPrivate != '')
{
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString."(automatic update)");
$iChangeId = $oMyChange->DBInsert();
$sOQL = "SELECT UserRequest WHERE parent_incident_id=:ticket";
$oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
array(),
@@ -1574,7 +1566,7 @@
while($oRequest = $oChildRequestSet->Fetch())
{
$oRequest->set('private_log',$sLogPrivate);
$oRequest->DBUpdateTracked($oMyChange);
$oRequest->DBUpdate();
}
}
return true;
@@ -1587,14 +1579,10 @@
<type>LifecycleAction</type>
<code><![CDATA[ public function UpdateChildIncidentLog()
{
$sLogPublic = utils::ReadPostedParam('attr_public_log', null,false,'raw_data');
if ( $sLogPublic != null)
$oLog = $this->Get('public_log');
$sLogPublic = $oLog->GetModifiedEntry();
if ($sLogPublic != '')
{
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString."(automatic update)");
$iChangeId = $oMyChange->DBInsert();
$sOQL = "SELECT Incident WHERE parent_incident_id=:ticket";
$oChildIncidentSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
array(),
@@ -1605,18 +1593,14 @@
while($oIncident = $oChildIncidentSet->Fetch())
{
$oIncident->set('public_log',$sLogPublic);
$oIncident->DBUpdateTracked($oMyChange);
$oIncident->DBUpdate();
}
}
$sLogPrivate = utils::ReadPostedParam('attr_private_log', null,false,'raw_data');
if ( $sLogPrivate != null)
$oLog = $this->Get('private_log');
$sLogPrivate = $oLog->GetModifiedEntry();
if ($sLogPrivate != '')
{
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString."(automatic update)");
$iChangeId = $oMyChange->DBInsert();
$sOQL = "SELECT Incident WHERE parent_incident_id=:ticket";
$oChildIncidentSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
array(),
@@ -1627,7 +1611,7 @@
while($oIncident = $oChildIncidentSet->Fetch())
{
$oIncident->set('private_log',$sLogPrivate);
$oIncident->DBUpdateTracked($oMyChange);
$oIncident->DBUpdate();
}
}
return true;