Skip to content

Commit

Permalink
feat(targetticket,targetcvhange,targetproblem): update actors array
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jun 27, 2022
1 parent be417f5 commit bce16be
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions inc/abstractitiltarget.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,30 @@ protected function initializeActors() {
];
}

public function cleanActors($data): array {
if (count($data['_users_id_requester']) < 1) {
unset($data['_users_id_requester']);
unset($data['_users_id_requester_notif']);
}

if (count($data['_users_id_observer']) < 1) {
unset($data['_users_id_observer']);
unset($data['_users_id_observer_notif']);
}

if (count($data['_users_id_assign']) < 1) {
unset($data['_users_id_assign']);
unset($data['_users_id_assign_notif']);
}

if (count($data['_suppliers_id_assign']) < 1) {
unset($data['_suppliers_id_assign']);
unset($data['_suppliers_id_assign_notif']);
}

return $data;
}

/**
* Set default values for the item to create
*
Expand Down
3 changes: 3 additions & 0 deletions inc/targetchange.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {

$this->appendFieldsData($formanswer, $data);

// Cleanup actors array
$data = $this->cleanActors($data);

// Create the target change
if (!$changeID = $change->add($data)) {
return null;
Expand Down
3 changes: 3 additions & 0 deletions inc/targetproblem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {

$this->appendFieldsData($formanswer, $data);

// Cleanup actors array
$data = $this->cleanActors($data);

// Create the target problem
if (!$problemID = $problem->add($data)) {
return null;
Expand Down
3 changes: 3 additions & 0 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {

$this->appendFieldsData($formanswer, $data);

// Cleanup actors array
$data = $this->cleanActors($data);

// Create the target ticket
$data['_auto_import'] = true;
if (!$ticketID = $ticket->add($data)) {
Expand Down

0 comments on commit bce16be

Please sign in to comment.