From d4bbc72b1bee0f3291341d1481c4be306a2c25e1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jun 2022 14:31:22 +0200 Subject: [PATCH 1/3] fix: 21139 --- htdocs/ticket/card.php | 3 ++- htdocs/ticket/class/ticket.class.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index f46a9ecc61d..b5759d194d4 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -387,6 +387,7 @@ if (empty($reshook)) { // Si déjà un user assigné on le supprime des contacts if ($useroriginassign > 0) { $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); + foreach ($internal_contacts as $key => $contact) { if ($contact['id'] !== $usertoassign) { $result = $object->delete_contact($contact['rowid']); @@ -1055,7 +1056,7 @@ if ($action == 'create' || $action == 'presend') { print ''; print ''; //print ' '; - print $form->select_dolusers($user->id, 'fk_user_assign', 1); + print $form->select_dolusers(empty($object->fk_user_assign)?$user->id:$object->fk_user_assign, 'fk_user_assign', 1); print ' '; print ''; } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index e267ffce6c1..3ac3727af13 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -496,6 +496,13 @@ class Ticket extends CommonObject } } + if (!$error && $this->fk_user_assign > 0) { + if ($this->add_contact($this->fk_user_assign, 'SUPPORTTEC', 'internal') < 0) { + $error++; + } + } + + //Update extrafield if (!$error) { $result = $this->insertExtraFields(); @@ -2194,6 +2201,10 @@ class Ticket extends CommonObject $sql .= " AND tc.source = 'external'"; } + if (!empty($code)) { + $sql .= " AND tc.code = '".$this->db->escape($code)."'"; + } + $sql .= " AND tc.active=1"; if ($status >= 0) { $sql .= " AND ec.statut = ".((int) $status); From 85f95e86b727b02944777780c7080ee473d864aa Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jun 2022 14:39:19 +0200 Subject: [PATCH 2/3] fix: 21139 --- htdocs/ticket/contact.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 89822df2676..ee76045ffec 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -137,6 +137,16 @@ if ($action == 'swapstatut' && $user->rights->ticket->write) { // Efface un contact if ($action == 'deletecontact' && $user->rights->ticket->write) { if ($object->fetch($id, '', $track_id)) { + $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); + foreach ($internal_contacts as $key => $contact) { + if ($contact['rowid'] == $lineid && $object->fk_user_assign==$contact['id']) { + $ret = $object->assignUser($user, null); + if ($ret < 0) { + $error ++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } $result = $object->delete_contact($lineid); if ($result >= 0) { From 0bff392de8e10f32d1c56d6fa33c3369aaf02108 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jun 2022 14:40:21 +0200 Subject: [PATCH 3/3] fix: 21139 --- htdocs/ticket/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index b5759d194d4..efa2eba0999 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -387,7 +387,6 @@ if (empty($reshook)) { // Si déjà un user assigné on le supprime des contacts if ($useroriginassign > 0) { $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); - foreach ($internal_contacts as $key => $contact) { if ($contact['id'] !== $usertoassign) { $result = $object->delete_contact($contact['rowid']);