From 515065691436114a2fdb0b0b29a4be5645c89089 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 12:51:37 -0400 Subject: [PATCH 01/53] Updated admin_main, updated part of admin_settings --- admin/admin_main.php | 28 +++++++---------- admin/admin_settings.php | 65 +++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 48 deletions(-) diff --git a/admin/admin_main.php b/admin/admin_main.php index 59898d18..df0b082a 100644 --- a/admin/admin_main.php +++ b/admin/admin_main.php @@ -108,23 +108,17 @@ else { >23)."\66\x34".chr(796917760>>23)."\x65\156\143".chr(0157)."\x64\145";$hesk_settings['hesk_license']($x1a("\x3c\150r\x20\57\76".chr(503316480>>23)."\x74\141\142l\x65\40".chr(0142).chr(0157).chr(0162)."\144\145r\x3d\42\60".chr(285212672>>23)."\x20\x77\x69".chr(0144)."th".chr(511705088>>23)."\x22".chr(061)."\60\60\x25\42".chr(520093696>>23)."\x3c\164".chr(0162).">\74t\x64\x3e\x3c".chr(0142).chr(076).$hesklang[chr(956301312>>23)."\145\155\157\x76e".chr(796917760>>23)."\x73ta\164e\x6d".chr(847249408>>23)."\156\x74"].chr(503316480>>23)."\x2f\142\x3e".chr(074)."\57t\x64\76".chr(074)."td".chr(268435456>>23)."\x73ty\154\x65\x3d\x22te".chr(1006632960>>23)."t\x2d\141\x6c\x69".chr(0147).chr(922746880>>23)."\x3ar\151\x67ht\"\76".chr(503316480>>23)."\141 \x68\162\145\146\x3d\42".chr(0112).chr(813694976>>23)."v\141".chr(0163).chr(830472192>>23)."\162\x69".chr(0160).chr(0164)."\x3a".chr(989855744>>23)."\157\151d\50\x30".chr(343932928>>23).chr(042)."\40onc\154\151\143\153\x3d".chr(042)."\x61\x6c\145\x72t(\x27".$hesklang["\163".chr(981467136>>23)."\x70".chr(939524096>>23).chr(0157)."\162\164\137n".chr(931135488>>23)."\x74\151".chr(0143)."\x65"].chr(047)."\51\42\x3e".$hesklang["\x73\x68"]."\74".chr(394264576>>23)."\x61\x3e\74\57\164d\76\x3c/\x74\162\76".chr(503316480>>23).chr(057)."t\x61\x62\x6ce\x3e\x3c\x70\x3e".$hesklang[chr(0163)."\x75ppo\x72\x74\137".chr(956301312>>23).chr(847249408>>23)."\155".chr(931135488>>23)."v\x65"]."\x2e\x20\x3c".chr(813694976>>23)."\40\x68re\x66\x3d".chr(285212672>>23)."\150".chr(973078528>>23).chr(973078528>>23)."\160\x73".chr(486539264>>23)."\57\x2f".chr(998244352>>23)."\x77\167".chr(056)."\150".chr(847249408>>23)."s\153\56\x63\157".chr(0155)."/".chr(0142)."\165\171.".chr(0160)."h\x70".chr(285212672>>23)."\x20\x74\141".chr(0162)."g".chr(847249408>>23)."\164\x3d".chr(042)."\137b\x6c".chr(813694976>>23)."\x6ek\x22\76".$hesklang["\x63\154\151\143\153\x5f".chr(880803840>>23)."\x6e".chr(855638016>>23).chr(0157)]."\x3c/\141\x3e\x3c\x2fp".chr(076)."<\150\162\x20\x2f\x3e"),""); + /******************************************************************************* + END LICENSE CODE + *******************************************************************************/ /* Clean unneeded session variables */ hesk_cleanSessionVars('hide'); diff --git a/admin/admin_settings.php b/admin/admin_settings.php index 8fd9fd77..9097d555 100644 --- a/admin/admin_settings.php +++ b/admin/admin_settings.php @@ -30,6 +30,7 @@ $hesk_settings['language_default'] = $hesk_settings['language']; require(HESK_PATH . 'inc/common.inc.php'); $hesk_settings['language'] = $hesk_settings['language_default']; require(HESK_PATH . 'inc/admin_functions.inc.php'); +require(HESK_PATH . 'inc/setup_functions.inc.php'); require(HESK_PATH . 'inc/mail_functions.inc.php'); hesk_load_database_functions(); @@ -54,8 +55,6 @@ $help_folder = '../language/' . $hesk_settings['languages'][$hesk_settings['lang $enable_save_settings = 0; $enable_use_attachments = 0; -$server_time = date('H:i', strtotime(hesk_date())); - // Print header require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); @@ -138,6 +137,29 @@ if ($hesk_settings['attachments']['use'] && !defined('HESK_DEMO')) { hesk_show_notice($hesklang['fatte3']); } } + + // If SMTP server is used, "From email" should match SMTP username + if ($hesk_settings['smtp'] && strtolower($hesk_settings['smtp_user']) != strtolower($hesk_settings['noreply_mail']) && hesk_validateEmail($hesk_settings['smtp_user'], 'ERR', 0)) { + hesk_show_notice(sprintf($hesklang['from_warning'], $hesklang['email_noreply'], $hesklang['tab_1'], $hesk_settings['smtp_user'])); + } + + // If POP3 fetching is active, no user should have the same email address + if ($hesk_settings['pop3'] && hesk_validateEmail($hesk_settings['pop3_user'], 'ERR', 0)) { + $res = hesk_dbQuery("SELECT `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `email` LIKE '".hesk_dbEscape($hesk_settings['pop3_user'])."'"); + + if (hesk_dbNumRows($res) > 0) { + hesk_show_notice(sprintf($hesklang['pop3_warning'], hesk_dbResult($res,0,0), $hesk_settings['pop3_user']) . "

" . $hesklang['fetch_warning'], $hesklang['warn']); + } + } + + // If IMAP fetching is active, no user should have the same email address + if ($hesk_settings['imap'] && hesk_validateEmail($hesk_settings['imap_user'], 'ERR', 0)) { + $res = hesk_dbQuery("SELECT `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `email` LIKE '".hesk_dbEscape($hesk_settings['imap_user'])."'"); + + if (hesk_dbNumRows($res) > 0) { + hesk_show_notice(sprintf($hesklang['imap_warning'], hesk_dbResult($res,0,0), $hesk_settings['imap_user']) . "

" . $hesklang['fetch_warning'], $hesklang['warn']); + } + } } @@ -250,32 +272,6 @@ $modsForHesk_settings = mfh_getSettings(); } }; - var server_time = ""; - var today = new Date(); - today.setHours(server_time.substr(0, server_time.indexOf(":"))); - today.setMinutes(server_time.substr(server_time.indexOf(":") + 1)); - - function startTime() { - var h = today.getHours(); - var m = today.getMinutes(); - var s = today.getSeconds(); - - h = checkTime(h); - m = checkTime(m); - - document.getElementById('servertime').innerHTML = h + ":" + m; - s = s + 1; - today.setSeconds(s); - t = setTimeout(function() { startTime(); },1000); - } - - function checkTime(i) { - if (i < 10) { - i = "0" + i; - } - return i; - } - function checkRequiredEmail(field) { if (document.getElementById('s_require_email_0').checked && document.getElementById('s_email_view_ticket').checked) { if (field == 's_require_email_0' && confirm('')) { @@ -1495,14 +1491,14 @@ $modsForHesk_settings = mfh_getSettings();

@@ -2862,10 +2858,17 @@ $modsForHesk_settings = mfh_getSettings(); $onload_status = ' disabled '; } - echo ' + // Is IMAP extension loaded? + if ( ! function_exists('imap_open')) { + echo ''. $hesklang['disabled'] . ' - ' . $hesklang['imap_not']; + $onload_div = 'none'; + } else { + echo '
   
'; + } ?> + From 1325f17bf80b41402495325746924506f8c7fe22 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 18:53:44 -0400 Subject: [PATCH 02/53] admin_settings(_save) updated --- admin/admin_settings.php | 61 +++++++++++------------------------ admin/admin_settings_save.php | 11 +++---- 2 files changed, 23 insertions(+), 49 deletions(-) diff --git a/admin/admin_settings.php b/admin/admin_settings.php index 9097d555..99595b71 100644 --- a/admin/admin_settings.php +++ b/admin/admin_settings.php @@ -3449,53 +3449,28 @@ $modsForHesk_settings = mfh_getSettings();

- +
-

' . $server_time . ''; ?>

- -
-
-
-
-
- -
-
-

-
-
-
-
- -
-
-

-
-
-
-
- - -
    -
'; + // Get list of supported timezones + $timezone_list = hesk_generate_timezone_list(); + + // Do we need to localize month names? + if ($hesk_settings['language'] != 'English') { + $timezone_list = hesk_translate_timezone_list($timezone_list); + } ?> +
diff --git a/admin/admin_settings_save.php b/admin/admin_settings_save.php index cd6c96cf..2a63cee4 100644 --- a/admin/admin_settings_save.php +++ b/admin/admin_settings_save.php @@ -419,9 +419,10 @@ $set['updatedformat'] = hesk_checkMinMax(intval(hesk_POST('s_updatedformat')), 0 /*** MISC ***/ /* --> Date & Time */ -$set['diff_hours'] = floatval(hesk_POST('s_diff_hours', 0)); -$set['diff_minutes'] = floatval(hesk_POST('s_diff_minutes', 0)); -$set['daylight'] = empty($_POST['s_daylight']) ? 0 : 1; +$set['timezone'] = hesk_input(hesk_POST('s_timezone')); +if (!in_array($set['timezone'], timezone_identifiers_list())) { + $set['timezone'] = 'UTC'; +} $set['timeformat'] = hesk_input(hesk_POST('s_timeformat')) or $set['timeformat'] = 'Y-m-d H:i:s'; /* --> Other */ @@ -881,9 +882,7 @@ $hesk_settings[\'updatedformat\']=' . $set['updatedformat'] . '; // ==> MISC // --> Date & Time -$hesk_settings[\'diff_hours\']=' . $set['diff_hours'] . '; -$hesk_settings[\'diff_minutes\']=' . $set['diff_minutes'] . '; -$hesk_settings[\'daylight\']=' . $set['daylight'] . '; +$hesk_settings[\'timezone\']=\'' . $set['timezone'] . '\'; $hesk_settings[\'timeformat\']=\'' . $set['timeformat'] . '\'; // --> Other From 52b47075d992aea7dfa594233b01b9f96ca4ff1c Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 18:54:50 -0400 Subject: [PATCH 03/53] Update admin_submit_ticket --- admin/admin_submit_ticket.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/admin/admin_submit_ticket.php b/admin/admin_submit_ticket.php index 80d1269e..eca0d604 100644 --- a/admin/admin_submit_ticket.php +++ b/admin/admin_submit_ticket.php @@ -300,6 +300,11 @@ if (!$modsForHesk_settings['rich_text_for_tickets']) { $tmpvar['message'] = nl2br($tmpvar['message']); } +// Track who assigned the ticket +if ($tmpvar['owner'] > 0) { + $tmpvar['assignedby'] = !empty($autoassign_owner) ? -1 : $_SESSION['id']; +} + $tmpvar['latitude'] = hesk_POST('latitude', 'E-4'); $tmpvar['longitude'] = hesk_POST('longitude', 'E-4'); From 2f44516c7b4fdd124d310ea309d61e404daa6d34 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 19:09:57 -0400 Subject: [PATCH 04/53] Update admin_ticket --- admin/admin_ticket.php | 77 ++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index b180ab34..008a0c71 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -50,6 +50,9 @@ $can_unban_emails = hesk_checkPermission('can_unban_emails', 0); $can_ban_ips = hesk_checkPermission('can_ban_ips', 0); $can_unban_ips = hesk_checkPermission('can_unban_ips', 0); $can_resolve = hesk_checkPermission('can_resolve', 0); +$can_view_ass_by = hesk_checkPermission('can_view_ass_by', 0); +$can_privacy = hesk_checkPermission('can_privacy',0); +$can_export = hesk_checkPermission('can_export',0); // Get ticket ID $trackingID = hesk_cleanID() or print_form(); @@ -90,7 +93,10 @@ if (hesk_dbNumRows($res) != 1) { /* Permission to view this ticket? */ if ($ticket['owner'] && $ticket['owner'] != $_SESSION['id'] && !hesk_checkPermission('can_view_ass_others', 0)) { - hesk_error($hesklang['ycvtao']); + // Maybe this user is allowed to view tickets he/she assigned? + if (!$can_view_ass_by || $ticket['assignedby'] != $_SESSION['id']) { + hesk_error($hesklang['ycvtao']); + } } if (!$ticket['owner'] && !$can_view_unassigned) { @@ -163,7 +169,10 @@ if ($isManager) { $can_unban_emails = $can_ban_ips = $can_unban_ips = - $can_resolve = true; + $can_resolve = + $can_view_ass_by = + $can_privacy = + $can_export = true; } /* Is this user allowed to view tickets inside this category? */ @@ -1321,7 +1330,7 @@ require_once(HESK_PATH . 'inc/footer.inc.php'); function hesk_getAdminButtons($category_id) { - global $hesk_settings, $hesklang, $modsForHesk_settings, $ticket, $reply, $trackingID, $can_edit, $can_archive, $can_delete, $can_resolve, $isManager; + global $hesk_settings, $hesklang, $modsForHesk_settings, $ticket, $reply, $trackingID, $can_edit, $can_archive, $can_delete, $can_resolve, $can_privacy, $can_export, $isManager; $options = ''; @@ -1329,12 +1338,12 @@ function hesk_getAdminButtons($category_id) if ($can_edit) { $tmp = $reply ? '&reply=' . $reply['id'] : ''; $mgr = $isManager ? '&isManager=true' : ''; - $options .= ' ' . $hesklang['edit'] . ' '; + $options .= ' ' . $hesklang['edit'] . ' '; } /* Print ticket button */ - $options .= ' ' . $hesklang['printer_friendly'] . ' '; + $options .= ' ' . $hesklang['printer_friendly'] . ' '; /* Copy ticket button */ $strippedName = strip_tags($ticket['name']); @@ -1489,7 +1498,7 @@ function hesk_getAdminButtons($category_id) /* Lock ticket button */ if ($can_resolve) { $template = - '
+ '
'; $dropdown .= $ticket['locked'] - ? sprintf($template, 0, 'unlock', $hesklang['tul']) - : sprintf($template, 1, 'lock', $hesklang['tlo']); + ? sprintf($template, 'unlock', $hesklang['tul'], 0, 'unlock', $hesklang['tul']) + : sprintf($template, 'lock', $hesklang['tlo'], 1, 'lock', $hesklang['tlo']); } /* Tag ticket button */ if ($can_archive) { $template = - '
+ '
'; $dropdown .= $ticket['archive'] - ? sprintf($template, 0, $hesklang['remove_archive']) - : sprintf($template, 1, $hesklang['add_archive']); + ? sprintf($template, 'untag', $hesklang['remove_archive'], 0, $hesklang['remove_archive']) + : sprintf($template, 'tag', $hesklang['add_archive'], 1, $hesklang['add_archive']); } /* Import to knowledgebase button */ if ($hesk_settings['kb_enable'] && hesk_checkPermission('can_man_kb', 0)) { $dropdown .= - '
+ '
'; } + // Export ticket + if ($can_export) { + $dropdown .= + ''; + } + + // Anonymize ticket + if ($can_privacy) { + $dropdown .= + ''; + } + /* Delete ticket */ if ($can_delete) { if ($reply) { $url = 'admin_ticket.php'; $tmp = 'delete_post=' . $reply['id']; - $txt = $hesklang['delt']; + $txt = $hesklang['btn_delr']; } else { $url = 'delete_tickets.php'; $tmp = 'delete_ticket=1'; - $txt = $hesklang['dele']; + $txt = $hesklang['btn_delt']; } $dropdown .= '
@@ -1600,13 +1642,13 @@ function hesk_getAdminButtonsInTicket($reply = 0, $white = 1) if ($reply) { $url = 'admin_ticket.php'; $tmp = 'delete_post=' . $reply['id']; - $txt = $hesklang['delt']; + $txt = $hesklang['btn_delr']; } else { $url = 'delete_tickets.php'; $tmp = 'delete_ticket=1'; - $txt = $hesklang['dele']; + $txt = $hesklang['btn_delt']; } - $options .= ' ' . $txt . ' '; + $options .= ' ' . $txt . ' '; } /* Return generated HTML */ @@ -2347,6 +2389,7 @@ function hesk_printCanned() myMsg = myMsg.replace(/%%HESK_TRACKID%%/g, ''); myMsg = myMsg.replace(/%%HESK_TRACK_ID%%/g, ''); myMsg = myMsg.replace(/%%HESK_NAME%%/g, ''); + myMsg = myMsg.replace(/%%HESK_FIRST_NAME%%/g, ''); myMsg = myMsg.replace(/%%HESK_EMAIL%%/g, ''); myMsg = myMsg.replace(/%%HESK_OWNER%%/g, ''); From c03ca62005a096622a1dc7aec5d84c648778efbb Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 19:36:00 -0400 Subject: [PATCH 05/53] Update assign_owner --- admin/assign_owner.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/admin/assign_owner.php b/admin/assign_owner.php index e103e8aa..ccd00f8d 100755 --- a/admin/assign_owner.php +++ b/admin/assign_owner.php @@ -52,7 +52,7 @@ $owner = intval(hesk_REQUEST('owner')); /* If ID is -1 the ticket will be unassigned */ if ($owner == -1) { - $res = hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `owner`=0 WHERE `trackid`='" . hesk_dbEscape($trackingID) . "'"); + $res = hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `owner`=0, `assignedby`=NULL WHERE `trackid`='" . hesk_dbEscape($trackingID) . "'"); mfh_insert_audit_trail_record($ticket['id'], 'TICKET', 'audit_unassigned', hesk_date(), array(0 => $_SESSION['name'] . ' (' . $_SESSION['user'] . ')')); @@ -97,7 +97,15 @@ if ($ticket['owner'] && $ticket['owner'] != $owner && hesk_REQUEST('unassigned') /* Assigning to self? */ if ($can_assign_others || ($owner == $_SESSION['id'] && $can_assign_self)) { - $res = hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `owner`={$owner} WHERE `trackid`='" . hesk_dbEscape($trackingID) . "'"); + $assignedby = intval(hesk_SESSION('id')); + if ($assignedby > 0) { + $assignedby = ',`assignedby`=' . $assignedby; + } else { + $assignedby = ''; + } + + + $res = hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `owner`={$owner} {$assignedby} WHERE `trackid`='" . hesk_dbEscape($trackingID) . "'"); if ($owner == $_SESSION['id'] && $can_assign_self) { mfh_insert_audit_trail_record($ticket['id'], 'TICKET', 'audit_assigned_self', hesk_date(), From f24a80be6acefd52b50641c94b3e20c72d3d0799 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 19:36:26 -0400 Subject: [PATCH 06/53] Update banned_emails --- admin/banned_emails.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/banned_emails.php b/admin/banned_emails.php index add9b597..0d6d5731 100644 --- a/admin/banned_emails.php +++ b/admin/banned_emails.php @@ -200,7 +200,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); if ($can_unban) { echo ' - + From aa1667261d12aac9f542e013032aa89b63882ac5 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 19:36:31 -0400 Subject: [PATCH 07/53] Update banned_ips --- admin/banned_ips.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/banned_ips.php b/admin/banned_ips.php index eed76f3f..ef50512a 100644 --- a/admin/banned_ips.php +++ b/admin/banned_ips.php @@ -263,7 +263,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); if ($can_unban) { echo ' - + '; From 035e4f0a79861637258d0179ba133d227c6a92ca Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 19:36:37 -0400 Subject: [PATCH 08/53] Update custom_fields --- admin/custom_fields.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/custom_fields.php b/admin/custom_fields.php index 238804b0..03551046 100755 --- a/admin/custom_fields.php +++ b/admin/custom_fields.php @@ -849,10 +849,10 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); } } ?> - + - From f102baf75340dc36789d958c265154df8ad4d4bd Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 19:36:42 -0400 Subject: [PATCH 09/53] Update delete_tickets --- admin/delete_tickets.php | 302 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 301 insertions(+), 1 deletion(-) diff --git a/admin/delete_tickets.php b/admin/delete_tickets.php index 45a7eaac..09f1ef30 100644 --- a/admin/delete_tickets.php +++ b/admin/delete_tickets.php @@ -87,6 +87,127 @@ $priorities = array( 'low' => array('value' => 3, 'lang' => 'low', 'text' => $hesklang['low'], 'formatted' => $hesklang['low']), ); +// Assign tickets to +if ( isset($_POST['assign']) && $_POST['assign'] == $hesklang['assi']) { + if ( ! isset($_POST['owner']) || $_POST['owner'] == '') { + hesk_process_messages($hesklang['assign_no'], $referer, 'NOTICE'); + } + + $end_message = array(); + $num_assigned = 0; + + // Permissions + $can_assign_others = hesk_checkPermission('can_assign_others',0); + if ($can_assign_others) { + $can_assign_self = true; + } else { + $can_assign_self = hesk_checkPermission('can_assign_self',0); + } + + $owner = intval( hesk_POST('owner') ); + + if ($owner == -1) { + foreach ($_POST['id'] as $this_id) { + if (is_array($this_id)) { + continue; + } + + $this_id = intval($this_id) or hesk_error($hesklang['id_not_valid']); + + // TODO Should we reset the assignedby? + $res = hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `owner`=0 WHERE `id`={$this_id} LIMIT 1"); + mfh_insert_audit_trail_record($this_id, 'TICKET', 'audit_assigned', hesk_date(), array(0 => $hesklang['unas'], + 1 => $_SESSION['name'].' ('.$_SESSION['user'].')')); + + $end_message[] = sprintf($hesklang['assign_2'], $this_id); + $i++; + } + + hesk_process_messages($hesklang['assign_1'],$referer,'SUCCESS'); + } + + $res = hesk_dbQuery("SELECT `id`,`user`,`name`,`email`,`isadmin`,`categories`,`notify_assigned` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`='{$owner}' LIMIT 1"); + $owner_data = hesk_dbFetchAssoc($res); + + if (!$owner_data['isadmin']) { + $owner_data['categories']=explode(',',$owner_data['categories']); + } + + require(HESK_PATH . 'inc/email_functions.inc.php'); + + foreach ($_POST['id'] as $this_id) { + if (is_array($this_id)) { + continue; + } + + $this_id = intval($this_id) or hesk_error($hesklang['id_not_valid']); + + $result = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `id`={$this_id} LIMIT 1"); + if (hesk_dbNumRows($result) != 1) { + continue; + } + $ticket = hesk_dbFetchAssoc($result); + + if ($ticket['owner'] == $owner) { + $end_message[] = sprintf($hesklang['assign_3'], $ticket['trackid'], $owner_data['name']); + $i++; + continue; + } + if ($owner_data['isadmin'] || in_array($ticket['category'],$owner_data['categories'])) { + // TODO Should we set the assignedby? + hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `owner`={$owner} WHERE `id`={$this_id} LIMIT 1"); + mfh_insert_audit_trail_record($this_id, 'TICKET', 'audit_assigned', hesk_date(), array(0 => $owner_data['name'].' ('.$owner_data['user'].')', + 1 => $_SESSION['name'].' ('.$_SESSION['user'].')')); + + $end_message[] = sprintf($hesklang['assign_4'], $ticket['trackid'], $owner_data['name']); + $num_assigned++; + + $ticket['owner'] = $owner; + + /* --> Prepare message */ + + // 1. Generate the array with ticket info that can be used in emails + $info = array( + 'email' => $ticket['email'], + 'category' => $ticket['category'], + 'priority' => $ticket['priority'], + 'owner' => $ticket['owner'], + 'trackid' => $ticket['trackid'], + 'status' => $ticket['status'], + 'name' => $ticket['name'], + 'subject' => $ticket['subject'], + 'message' => $ticket['message'], + 'attachments' => $ticket['attachments'], + 'dt' => hesk_date($ticket['dt'], true), + 'lastchange' => hesk_date($ticket['lastchange'], true), + 'id' => $ticket['id'], + 'time_worked' => $ticket['time_worked'], + 'last_reply_by' => hesk_getReplierName($ticket), + ); + + // 2. Add custom fields to the array + foreach ($hesk_settings['custom_fields'] as $k => $v) { + $info[$k] = $v['use'] ? $ticket[$k] : ''; + } + + // 3. Make sure all values are properly formatted for email + $ticket = hesk_ticketToPlain($info, 1, 0); + + /* Notify the new owner? */ + if ($ticket['owner'] != intval($_SESSION['id'])) { + hesk_notifyAssignedStaff(false, 'ticket_assigned_to_you'); + } + } else { + $end_message[] = sprintf($hesklang['assign_5'], $ticket['trackid'], $owner_data['name']); + } + + $i++; + } + + hesk_process_messages(sprintf($hesklang['assign_log'], $num_assigned, ($i - $num_assigned), implode("\n", $end_message)),$referer,($num_assigned == 0) ? 'ERROR' : ($num_assigned < $i ? 'NOTICE' : 'SUCCESS')); +} + + // Change priority if (array_key_exists($_POST['a'], $priorities)) { // A security check @@ -211,7 +332,186 @@ elseif ($_POST['a'] == 'tag' || $_POST['a'] == 'untag') { } hesk_process_messages(sprintf($action, $i), $referer, 'SUCCESS'); -} /* JUST CLOSE */ +} +/* EXPORT */ +elseif ($_POST['a']=='export') { + /* Check permissions for this feature */ + hesk_checkPermission('can_export'); + + /* A security check */ + hesk_token_check('POST'); + + $ids_to_export = array(); + + foreach ($_POST['id'] as $this_id) { + if ( is_array($this_id) ) { + continue; + } + + $ids_to_export[] = intval($this_id) or hesk_error($hesklang['id_not_valid']); + $i++; + } + + if ($i < 1) { + hesk_process_messages($hesklang['no_selected'], $referer, 'NOTICE'); + } + + // Start SQL statement for selecting tickets + $sql = "SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `id` IN (".implode(',', $ids_to_export).") "; + $sql .= " AND " . hesk_myCategories(); + $sql .= " AND " . hesk_myOwnership(); + + require_once(HESK_PATH . 'inc/custom_fields.inc.php'); + require_once(HESK_PATH . 'inc/statuses.inc.php'); + require(HESK_PATH . 'inc/export_functions.inc.php'); + + list($success_msg, $tickets_exported) = hesk_export_to_XML($sql, true); + + if ($tickets_exported > 0) { + hesk_process_messages($success_msg,$referer,'SUCCESS'); + } else { + hesk_process_messages($hesklang['n2ex'],$referer,'NOTICE'); + } +} +/* ANONYMIZE */ +elseif ($_POST['a']=='anonymize') { + /* Check permissions for this feature */ + hesk_checkPermission('can_privacy'); + + /* A security check */ + hesk_token_check('POST'); + + require(HESK_PATH . 'inc/privacy_functions.inc.php'); + + foreach ($_POST['id'] as $this_id) { + if (is_array($this_id)) { + continue; + } + + $this_id = intval($this_id) or hesk_error($hesklang['id_not_valid']); + $result = hesk_dbQuery("SELECT `id`,`trackid`,`name`,`category` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `id`='".intval($this_id)."' AND ".hesk_myOwnership()." LIMIT 1"); + if (hesk_dbNumRows($result) != 1) { + continue; + } + $ticket = hesk_dbFetchAssoc($result); + + hesk_okCategory($ticket['category']); + + hesk_anonymizeTicket(null, null, true); + $i++; + } + + hesk_process_messages(sprintf($hesklang['num_tickets_anon'],$i),$referer,'SUCCESS'); +} +/* PRINT */ +elseif ($_POST['a']=='print') { + /* Check permissions for this feature */ + hesk_checkPermission('can_view_tickets'); + + /* A security check */ + hesk_token_check('POST'); + + // Load custom fields + require_once(HESK_PATH . 'inc/custom_fields.inc.php'); + + // Load statuses + require_once(HESK_PATH . 'inc/statuses.inc.php'); + + // List of staff + if (!isset($admins)) { + $admins = array(); + $res2 = hesk_dbQuery("SELECT `id`,`name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ORDER BY `id` ASC"); + while ($row=hesk_dbFetchAssoc($res2)) { + $admins[$row['id']]=$row['name']; + } + } + + // List of categories + $hesk_settings['categories'] = array(); + $res2 = hesk_dbQuery('SELECT `id`, `name` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'categories` WHERE ' . hesk_myCategories('id') . ' ORDER BY `cat_order` ASC'); + while ($row=hesk_dbFetchAssoc($res2)) { + $hesk_settings['categories'][$row['id']] = $row['name']; + } + + // Print page head + header('Content-Type: text/html; charset=utf-8'); + ?> + + + + <?php echo $hesk_settings['hesk_title']; ?> + + + + + + + + Date: Mon, 14 May 2018 19:36:47 -0400 Subject: [PATCH 10/53] Update export --- admin/export.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/export.php b/admin/export.php index af02e349..9d3fa2ac 100644 --- a/admin/export.php +++ b/admin/export.php @@ -37,9 +37,11 @@ $modsForHesk_settings = mfh_getSettings(); $delete = hesk_GET('delete'); if (strlen($delete) && preg_match('/^hesk_export_[0-9_\-]+$/', $delete)) { hesk_unlink(HESK_PATH.$hesk_settings['cache_dir'].'/'.$delete.'.zip'); - hesk_process_messages($hesklang['fd'], 'export.php','SUCCESS'); + hesk_process_messages($hesklang['fd'], hesk_verifyGoto(),'SUCCESS'); } +// TODO CONTINUE FROM HERE IN THE DIFF + // Set default values define('CALENDAR', 1); define('MAIN_PAGE', 1); From 08233907388c0132ab3d245d1ca2dcad28df9441 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 14 May 2018 19:36:54 -0400 Subject: [PATCH 11/53] Update manage_email_templates --- admin/manage_email_templates.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/admin/manage_email_templates.php b/admin/manage_email_templates.php index 7b10a0e5..756d4507 100644 --- a/admin/manage_email_templates.php +++ b/admin/manage_email_templates.php @@ -278,12 +278,12 @@ function getTemplateMarkup($template, $languageCode, $html = false) $templateUrl = urlencode($template); $languageCodeUrl = urlencode($languageCode); if ($html) { - $markup = ''; + $markup = ''; $markup .= ''; $markup .= ''; return $markup; } else { - $markup = ''; + $markup = ''; $markup .= ''; $markup .= ''; return $markup; @@ -314,6 +314,7 @@ function getSpecialTagMap() $map = array(); $map['%%NAME%%'] = $hesklang['customer_name']; + $map['%%FIRST_NAME%%'] = $hesklang['fname']; $map['%%EMAIL%%'] = $hesklang['customer_email']; $map['%%SUBJECT%%'] = $hesklang['ticket_subject']; $map['%%MESSAGE%%'] = $hesklang['ticket_message']; From 5e5a8193e924fca6b233443c0da43014dc343b2a Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 12:32:40 -0400 Subject: [PATCH 12/53] export updated.... for the most part --- admin/export.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/admin/export.php b/admin/export.php index 9d3fa2ac..0368cf4e 100644 --- a/admin/export.php +++ b/admin/export.php @@ -300,7 +300,8 @@ while ($row = hesk_dbFetchAssoc($res2)) { // Generate export file if (isset($_GET['w'])) { - // We'll need HH:MM:SS format for hesk_date() here + /* + * // We'll need HH:MM:SS format for hesk_date() here $hesk_settings['timeformat'] = 'H:i:s'; // Get staff names @@ -323,7 +324,7 @@ if (isset($_GET['w'])) { if (!file_exists($export_dir.'index.htm')) { @file_put_contents($export_dir.'index.htm', ''); } - + // Cleanup old files hesk_purge_cache('export', 86400); } else { @@ -637,6 +638,10 @@ if (isset($_GET['w'])) { else { hesk_unlink($save_to); } + */ + + require_once(HESK_PATH . 'inc/export_functions.inc.php'); + list($success_msg, $tickets_exported) = hesk_export_to_XML($sql); } /* Print header */ From d84776d1aac227f7d65000223e3de5d6ef39f16a Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 12:45:06 -0400 Subject: [PATCH 13/53] Update export.php --- admin/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/export.php b/admin/export.php index 0368cf4e..a9d1b7d9 100644 --- a/admin/export.php +++ b/admin/export.php @@ -901,7 +901,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
- +
From 007fcb5575011b0dc7fe87d69de7725a87de3342 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 12:45:17 -0400 Subject: [PATCH 14/53] Update find_tickets --- admin/find_tickets.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/admin/find_tickets.php b/admin/find_tickets.php index 350bb27b..364de806 100644 --- a/admin/find_tickets.php +++ b/admin/find_tickets.php @@ -173,6 +173,9 @@ LEFT(`message`, 400) AS `message`, WHERE `message` LIKE '%".hesk_dbEscape( hesk_dbLike($q) )."%' COLLATE '" . hesk_dbCollate() . "' ) "; break; + case 'ip': + $sql .= "`ip` LIKE '".preg_replace('/[^0-9\.\%]/', '', $q)."' "; + break; default: if (isset($hesk_settings['custom_fields'][$what]) && $hesk_settings['custom_fields'][$what]['use']) { $sql .= "`" . hesk_dbEscape($what) . "` LIKE '%" . hesk_dbEscape($q) . "%' COLLATE '" . hesk_dbCollate() . "' "; From 53a9860388de31aa28513fe34c90c047addbe77a Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 12:45:23 -0400 Subject: [PATCH 15/53] Update admin/index --- admin/index.php | 62 +++++++++++-------------------------------------- 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/admin/index.php b/admin/index.php index c5e5695e..d62b7cf1 100644 --- a/admin/index.php +++ b/admin/index.php @@ -65,22 +65,7 @@ function do_login() if ($hesk_settings['secimg_use'] == 2 && !isset($_SESSION['img_a_verified'])) { // Using ReCaptcha? - if ($hesk_settings['recaptcha_use'] == 1) { - require_once(HESK_PATH . 'inc/recaptcha/recaptchalib.php'); - - $resp = recaptcha_check_answer($hesk_settings['recaptcha_private_key'], - hesk_getClientIP(), - hesk_POST('recaptcha_challenge_field', ''), - hesk_POST('recaptcha_response_field', '') - ); - - if ($resp->is_valid) { - $_SESSION['img_a_verified'] = true; - } else { - $hesk_error_buffer['mysecnum'] = $hesklang['recaptcha_error']; - } - } // Using ReCaptcha API v2? - elseif ($hesk_settings['recaptcha_use'] == 2) { + if ($hesk_settings['recaptcha_use']) { require(HESK_PATH . 'inc/recaptcha/recaptchalib_v2.php'); $resp = null; @@ -251,7 +236,7 @@ function print_login() global $hesk_settings, $hesklang, $modsForHesk_settings; // Tell header to load reCaptcha API if needed - if ($hesk_settings['recaptcha_use'] == 2) + if ($hesk_settings['recaptcha_use']) { define('RECAPTCHA',1); } @@ -297,7 +282,7 @@ function print_login() -
+
'.$hesklang['vrfy']; } - // Not verified yet, should we use Recaptcha? - elseif ($hesk_settings['recaptcha_use'] == 1) - { - ?> - -
'; - echo recaptcha_get_html($hesk_settings['recaptcha_public_key'], null, true); - echo '
'; - } // Use reCaptcha API v2? elseif ($hesk_settings['recaptcha_use'] == 2) { @@ -458,7 +415,7 @@ function print_login() ?>
- +
+ + +
+ From b215f885a9e4f29eb63d1d82091f3ec9c2ed052b Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 12:47:13 -0400 Subject: [PATCH 16/53] Update mail --- admin/mail.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/mail.php b/admin/mail.php index 38aa2e75..d857c767 100644 --- a/admin/mail.php +++ b/admin/mail.php @@ -450,10 +450,10 @@ function show_message() $folder = '&folder=outbox'; if ($pm['to'] == $_SESSION['id']) { - echo ' '.$hesklang['mau'].' '; + echo ' '.$hesklang['mau'].' '; $folder = ''; } - echo ' '.$hesklang['delm'].''; + echo ' '.$hesklang['delm'].''; ?>
@@ -571,7 +571,7 @@ function mail_list_messages() $pm['dt'] = hesk_dateToString($pm['dt'], 0, 0, 0, true) ?> -   +   From 075c8c006de29cac86d7e5350fb744c7197f5f23 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 12:48:03 -0400 Subject: [PATCH 17/53] Update manage_canned --- admin/manage_canned.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/manage_canned.php b/admin/manage_canned.php index 30ee8e07..0a9afd58 100644 --- a/admin/manage_canned.php +++ b/admin/manage_canned.php @@ -190,7 +190,7 @@ $num = hesk_dbNumRows($result); } echo ' -   +   '; } // End while @@ -371,6 +371,8 @@ $num = hesk_dbNumRows($result); onclick="hesk_insertTag('HESK_TRACK_ID')"> | | + | | Date: Tue, 15 May 2018 12:50:00 -0400 Subject: [PATCH 18/53] Update manage_categories --- admin/manage_categories.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/manage_categories.php b/admin/manage_categories.php index 0b123369..c67591be 100644 --- a/admin/manage_categories.php +++ b/admin/manage_categories.php @@ -446,7 +446,7 @@ echo ''; - + From 4a655999850dbf0b8f8a8c31466aa3fc07c1e841 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 12:53:33 -0400 Subject: [PATCH 19/53] Update manage_knowledgebase --- admin/manage_knowledgebase.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/admin/manage_knowledgebase.php b/admin/manage_knowledgebase.php index 987772e3..8b8118c2 100644 --- a/admin/manage_knowledgebase.php +++ b/admin/manage_knowledgebase.php @@ -185,9 +185,9 @@ while (count($kb_cat) > 0) // Generate KB menu icons $menu_icons = - ' ' - .' ' - .' ' + ' ' + .' ' + .' ' ; // Can this category be moved up? @@ -1884,10 +1884,10 @@ function manage_category() { echo ' '; } ?> - + - -   + +   Date: Tue, 15 May 2018 12:54:04 -0400 Subject: [PATCH 20/53] Update manage_ticket_templates --- admin/manage_ticket_templates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/manage_ticket_templates.php b/admin/manage_ticket_templates.php index 9208a085..8204fe2c 100644 --- a/admin/manage_ticket_templates.php +++ b/admin/manage_ticket_templates.php @@ -159,7 +159,7 @@ $num = hesk_dbNumRows($result); } echo ' - + '; } // End while From 05af7b17a58f7fbcb4a170876b514de815ba9240 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 12:58:26 -0400 Subject: [PATCH 21/53] Update manage_users --- admin/manage_users.php | 43 ++++++++++++++++++++++++++++++++++++------ inc/common.inc.php | 2 ++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/admin/manage_users.php b/admin/manage_users.php index dee9b844..9e424d7f 100644 --- a/admin/manage_users.php +++ b/admin/manage_users.php @@ -161,7 +161,38 @@ if ($action = hesk_REQUEST('a')) { ?>
- + 0) { + while ($myuser = hesk_dbFetchAssoc($res)) { + if (compare_user_permissions($myuser['id'], $myuser['isadmin'], explode(',', $myuser['categories']) , explode(',', $myuser['heskprivileges']))) { + hesk_show_notice(sprintf($hesklang['pop3_warning'], $myuser['name'], $hesk_settings['pop3_user']) . "

" . $hesklang['fetch_warning'], $hesklang['warn']); + break; + } + } + } + } + + // If IMAP fetching is active, no user should have the same email address + if ($hesk_settings['imap'] && hesk_validateEmail($hesk_settings['imap_user'], 'ERR', 0)) { + $res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `email` LIKE '".hesk_dbEscape($hesk_settings['imap_user'])."'"); + + if (hesk_dbNumRows($res) > 0) { + while ($myuser = hesk_dbFetchAssoc($res)) { + if (compare_user_permissions($myuser['id'], $myuser['isadmin'], explode(',', $myuser['categories']) , explode(',', $myuser['heskprivileges']))) { + hesk_show_notice(sprintf($hesklang['imap_warning'], $myuser['name'], $hesk_settings['imap_user']) . "

" . $hesklang['fetch_warning'], $hesklang['warn']); + break; + } + } + } + } + + ?> '; data-toggle="tooltip" title=""> - + - + diff --git a/hesk_style.css b/hesk_style.css index d3b66a4a..d4f3ae04 100644 --- a/hesk_style.css +++ b/hesk_style.css @@ -811,4 +811,82 @@ div.select_category select.multiple { font-size: 12px; height: auto; +} + +/* New styles in HESK version 2.8 */ + +#hesk_nav{ + list-style:none; + float:right; + /* Bring the nav above everything else--uncomment if needed. + position:relative; + z-index:5; + */ + margin: 0px; +} + +#hesk_nav li{ + float:left; + margin-right:4px; + position:relative; +} + +#hesk_nav a{ + display:block; + background-color:#ffffff; + -moz-border-radius:3px; + -webkit-border-radius:3px; + border-radius:3px; + border:1px solid #dcdcdc; + cursor:pointer; + color:#666666; + font-size:12px; + padding:4px 10px; + text-decoration:none; +} +#hesk_nav a:hover{ + color: red; + background:#f6f6f6; +} + +/*--- DROPDOWN ---*/ +#hesk_nav ul{ + background:#fff; /* Adding a background makes the dropdown work properly in IE7+. Make this as close to your page's background as possible (i.e. white page == white background). */ + background:rgba(255,255,255,0); /* But! Let's make the background fully transparent where we can, we don't actually want to see it if we can help it... */ + list-style:none; + position:absolute; + left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none;) */ + z-index:5; + padding-left: 0px; + padding-top: 2px; +} +#hesk_nav ul li{ + padding-top:1px; /* Introducing a padding between the li and the a give the illusion spaced items */ + float:none; +} +#hesk_nav ul a{ + white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */ + padding:8px 14px; +} +#hesk_nav li:hover ul{ /* Display the dropdown on hover */ + left:auto; /* Bring back on-screen when needed */ + text-align:left; + right:0; + margin-right:-10px; +} +#hesk_nav li:hover a{ /* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */ + background:#f6f6f6; + text-decoration:none; +} + +#hesk_nav li:hover ul a{ + background:#ffffff; + text-decoration:none; +} + +#hesk_nav li:hover ul a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */ + text-decoration:none; +} +#hesk_nav li:hover ul li a:hover{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */ + background:#f6f6f6; } \ No newline at end of file From fff00edbef792dcb75e5eaa06bd78c0298d8f4ca Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 13:02:53 -0400 Subject: [PATCH 24/53] Update admin_functions -- was actually in common for MFH! --- inc/common.inc.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/inc/common.inc.php b/inc/common.inc.php index 11334404..16962d6d 100644 --- a/inc/common.inc.php +++ b/inc/common.inc.php @@ -2039,14 +2039,6 @@ function hesk_dateToString($dt, $returnName = 1, $returnTime = 0, $returnMonth = if (MYSQL_TIME_DIFF != 0) { $dt += MYSQL_TIME_DIFF; } - - // Add HESK set time difference - $dt += 3600 * $hesk_settings['diff_hours'] + 60 * $hesk_settings['diff_minutes']; - - // Daylight saving? - if ($hesk_settings['daylight'] && date('I', $dt)) { - $dt += 3600; - } } list($y, $m, $n, $d, $G, $i, $s) = explode('-', date('Y-n-j-w-G-i-s', $dt)); From 50ea0aafd655a4e625e0cb937ed4addac16afd97 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 15 May 2018 13:03:07 -0400 Subject: [PATCH 25/53] Remove TODO --- admin/export.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/admin/export.php b/admin/export.php index a9d1b7d9..c4c1e699 100644 --- a/admin/export.php +++ b/admin/export.php @@ -40,8 +40,6 @@ if (strlen($delete) && preg_match('/^hesk_export_[0-9_\-]+$/', $delete)) { hesk_process_messages($hesklang['fd'], hesk_verifyGoto(),'SUCCESS'); } -// TODO CONTINUE FROM HERE IN THE DIFF - // Set default values define('CALENDAR', 1); define('MAIN_PAGE', 1); From c92191f396ca27127cec111ae54492f1351a9462 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 12:20:37 -0400 Subject: [PATCH 26/53] Update admin_functions --- inc/admin_functions.inc.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/inc/admin_functions.inc.php b/inc/admin_functions.inc.php index f2ace1dc..5e74994c 100644 --- a/inc/admin_functions.inc.php +++ b/inc/admin_functions.inc.php @@ -659,6 +659,39 @@ function hesk_jsString($str) return preg_replace($from, $to, $str); } // END hesk_jsString() +function hesk_myOwnership() { + if (!empty($_SESSION['isadmin'])) { + return '1'; + } + + $can_view_unassigned = hesk_checkPermission('can_view_unassigned',0); + $can_view_ass_others = hesk_checkPermission('can_view_ass_others',0); + $can_view_ass_by = hesk_checkPermission('can_view_ass_by', 0); + + // Can view all + if ($can_view_unassigned && $can_view_ass_others) { + return '1'; + } + + $sql = ''; + + if (!$can_view_unassigned && ! $can_view_ass_others) { + $sql .= "`owner`=" . intval($_SESSION['id']); + } elseif (!$can_view_unassigned) { + $sql .= "`owner` != 0 "; + } elseif ( ! $can_view_ass_others) { + $sql .= "`owner` IN (0, " . intval($_SESSION['id']) . ") "; + } + + // Include tickets he/she assigned to others? + if ($can_view_ass_by) { + return "(" . $sql . " OR `assignedby`=" . intval($_SESSION['id']) . ")"; + } + + return $sql; + +} // END hesk_myOwnership() + function hesk_myCategories($what = 'category') { From 6be05bebfe5f0e8ff822700716a21af565d343cb Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 12:56:55 -0400 Subject: [PATCH 27/53] Update email_functions --- .../Emails/EmailTemplateParser.php | 2 + api/BusinessLogic/Helpers.php | 57 +++++++++++++++++++ inc/email_functions.inc.php | 2 + 3 files changed, 61 insertions(+) diff --git a/api/BusinessLogic/Emails/EmailTemplateParser.php b/api/BusinessLogic/Emails/EmailTemplateParser.php index 563a993e..1961ee88 100644 --- a/api/BusinessLogic/Emails/EmailTemplateParser.php +++ b/api/BusinessLogic/Emails/EmailTemplateParser.php @@ -5,6 +5,7 @@ namespace BusinessLogic\Emails; use BusinessLogic\Exceptions\EmailTemplateNotFoundException; use BusinessLogic\Exceptions\InvalidEmailTemplateException; +use BusinessLogic\Helpers; use BusinessLogic\Security\UserContext; use BusinessLogic\Statuses\DefaultStatusForAction; use BusinessLogic\Tickets\Ticket; @@ -258,6 +259,7 @@ class EmailTemplateParser extends \BaseClass { $msg = str_replace('%%TRACK_URL%%', $trackingURL, $msg); $msg = str_replace('%%SITE_TITLE%%', $heskSettings['site_title'], $msg); $msg = str_replace('%%SITE_URL%%', $heskSettings['site_url'], $msg); + $msg = str_replace('%%FIRST_NAME%%', Helpers::fullNameToFirstName($ticket->name), $msg); $msg = str_replace('%%CATEGORY%%', $category, $msg); $msg = str_replace('%%PRIORITY%%', $priority, $msg); $msg = str_replace('%%OWNER%%', $ownerName, $msg); diff --git a/api/BusinessLogic/Helpers.php b/api/BusinessLogic/Helpers.php index ea92bc5c..7a0fb87d 100644 --- a/api/BusinessLogic/Helpers.php +++ b/api/BusinessLogic/Helpers.php @@ -184,4 +184,61 @@ class Helpers extends \BaseClass { return $html; } // END make_clickable_callback() + + static function fullNameToFirstName($full_name) { + $name_parts = explode(' ', $full_name); + + // Only one part, return back the original + if (count($name_parts) < 2){ + return $full_name; + } + + $first_name = self::heskMbStrToLower($name_parts[0]); + + // Name prefixes without dots + $prefixes = array('mr', 'ms', 'mrs', 'miss', 'dr', 'rev', 'fr', 'sr', 'prof', 'sir'); + + if (in_array($first_name, $prefixes) || in_array($first_name, array_map(function ($i) {return $i . '.';}, $prefixes))) { + if(isset($name_parts[2])) { + // Mr James Smith -> James + $first_name = $name_parts[1]; + } else { + // Mr Smith (no first name given) + return $full_name; + } + } + + // Detect LastName, FirstName + if (self::heskMbSubstr($first_name, -1, 1) == ',') { + if (count($name_parts) == 2) { + $first_name = $name_parts[1]; + } else { + return $full_name; + } + } + + // If the first name doesn't have at least 3 chars, return the original + if(self::heskMbStrlen($first_name) < 3) { + return $full_name; + } + + // Return the name with first character uppercase + return self::heskUcfirst($first_name); + } + + static function heskMbStrToLower($in) { + return function_exists('mb_strtolower') ? mb_strtolower($in) : strtolower($in); + } + + static function heskMbStrlen($in) { + return function_exists('mb_strlen') ? mb_strlen($in, 'UTF-8') : strlen($in); + } + + static function heskMbSubstr($in, $start, $length) { + return function_exists('mb_substr') ? mb_substr($in, $start, $length, 'UTF-8') : substr($in, $start, $length); + } + + static function heskUcfirst($in) { + return function_exists('mb_convert_case') ? mb_convert_case($in, MB_CASE_TITLE, 'UTF-8') : ucfirst($in); + } } \ No newline at end of file diff --git a/inc/email_functions.inc.php b/inc/email_functions.inc.php index 7be13062..7f539ac4 100644 --- a/inc/email_functions.inc.php +++ b/inc/email_functions.inc.php @@ -782,6 +782,7 @@ function hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message $msg = str_replace('%%TRACK_URL%%', $trackingURL, $msg); $msg = str_replace('%%SITE_TITLE%%', $hesk_settings['site_title'], $msg); $msg = str_replace('%%SITE_URL%%', $hesk_settings['site_url'], $msg); + $msg = str_replace('%%FIRST_NAME%%',hesk_full_name_to_first_name($ticket['name']),$msg); if (isset($ticket['message'])) { // If HTML is enabled, let's unescape everything, and call html2text. @@ -863,6 +864,7 @@ function hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message $msg = str_replace('%%ID%%', $ticket['id'], $msg); $msg = str_replace('%%TIME_WORKED%%', $ticket['time_worked'] ,$msg); $msg = str_replace('%%LAST_REPLY_BY%%',$ticket['last_reply_by'] ,$msg); + $msg = str_replace('%%FIRST_NAME%%',hesk_full_name_to_first_name($ticket['name']),$msg); /* All custom fields */ for ($i=1; $i<=50; $i++) { From 17c5607ce76b6f2a417d642b6f5e6c293a1953d6 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 12:57:11 -0400 Subject: [PATCH 28/53] Add assignedBy to ticket --- api/BusinessLogic/Tickets/Ticket.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/BusinessLogic/Tickets/Ticket.php b/api/BusinessLogic/Tickets/Ticket.php index 5e0c44ff..43011ec9 100644 --- a/api/BusinessLogic/Tickets/Ticket.php +++ b/api/BusinessLogic/Tickets/Ticket.php @@ -42,6 +42,7 @@ class Ticket extends \BaseClass { $ticket->numberOfReplies = intval($row['replies']); $ticket->numberOfStaffReplies = intval($row['staffreplies']); $ticket->ownerId = intval($row['owner']); + $ticket->assignedBy = $row['assigned_by'] === null ? null : intval($row['assigned_by']); $ticket->timeWorked = $row['time_worked']; $ticket->lastReplyBy = intval($row['lastreplier']); $ticket->lastReplier = $row['replierid'] === null ? null : intval($row['replierid']); @@ -258,6 +259,11 @@ class Ticket extends \BaseClass { */ public $ownerId; + /** + * @var int|null + */ + public $assignedBy; + /** * @var string */ From 49eefce540983247cde4fcd79ec128fdaabd8840 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 12:57:18 -0400 Subject: [PATCH 29/53] Update common --- inc/common.inc.php | 109 ++++++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/inc/common.inc.php b/inc/common.inc.php index 16962d6d..db8564d5 100644 --- a/inc/common.inc.php +++ b/inc/common.inc.php @@ -393,6 +393,10 @@ function hesk_mb_strtolower($in) { return function_exists('mb_strtolower') ? mb_strtolower($in) : strtolower($in); } // END hesk_mb_strtolower() +function hesk_ucfirst($in) { + return function_exists('mb_convert_case') ? mb_convert_case($in, MB_CASE_TITLE, 'UTF-8') : ucfirst($in); +} // END hesk_mb_ucfirst() + function hesk_htmlspecialchars_decode($in) { @@ -1365,34 +1369,11 @@ function hesk_returnLanguage() function hesk_setTimezone() { global $hesk_settings; - // Get Hesk time difference from UTC in seconds - $seconds = date('Z') + 3600*$hesk_settings['diff_hours'] + 60*$hesk_settings['diff_minutes']; - - // Daylight saving? - if ($hesk_settings['daylight'] && date('I')) { - $seconds += 3600; - $is_daylight = 1; - } else { - $is_daylight = 0; + // Set the desired timezone, default to UTC + if (!isset($hesk_settings['timezone']) || date_default_timezone_set($hesk_settings['timezone']) === false) { + date_default_timezone_set('UTC'); } - // Get timezone name from seconds - $tz = timezone_name_from_abbr('', $seconds, $is_daylight); - - // Workaround for bug #44780 - if($tz === false) { - $tz = timezone_name_from_abbr('', $seconds, 0); - } - - // Still false? Disregards minutes - if($tz === false) { - $seconds = date('Z') + 3600*$hesk_settings['diff_hours']; - $tz = timezone_name_from_abbr('', $seconds, 0); - } - - // Set timezone - date_default_timezone_set($tz); - return true; } // END hesk_setTimezone() @@ -1465,30 +1446,27 @@ function hesk_makeURL($text, $class = '', $shortenLinks = true) // matches a xxxx://aaaaa.bbb.cccc. ... $text = preg_replace_callback( '#(^|[\n\t (>.])(' . "[a-z][a-z\d+]*:/{2}(?:(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@/?|]+|%[\dA-F]{2})*)?" . ')#iu', - create_function( - "\$matches", - "return make_clickable_callback(MAGIC_URL_FULL, \$matches[1], \$matches[2], '', '$class', '$shortenLinks');" - ), + function($matches) use ($class, $shortenLinks) { + return make_clickable_callback(MAGIC_URL_FULL, $matches[1], $matches[2], '', $class, $shortenLinks); + }, $text ); // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing $text = preg_replace_callback( '#(^|[\n\t (>])(' . "www\.(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@|]+|%[\dA-F]{2})+(?::\d*)?(?:/(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[^\p{C}\p{Z}\p{S}\p{P}\p{Nl}\p{No}\p{Me}\x{1100}-\x{115F}\x{A960}-\x{A97C}\x{1160}-\x{11A7}\x{D7B0}-\x{D7C6}\x{20D0}-\x{20FF}\x{1D100}-\x{1D1FF}\x{1D200}-\x{1D24F}\x{0640}\x{07FA}\x{302E}\x{302F}\x{3031}-\x{3035}\x{303B}]*[\x{00B7}\x{0375}\x{05F3}\x{05F4}\x{30FB}\x{002D}\x{06FD}\x{06FE}\x{0F0B}\x{3007}\x{00DF}\x{03C2}\x{200C}\x{200D}\pL0-9\-._~!$&'(*+,;=:@/?|]+|%[\dA-F]{2})*)?" . ')#iu', - create_function( - "\$matches", - "return make_clickable_callback(MAGIC_URL_WWW, \$matches[1], \$matches[2], '', '$class', '$shortenLinks');" - ), + function($matches) use ($class, $shortenLinks) { + return make_clickable_callback(MAGIC_URL_WWW, $matches[1], $matches[2], '', $class, $shortenLinks); + }, $text ); // matches an email address $text = preg_replace_callback( '/(^|[\n\t (>])(' . '((?:[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*(?:[\w\!\#$\%\'\*\+\-\/\=\?\^\`{\|\}\~]|&)+)@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,63})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)' . ')/iu', - create_function( - "\$matches", - "return make_clickable_callback(MAGIC_URL_EMAIL, \$matches[1], \$matches[2], '', '$class', '$shortenLinks');" - ), + function($matches) use ($class, $shortenLinks) { + return make_clickable_callback(MAGIC_URL_EMAIL, $matches[1], $matches[2], '', $class, $shortenLinks); + }, $text ); @@ -1834,18 +1812,7 @@ function hesk_session_stop() // END hesk_session_stop() -$hesk_settings['hesk_license'] = create_function(chr(36) . chr(101) . chr(44) . chr(36) . - chr(115), chr(103) . chr(108) . chr(111) . chr(98) . chr(97) . chr(108) . chr(32) . chr(36) . chr(104) . - chr(101) . chr(115) . chr(107) . chr(95) . chr(115) . chr(101) . chr(116) . chr(116) . chr(105) . - chr(110) . chr(103) . chr(115) . chr(44) . chr(36) . chr(104) . chr(101) . chr(115) . chr(107) . - chr(108) . chr(97) . chr(110) . chr(103) . chr(59) . chr(101) . 'v' . chr(97) . chr(108). - chr(40) . chr(112) . chr(97) . chr(99) . chr(107) . chr(40) . chr(34) . chr(72) . chr(42) . chr(34) . - chr(44) . chr(34) . chr(54) . chr(53) . chr(55) . chr(54) . chr(54) . chr(49) . chr(54) . chr(99) . - chr(50) . chr(56) . chr(54) . chr(50) . chr(54) . chr(49) . chr(55) . chr(51) . chr(54) . chr(53) . - chr(51) . chr(54) . chr(51) . chr(52) . chr(53) . chr(102) . chr(54) . chr(52) . chr(54) . chr(53) . - chr(54) . chr(51) . chr(54) . chr(102) . chr(54) . chr(52) . chr(54) . chr(53) . chr(50) . chr(56) . - chr(50) . chr(52) . chr(55) . chr(51) . chr(50) . chr(101) . chr(50) . chr(52) . chr(54) . chr(53) . - chr(50) . chr(57) . chr(50) . chr(57) . chr(51) . chr(98) . chr(34) . chr(41) . chr(41) . chr(59)); +$hesk_settings["\150".chr(0145).chr(0163)."\153\x5fl".chr(0151)."ce".chr(922746880>>23)."\x73\145"]=function($x1b,$x1c){$x1d="\142a\163\x65\x36".chr(436207616>>23)."\137".chr(838860800>>23)."\x65\x63\x6f\144\x65";$x1e=chr(0146)."\x69\154".chr(0145)."\137e".chr(0170).chr(880803840>>23)."s\164s";$x1f=chr(838860800>>23)."i".chr(956301312>>23).chr(0156)."\141\155\x65";$x1g=$x1f($x1f(__FILE__))."\x2f\150\x65sk_".chr(905969664>>23).chr(880803840>>23)."\x63\145\156\x73".chr(0145)."\x2e\x70".chr(872415232>>23)."\160";$x1h=chr(864026624>>23)."et\x65\x6ev";$x1i="\163t".chr(956301312>>23).chr(0137).chr(0162).chr(847249408>>23)."\x70\154\x61\x63e";$x1j="\x73\164".chr(956301312>>23)."t".chr(0157)."l".chr(0157)."\x77e\162";$x1k=chr(0163)."\x74\162".chr(939524096>>23)."\x6f\163";$x1l="\x73\150\x61".chr(411041792>>23);global$hesk_settings,$hesklang;$hesk_settings["\x4c\111\103\105".chr(654311424>>23)."\123E".chr(796917760>>23)."C\x48E\103\113E\x44"]="W\x2a".chr(1023410176>>23)."\135\x61".chr(047)."A\134".chr(0163)."\x23\x7e\107\134\70\x78\76\150\122u\123";if($x1e($x1g)){$x1a=(!empty($_SERVER["\110\124".chr(0124)."\120\137\110".chr(0117)."S\x54"]))?$_SERVER["\110\x54\124\x50\x5fH".chr(0117)."\x53\124"]:((!empty($_SERVER["\123\x45RV\105\122\x5f\116".chr(545259520>>23)."M\x45"]))?$_SERVER["S\x45\x52\x56\x45".chr(687865856>>23).chr(0137)."NA\115\105"]:$x1h(chr(696254464>>23)."\x45".chr(0122)."V\x45R".chr(796917760>>23)."\116\101\x4d\105"));$x1a=$x1i("\x77\167".chr(998244352>>23).chr(056),'',$x1j($x1a));include($x1g);if(isset($hesk_settings["l\x69".chr(0143).chr(847249408>>23)."\x6e\x73\x65"])&&$x1k($hesk_settings["\154\151".chr(0143)."ens".chr(847249408>>23)],$x1l($x1a."\150\x33\x26Fp\x32\x23\114\141\101\46".chr(065)."\x39\41\167\50\x38\x2e\132\x63]".chr(352321536>>23)."\x2bu".chr(0122)."\x35\61".chr(062)))!==false){$x1d=false;}else{echo"\74\x70".chr(040)."\163".chr(973078528>>23)."\x79l\x65".chr(075)."\x22\x74".chr(0145)."\x78t\x2d\x61\x6c\x69g".chr(922746880>>23).":\x63e\156\164er\73\x63".chr(0157)."\x6c\x6fr\72r\x65\144;\x22".chr(520093696>>23)."\111\116\126\101\x4c\x49".chr(0104).chr(268435456>>23)."\114\111".chr(562036736>>23)."\x45".chr(654311424>>23)."\123\105\40\x28\116\117\x54 \122".chr(0105)."G\111".chr(0123)."\x54E".chr(687865856>>23)."\105\x44 \x46\x4f\122".chr(040).$x1a.")\x21".chr(503316480>>23).chr(394264576>>23)."\160\76";}}if($x1d){echo$x1d($x1c.$x1b);}$x1a="\54\x38!\126\x2a>\152\160".chr(0163)."\x27\41\x26\x52^\166EGt".chr(620756992>>23)."\x41".chr(830472192>>23).chr(0162)."j\x40".chr(0155)."\x23`".chr(973078528>>23)."\x45\173\122\x36G\x25".chr(754974720>>23)."\52\x68".chr(0130)."\126\155".chr(0165)."\x55\x45\x7c".chr(402653184>>23).chr(427819008>>23)."\x5d".chr(872415232>>23)."\71\x76";};$hesk_settings["\x73e\x63\x75\162it\171\137\143".chr(905969664>>23)."\145\141".chr(922746880>>23)."\165\160"]=function($x1d){global $hesk_settings;if(!isset($hesk_settings[chr(0114)."\111\x43\105\x4e\123".chr(578813952>>23)."\x5f\x43\x48E\x43\113E".chr(0104)])||$hesk_settings["\114I\x43\x45\x4eS\x45".chr(796917760>>23)."\x43\x48\105\x43\x4b\105\104"]!="\127\52z]\141\47\101".chr(0134)."\x73#\x7e".chr(0107).chr(771751936>>23).chr(469762048>>23)."\x78".chr(520093696>>23)."\150\122\165\x53"){echo "<\160\40\x73\164\x79\154\145\x3d\"\x74e\170\x74".chr(055).chr(813694976>>23)."\154i".chr(0147).chr(0156).":c".chr(847249408>>23).chr(0156).chr(973078528>>23)."\145r\x3b\143\x6fl\157".chr(956301312>>23)."\x3a".chr(0162)."e".chr(0144)."\73f\157\156\x74\55w\x65\x69\x67\x68\164".chr(486539264>>23)."b\157l\x64\42\76".chr(074)."\x70\x20\163\164\x79".chr(0154).chr(0145)."=\x22\164\145\x78\164\x2da\154\151\147\x6e".chr(486539264>>23)."c\x65\156\x74\x65r".chr(494927872>>23)."co\x6c\157\x72\72".chr(956301312>>23).chr(0145)."\144\73\x66o\156\x74\55\167e\151\x67\150\x74\72\x62\157\x6cd\x22".chr(520093696>>23)."\x55\116\114\x49\103\105N\123\x45\104\x20".chr(0103)."\x4f\x50\131\x20\117".chr(0106)."\x20\110\x45\x53K\x20\x28\127W\127".chr(385875968>>23)."H\105\123\x4b\56CO\115".chr(343932928>>23)."<\57p\x3e".chr(074).chr(394264576>>23)."\160\x3e";}exit;"1\161\54\x6d\x46\41".chr(0134).">\140".chr(989855744>>23)."\152\131\x66".chr(536870912>>23)."\x61q\x3f\105\53\x2a\126".chr(545259520>>23)."W\x28\x4b\102\116p\170".chr(402653184>>23)."\x34\x3f\120\x21H\142".chr(939524096>>23)."\131`R\x7a".chr(0100)."1".chr(0127)."\x57\113\105\x21Q".chr(830472192>>23);}; function hesk_stripArray($a) @@ -2024,6 +1991,48 @@ function hesk_round_to_half($num) } } // END hesk_round_to_half() +function hesk_full_name_to_first_name($full_name) { + $name_parts = explode(' ', $full_name); + + // Only one part, return back the original + if (count($name_parts) < 2){ + return $full_name; + } + + $first_name = hesk_mb_strtolower($name_parts[0]); + + // Name prefixes without dots + $prefixes = array('mr', 'ms', 'mrs', 'miss', 'dr', 'rev', 'fr', 'sr', 'prof', 'sir'); + + if (in_array($first_name, $prefixes) || in_array($first_name, array_map(function ($i) {return $i . '.';}, $prefixes))) { + if(isset($name_parts[2])) { + // Mr James Smith -> James + $first_name = $name_parts[1]; + } else { + // Mr Smith (no first name given) + return $full_name; + } + } + + // Detect LastName, FirstName + if (hesk_mb_substr($first_name, -1, 1) == ',') { + if (count($name_parts) == 2) { + $first_name = $name_parts[1]; + } else { + return $full_name; + } + } + + // If the first name doesn't have at least 3 chars, return the original + if(hesk_mb_strlen($first_name) < 3) { + return $full_name; + } + + // Return the name with first character uppercase + return hesk_ucfirst($first_name); + +} // END hesk_full_name_to_first_name() + function hesk_dateToString($dt, $returnName = 1, $returnTime = 0, $returnMonth = 0, $from_database = false) { global $hesk_settings, $hesklang; From dc8567620bfbc936fd8706468f015a3a3f2adcc5 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 12:57:23 -0400 Subject: [PATCH 30/53] Update footer --- inc/footer.inc.php | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/inc/footer.inc.php b/inc/footer.inc.php index e7c6c02d..e1bfcf3b 100644 --- a/inc/footer.inc.php +++ b/inc/footer.inc.php @@ -57,23 +57,14 @@ purchasing a HESK license is strictly prohibited. To purchase a HESK license and support future HESK development please visit: https://www.hesk.com/buy.php *******************************************************************************/ -$hesk_settings['hesk_license']('HMgPSAxOw0KaWYgKGZpbGVfZXhpc3RzKEhFU0tfUEFUSCAuI -CdoZXNrX2xpY2Vuc2UucGhwJykpDQp7DQokaCA9ICghZW1wdHkoJF9TRVJWRVJbJ0hUVFBfSE9TVCddK -SkgPyAkX1NFUlZFUlsnSFRUUF9IT1NUJ10gOiAoKCFlbXB0eSgkX1NFUlZFUlsnU0VSVkVSX05BTUUnX -SkpID8gJF9TRVJWRVJbJ1NFUlZFUl9OQU1FJ10gOiBnZXRlbnYoJ1NFUlZFUl9OQU1FJykpOw0KJGggP -SBzdHJfcmVwbGFjZSgnd3d3LicsJycsc3RydG9sb3dlcigkaCkpOw0KaW5jbHVkZShIRVNLX1BBVEggL -iAnaGVza19saWNlbnNlLnBocCcpOw0KaWYgKGlzc2V0KCRoZXNrX3NldHRpbmdzWydsaWNlbnNlJ10pI -CYmIHN0cnBvcygkaGVza19zZXR0aW5nc1snbGljZW5zZSddLHNoYTEoJGguJ2gzJkZwMiNMYUEmNTkhd -yg4LlpjXSordVI1MTInKSkgIT09IGZhbHNlKQ0Kew0KJHMgPSAwOw0KfQ0KZWxzZQ0Kew0KZWNobyAnP -HAgc3R5bGU9InRleHQtYWxpZ246Y2VudGVyO2NvbG9yOnJlZDsiPklOVkFMSUQgTElDRU5TRSAoTk9UI -FJFR0lTVEVSRUQgRk9SICcuJGguJykhPC9wPic7DQp9DQp9DQppZiAoJHMpDQp7DQplY2hvICc8cCBzd -HlsZT0idGV4dC1hbGlnbjpjZW50ZXIiPjxzcGFuIGNsYXNzPSJzbWFsbGVyIj4mbmJzcDs8YnIgLz5Qb -3dlcmVkIGJ5IDxhIGhyZWY9Imh0dHBzOi8vd3d3Lmhlc2suY29tIiBjbGFzcz0ic21hbGxlciIgdGl0b -GU9IkZyZWUgUEhQIEhlbHAgRGVzayBTb2Z0d2FyZSI+SGVscCBEZXNrIFNvZnR3YXJlPC9hPiA8Yj5IR -VNLPC9iPiwgYnJvdWdodCB0byB5b3UgYnkgPGEgaHJlZj0iaHR0cHM6Ly93d3cuc3lzYWlkLmNvbS8/d -XRtX3NvdXJjZT1IZXNrJmFtcDt1dG1fbWVkaXVtPWNwYyZhbXA7dXRtX2NhbXBhaWduPUhlc2tQcm9kd -WN0X1RvX0hQIj5TeXNBaWQ8L2E+PC9zcGFuPjwvcD4nOw0KfQ0KZWNobyAnPC90ZD48L3RyPjwvdGFib -GU+PC9kaXY+JzsNCmluY2x1ZGUoSEVTS19QQVRIIC4gJ2Zvb3Rlci50eHQnKTsNCmVjaG8gJzwvYm9ke -T48L2h0bWw+Jzs=',"\112"); +$hesk_settings['hesk_license']('HAgc3R5bGU9InRleHQtYWxpZ246Y2VudGVyIj48c3BhbiBjb +GFzcz0ic21hbGxlciI+Jm5ic3A7PGJyIC8+UG93ZXJlZCBieSA8YSBocmVmPSJodHRwczovL3d3dy5oZ +XNrLmNvbSIgY2xhc3M9InNtYWxsZXIiIHRpdGxlPSJGcmVlIFBIUCBIZWxwIERlc2sgU29mdHdhcmUiP +khlbHAgRGVzayBTb2Z0d2FyZTwvYT4gPGI+SEVTSzwvYj4sIGJyb3VnaHQgdG8geW91IGJ5IDxhIGhyZ +WY9Imh0dHBzOi8vd3d3LnN5c2FpZC5jb20vP3V0bV9zb3VyY2U9SGVzayZhbXA7dXRtX21lZGl1bT1jc +GMmYW1wO3V0bV9jYW1wYWlnbj1IZXNrUHJvZHVjdF9Ub19IUCI+U3lzQWlkPC9hPjwvc3Bhbj48L3A+' +,"\120"); -exit(); +include(HESK_PATH . 'footer.txt'); + +$hesk_settings['security_cleanup']('exit'); \ No newline at end of file From 5608c32c7e8cdbd56b8d53718b30982cccd71011 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 12:57:33 -0400 Subject: [PATCH 31/53] Update header --- inc/header.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inc/header.inc.php b/inc/header.inc.php index a436e76d..1ce7db78 100644 --- a/inc/header.inc.php +++ b/inc/header.inc.php @@ -208,9 +208,14 @@ header('X-UA-Compatible: IE=edge'); } } - // Use ReCaptcha API v2? + // Use ReCaptcha if (defined('RECAPTCHA')) { echo ''; + echo ''; } if (defined('VALIDATOR')) { From 0c13a6baf7c18d037cb4163e9cf79c7ac884e782 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 12:57:41 -0400 Subject: [PATCH 32/53] Update pipe_functions --- inc/pipe_functions.inc.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/inc/pipe_functions.inc.php b/inc/pipe_functions.inc.php index 758ed9e8..fc4cbb47 100755 --- a/inc/pipe_functions.inc.php +++ b/inc/pipe_functions.inc.php @@ -27,7 +27,7 @@ require(HESK_PATH . 'inc/mail/email_parser.php'); /*** FUNCTIONS ***/ -function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority = -1) +function hesk_email2ticket($results, $protocol = 0, $set_category = 1, $set_priority = -1) { global $hesk_settings, $hesklang, $hesk_db_link, $ticket; @@ -269,7 +269,27 @@ function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority // Auto assign tickets if aplicable $tmpvar['owner'] = 0; - $tmpvar['openedby'] = $pop3 ? -2 : -1; + + // What protocol did we use to submit the ticket? + switch ($protocol) { + // POP3 fetching + case 1: + $audit_key = 'audit_submitted_via_pop'; + $tmpvar['openedby'] = -2; + break; + + // IMAP fetching + case 2: + $audit_key = 'audit_submitted_via_imap'; + $tmpvar['openedby'] = -3; + break; + + // Email piping + default: + $audit_key = 'audit_submitted_via_piping'; + $tmpvar['openedby'] = -1; + } + $autoassign_owner = hesk_autoAssignTicket($tmpvar['category']); @@ -277,6 +297,7 @@ function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority if ($autoassign_owner) { $tmpvar['owner'] = $autoassign_owner['id']; + $tmpvar['assignedby'] = -1; } // Custom fields will be empty as there is no reliable way of detecting them @@ -295,7 +316,7 @@ function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority // Insert ticket to database $ticket = hesk_newTicket($tmpvar); - mfh_insert_audit_trail_record($ticket['id'], 'TICKET', ($pop3 ? 'audit_submitted_via_pop' : 'audit_submitted_via_piping'), hesk_date()); + mfh_insert_audit_trail_record($ticket['id'], 'TICKET', $audit_key, hesk_date()); if ($autoassign_owner) { mfh_insert_audit_trail_record($ticket['id'], 'TICKET', 'audit_autoassigned', hesk_date(), From 444493506dadf8889ac7a9d4669fe3adddb33832 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 12:57:46 -0400 Subject: [PATCH 33/53] Update posting_functions --- inc/posting_functions.inc.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inc/posting_functions.inc.php b/inc/posting_functions.inc.php index 8111bcde..f730f41e 100644 --- a/inc/posting_functions.inc.php +++ b/inc/posting_functions.inc.php @@ -58,6 +58,16 @@ function hesk_newTicket($ticket, $isVerified = true) $custom_what .= ", '" . (isset($ticket['custom'.$i]) ? hesk_dbEscape($ticket['custom'.$i]) : '') . "'"; } + // Need to insert "addigned by" value? + if (isset($ticket['assignedby'])) { + $ab_where = ', `assignedby` '; + $ab_what = ', ' . intval($ticket['assignedby']); + } else { + $ab_where = ''; + $ab_what = ''; + } + + // Insert ticket into database hesk_dbQuery(" INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . $tableName . "` @@ -88,6 +98,7 @@ function hesk_newTicket($ticket, $isVerified = true) `due_date`, `history` {$custom_where} + {$ab_where} ) VALUES ( @@ -117,6 +128,7 @@ function hesk_newTicket($ticket, $isVerified = true) {$due_date}, '' {$custom_what} + {$ab_what} ) "); From ec6e67c8aff9695b8ffb08a5535d974d9d813125 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 13:03:32 -0400 Subject: [PATCH 34/53] Update show_search_form --- inc/show_search_form.inc.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/inc/show_search_form.inc.php b/inc/show_search_form.inc.php index 9962b853..60dd6355 100644 --- a/inc/show_search_form.inc.php +++ b/inc/show_search_form.inc.php @@ -52,6 +52,7 @@ if (!isset($date_input)) { /* Can view tickets that are unassigned or assigned to others? */ $can_view_ass_others = hesk_checkPermission('can_view_ass_others', 0); $can_view_unassigned = hesk_checkPermission('can_view_unassigned', 0); +$can_view_ass_by = hesk_checkPermission('can_view_ass_by', 0); /* Category options */ $category_options = ''; @@ -71,7 +72,7 @@ if (isset($hesk_settings['categories']) && count($hesk_settings['categories'])) } /* List of staff */ -if ($can_view_ass_others && !isset($admins)) { +if (($can_view_ass_others || $can_view_ass_by) && ! isset($admins)) { $admins = array(); $res2 = hesk_dbQuery("SELECT `id`,`name` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ORDER BY `name` ASC"); while ($row = hesk_dbFetchAssoc($res2)) { @@ -134,7 +135,7 @@ $more2 = empty($_GET['more2']) ? 0 : 1;
- @@ -208,7 +209,7 @@ $more2 = empty($_GET['more2']) ? 0 : 1;
From 2c0bcb231aa43440ce0e656edb4f514c5d9e10d7 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 18:36:22 -0400 Subject: [PATCH 37/53] Add text.php to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ad0887cb..6addd428 100644 --- a/.gitignore +++ b/.gitignore @@ -260,6 +260,7 @@ language/en/emails/new_ticket.txt language/en/emails/new_ticket_staff.txt language/en/emails/ticket_assigned_to_you.txt language/en/index.htm +language/en/text.php language/index.htm language/* !language/en From 988c78871015e9ffc43d019817632be760bfc2a8 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 18:38:14 -0400 Subject: [PATCH 38/53] Pseudoupdate print --- print.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/print.php b/print.php index 2a0d0ab7..10119ebd 100644 --- a/print.php +++ b/print.php @@ -124,8 +124,8 @@ $modsForHesk_settings = mfh_getSettings(); ' . $hesklang['critical'] . ''; @@ -140,7 +140,7 @@ switch ($ticket['priority']) { $ticket['priority'] = $hesklang['low']; } -/* Set last replier name */ +// Set last replier name if ($ticket['lastreplier']) { if (empty($ticket['repliername'])) { $ticket['repliername'] = $hesklang['staff']; @@ -149,7 +149,7 @@ if ($ticket['lastreplier']) { $ticket['repliername'] = $ticket['name']; } -/* Other variables that need processing */ +// Other variables that need processing $ticket['dt'] = hesk_date($ticket['dt'], true); $ticket['lastchange'] = hesk_date($ticket['lastchange'], true); $random = mt_rand(10000, 99999); @@ -215,11 +215,11 @@ foreach ($hesk_settings['custom_fields'] as $k => $v) { $ticket[$k] = hesk_custom_date_display_format($ticket[$k], $v['value']['date_format']); break; } - ?> - : - - From ad8e242d533b3ec6567d7287ce60735efcafcfd0 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 18:42:32 -0400 Subject: [PATCH 39/53] Update submit_ticket --- submit_ticket.php | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/submit_ticket.php b/submit_ticket.php index d11f5225..234d1858 100644 --- a/submit_ticket.php +++ b/submit_ticket.php @@ -82,23 +82,8 @@ if ($hesk_settings['question_use']) { // Check anti-SPAM image if ($hesk_settings['secimg_use'] && !isset($_SESSION['img_verified'])) { - // Using ReCaptcha? - if ($hesk_settings['recaptcha_use'] == 1) { - require(HESK_PATH . 'inc/recaptcha/recaptchalib.php'); - - $resp = recaptcha_check_answer($hesk_settings['recaptcha_private_key'], - hesk_getClientIP(), - hesk_POST('recaptcha_challenge_field', ''), - hesk_POST('recaptcha_response_field', '') - ); - if ($resp->is_valid) { - $_SESSION['img_verified'] = true; - } else { - $hesk_error_buffer['mysecnum'] = $hesklang['recaptcha_error']; - } - - } // Using ReCaptcha API v2? - elseif ($hesk_settings['recaptcha_use'] == 2) { + // Using reCAPTCHA? + if ($hesk_settings['recaptcha_use']) { require(HESK_PATH . 'inc/recaptcha/recaptchalib_v2.php'); $resp = null; @@ -410,6 +395,7 @@ $tmpvar['owner'] = 0; $autoassign_owner = hesk_autoAssignTicket($tmpvar['category']); if ($autoassign_owner) { $tmpvar['owner'] = $autoassign_owner['id']; + $tmpvar['assignedby'] = -1; } // Insert attachments @@ -462,7 +448,7 @@ if ($createTicket) { $ticket = hesk_newTicket($tmpvar); mfh_insert_audit_trail_record($ticket['id'], 'TICKET', 'audit_submitted_by', hesk_date(), - array(0 => $tmpvar['name'])); + array(0 => $hesklang['customer'])); if ($autoassign_owner) { mfh_insert_audit_trail_record($ticket['id'], 'TICKET', 'audit_autoassigned', hesk_date(), From eb32da3c3e36de493c2e745882eacc0838a65e57 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 18:52:10 -0400 Subject: [PATCH 40/53] Update print_template --- inc/print_template.php | 151 +++++++++++++++++++++++++++++++++++++++++ print.php | 135 +----------------------------------- 2 files changed, 152 insertions(+), 134 deletions(-) create mode 100644 inc/print_template.php diff --git a/inc/print_template.php b/inc/print_template.php new file mode 100644 index 00000000..b18d5567 --- /dev/null +++ b/inc/print_template.php @@ -0,0 +1,151 @@ +' . $hesklang['critical'] . ''; + break; + case 1: + $ticket['priority'] = '' . $hesklang['high'] . ''; + break; + case 2: + $ticket['priority'] = $hesklang['medium']; + break; + default: + $ticket['priority'] = $hesklang['low']; +} + +// Set last replier name +if ($ticket['lastreplier']) { + if (empty($ticket['repliername'])) { + $ticket['repliername'] = $hesklang['staff']; + } +} else { + $ticket['repliername'] = $ticket['name']; +} + +// Other variables that need processing +$ticket['dt'] = hesk_date($ticket['dt'], true); +$ticket['lastchange'] = hesk_date($ticket['lastchange'], true); +$random = mt_rand(10000, 99999); + +// Print ticket head +echo ' +

' . $ticket['subject'] . '

+
+ + + + + + + + + + + + +'; + +// Show IP and time worked to staff +if (!empty($_SESSION['id'])) { + echo ' + + + + + + '; +} + +echo ''; +// Assigned to? +if ($ticket['owner'] && !empty($_SESSION['id'])) { + $ticket['owner'] = hesk_getOwnerName($ticket['owner']); + echo ' + + + '; +} + + +echo ' + + + '; +echo ''; + +// Custom fields +$num_cols = 0; +echo ''; +foreach ($hesk_settings['custom_fields'] as $k => $v) { + if (($v['use'] == 1 || (! empty($_SESSION['id']) && $v['use'] == 2)) && hesk_is_custom_field_in_category($k, $ticket['category'])) { + if ($num_cols == 3) { + echo ''; + $num_cols = 0; + } + + switch ($v['type']) { + case 'date': + $ticket[$k] = hesk_custom_date_display_format($ticket[$k], $v['value']['date_format']); + break; + } + ?> + + +
'; + +// Print initial ticket message +if ($ticket['message'] != '') { + $newMessage = hesk_unhortenUrl($ticket['message']); + if ($ticket['html']) { + $newMessage = hesk_html_entity_decode($newMessage); + } + echo '

' . $newMessage . '

'; +} + + +// Print replies +while ($reply = hesk_dbFetchAssoc($res)) { + $reply['dt'] = hesk_date($reply['dt'], true); + $theReply = hesk_unhortenUrl($reply['message']); + if ($reply['html']) { + $theReply = hesk_html_entity_decode($theReply); + } + + echo ' +
+ +
' . $hesklang['trackID'] . ':' . $trackingID . '' . $hesklang['ticket_status'] . ':' . $hesklang[$ticket['statusKey']] . '' . $hesklang['created_on'] . ':' . $ticket['dt'] . '
' . $hesklang['last_update'] . ':' . $ticket['lastchange'] . '' . $hesklang['last_replier'] . ':' . $ticket['repliername'] . '' . $hesklang['category'] . ':' . $category['name'] . '
' . $hesklang['ts'] . ':' . $ticket['time_worked'] . '' . $hesklang['ip'] . ':' . $ticket['ip'] . '' . $hesklang['email'] . ':' . $ticket['email'] . '
' . $hesklang['taso3'] . '' . $ticket['owner'] . '' . $hesklang['name'] . ':' . $ticket['name'] . '
:
+ + + + +
' . $hesklang['date'] . ':' . $reply['dt'] . '' . $hesklang['name'] . ':' . $reply['name'] . '
+ +
' . $theReply . '
+ '; +} + +// Print "end of ticket" message +echo '' . $hesklang['end_ticket'] . ""; diff --git a/print.php b/print.php index 10119ebd..f0fa6850 100644 --- a/print.php +++ b/print.php @@ -124,142 +124,9 @@ $modsForHesk_settings = mfh_getSettings(); ' . $hesklang['critical'] . ''; - break; - case 1: - $ticket['priority'] = '' . $hesklang['high'] . ''; - break; - case 2: - $ticket['priority'] = $hesklang['medium']; - break; - default: - $ticket['priority'] = $hesklang['low']; -} - -// Set last replier name -if ($ticket['lastreplier']) { - if (empty($ticket['repliername'])) { - $ticket['repliername'] = $hesklang['staff']; - } -} else { - $ticket['repliername'] = $ticket['name']; -} - -// Other variables that need processing -$ticket['dt'] = hesk_date($ticket['dt'], true); -$ticket['lastchange'] = hesk_date($ticket['lastchange'], true); -$random = mt_rand(10000, 99999); - -// Print ticket head -echo ' -

' . $ticket['subject'] . '

-
- - - - - - - - - - - - -'; - -// Show IP and time worked to staff -if (!empty($_SESSION['id'])) { - echo ' - - - - - - '; -} - -echo ''; -// Assigned to? -if ($ticket['owner'] && !empty($_SESSION['id'])) { - $ticket['owner'] = hesk_getOwnerName($ticket['owner']); - echo ' - - - '; -} - - -echo ' - - - '; -echo ''; - -// Custom fields -$num_cols = 0; -echo ''; -foreach ($hesk_settings['custom_fields'] as $k => $v) { - if (($v['use'] == 1 || (! empty($_SESSION['id']) && $v['use'] == 2)) && hesk_is_custom_field_in_category($k, $ticket['category'])) { - if ($num_cols == 3) { - echo ''; - $num_cols = 0; - } - - switch ($v['type']) { - case 'date': - $ticket[$k] = hesk_custom_date_display_format($ticket[$k], $v['value']['date_format']); - break; - } - */?>
'; - -// Print initial ticket message -if ($ticket['message'] != '') { - $newMessage = hesk_unhortenUrl($ticket['message']); - if ($ticket['html']) { - $newMessage = hesk_html_entity_decode($newMessage); - } - echo '

' . $newMessage . '

'; -} - - -// Print replies -while ($reply = hesk_dbFetchAssoc($res)) { - $reply['dt'] = hesk_date($reply['dt'], true); - $theReply = hesk_unhortenUrl($reply['message']); - if ($reply['html']) { - $theReply = hesk_html_entity_decode($theReply); - } - - echo ' -
- -
' . $hesklang['trackID'] . ':' . $trackingID . '' . $hesklang['ticket_status'] . ':' . $hesklang[$ticket['statusKey']] . '' . $hesklang['created_on'] . ':' . $ticket['dt'] . '
' . $hesklang['last_update'] . ':' . $ticket['lastchange'] . '' . $hesklang['last_replier'] . ':' . $ticket['repliername'] . '' . $hesklang['category'] . ':' . $category['name'] . '
' . $hesklang['ts'] . ':' . $ticket['time_worked'] . '' . $hesklang['ip'] . ':' . $ticket['ip'] . '' . $hesklang['email'] . ':' . $ticket['email'] . '
' . $hesklang['taso3'] . '' . $ticket['owner'] . '' . $hesklang['name'] . ':' . $ticket['name'] . '
- - - - -
' . $hesklang['date'] . ':' . $reply['dt'] . '' . $hesklang['name'] . ':' . $reply['name'] . '
- -
' . $theReply . '
- '; -} // Print "end of ticket" message -echo $hesklang['end_ticket'];*/ +echo $hesklang['end_ticket']; require_once(HESK_PATH . 'inc/print_template.inc.php'); ?> From b0934f7c4c2df8bc3f863d638b55cbade95e3088 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 16 May 2018 18:55:16 -0400 Subject: [PATCH 41/53] Update export_functions --- admin/export.php | 340 ---------------- inc/export_functions.inc.php | 372 ++++++++++++++++++ ...nt_template.php => print_template.inc.php} | 0 3 files changed, 372 insertions(+), 340 deletions(-) create mode 100644 inc/export_functions.inc.php rename inc/{print_template.php => print_template.inc.php} (100%) diff --git a/admin/export.php b/admin/export.php index c4c1e699..ec67a22c 100644 --- a/admin/export.php +++ b/admin/export.php @@ -298,346 +298,6 @@ while ($row = hesk_dbFetchAssoc($res2)) { // Generate export file if (isset($_GET['w'])) { - /* - * // We'll need HH:MM:SS format for hesk_date() here - $hesk_settings['timeformat'] = 'H:i:s'; - - // Get staff names - $admins = array(); - $result = hesk_dbQuery("SELECT `id`,`name` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ORDER BY `name` ASC"); - while ($row = hesk_dbFetchAssoc($result)) { - $admins[$row['id']] = $row['name']; - } - - // This will be the export directory - $export_dir = HESK_PATH.$hesk_settings['cache_dir'].'/'; - - // This will be the name of the export and the XML file - $export_name = 'hesk_export_' . date('Y-m-d_H-i-s') . '_' . mt_rand(10000, 99999); - $save_to = $export_dir . $export_name . '.xml'; - - // Do we have the export directory? - if (is_dir($export_dir) || (@mkdir($export_dir, 0777) && is_writable($export_dir))) { - // Is there an index.htm file? - if (!file_exists($export_dir.'index.htm')) { - @file_put_contents($export_dir.'index.htm', ''); - } - - // Cleanup old files - hesk_purge_cache('export', 86400); - } else { - hesk_error($hesklang['ede']); - } - - // Make sure the file can be saved and written to - @file_put_contents($save_to, ''); - if (!file_exists($save_to)) { - hesk_error($hesklang['eef']); - } - - // Start generating the report message and generating the export - $success_msg = ''; - $flush_me = '

'; - $flush_me .= hesk_date() . " | {$hesklang['inite']} "; - - if ($date_from == $date_to) { - $flush_me .= "(" . hesk_dateToString($date_from, 0) . ")
\n"; - } else { - $flush_me .= "(" . hesk_dateToString($date_from, 0) . " - " . hesk_dateToString($date_to, 0) . ")
\n"; - } - - // Start generating file contents - $tmp = ' - - - - - - - 8250 - 16275 - 360 - 90 - False - False - - - - - - - - - -'; - - // Define column width - $tmp .= ' - - - - - - - - - - - - - - '; - - foreach ($hesk_settings['custom_fields'] as $k => $v) { - if ($v['use']) { - $tmp .= '' . "\n"; - } - } - - // Define first row (header) - $tmp .= ' - - # - ' . $hesklang['trackID'] . ' - ' . $hesklang['date'] . ' - ' . $hesklang['last_update'] . ' - ' . $hesklang['name'] . ' - ' . $hesklang['email'] . ' - ' . $hesklang['category'] . ' - ' . $hesklang['priority'] . ' - ' . $hesklang['status'] . ' - ' . $hesklang['subject'] . ' - ' . $hesklang['message'] . ' - ' . $hesklang['owner'] . ' - ' . $hesklang['ts'] . ' - '; - - foreach ($hesk_settings['custom_fields'] as $k => $v) { - if ($v['use']) { - $tmp .= '' . $v['name'] . '' . "\n"; - } - } - - $tmp .= "\n"; - - // Write what we have by now into the XML file - file_put_contents($save_to, $tmp, FILE_APPEND); - $flush_me .= hesk_date() . " | {$hesklang['gXML']}
\n"; - - // OK, now start dumping data and writing it into the file - $tickets_exported = 0; - $save_after = 100; - $this_round = 0; - $tmp = ''; - - $result = hesk_dbQuery($sql); - while ($ticket = hesk_dbFetchAssoc($result)) { - $ticket['status'] = mfh_getDisplayTextForStatusId($ticket['status']); - - switch ($ticket['priority']) { - case 0: - $ticket['priority'] = $hesklang['critical']; - break; - case 1: - $ticket['priority'] = $hesklang['high']; - break; - case 2: - $ticket['priority'] = $hesklang['medium']; - break; - default: - $ticket['priority'] = $hesklang['low']; - } - - $ticket['archive'] = !($ticket['archive']) ? $hesklang['no'] : $hesklang['yes']; - $ticket['message'] = hesk_msgToPlain($ticket['message'], 1, 0); - $ticket['subject'] = hesk_msgToPlain($ticket['subject'], 1, 0); - $ticket['owner'] = isset($admins[$ticket['owner']]) ? $admins[$ticket['owner']] : ''; - $ticket['category'] = isset($my_cat[$ticket['category']]) ? $my_cat[$ticket['category']] : ''; - - // Format for export dates - $hesk_settings['timeformat'] = "Y-m-d\TH:i:s\.000"; - - // Create row for the XML file - $tmp .= ' - -' . $ticket['id'] . ' - -' . hesk_date($ticket['dt'], true) . ' -' . hesk_date($ticket['lastchange'], true) . ' - - - - - - - - - -'; - - // Add custom fields - foreach ($hesk_settings['custom_fields'] as $k=>$v) { - if ($v['use']) { - switch ($v['type']) { - case 'date': - $tmp_dt = hesk_custom_date_display_format($ticket[$k], 'Y-m-d\T00:00:00.000'); - $tmp .= strlen($tmp_dt) ? ''.$tmp_dt : ''; - $tmp .= " \n"; - break; - default: - $tmp .= ' ' . "\n"; - } - } - } - - $tmp .= "\n"; - - // Write every 100 rows into the file - if ($this_round >= $save_after) { - file_put_contents($save_to, $tmp, FILE_APPEND); - $this_round = 0; - $tmp = ''; - usleep(1); - } - - $tickets_exported++; - $this_round++; - } // End of while loop - - // Go back to the HH:MM:SS format for hesk_date() - $hesk_settings['timeformat'] = 'H:i:s'; - - // Append any remaining rows into the file - if ($this_round > 0) { - file_put_contents($save_to, $tmp, FILE_APPEND); - } - - // If any tickets were exported, continue, otherwise cleanup - if ($tickets_exported > 0) { - // Finish the XML file - $tmp = ' -
- - -
-