'That reply no longer exists.']); exit; } $ticket_reply_type = escapeHtml($row['ticket_reply_type']); $ticket_reply_time_worked = date_create($row['ticket_reply_time_worked']); $ticket_reply_time_worked_formatted = date_format($ticket_reply_time_worked, 'H:i:s'); $ticket_reply = escapeHtml($row['ticket_reply']); $client_id = intval($row['ticket_client_id']); if ($client_id) { enforceClientAccess(); } // Emailing it from here - as the reply box can: mail set up and a contact with an email address - not on a closed ticket, // nor a second time $contact_email = (string) (mysqli_fetch_row(mysqli_query($mysqli, "SELECT contact_email FROM tickets JOIN contacts ON contact_id = ticket_contact_id WHERE ticket_id = " . intval($row['ticket_id'])))[0] ?? ''); $can_email = $row['ticket_reply_type'] !== 'Client' && empty($row['ticket_closed_at']) && intval($row['ticket_reply_emailed']) !== 1 && $contact_email !== '' && !empty($config_smtp_provider); $reply_to = $can_email && ticketReplyRecipientsReady() ? ticketReplyRecipients(intval($row['ticket_id'])) : []; $writer = $row['reply_by_name'] !== null ? (string) $row['reply_by_name'] : ''; // Who it was emailed to - they have it as it was sent $emailed_to = ''; if (intval($row['ticket_reply_emailed']) === 1) { $emailed_names = array_map(function ($recipient) { return (string) (($recipient['name'] ?? '') !== '' ? $recipient['name'] : ($recipient['email'] ?? '')); }, (array) json_decode((string) $row['ticket_reply_emailed_to'], true)); $emailed_names = array_values(array_filter($emailed_names)); $emailed_to = $emailed_names ? $emailed_names[0] . (count($emailed_names) > 1 ? ' and ' . (count($emailed_names) - 1) . ' more' : '') : 'the client'; } // Generate the HTML form content using output buffering. ob_start(); ?>