From a488c42dca962dcf3bba7bfaa74ddc4c84bdbd9f Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Fri, 16 Nov 2018 17:19:45 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B0721:=20ResolveFrom=20now=20only=20set=20?= =?UTF-8?q?attributes=20mandatory=20in=20resolved=20&=20closed=20states=20?= =?UTF-8?q?that=20aren't=20already=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datamodel.itop-incident-mgmt-itil.xml | 31 ++++++++++++++----- .../datamodel.itop-request-mgmt-itil.xml | 31 ++++++++++++++----- .../datamodel.itop-request-mgmt.xml | 29 ++++++++++++----- 3 files changed, 68 insertions(+), 23 deletions(-) diff --git a/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml b/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml index a5734437e..04cc671a7 100755 --- a/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml +++ b/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml @@ -1215,21 +1215,36 @@ false public Internal - Get('status') != 'resolved') + if ($this->Get('status') != 'resolved' && $this->Get('status') != 'closed' ) { - $this->Set('servicesubcategory_id', $oParentTicket->Get('servicesubcategory_id')); - $this->Set('service_id', $oParentTicket->Get('service_id')); - $this->Set('team_id', $oParentTicket->Get('team_id')); - $this->Set('agent_id', $oParentTicket->Get('agent_id')); - $this->Set('resolution_code', $oParentTicket->Get('resolution_code')); + $aDummy = array(); + $aExcludedAttributes = array('team_id', 'agent_id'); + foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef) + { + // Exclude inter dependant attributes to keep consistency + if(in_array($sAttCode, $aExcludedAttributes)) + { + continue; + } + + if (($this->GetAttributeFlags($sAttCode, $aDummy, 'resolved') & OPT_ATT_MANDATORY) && empty($this->Get($sAttCode))) + { + $this->Set($sAttCode, $oParentTicket->Get($sAttCode)); + } + } + if (($this->Get('team_id') == 0) || ($this->Get('agent_id') ==0)) + { + $this->Set('team_id', $oParentTicket->Get('team_id')); + $this->Set('agent_id', $oParentTicket->Get('agent_id')); + } $sParent = '[['.get_class($oParentTicket).':'.$oParentTicket->Get('ref').']]'; $this->Set('solution', Dict::Format('Tickets:ResolvedFrom', $sParent, MetaModel::GetName(get_class($oParentTicket)))); $this->ApplyStimulus('ev_autoresolve'); $this->DBUpdate(); } - }]]> + }]]> false diff --git a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml index effe9bf40..073fba1d7 100755 --- a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml +++ b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml @@ -1315,21 +1315,36 @@ false public Internal - Get('status') != 'resolved') + if ($this->Get('status') != 'resolved' && $this->Get('status') != 'closed' ) { - $this->Set('servicesubcategory_id', $oParentTicket->Get('servicesubcategory_id')); - $this->Set('service_id', $oParentTicket->Get('service_id')); - $this->Set('team_id', $oParentTicket->Get('team_id')); - $this->Set('agent_id', $oParentTicket->Get('agent_id')); - $this->Set('resolution_code', $oParentTicket->Get('resolution_code')); + $aDummy = array(); + $aExcludedAttributes = array('team_id', 'agent_id'); + foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef) + { + // Exclude inter dependant attributes to keep consistency + if(in_array($sAttCode, $aExcludedAttributes)) + { + continue; + } + + if (($this->GetAttributeFlags($sAttCode, $aDummy, 'resolved') & OPT_ATT_MANDATORY) && empty($this->Get($sAttCode))) + { + $this->Set($sAttCode, $oParentTicket->Get($sAttCode)); + } + } + if (($this->Get('team_id') == 0) || ($this->Get('agent_id') ==0)) + { + $this->Set('team_id', $oParentTicket->Get('team_id')); + $this->Set('agent_id', $oParentTicket->Get('agent_id')); + } $sParent = '[['.get_class($oParentTicket).':'.$oParentTicket->Get('ref').']]'; $this->Set('solution', Dict::Format('Tickets:ResolvedFrom', $sParent, MetaModel::GetName(get_class($oParentTicket)))); $this->ApplyStimulus('ev_autoresolve'); $this->DBUpdate(); } - }]]> + }]]> false diff --git a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml index 1b5f9db17..c7122fa83 100755 --- a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml +++ b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml @@ -1340,19 +1340,34 @@ Internal Get('status') != 'resolved') + if ($this->Get('status') != 'resolved' && $this->Get('status') != 'closed' ) { - $this->Set('servicesubcategory_id', $oParentTicket->Get('servicesubcategory_id')); - $this->Set('service_id', $oParentTicket->Get('service_id')); - $this->Set('team_id', $oParentTicket->Get('team_id')); - $this->Set('agent_id', $oParentTicket->Get('agent_id')); - $this->Set('resolution_code', $oParentTicket->Get('resolution_code')); + $aDummy = array(); + $aExcludedAttributes = array('team_id', 'agent_id'); + foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef) + { + // Exclude inter dependant attributes to keep consistency + if(in_array($sAttCode, $aExcludedAttributes)) + { + continue; + } + + if (($this->GetAttributeFlags($sAttCode, $aDummy, 'resolved') & OPT_ATT_MANDATORY) && empty($this->Get($sAttCode))) + { + $this->Set($sAttCode, $oParentTicket->Get($sAttCode)); + } + } + if (($this->Get('team_id') == 0) || ($this->Get('agent_id') ==0)) + { + $this->Set('team_id', $oParentTicket->Get('team_id')); + $this->Set('agent_id', $oParentTicket->Get('agent_id')); + } $sParent = '[['.get_class($oParentTicket).':'.$oParentTicket->Get('ref').']]'; $this->Set('solution', Dict::Format('Tickets:ResolvedFrom', $sParent, MetaModel::GetName(get_class($oParentTicket)))); $this->ApplyStimulus('ev_autoresolve'); $this->DBUpdate(); } - }]]> + }]]> false