Skip to content

Commit

Permalink
fix(ticket): use default values to set actors of tickets
Browse files Browse the repository at this point in the history
This fix solves issues with Behaiours plugin < 2.0.2 and creates tickets like GLPI does internally

fix pluginsGLPI#629
  • Loading branch information
btry committed Mar 21, 2018
1 parent fb2c711 commit 764c3bc
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 764c3bc

Please sign in to comment.