mirror of
https://github.com/itflow-org/itflow
synced 2026-12-03 09:39:02 +00:00
Contact alternate email (DB 4.4.1): one more address per contact in the contact window under Email, shown on their page, quick look and the Reach column, searched by the contacts, clients, tickets and global searches, exported and imported as Alternate Email and in the API as contact_email_alt, and recognized on incoming email as theirs - a new ticket as them at their client even with unknown senders off, and their reply by ticket number, conversation or subject - with the ticket's from line showing the address it came from while everything ITFlow sends still goes to their Email and neither address is copied in; the duplicate warning, Try an Email, Unprocessed Email and the ignored sender and routing rule warnings count it too, and the same-as-Email warning shows while typing (contactEmailSql(), contactHasEmail(), contactEmailMatchSql()); 26.12.4 changelog
This commit is contained in:
@@ -147,15 +147,17 @@ function ticketMailDecide(array $in) {
|
||||
$domain_row = null;
|
||||
$contact = null;
|
||||
if (!$visitor) {
|
||||
$contact = $route['contact'] ? $route['contact'] + ['client_name' => $route_client['client_name']] : (mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, contact_client_id, client_name
|
||||
FROM contacts LEFT JOIN clients ON client_id = contact_client_id WHERE contact_client_id = " . intval($route_client['client_id']) . " AND contact_email = '$from_sql' AND contact_archived_at IS NULL LIMIT 1")) ?: null);
|
||||
$contact = $route['contact'] ? $route['contact'] + ['client_name' => $route_client['client_name']] : (mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, " . contactEmailAltColumn() . ", contact_client_id, client_name
|
||||
FROM contacts LEFT JOIN clients ON client_id = contact_client_id WHERE contact_client_id = " . intval($route_client['client_id']) . " AND " . contactEmailSql($from) . " AND contact_archived_at IS NULL LIMIT 1")) ?: null);
|
||||
}
|
||||
}
|
||||
// A routed email's sender is answered and copied in only as the ticket's contact - who they are, or who they will be as a
|
||||
// new contact at a client's domain: a system's address isn't sent "we have your email" and every reply after it
|
||||
$sender_is_contact = $contact && strtolower((string) $contact['contact_email']) === $from;
|
||||
// The sender is the contact by their email or their alternate one (contactHasEmail(), functions/contact.php) - from their
|
||||
// alternate one, or someone else's for a rule's contact, the ticket says the address it came from
|
||||
$sender_is_contact = $contact && contactHasEmail($contact, $from);
|
||||
$out['quiet'] = $route && !($visitor || $sender_is_contact || ($domain_row && $forged === ''));
|
||||
if ($contact && !$sender_is_contact && !$visitor) {
|
||||
if ($contact && !$visitor && strtolower(trim((string) $contact['contact_email'])) !== $from) {
|
||||
$out['sender'] = ['name' => (string) ($in['from_name'] ?? ''), 'email' => $from];
|
||||
}
|
||||
|
||||
@@ -176,7 +178,7 @@ function ticketMailDecide(array $in) {
|
||||
}
|
||||
if ($out['similar']) {
|
||||
$similar = $out['similar'];
|
||||
$theirs = !$visitor && !$forward && !$out['quiet'] && (($contact && !$out['sender'] && intval($contact['contact_id']) === intval($similar['ticket_contact_id']))
|
||||
$theirs = !$visitor && !$forward && !$out['quiet'] && (($contact && $sender_is_contact && intval($contact['contact_id']) === intval($similar['ticket_contact_id']))
|
||||
|| ($from !== '' && mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM ticket_ccs WHERE ticket_cc_ticket_id = " . intval($similar['ticket_id']) . " AND ticket_cc_email = '$from_sql' LIMIT 1"))));
|
||||
if ($theirs) {
|
||||
$step('The same subject as an open ticket of theirs from the last week?', 'Yes - ' . ticketReference($similar));
|
||||
@@ -197,7 +199,8 @@ function ticketMailDecide(array $in) {
|
||||
// 4. A contact - a website form sent as one (an address made a contact before) is that contact's client's, from its visitor
|
||||
if ($contact) {
|
||||
$others = $picked['others'] ? ' - and at ' . implode(', ', $picked['others']) . ' too, so it goes to ' . ($contact['client_name'] ?? 'no client') . ', ' . $picked['why'] : '';
|
||||
$step('A contact\'s address?', 'Yes - ' . $contact['contact_name'] . ($contact['client_name'] !== null ? ', ' . $contact['client_name'] : '') . $others);
|
||||
$step('A contact\'s address?', 'Yes - ' . $contact['contact_name'] . ($contact['client_name'] !== null ? ', ' . $contact['client_name'] : '')
|
||||
. (strtolower(trim((string) $contact['contact_email'])) !== $from ? ' - their alternate email' : '') . $others);
|
||||
return ['action' => 'ticket', 'client_id' => intval($contact['contact_client_id']), 'client_name' => $contact['client_name'] ?? null,
|
||||
'contact' => $visitor ? null : $contact, 'picked' => $visitor ? [] : $picked] + $out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user