diff --git a/inc/ticket.class.php b/inc/ticket.class.php index fc984b0689..078c1ba8c0 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -1770,17 +1770,24 @@ function prepareInputForAdd($input) { // Replay setting auto assign if set in rules engine or by auto_assign_mode // Do not force status if status has been set by rules - if (((isset($input["_users_id_assign"]) - && ((!is_array($input['_users_id_assign']) && $input["_users_id_assign"] > 0) - || is_array($input['_users_id_assign']) && count($input['_users_id_assign']) > 0)) - || (isset($input["_groups_id_assign"]) - && ((!is_array($input['_groups_id_assign']) && $input["_groups_id_assign"] > 0) - || is_array($input['_groups_id_assign']) && count($input['_groups_id_assign']) > 0)) - || (isset($input["_suppliers_id_assign"]) - && ((!is_array($input['_suppliers_id_assign']) && $input["_suppliers_id_assign"] > 0) - || is_array($input['_suppliers_id_assign']) && count($input['_suppliers_id_assign']) > 0))) - && (in_array($input['status'], $this->getNewStatusArray())) - && !$this->isStatusComputationBlocked($input)) { + if (( + $this->isSomeoneAssigned($input, '_users_id_assign') + || + $this->isSomeoneAssigned($input, '_groups_id_assign') + || + $this->isSomeoneAssigned($input, '_suppliers_id_assign') + || + $this->isSomeoneAssigned($input, '_additional_assigns') + || + $this->isSomeoneAssigned($input, '_additional_groups_assigns') + || + $this->isSomeoneAssigned($input, '_additional_suppliers_assigns') + ) + && + ( + in_array($input['status'], $this->getNewStatusArray()) + ) + && !$this->isStatusComputationBlocked($input)) { $input["status"] = self::ASSIGNED; } @@ -7440,4 +7447,30 @@ static function getIcon() { public static function getItemLinkClass(): string { return Item_Ticket::class; } + + /** + * Check if input contains a person or a group assigned. + * + * @param array $input + * + * @return boolean + */ + private function isSomeoneAssigned(array $input, $key) { + return ( + isset($input[$key]) + && + ( + ( + !is_array($input[$key]) + && $input[$key] > 0 + ) + || + ( + is_array($input[$key]) + && count($input[$key]) > 0 + ) + ) + ); + } + } diff --git a/tests/functionnal/Ticket.php b/tests/functionnal/Ticket.php index a3f95e9b43..3e164014bb 100644 --- a/tests/functionnal/Ticket.php +++ b/tests/functionnal/Ticket.php @@ -2502,6 +2502,27 @@ protected function statusComputationOnCreateProvider() { ], 'expected' => \CommonITILObject::WAITING, // status not changed as not "new" ], + [ + 'input' => [ + '_additional_assigns' => ['4'], // "tech" + 'status' => \CommonITILObject::INCOMING, + ], + 'expected' => \CommonITILObject::ASSIGNED, // incoming changed to assign as actors are set + ], + [ + 'input' => [ + '_additional_groups_assigns' => [$group_id], // "group" + 'status' => \CommonITILObject::INCOMING, + ], + 'expected' => \CommonITILObject::ASSIGNED, // incoming changed to assign as groups are set + ], + [ + 'input' => [ + '_additional_suppliers_assigns' => ['1'], // "supplier" + 'status' => \CommonITILObject::INCOMING, + ], + 'expected' => \CommonITILObject::ASSIGNED, // incoming changed to assign as suppliers are set + ], ]; }