From 764c3bc0315096f0e43f900b21951b42c4d87f46 Mon Sep 17 00:00:00 2001 From: btry Date: Mon, 5 Mar 2018 10:57:39 +0100 Subject: [PATCH] fix(ticket): use default values to set actors of tickets This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally fix #629 --- inc/targetticket.class.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/inc/targetticket.class.php b/inc/targetticket.class.php index f79effc8bf..a6143de811 100644 --- a/inc/targetticket.class.php +++ b/inc/targetticket.class.php @@ -1065,7 +1065,7 @@ public function save(PluginFormcreatorForm_Answer $formanswer) { '_groups_id_assign' => [], ]; - $data = []; + $data = Ticket::getDefaultValues(); $ticket = new Ticket(); $form = $formanswer->getForm(); $answer = new PluginFormcreatorAnswer(); @@ -1238,8 +1238,28 @@ public function save(PluginFormcreatorForm_Answer $formanswer) { $data = $this->setTargetLocation($data, $formanswer); - $data = $this->requesters + $this->observers + $this->assigned + $this->assignedSuppliers + $data; - $data = $this->requesterGroups + $this->observerGroups + $this->assignedGroups + $data; + // Overwrite default actors only if populated + if (!is_array($this->requesters['_users_id_requester'])) { + $data = $data + $this->requesters; + } + if (!is_array($this->observers['_users_id_observer'])) { + $data = $data + $this->observers; + } + if (!is_array($this->assigned['_users_id_assign'])) { + $data = $data + $this->assigned; + } + if (!is_array($this->assignedSuppliers['_suppliers_id_assign'])) { + $data = $data + $this->assignedSuppliers; + } + if (!is_array($this->requesterGroups['_groups_id_requester'])) { + $data = $data + $this->requesterGroups; + } + if (!is_array($this->observerGroups['_groups_id_observer'])) { + $data = $data + $this->observerGroups; + } + if (!is_array($this->assignedGroups['_groups_id_assign'])) { + $data = $data + $this->assignedGroups; + } // Create the target ticket if (!$ticketID = $ticket->add($data)) {