Compute impacted CIs and Contacts and attach them to the ticket

SVN:trunk[590]
This commit is contained in:
Romain Quetiez
2010-07-07 10:10:37 +00:00
parent b7d6771ddb
commit f399489175
2 changed files with 59 additions and 0 deletions

View File

@@ -247,9 +247,37 @@ abstract class Change extends Ticket
protected function OnInsert()
{
$oToNotify = $this->Get('contact_list');
$oToImpact = $this->Get('ci_list');
$oImpactedInfras = DBObjectSet::FromLinkSet($this, 'ci_list', 'ci_id');
$aComputed = $oImpactedInfras->GetRelatedObjects('impacts', 10);
if (isset($aComputed['FunctionalCI']) && is_array($aComputed['FunctionalCI']))
{
foreach($aComputed['FunctionalCI'] as $iKey => $oObject)
{
$oNewLink = new lnkTicketToCI();
$oNewLink->Set('ci_id', $iKey);
$oToImpact->AddObject($oNewLink);
}
}
if (isset($aComputed['Contact']) && is_array($aComputed['Contact']))
{
foreach($aComputed['Contact'] as $iKey => $oObject)
{
$oNewLink = new lnkTicketToContact();
$oNewLink->Set('contact_id', $iKey);
$oNewLink->Set('role', 'contact automatically computed');
$oToNotify->AddObject($oNewLink);
}
}
$this->Set('creation_date', time());
$this->Set('last_update', time());
}
protected function OnUpdate()
{
$this->Set('last_update', time());

View File

@@ -61,6 +61,37 @@ class Incident extends ResponseTicket
$this->Set('ref', $sName);
return parent::ComputeValues();
}
protected function OnInsert()
{
$oToNotify = $this->Get('contact_list');
$oToImpact = $this->Get('ci_list');
$oImpactedInfras = DBObjectSet::FromLinkSet($this, 'ci_list', 'ci_id');
$aComputed = $oImpactedInfras->GetRelatedObjects('impacts', 10);
if (isset($aComputed['FunctionalCI']) && is_array($aComputed['FunctionalCI']))
{
foreach($aComputed['FunctionalCI'] as $iKey => $oObject)
{
$oNewLink = new lnkTicketToCI();
$oNewLink->Set('ci_id', $iKey);
$oToImpact->AddObject($oNewLink);
}
}
if (isset($aComputed['Contact']) && is_array($aComputed['Contact']))
{
foreach($aComputed['Contact'] as $iKey => $oObject)
{
$oNewLink = new lnkTicketToContact();
$oNewLink->Set('contact_id', $iKey);
$oNewLink->Set('role', 'contact automatically computed');
$oToNotify->AddObject($oNewLink);
}
}
parent::OnInsert();
}
}
$oMyMenuGroup = new MenuGroup('IncidentManagement', 40 /* fRank */);