diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68522cb4b..b5ef33427 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ This file documents all notable changes made to ITFlow.
### Upgrading to 26.12.3
-Update from Maintenance > Update as usual - this release has twelve database changes: 4.2.2 adds a table for passkeys and a setting to turn them on or off, 4.2.3 lets a document keep the Markdown it was written in, 4.2.4 lets a ticket keep its pictures as files, 4.2.5 adds identity providers, 4.2.6 keeps each ticket's email conversation together, 4.2.7 lets a reply from a CC say who sent it, 4.2.8 renames the watchers table for CCs, 4.2.9 lets the mail queue go at a pace your mail host takes, 4.3.0 lets contacts unsubscribe from bulk email, 4.3.1 encrypts the mail passwords and tokens, 4.3.2 keeps the email the ticket mailbox couldn't take, for your team to sort, and 4.3.3 adds Undo send and Reply-To for ticket emails. The client portal's Microsoft 365 single sign-on becomes the first identity provider, for client contacts, and keeps its redirect address, so nothing changes in Microsoft Entra. Nothing else is required: passkeys are on, and no one has one until they add it. Pictures already inside tickets move to files in the background afterwards - the new Ticket Pictures job in Maintenance > Cron does a batch a minute, so an install with years of emailed screenshots may take a while, and tickets work as usual meanwhile. A passkey is made for your ITFlow's address (the one in config.php) and only works there, over HTTPS - if you move ITFlow to a new address, everyone adds theirs again. Watchers are called CCs now. Emails about a ticket go to its contact with the CCs copied in, rather than one each - Admin > Settings > Tickets has the switch, under Emails about a ticket. On nginx, where ITFlow's .htaccess files aren't read, add `location ^~ /uploads/mail_unprocessed/ { deny all; }` beside the other private folders - it holds copies of the email kept for Unprocessed Email. Emailed and texted replies now wait 10 seconds on the ticket page, with Undo, before they go - Admin > Settings > Tickets sets how long, or turns it off. Ticket emails sent from another address than the mailbox ITFlow reads now ask for replies at that mailbox (Reply-To) - turn that off in the same place if the From address is an alias of that mailbox and you'd rather clients only saw it.
+Update from Maintenance > Update as usual - this release has thirteen database changes: 4.2.2 adds a table for passkeys and a setting to turn them on or off, 4.2.3 lets a document keep the Markdown it was written in, 4.2.4 lets a ticket keep its pictures as files, 4.2.5 adds identity providers, 4.2.6 keeps each ticket's email conversation together, 4.2.7 lets a reply from a CC say who sent it, 4.2.8 renames the watchers table for CCs, 4.2.9 lets the mail queue go at a pace your mail host takes, 4.3.0 lets contacts unsubscribe from bulk email, 4.3.1 encrypts the mail passwords and tokens, 4.3.2 keeps the email the ticket mailbox couldn't take, for your team to sort, 4.3.3 adds Undo send and Reply-To for ticket emails, and 4.3.4 lets the links in emails stop working once they're done with and keeps your own wording for the emails about a ticket. The client portal's Microsoft 365 single sign-on becomes the first identity provider, for client contacts, and keeps its redirect address, so nothing changes in Microsoft Entra. Nothing else is required: passkeys are on, and no one has one until they add it. Pictures already inside tickets move to files in the background afterwards - the new Ticket Pictures job in Maintenance > Cron does a batch a minute, so an install with years of emailed screenshots may take a while, and tickets work as usual meanwhile. A passkey is made for your ITFlow's address (the one in config.php) and only works there, over HTTPS - if you move ITFlow to a new address, everyone adds theirs again. Watchers are called CCs now. Emails about a ticket go to its contact with the CCs copied in, rather than one each - Admin > Settings > Tickets has the switch, under Emails about a ticket. On nginx, where ITFlow's .htaccess files aren't read, add `location ^~ /uploads/mail_unprocessed/ { deny all; }` beside the other private folders - it holds copies of the email kept for Unprocessed Email. Emailed and texted replies now wait 10 seconds on the ticket page, with Undo, before they go - Admin > Settings > Tickets sets how long, or turns it off. Ticket emails sent from another address than the mailbox ITFlow reads now ask for replies at that mailbox (Reply-To) - turn that off in the same place if the From address is an alias of that mailbox and you'd rather clients only saw it. The links in emails that open a ticket, an invoice or a quote without signing in now stop working 90 days after it is done - a ticket closed, an invoice paid, a quote answered or run out - so after the update, links to ones done longer ago than that no longer open them. The client portal still shows them, and Admin > Settings > Security sets how long, or keeps them working as before.
### Security
@@ -83,6 +83,8 @@ Update from Maintenance > Update as usual - this release has twelve database cha
- From Unprocessed Email an email can be opened (as text - nothing in it loads), made a ticket at the client you pick - for one of their contacts, or with the sender made a contact there first - added to a ticket, with the sender made a CC on it if you like, tried again (after making them a contact, say), dismissed, or downloaded as a .eml file. Try Again and Dismiss also work on several at once. The ticket or reply is made within a minute, as any email is, attachments and all, and the email shows which ticket it went on. Sorted and dismissed email is kept 30 days, and email nobody sorts 90.
- Undo send: an emailed or texted reply waits a few seconds under the reply box - "Emailing it in 10 seconds" - with Undo and Send now. Undo leaves it in the reply box, as it was, to change or send later: nothing about it has happened yet - no email, no status change, no time added. Escape undoes it too, and leaving the page while it waits asks first. Admin > Settings > Tickets, Emails about a ticket, sets how long - 5, 10 (to start), 20 or 30 seconds - or turns it off. A public or internal note goes at once, as before.
- Replies to ticket emails come back: an email about a ticket sent from another address than the mailbox ITFlow reads - a no-reply address, or one that isn't delivered there - asks for replies at that mailbox (Reply-To), where a client's reply used to go to the From address and be lost if nobody read it. Admin > Settings > Tickets says which addresses it uses, and turns it off for a From address that is an alias of the mailbox.
+- Links in emails stop working once they're done with: the link that opens a ticket, an invoice or a quote without signing in - in its emails, forwarded on or kept for years - stops working 90 days after the ticket is closed, the invoice paid in full, or the quote accepted, declined, invoiced or run out. Open tickets, unpaid invoices and quotes waiting for an answer always work, a reopened ticket's link works again, and emailing an invoice or quote again counts from then. An expired link says so and points to the client portal, where they're shown as always. On an invoice or a quote, Copy Client Link says Expired once it has. Admin > Settings > Security, Links in emails, sets 30, 60, 90 (to start), 180 days or a year - or never, as before.
+- Your own wording for the emails about a ticket to clients: Admin > Settings > Mail > Previews has Edit Wording on each of the 13 - ticket opened, their email became a ticket, scheduled ticket, reply, resolved, closed, a client's reply passed on, added as a CC, new ticket at their company, approval needed, work booked, booked work cancelled and replied to a closed ticket. Change its subject, heading, opening and closing text, with words in square brackets filled in as it goes, as in canned responses - [Ticket], [Subject], [First Name], [Client], [Agent], [Company] and each email's own, such as [By] and [When]. The preview shows it at once, the list marks the ones you changed, and Use ITFlow's Wording puts one back. The subject always starts with the ticket's number, so replies still find it.
### Bug Fixes
@@ -166,6 +168,7 @@ Update from Maintenance > Update as usual - this release has twelve database cha
- Mail review stage 7a: database 4.3.1 widens config_smtp_password, config_imap_password and config_mail_oauth_client_secret to varchar(500) and encrypts what is saved. functions/mail_secret.php seals MAIL_SECRET_COLUMNS (the two passwords, the OAuth secret, refresh and access tokens, and config_mail_graph_token) with secretSeal($plain, 'mail') as RMM and identity provider secrets are - but keeps a value as typed when there is no key, as mail would otherwise stop. mailSecretOpen() reads an unsealed value as it is, so nothing breaks before it is sealed: load_global_settings.php, cron/mail_queue.php, cron/nightly_tasks.php and mailGraphToken() open them; settingsWrite() seals secret-kind mail columns; every token write (the parser's two refreshes, persistMailOauthTokens(), the Microsoft callback, the Test OAuth refresh, mailGraphToken()) goes through mailSecretSql(). mailSecretsSealAll() runs in the update and nightly; mailSecretProblem() is the Admin > Settings > Mail warning. Remote pictures: ticketHtmlForAgents($purifier, $html) purifies and then ticketRemoteImagesHold() moves an http(s) or // img src to data-remote-src (a blank GIF and .itflow-remote-image in its place) and a style with a remote url() to data-remote-style - in agent/ticket.php, the quick look and ticketWorkOrderHtml(); ticketRemoteImagesNote() and js/app.js show the note and put them back. login.php drops the SMTP host, port, encryption, username and password it loaded but never used.
- Mail review stage 7b: database 4.3.2 adds email_unprocessed. functions/mail_unprocessed.php keeps an email the parser couldn't take - mailUnprocessedKeep($raw, $meta, $reason) writes its MIME to uploads/mail_unprocessed (denied to the web, as uploads/backups) and a row, one per Message-ID - and mailUnprocessedDecide() records an agent's ticket, reply, retry or dismiss (agent/email_unprocessed.php, agent/post/email_unprocessed.php). cron/ticket_email_parser.php appends mailUnprocessedAsked() to the run as MailUnprocessedMessage (functions/mail_unprocessed_message.php), a FileMessage whose move() is mailUnprocessedDone() with the ticket it went on and whose flags do nothing: a ticket or reply ask skips steps 1 to 6 for addTicket() at the chosen contact or client (or a new contact, as the domain match makes one) or addReply() on the chosen ticket (the sender added through ticketAddCcs() first, if asked); a retry goes the usual way. mailUnprocessedLeave() takes the unprocessed and exception branches - kept, then marked seen and moved to the ITFlow folder; flagged and unread as before when it can't be kept; an ask that fails waits again with the reason. mailUnprocessedCleanup() runs nightly.
- Mail review stage 7c: database 4.3.3 adds settings.config_ticket_reply_undo_seconds (0, 5, 10, 20 or 30 - TICKET_REPLY_UNDO_CHOICES) and config_ticket_reply_to_read, read by ticketReplySendSettings() (functions/ticket_reply_send.php). Undo send is the ticket page alone: #ticketReplyForm's data-undo-seconds, and agent/js/ticket_reply_extras.js holds an emailed or texted reply's submit in a window listener - after the form's own checks and the canned response check on the document - with the reply card inert and the [data-reply-hold] bar, then requestSubmit()s it with holdOk, cannedSendAnyway and noTimeOk set; agent/post/ticket.php is unchanged. emailQueue() puts Reply-To (ticketMailReplyToRead(): email to ticket on, the setting on, the IMAP username an address and not From) in a thread email's headers; MAIL_QUEUE_HEADERS lets one bare address through and sendQueueEmail() gives it to addReplyTo(), so Graph's large-email draft carries it too.
+- Mail review stage 7d: database 4.3.4 adds settings.config_guest_link_days (GUEST_LINK_DAYS_CHOICES, 90) and email_templates. functions/guest_link.php: guestLinkDoneAt() - ticket_closed_at; a Paid invoice's last unarchived payment (else its Paid history, else invoice_updated_at); an Accepted, Declined or Invoiced quote's history for it, or the end of quote_expire for one unanswered - later of that and the last history line with 'emailed' in it; guestLinkExpired() adds the days. ticketByGuestKey() returns null for an expired link, setting its new &$expired, so the guest ticket page, its attachments, its posts and its calendar file all refuse it; guest_view_invoice.php, guest_view_quote.php, the guest PDF exports (410) and the quote upload check it too, and guestLinkExpiredHtml() is the page; agent/invoice.php and agent/quote.php mark Copy Client Link Expired. functions/email_template.php: EMAIL_TEMPLATES (the 13 Tickets - to clients preview keys, with ITFlow's wording in placeholders), emailTemplateApply() replaces title, intro (paragraphs) and after where saved, filling [Placeholders] from emailTemplateValues() (ticketPlaceholderValues() and the email's own; empty when there is nothing), and puts the subject in template_subject for emailTemplateSubject(), which prefixes [REF] when it isn't in it. Applied in ticketEmailContent() (not the stranger's subject, nor Resolve - no response's intro), ticketMailSend(), ticketMailCcsAdded(), ticketMailColleaguesNew(), ticketMailTaskApproval() (the client's only) and ticketMailClosedReply(). admin/modals/email_template/email_template_edit.php and admin/post/email_template.php (save_email_template, reset_email_template - a part sent back as the default is NULL); mail_preview.php answers template and edited.
## [26.12.2]
diff --git a/admin/database_updates/4.3.4.php b/admin/database_updates/4.3.4.php
new file mode 100644
index 000000000..b4500a481
--- /dev/null
+++ b/admin/database_updates/4.3.4.php
@@ -0,0 +1,32 @@
+ array_values(array_unique($others)),
'calendar' => !empty($email['cal_str']),
'html' => $email['html'] ?? '',
+ // Its wording can be changed - one of the emails about a ticket to clients (functions/email_template.php)
+ 'template' => isset(EMAIL_TEMPLATES[(string) ($_GET['email'] ?? '')]) && emailTemplateReady(),
+ 'edited' => emailTemplateEdited((string) ($_GET['email'] ?? '')),
'error' => $email ? '' : ($preview['error'] !== '' ? 'It could not be made: ' . $preview['error'] : 'Nothing would be sent with the sample records.'),
]);
diff --git a/admin/modals/email_template/email_template_edit.php b/admin/modals/email_template/email_template_edit.php
new file mode 100644
index 000000000..6761a7eb0
--- /dev/null
+++ b/admin/modals/email_template/email_template_edit.php
@@ -0,0 +1,99 @@
+ Settings > Mail > Previews. Each field starts with the wording it sends
+ * now - yours, or ITFlow's own - and the words in square brackets are filled in as it goes. Saved by
+ * save_email_template (admin/post/email_template.php); Use ITFlow's Wording puts all of it back.
+ */
+
+require_once '../../includes/modal_header.php';
+
+$key = (string) ($_GET['key'] ?? '');
+if (!isset(EMAIL_TEMPLATES[$key]) || !emailTemplateReady()) {
+ echo json_encode(['error' => !emailTemplateReady() ? 'Your own wording arrives with the 4.3.4 database update.' : "That email's wording can't be changed."]);
+ exit;
+}
+
+$label = (string) (emailPreviewCatalog()[$key]['label'] ?? $key);
+$saved = emailTemplatesSaved()[$key] ?? [];
+$value = function ($part) use ($key, $saved) {
+ return escapeHtml($saved[$part] ?? emailTemplateDefault($key, $part));
+};
+$edited = emailTemplateEdited($key);
+$reference = escapeHtml(($config_ticket_prefix ?? 'TCK-') . '123');
+
+ob_start();
+
+?>
+
+
Edit Wording = escapeHtml($label) ?>
+
+
+
+
+ Settings > Mail > Previews, Edit Wording (admin/modals/email_template/email_template_edit.php):
+ * save_email_template keeps your own subject, heading, opening and closing text for one of the emails about a ticket
+ * to clients (functions/email_template.php) - each part sent back as ITFlow's own words, or a subject or heading left
+ * empty, is kept as none, so it follows ITFlow's own; an opening or closing text left empty leaves it out.
+ * reset_email_template puts all of it back to ITFlow's own. Both go back to the email's preview.
+ */
+
+defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
+
+if (isset($_POST['save_email_template']) || isset($_POST['reset_email_template'])) {
+
+ validateCSRFToken();
+
+ $key = (string) ($_POST['email_template_key'] ?? '');
+ if (!isset(EMAIL_TEMPLATES[$key]) || !emailTemplateReady()) {
+ flashAlert("That email's wording can't be changed", 'error');
+ redirect('settings_mail.php?tab=previews');
+ }
+ $label = (string) (emailPreviewCatalog()[$key]['label'] ?? $key);
+ $back = 'settings_mail.php?tab=previews&email=' . rawurlencode($key);
+ $key_sql = escapeSql($key);
+
+ if (isset($_POST['reset_email_template'])) {
+ mysqli_query($mysqli, "DELETE FROM email_templates WHERE email_template_key = '$key_sql'");
+ logAudit("Settings", "Edit", "$session_name put the wording of the email " . escapeSql($label) . " back to ITFlow's own");
+ flashAlert("" . escapeHtml($label) . " uses ITFlow's own wording again");
+ redirect($back);
+ }
+
+ $set = [];
+ foreach (EMAIL_TEMPLATE_PARTS as $part => $length) {
+ $text = str_replace("\r", '', (string) ($_POST["email_template_$part"] ?? ''));
+ // One line for the subject and heading; trailing spaces off every line
+ $text = in_array($part, ['subject', 'title'], true) ? trim(preg_replace('/\s+/u', ' ', $text)) : trim(preg_replace('/[ \t]+$/m', '', $text));
+ $text = mb_substr($text, 0, $length);
+ $own = $text === emailTemplateDefault($key, $part) || ($text === '' && in_array($part, ['subject', 'title'], true));
+ $set[$part] = $own ? null : $text;
+ }
+
+ if (count(array_filter($set, function ($text) { return $text !== null; })) === 0) {
+ mysqli_query($mysqli, "DELETE FROM email_templates WHERE email_template_key = '$key_sql'");
+ } else {
+ // Kept as typed - it is plain text, escaped as each email is made (emailHtml())
+ $sql = function ($text) use ($mysqli) {
+ return $text === null ? 'NULL' : "'" . mysqli_real_escape_string($mysqli, $text) . "'";
+ };
+ $columns = "email_template_subject = {$sql($set['subject'])}, email_template_title = {$sql($set['title'])}, email_template_intro = {$sql($set['intro'])},
+ email_template_after = {$sql($set['after'])}, email_template_updated_by = " . intval($session_user_id) . ", email_template_updated_at = NOW()";
+ mysqli_query($mysqli, "INSERT INTO email_templates SET email_template_key = '$key_sql', $columns ON DUPLICATE KEY UPDATE $columns");
+ }
+
+ logAudit("Settings", "Edit", "$session_name changed the wording of the email " . escapeSql($label));
+ flashAlert("Wording saved for " . escapeHtml($label) . " - the preview shows it");
+
+ redirect($back);
+
+}
diff --git a/admin/post/settings_security.php b/admin/post/settings_security.php
index 591f9001e..a300e90fa 100644
--- a/admin/post/settings_security.php
+++ b/admin/post/settings_security.php
@@ -4,8 +4,9 @@
* Admin > Settings > Security (admin/settings_security.php):
* edit_security_settings saves the sign-in page's message and login key, how
* long a browser is remembered, whether passkeys sign people in, when admins
- * hear of failed sign-ins, whether the API takes a key in the address, and
- * shared links. A login key required with none set - which would leave
+ * hear of failed sign-ins, whether the API takes a key in the address,
+ * shared links, and how long the links in emails work once a ticket, invoice
+ * or quote is done. A login key required with none set - which would leave
* agents no way in but the database - is refused, as is a key that couldn't
* be typed into an address, or a time out of range. Nothing is saved then.
* A choice not offered settles to the usual one.
@@ -20,7 +21,9 @@ if (isset($_POST['edit_security_settings'])) {
$before = settingsCurrent(array_merge(['config_login_message', 'config_login_key_required', 'config_login_key_secret', 'config_login_remember_me_expire',
'config_login_alert_failures', 'config_api_key_in_address', 'config_share_max_hours', 'config_share_require_protection'],
// Passkeys, once the database has them (functions/passkey.php)
- passkeysReady() ? ['config_login_passkeys'] : []));
+ passkeysReady() ? ['config_login_passkeys'] : [],
+ // How long a done ticket's, invoice's or quote's link works (functions/guest_link.php)
+ guestLinkReady() ? ['config_guest_link_days'] : []));
// What was sent, and what is saved for anything that wasn't - a switch not sent is off
$in = $_POST + array_map(function ($value) { return (string) $value; }, $before);
@@ -38,6 +41,9 @@ if (isset($_POST['edit_security_settings'])) {
if (array_key_exists('config_login_passkeys', $before)) {
$after['config_login_passkeys'] = empty($_POST['config_login_passkeys']) ? 0 : 1;
}
+ if (array_key_exists('config_guest_link_days', $before)) {
+ $after['config_guest_link_days'] = intval($in['config_guest_link_days']);
+ }
$errors = [];
if ($after['config_login_key_secret'] !== '' && !preg_match('/^\w{3,99}$/', $after['config_login_key_secret'])) {
@@ -56,6 +62,9 @@ if (isset($_POST['edit_security_settings'])) {
if (!isset(shareMaxOptions()[$after['config_share_max_hours']])) {
$after['config_share_max_hours'] = 720;
}
+ if (isset($after['config_guest_link_days']) && !isset(GUEST_LINK_DAYS_CHOICES[$after['config_guest_link_days']])) {
+ $after['config_guest_link_days'] = GUEST_LINK_DAYS_DEFAULT;
+ }
if ($errors) {
settingsRefuse('security', $errors);
}
diff --git a/admin/settings_mail.php b/admin/settings_mail.php
index a87728d7d..0e3a94d37 100644
--- a/admin/settings_mail.php
+++ b/admin/settings_mail.php
@@ -4,7 +4,8 @@
* Admin > Settings > Mail - sending (an SMTP server, or Google Workspace /
* Microsoft 365 by OAuth), receiving the mailbox email to ticket reads, the
* OAuth app both share, the addresses and names emails come from, tests, and
- * a preview of every email ITFlow sends. Each tab's form saves on its own
+ * a preview of every email ITFlow sends - with Edit Wording on the emails about a ticket to clients
+ * (functions/email_template.php). Each tab's form saves on its own
* (admin/post/settings_mail.php), with the frame's save bar. Passwords, the
* OAuth secret and its refresh token are never put back into the page: left
* empty, they stay as saved.
@@ -461,7 +462,7 @@ if (!$config_module_enable_ticketing) {
$preview_entry) { ?>
@@ -480,6 +481,10 @@ if (!$config_module_enable_ticketing) {
Calendar file attached
+
+
@@ -558,6 +563,9 @@ if (!$config_module_enable_ticketing) {
card.querySelector('[data-preview-cc-line]').classList.toggle('d-none', !(data.cc && data.cc.length));
card.querySelector('[data-preview-when]').textContent = 'Sent when: ' + (data.when || '');
card.querySelector('[data-preview-calendar]').classList.toggle('d-none', !data.calendar);
+ var edit = card.querySelector('[data-preview-edit]');
+ edit.classList.toggle('d-none', !data.template);
+ edit.setAttribute('data-modal-url', data.template ? 'modals/email_template/email_template_edit.php?key=' + encodeURIComponent(key) : '');
var error = card.querySelector('[data-preview-error]');
error.textContent = data.error || '';
error.classList.toggle('d-none', !data.error);
diff --git a/admin/settings_security.php b/admin/settings_security.php
index f3d8db543..0a4786286 100644
--- a/admin/settings_security.php
+++ b/admin/settings_security.php
@@ -69,6 +69,13 @@ echo settingsPageStart('security');
= settingsSwitch('config_share_require_protection', $config_share_require_protection, ['help' => 'A shared password or secure note opens only with a passphrase the agent gives, or a code emailed to the person it is for.']) ?>
= settingsSectionEnd() ?>
+
+ = settingsSectionStart('guest-links', 'Links in emails', 'The link in an email about a ticket, an invoice or a quote opens it without signing in - for anyone the email reaches, forwarded or kept for years. Once it is done, the link can stop working.') ?>
+ = settingsSelect('config_guest_link_days', guestLinkDays(), GUEST_LINK_DAYS_CHOICES, ['icon' => 'fa-link',
+ 'help' => 'This long after a ticket is closed, an invoice paid in full, or a quote accepted, declined, invoiced or run out. Open tickets, unpaid invoices and quotes still waiting always work, a ticket reopened works again, and emailing an invoice or quote again counts from then. The client portal always shows them.']) ?>
+ = settingsSectionEnd() ?>
+
+
= settingsSaveBar('edit_security_settings') ?>