From e3d4fc89dc76d89a641ab16681f53ee03138a43c Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 8 Jul 2018 21:55:53 -0400 Subject: [PATCH 1/6] Add migration for service message languages --- install/migrations/core.php | 3 ++ .../MigrateServiceMessageLanguages.php | 49 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 install/migrations/vv201811/MigrateServiceMessageLanguages.php diff --git a/install/migrations/core.php b/install/migrations/core.php index 69b65f84..6a4c6c0b 100644 --- a/install/migrations/core.php +++ b/install/migrations/core.php @@ -231,5 +231,8 @@ function getAllMigrations() { 173 => new UpdateMigration('3.3.1', '3.3.0', 173), // 2018.1.0 174 => new UpdateMigration('2018.1.0', '3.3.1', 174), + // 2018.1.1 + 175 => new \vv201811\MigrateServiceMessageLanguages(175), + 176 => new UpdateMigration('2018.1.1', '2018.1.0', 176), ); } \ No newline at end of file diff --git a/install/migrations/vv201811/MigrateServiceMessageLanguages.php b/install/migrations/vv201811/MigrateServiceMessageLanguages.php new file mode 100644 index 00000000..563c9d3e --- /dev/null +++ b/install/migrations/vv201811/MigrateServiceMessageLanguages.php @@ -0,0 +1,49 @@ + $info) { + $languageMap[$name] = $info['folder']; + } + } + + $mfh_language = $languageMap[$row['language']]; + + hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` + SET `mfh_language` = '" . hesk_dbEscape($mfh_language) . "' WHERE `id` = " . intval($row['id'])); + } + } + + function innerDown($hesk_settings) { + // Get all service messages with non-null language (only HESK will populate this; MFH won't) + $rs = hesk_dbQuery("SELECT `id`, `mfh_language` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`"); + + $language_map = []; + while ($row = hesk_dbFetchAssoc($rs)) { + // Get the language + if (count($language_map) === 0) { + // Initialize the map for the first run + foreach($hesk_settings['languages'] as $name => $info) { + $language_map[$info['folder']] = $name; + } + } + + $language = $row['mfh_language'] === 'ALL' ? 'NULL' : "'" . hesk_dbEscape($language_map[$row['mfh_language']]) . "'"; + + hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` + SET `language` = {$language} WHERE `id` = " . intval($row['id'])); + } + } +} \ No newline at end of file From 4418a36ccf4db9442576f663d4ee70f3b4be150e Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 8 Jul 2018 21:58:07 -0400 Subject: [PATCH 2/6] Update admin_functions and common from HESK 2.8.2 --- inc/admin_functions.inc.php | 4 ++-- inc/common.inc.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/admin_functions.inc.php b/inc/admin_functions.inc.php index 5e74994c..5c9829d6 100644 --- a/inc/admin_functions.inc.php +++ b/inc/admin_functions.inc.php @@ -222,10 +222,10 @@ function hesk_mergeTickets($merge_these, $merge_into) $total = 0; $staffreplies = 0; - $res = hesk_dbQuery("SELECT COUNT(*) as `cnt`, `staffid` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "replies` WHERE `replyto`=" . intval($ticket['id']) . " GROUP BY CASE WHEN `staffid` = 0 THEN 0 ELSE 1 END ASC"); + $res = hesk_dbQuery("SELECT COUNT(*) as `cnt`, (CASE WHEN `staffid` = 0 THEN 0 ELSE 1 END) AS `staffcnt` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "replies` WHERE `replyto`=" . intval($ticket['id']) . " GROUP BY CASE WHEN `staffid` = 0 THEN 0 ELSE 1 END ASC"); while ($row = hesk_dbFetchAssoc($res)) { $total += $row['cnt']; - $staffreplies += ($row['staffid'] ? $row['cnt'] : 0); + $staffreplies += ($row['staffcnt'] ? $row['cnt'] : 0); } $replies_sql = " `replies`={$total}, `staffreplies`={$staffreplies} , "; diff --git a/inc/common.inc.php b/inc/common.inc.php index 0dba9eee..e862aa99 100644 --- a/inc/common.inc.php +++ b/inc/common.inc.php @@ -390,7 +390,7 @@ function hesk_mb_strlen($in) } // END hesk_mb_strlen() function hesk_mb_strtolower($in) { - return function_exists('mb_strtolower') ? mb_strtolower($in) : strtolower($in); + return function_exists('mb_strtolower') ? mb_strtolower($in, 'UTF-8') : strtolower($in); } // END hesk_mb_strtolower() function hesk_ucfirst($in) { From c11a9d3a8003c5fdf60afbfd6a2e9efc9b40666a Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 8 Jul 2018 22:01:01 -0400 Subject: [PATCH 3/6] Update email_functions --- inc/email_functions.inc.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/inc/email_functions.inc.php b/inc/email_functions.inc.php index 62d93059..bf5c09ec 100644 --- a/inc/email_functions.inc.php +++ b/inc/email_functions.inc.php @@ -1010,5 +1010,21 @@ function hesk_generateMessageID() { $id = uniqid('', true); } - return '<' . $id . '.' . gmdate('YmdHis') . '@' . $_SERVER['SERVER_NAME'] . '>'; + // If run from CLI, set the Hesk URL as host name + if (isset($_SERVER['SERVER_NAME'])) { + $host = $_SERVER['SERVER_NAME']; + } else { + global $hesk_settings; + + $parts = parse_url($hesk_settings['hesk_url']); + + if (empty($parts['host'])) { + $host = gethostname(); + $host = str_replace('>', '', $host); + } else { + $host = $parts['host']; + } + } + + return '<' . $id . '.' . gmdate('YmdHis') . '@' . $host . '>'; } // END hesk_generateMessageID() From f39dbdfd8798771f308f384095cacbe1f55b10d2 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 9 Jul 2018 12:16:40 -0400 Subject: [PATCH 4/6] Update footer for HESK 2.8.2 --- inc/footer.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/footer.inc.php b/inc/footer.inc.php index e1bfcf3b..36d51985 100644 --- a/inc/footer.inc.php +++ b/inc/footer.inc.php @@ -60,10 +60,10 @@ https://www.hesk.com/buy.php $hesk_settings['hesk_license']('HAgc3R5bGU9InRleHQtYWxpZ246Y2VudGVyIj48c3BhbiBjb GFzcz0ic21hbGxlciI+Jm5ic3A7PGJyIC8+UG93ZXJlZCBieSA8YSBocmVmPSJodHRwczovL3d3dy5oZ XNrLmNvbSIgY2xhc3M9InNtYWxsZXIiIHRpdGxlPSJGcmVlIFBIUCBIZWxwIERlc2sgU29mdHdhcmUiP -khlbHAgRGVzayBTb2Z0d2FyZTwvYT4gPGI+SEVTSzwvYj4sIGJyb3VnaHQgdG8geW91IGJ5IDxhIGhyZ -WY9Imh0dHBzOi8vd3d3LnN5c2FpZC5jb20vP3V0bV9zb3VyY2U9SGVzayZhbXA7dXRtX21lZGl1bT1jc -GMmYW1wO3V0bV9jYW1wYWlnbj1IZXNrUHJvZHVjdF9Ub19IUCI+U3lzQWlkPC9hPjwvc3Bhbj48L3A+' -,"\120"); +khlbHAgRGVzayBTb2Z0d2FyZTwvYT4gPGI+SEVTSzwvYj4sIGluIHBhcnRuZXJzaGlwIHdpdGggPGEga +HJlZj0iaHR0cHM6Ly93d3cuc3lzYWlkLmNvbS8/dXRtX3NvdXJjZT1IZXNrJmFtcDt1dG1fbWVkaXVtP +WNwYyZhbXA7dXRtX2NhbXBhaWduPUhlc2tQcm9kdWN0X1RvX0hQIj5TeXNBaWQgVGVjaG5vbG9naWVzP +C9hPjwvc3Bhbj48L3A+',"\120"); include(HESK_PATH . 'footer.txt'); From 205035fa0c8861521785e87d9f7722e3a52312ac Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 9 Jul 2018 12:28:55 -0400 Subject: [PATCH 5/6] Update build #, version # --- build.php | 2 +- install/install_functions.inc.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.php b/build.php index 4672732b..322f4d71 100644 --- a/build.php +++ b/build.php @@ -1,4 +1,4 @@ Date: Mon, 9 Jul 2018 12:32:20 -0400 Subject: [PATCH 6/6] Fix array designation for 5.3 --- .../migrations/vv201811/MigrateServiceMessageLanguages.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/migrations/vv201811/MigrateServiceMessageLanguages.php b/install/migrations/vv201811/MigrateServiceMessageLanguages.php index 563c9d3e..69504795 100644 --- a/install/migrations/vv201811/MigrateServiceMessageLanguages.php +++ b/install/migrations/vv201811/MigrateServiceMessageLanguages.php @@ -9,7 +9,7 @@ class MigrateServiceMessageLanguages extends \AbstractUpdatableMigration { $rs = hesk_dbQuery("SELECT `id`, `language` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `language` IS NOT NULL"); - $languageMap = []; + $languageMap = array(); while ($row = hesk_dbFetchAssoc($rs)) { // Get the MFH language if (count($languageMap) === 0) { @@ -30,7 +30,7 @@ class MigrateServiceMessageLanguages extends \AbstractUpdatableMigration { // Get all service messages with non-null language (only HESK will populate this; MFH won't) $rs = hesk_dbQuery("SELECT `id`, `mfh_language` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages`"); - $language_map = []; + $language_map = array(); while ($row = hesk_dbFetchAssoc($rs)) { // Get the language if (count($language_map) === 0) {