mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +00:00
Rename watchers to CCs in the database and code: database 4.2.8 renames ticket_watchers to ticket_ccs with its columns and index, functions, settings, form and post names, the Add CC modal file, JavaScript IDs, the email preview key and the To line group follow; the ticket email parser waits while a database update is pending instead of flagging email it cannot take; 26.12.3 changelog updated
This commit is contained in:
55
admin/database_updates/4.2.8.php
Normal file
55
admin/database_updates/4.2.8.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - Database update to version 4.2.8 (from 4.2.7)
|
||||
* Included by admin/database_updates.php - do not access directly
|
||||
*
|
||||
* Watchers are CCs - the people copied in on every email about a ticket, whose replies count as
|
||||
* the client's. Their table and columns take the name:
|
||||
* ticket_watchers -> ticket_ccs
|
||||
* watcher_id -> ticket_cc_id
|
||||
* watcher_name -> ticket_cc_name
|
||||
* watcher_email -> ticket_cc_email
|
||||
* watcher_ticket_id -> ticket_cc_ticket_id, its index with it
|
||||
*
|
||||
* Re-runnable: the table is renamed only while ticket_watchers is there and ticket_ccs isn't, and
|
||||
* each column and the index only while it has its old name.
|
||||
*/
|
||||
|
||||
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
|
||||
|
||||
$itflow_table_exists = function ($table) use ($mysqli) {
|
||||
$result = mysqli_query($mysqli, "SELECT 1 FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$table' LIMIT 1");
|
||||
return $result && mysqli_num_rows($result) > 0;
|
||||
};
|
||||
if ($itflow_table_exists('ticket_watchers') && !$itflow_table_exists('ticket_ccs')) {
|
||||
mysqli_query($mysqli, "RENAME TABLE `ticket_watchers` TO `ticket_ccs`");
|
||||
}
|
||||
|
||||
if ($itflow_table_exists('ticket_ccs')) {
|
||||
$itflow_cc_columns = [
|
||||
'watcher_id' => "`ticket_cc_id` int(11) NOT NULL AUTO_INCREMENT",
|
||||
'watcher_name' => "`ticket_cc_name` varchar(255) DEFAULT NULL",
|
||||
'watcher_email' => "`ticket_cc_email` varchar(255) NOT NULL",
|
||||
'watcher_ticket_id' => "`ticket_cc_ticket_id` int(11) NOT NULL",
|
||||
];
|
||||
foreach ($itflow_cc_columns as $itflow_old_column => $itflow_definition) {
|
||||
$itflow_column_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ticket_ccs' AND COLUMN_NAME = '$itflow_old_column' LIMIT 1");
|
||||
if ($itflow_column_exists && mysqli_num_rows($itflow_column_exists) > 0) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `ticket_ccs` CHANGE `$itflow_old_column` $itflow_definition");
|
||||
}
|
||||
}
|
||||
|
||||
// The index on the ticket, under its new name
|
||||
$itflow_index = function ($name) use ($mysqli) {
|
||||
$result = mysqli_query($mysqli, "SELECT 1 FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ticket_ccs' AND INDEX_NAME = '$name' LIMIT 1");
|
||||
return $result && mysqli_num_rows($result) > 0;
|
||||
};
|
||||
if ($itflow_index('watcher_ticket_id')) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `ticket_ccs` DROP INDEX `watcher_ticket_id`");
|
||||
}
|
||||
if (!$itflow_index('ticket_cc_ticket_id')) {
|
||||
mysqli_query($mysqli, "ALTER TABLE `ticket_ccs` ADD KEY `ticket_cc_ticket_id` (`ticket_cc_ticket_id`)");
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ echo json_encode([
|
||||
'subject' => $email['subject'] ?? '',
|
||||
'from' => $email ? ($email['from'] !== '' ? $person($email['from_name'], $email['from']) : 'No address yet - set it under From Addresses') : '',
|
||||
'to' => $email ? $person($email['to_name'], $email['to']) : '',
|
||||
// Copied in on it - a ticket's watchers, on one email with its contact (emailQueue()'s together)
|
||||
// Copied in on it - a ticket's CCs, on one email with its contact (emailQueue()'s together)
|
||||
'cc' => $email ? array_map(function ($copied) use ($person) { return $person($copied['name'], $copied['email']); }, $email['cc'] ?? []) : [],
|
||||
'also' => array_values(array_unique($others)),
|
||||
'calendar' => !empty($email['cal_str']),
|
||||
|
||||
@@ -827,7 +827,7 @@ function demoDataRemove($mysqli) {
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_replies WHERE ticket_reply_ticket_id IN ($ticket_ids)");
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_history WHERE ticket_history_ticket_id IN ($ticket_ids)");
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_assets WHERE ticket_id IN ($ticket_ids)");
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_watchers WHERE watcher_ticket_id IN ($ticket_ids)");
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_ccs WHERE ticket_cc_ticket_id IN ($ticket_ids)");
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_views WHERE view_ticket_id IN ($ticket_ids)");
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_reads WHERE ticket_id IN ($ticket_ids)");
|
||||
mysqli_query($mysqli, "DELETE FROM ticket_attachments WHERE ticket_attachment_ticket_id IN ($ticket_ids)");
|
||||
@@ -2602,11 +2602,11 @@ function demoSeedTicket($mysqli, $fields, $trail, $context, &$counts) {
|
||||
|
||||
}
|
||||
|
||||
// A watcher, where somebody else wanted to be kept in the loop
|
||||
if (!empty($trail['watcher'])) {
|
||||
starterInsert($mysqli, 'ticket_watchers', [
|
||||
'watcher_email' => $trail['watcher'],
|
||||
'watcher_ticket_id' => $ticket_id,
|
||||
// A CC, where somebody else wanted to be kept in the loop
|
||||
if (!empty($trail['cc'])) {
|
||||
starterInsert($mysqli, 'ticket_ccs', [
|
||||
'ticket_cc_email' => $trail['cc'],
|
||||
'ticket_cc_ticket_id' => $ticket_id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -2937,7 +2937,7 @@ function demoBuildTickets($mysqli, $profile, $index, $client_id, $contact_ids, $
|
||||
'sla_paused_at' => $on_hold ? demoDateTime(max(0, $stage['created'] - 1), 11, 30) : '',
|
||||
'replies' => $replies,
|
||||
'tasks' => !$stage['closed'] ? ($ticket['tasks'] ?? []) : [],
|
||||
'watcher' => $slot === 3 && $contact_ids ? demoContactEmail($profile['people'][0][0], $profile['domain']) : '',
|
||||
'cc' => $slot === 3 && $contact_ids ? demoContactEmail($profile['people'][0][0], $profile['domain']) : '',
|
||||
], $context, $counts);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user