diff --git a/inc/targetticket.class.php b/inc/targetticket.class.php index f79effc8bf..8ff00eac11 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,27 @@ 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; + $data = $data + $this->requesters; + + // Overwrite default actors only if populated + if (count($this->observers['_users_id_observer']) > 0) { + $data = $data + $this->observers; + } + if (count($this->assigned['_users_id_assign']) > 0) { + $data = $data + $this->assigned; + } + if (count($this->assignedSuppliers['_suppliers_id_assign']) > 0) { + $data = $data + $this->assignedSuppliers; + } + if (count($this->requesterGroups['_groups_id_requester']) > 0) { + $data = $data + $this->requesterGroups; + } + if (count($this->observerGroups['_groups_id_observer']) > 0) { + $data = $data + $this->observerGroups; + } + if (count($this->assignedGroups['_groups_id_assign']) > 0) { + $data = $data + $this->assignedGroups; + } // Create the target ticket if (!$ticketID = $ticket->add($data)) {