From 923dd4f62fade698412d3e95b0064584c0d2d91c Mon Sep 17 00:00:00 2001 From: Stanislas Date: Thu, 26 Dec 2024 12:55:29 +0100 Subject: [PATCH] Fix(Core): take care of mandatory field (#240) * Fix(Core): take care of mandatory field fix CS * adapt changelog * fix changelog --- CHANGELOG.md | 1 + front/ticket.form.php | 40 ++++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 968b5968..19aa87a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Redirect users without ticket rights after escalation. +- Fix private task added when ticket mandatory fields are not filled ## [2.9.10] - 2024-11-27 diff --git a/front/ticket.form.php b/front/ticket.form.php index 214aed05..18f3b79a 100644 --- a/front/ticket.form.php +++ b/front/ticket.form.php @@ -70,24 +70,28 @@ $_form_object['status'] = $_SESSION['plugins']['escalade']['config']['ticket_last_status']; } $updates_ticket = new Ticket(); - $updates_ticket->update($_POST['ticket_details'] + [ - '_actors' => PluginEscaladeTicket::getTicketFieldsWithActors($tickets_id, $group_id), - '_plugin_escalade_no_history' => true, // Prevent a duplicated task to be added - 'actortype' => CommonITILActor::ASSIGN, - 'groups_id' => $group_id, - '_form_object' => $_form_object, - ]); - - $task = new TicketTask(); - $task->add([ - 'tickets_id' => $tickets_id, - 'is_private' => true, - 'state' => Planning::INFO, - // Sanitize before merging with $_POST['comment'] which is already sanitized - 'content' => Sanitizer::sanitize( - '

' . sprintf(__('Escalation to the group %s.', 'escalade'), Sanitizer::unsanitize($group->getName())) . '


' - ) . $_POST['comment'] - ]); + if ( + $updates_ticket->update( + $_POST['ticket_details'] + [ + '_actors' => PluginEscaladeTicket::getTicketFieldsWithActors($tickets_id, $group_id), + '_plugin_escalade_no_history' => true, // Prevent a duplicated task to be added + 'actortype' => CommonITILActor::ASSIGN, + 'groups_id' => $group_id, + '_form_object' => $_form_object, + ] + ) + ) { + $task = new TicketTask(); + $task->add([ + 'tickets_id' => $tickets_id, + 'is_private' => true, + 'state' => Planning::INFO, + // Sanitize before merging with $_POST['comment'] which is already sanitized + 'content' => Sanitizer::sanitize( + '

' . sprintf(__('Escalation to the group %s.', 'escalade'), Sanitizer::unsanitize($group->getName())) . '


' + ) . $_POST['comment'] + ]); + } } $track = new Ticket();