mirror of
https://github.com/itflow-org/itflow
synced 2026-11-18 02:17:27 +00:00
View as Client no longer counts as the client viewing: an invoice, quote or contract link opened in a browser signed in to ITFlow as an agent leaves its status, history and notifications alone, through userSignedInAgent, which takes the session as the agent pages do; 26.11.9 changelog entries
This commit is contained in:
@@ -66,6 +66,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Invoices, quotes and contracts: opening one from its link while signed in to ITFlow - View as Client - counted as the client viewing it. A sent one became Viewed, its history said the client had viewed it, and your team was told. An agent looking doesn't count now; the client opening it still does.
|
||||
- Ticket emails: a picture of about 750 KB or more pasted into a reply, or into a ticket's details, left the email without its message - the picture went missing, and the words with it. The email has all of it now, whatever the picture's size. The same picture made a document come out empty in a client export, and a document template come out empty when it was exported or imported.
|
||||
- Ticket emails: a picture pasted into a reply, or into a ticket's details, now goes with the email as a picture attached inline, where the message shows it, rather than as data inside the message. Gmail, among others, showed no picture sent the old way. The mail queue also keeps each picture once, instead of a copy inside every email it sends. Admin > Mail Queue still shows the email with its pictures.
|
||||
- App Logs: the email parser wrote an entry every minute that mail came in or was left in the inbox ("Cron Email Parser executed in 0.16 seconds. Processed: 0 email(s), Unprocessed: 2 email(s)"), and the mail queue and email parser wrote one every minute while no mail server was set up. Neither does now. Each email is still a ticket or a reply, one that can't be is still left flagged and unread in the inbox, and an email that fails is still logged, once. With no mail server set up, Maintenance > Cron says so instead. The Mail Queue, Ticket SLA Monitor, Domain Refresher and Certificate Refresher also no longer log an error each time they run while cron is switched off - Maintenance > Cron says why they stopped, as the email parser already did.
|
||||
@@ -117,6 +118,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
|
||||
- Database 3.7.1: `email_queue.email_sensitive`, set by `emailQueue()`'s new `sensitive` option (`addToMailQueue()` writes it once the column is there, `mailQueueHasSensitive()`). It is passed by `shareEmailLink()`, `shareEmailCode()`, `portalInviteMail()`, `portalMailInvite()` and `portalMailSignupExists()` when the account is local, `portalMailPasswordReset()`, `userInviteMail()`, `contractSignatureRequestEmail()` and `ticketMailTaskApproval()`. `cron/mail_queue.php` marks an email sent with `mailQueueSentSql()`, which clears `email_content`, `email_cal_str` and `email_attachments` only where `email_sensitive` is 1 - every email before the update, as before. `mailQueueClearSensitive()` (nightly) clears a failed or cancelled one a day after it was queued. Retry (`mailQueueCan()`, `mailQueueAct()`) needs `email_content`, and Admin > Mail Queue reads `email_content = '' AS email_cleared` for it. The update marks the emails waiting or being sent as sensitive, as they would have been cleared.
|
||||
- `emailMessageHtml()` styled images and paragraphs with a lookahead across each tag (`(?![^>]*\bstyle=)`). On a data: image of 750 KB or more - its base64 is a million characters - that ran out of `pcre.backtrack_limit`, `preg_replace()` returned `null` and the message came out ''. It now works a tag at a time (`/<(img|p)\b([^>]*)>/`, which never backtracks into a tag) and keeps its input should a pattern fail. The same kind of scan through a tag to an attribute is replaced in `documentTemplateInlineImages()` and in the template import's alt and uploads clean-up (`functions/document_template_transfer.php`), and `clientExportLocalImages()` stops at the first `src=` and keeps its input on failure.
|
||||
- `emailInlineImages()` (`functions/email.php`), called by `emailQueue()` for each email it queues, takes every `<img>` whose `src` is a data: picture (checked with `getimagesizefromstring()`) out to `uploads/tmp/mail_images/<sha256>.<ext>` - written once, whoever it goes to - and points it at `cid:<first 32 of the hash>@itflow`. Each goes in the email's attachment manifest with a `cid` (`addToMailQueue()` keeps it), and `cron/mail_queue.php` attaches it with `addEmbeddedImage()`, so the message is `multipart/related`. A meeting request with pictures goes as an attached `invite.ics`, as one with files already did, since PHPMailer leaves the calendar part out of a message with inline parts. `mailQueueAttachments()` splits a manifest into files and pictures - the list's paperclip and the email's attachments are files only - and `mailQueueShowImages()` puts the pictures back as data to show the email in Admin > Mail Queue. `mailQueueImageCleanup()` (nightly) deletes a picture no queued email points at once it is a day old.
|
||||
- `userSignedInAgent()` (`functions/user.php`) is the agent signed in to ITFlow in this browser - their id, or 0 - taking the session as `includes/load_user_session.php` does: an active, unarchived agent whose session stamp still matches their password. `billingGuestViewed()` and `contractSignatureViewed()` record nothing for a link opened in such a browser, as the portal's View as contact already didn't.
|
||||
|
||||
## [26.11.8]
|
||||
|
||||
|
||||
@@ -2541,7 +2541,8 @@ function billingPdfSend(array $pdf, $download = false) {
|
||||
* portal ($who, the contact): a sent one becomes viewed, the view goes in
|
||||
* its history (where from, in plain text), and the agents hear about it
|
||||
* while it still matters - an invoice not yet paid, a quote not yet
|
||||
* answered.
|
||||
* answered. Not when its link is opened in a browser signed in to ITFlow as
|
||||
* an agent - View as Client (userSignedInAgent()).
|
||||
*/
|
||||
function billingGuestViewed($type, array $row, $who = '') {
|
||||
global $mysqli;
|
||||
@@ -2552,6 +2553,11 @@ function billingGuestViewed($type, array $row, $who = '') {
|
||||
$number = billingNumber($type, $row);
|
||||
$who = trim((string) $who);
|
||||
|
||||
// An agent looking from its link - View as Client - isn't the client viewing it
|
||||
if ($who === '' && userSignedInAgent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($status === 'Sent') {
|
||||
mysqli_query($mysqli, "UPDATE {$t['table']} SET {$c}_status = 'Viewed' WHERE {$c}_id = $id AND {$c}_status = 'Sent'");
|
||||
}
|
||||
|
||||
@@ -614,13 +614,17 @@ function contractSignatureWithdraw(array $round, $reason) {
|
||||
|
||||
/*
|
||||
* The client has opened a round - the first time is noted, and the agents
|
||||
* told. Nothing when an agent is looking (the portal's View as contact).
|
||||
* told. Nothing when an agent is looking (the portal's View as contact, or
|
||||
* its link opened in a browser signed in to ITFlow).
|
||||
*/
|
||||
function contractSignatureViewed(array $round, $who = '') {
|
||||
global $mysqli;
|
||||
if (!empty($round['contract_signature_viewed_at']) || !contractSignaturePending($round) || !empty($round['contract_signature_client_signed_at'])) {
|
||||
return;
|
||||
}
|
||||
if (trim((string) $who) === '' && userSignedInAgent()) {
|
||||
return;
|
||||
}
|
||||
mysqli_query($mysqli, "UPDATE contract_signatures SET contract_signature_viewed_at = NOW() WHERE contract_signature_id = " . intval($round['contract_signature_id']) . " AND contract_signature_viewed_at IS NULL");
|
||||
if (mysqli_affected_rows($mysqli) === 1) {
|
||||
$who = trim((string) $who) !== '' ? trim((string) $who) . ' in the client portal' : 'the client, from its link';
|
||||
|
||||
@@ -221,6 +221,26 @@ function userSessionStamp($password_hash) {
|
||||
return hash('sha256', 'itflow-session|' . (string) $password_hash);
|
||||
}
|
||||
|
||||
/*
|
||||
* The agent signed in to ITFlow in this browser - their user id, or 0. For the pages anyone with
|
||||
* the link can open (guest/), to tell an agent looking - View as Client - from the client. Their
|
||||
* session counts only as an agent page would take it (includes/load_user_session.php): an active
|
||||
* agent, whose password hasn't changed since.
|
||||
*/
|
||||
function userSignedInAgent() {
|
||||
global $mysqli;
|
||||
if (session_status() !== PHP_SESSION_ACTIVE || empty($_SESSION['logged']) || !intval($_SESSION['user_id'] ?? 0)) {
|
||||
return 0;
|
||||
}
|
||||
$user_id = intval($_SESSION['user_id']);
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT user_password FROM users
|
||||
WHERE user_id = $user_id AND user_type = 1 AND user_status = 1 AND user_archived_at IS NULL LIMIT 1"));
|
||||
if (!$row || !hash_equals(userSessionStamp($row['user_password']), (string) ($_SESSION['user_session_stamp'] ?? ''))) {
|
||||
return 0;
|
||||
}
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep this browser signed in when the password just changed is its own user's - a new
|
||||
* session id, and the stamp of the new hash. Every other session of theirs still ends.
|
||||
|
||||
Reference in New Issue
Block a user