Forráskód Böngészése

Compute impacted CIs and Contacts and attach them to the ticket

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@590 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 éve
szülő
commit
8ae4a4336d

+ 28 - 0
modules/itop-change-mgmt-1.0.0/model.itop-change-mgmt.php

@@ -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());

+ 31 - 0
modules/itop-incident-mgmt-1.0.0/model.itop-incident-mgmt.php

@@ -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 */);