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 #629
  • Loading branch information
btry committed Apr 23, 2018
1 parent ffead90 commit fa3f816
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 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 @@ -1231,15 +1231,32 @@ public function save(PluginFormcreatorForm_Answer $formanswer) {
}

$data = $this->setTargetDueDate($data, $formanswer);

$data = $this->setTargetUrgency($data, $formanswer);

$data = $this->setTargetCategory($data, $formanswer);

$data = $this->setTargetLocation($data, $formanswer);

$data = $this->requesters + $this->observers + $this->assigned + $this->assignedSuppliers + $data;
$data = $this->requesterGroups + $this->observerGroups + $this->assignedGroups + $data;
// There is always at least one requester
$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)) {
Expand Down

0 comments on commit fa3f816

Please sign in to comment.