From e0f7460e08636bcd6357d74b2ba8dd5cc478ee53 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Mon, 19 Jan 2026 17:01:38 -0500 Subject: [PATCH] If not client_id then do not include &client_id= in ticket uris as this would cause ticket viewing to break if client_id is 0. --- cron/cron.php | 8 +++++++- cron/ticket_email_parser.php | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cron/cron.php b/cron/cron.php index d6f943e1..fb9634d8 100644 --- a/cron/cron.php +++ b/cron/cron.php @@ -317,6 +317,12 @@ if (mysqli_num_rows($sql_recurring_tickets) > 0) { $ticket_status = 2; // Set to open if we've auto-assigned an agent } + if ($client_id) { + $client_uri = "&client_id=$client_id"; + } else { + $client_uri = ''; + } + // Atomically increment and get the new ticket number mysqli_query($mysqli, " UPDATE settings @@ -391,7 +397,7 @@ if (mysqli_num_rows($sql_recurring_tickets) > 0) { if (filter_var($config_ticket_new_ticket_notification_email, FILTER_VALIDATE_EMAIL)) { $email_subject = "ITFlow - New Recurring Ticket - $client_name: $ticket_subject"; - $email_body = "Hello,

This is a notification that a recurring (scheduled) ticket has been raised in ITFlow.
Ticket: $ticket_prefix$ticket_number
Client: $client_name
Priority: $priority
Link: https://$config_base_url/agent/ticket.php?ticket_id=$id&client_id=$client_id

--------------------------------

$ticket_subject
$ticket_details"; + $email_body = "Hello,

This is a notification that a recurring (scheduled) ticket has been raised in ITFlow.
Ticket: $ticket_prefix$ticket_number
Client: $client_name
Priority: $priority
Link: https://$config_base_url/agent/ticket.php?ticket_id=$id$client_uri

--------------------------------

$ticket_subject
$ticket_details"; $email = [ 'from' => $config_ticket_from_email, diff --git a/cron/ticket_email_parser.php b/cron/ticket_email_parser.php index c209fef6..7bcd352f 100644 --- a/cron/ticket_email_parser.php +++ b/cron/ticket_email_parser.php @@ -249,13 +249,18 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac $ticket_reply_contact = intval($row['ticket_contact_id']); $ticket_contact_email = sanitizeInput($row['contact_email']); $client_id = intval($row['ticket_client_id']); + if ($client_id) { + $client_uri = "&client_id=$client_id"; + } else { + $client_uri = ''; + } $client_name = sanitizeInput($row['client_name']); if ($ticket_status == 5) { $config_ticket_prefix_esc = mysqli_real_escape_string($mysqli, $config_ticket_prefix); $ticket_number_esc2 = mysqli_real_escape_string($mysqli, $ticket_number); - appNotify("Ticket", "Email parser: $from_email attempted to re-open ticket $config_ticket_prefix_esc$ticket_number_esc2 (ID $ticket_id) - check inbox manually to see email", "/agent/ticket.php?ticket_id=$ticket_id&client_id=$client_id", $client_id); + appNotify("Ticket", "Email parser: $from_email attempted to re-open ticket $config_ticket_prefix_esc$ticket_number_esc2 (ID $ticket_id) - check inbox manually to see email", "/agent/ticket.php?ticket_id=$ticket_id$client_uri", $client_id); $email_subject = "Action required: This ticket is already closed"; $email_body = "Hi there,

You've tried to reply to a ticket that is closed - we won't see your response.

Please raise a new ticket by sending a new e-mail to our support address below.

--
$company_name - Support
$config_ticket_from_email
$company_phone"; @@ -327,7 +332,7 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac $tech_name = sanitizeInput($tech_row['user_name']); $email_subject = "$config_app_name - Ticket updated - [$config_ticket_prefix$ticket_number] $ticket_subject"; - $email_body = "Hello $tech_name,

A new reply has been added to the below ticket.

Client: $client_name
Ticket: $config_ticket_prefix$ticket_number
Subject: $ticket_subject
Link: https://$config_base_url/agent/ticket.php?ticket_id=$ticket_id&client_id=$client_id

--------------------------------
$message_esc"; + $email_body = "Hello $tech_name,

A new reply has been added to the below ticket.

Client: $client_name
Ticket: $config_ticket_prefix$ticket_number
Subject: $ticket_subject
Link: https://$config_base_url/agent/ticket.php?ticket_id=$ticket_id$client_uri

--------------------------------
$message_esc"; $data = [ [