#327 Settings are finally all driven through the database

merge-requests/2/head
Mike Koch 9 years ago
parent 57ba54d044
commit 849ef01b17

2
.gitignore vendored

@ -1,8 +1,6 @@
admin/admin_suggest_articles.php admin/admin_suggest_articles.php
admin/archive.php admin/archive.php
admin/assign_owner.php
admin/generate_spam_question.php admin/generate_spam_question.php
admin/move_category.php
admin/priority.php admin/priority.php
admin/test_connection.php admin/test_connection.php
attachments/index.htm attachments/index.htm

@ -388,13 +388,13 @@ if ($submit_as_customer)
{ {
if ($ticket['owner'] && $ticket['owner'] != $_SESSION['id']) if ($ticket['owner'] && $ticket['owner'] != $_SESSION['id'])
{ {
hesk_notifyAssignedStaff(false, 'new_reply_by_customer', 'notify_reply_my'); hesk_notifyAssignedStaff(false, 'new_reply_by_customer', $modsForHesk_settings, 'notify_reply_my');
} }
} }
// Notify customer? // Notify customer?
elseif ( ! isset($_POST['no_notify']) || intval( hesk_POST('no_notify') ) != 1) elseif ( ! isset($_POST['no_notify']) || intval( hesk_POST('no_notify') ) != 1)
{ {
hesk_notifyCustomer('new_reply_by_staff'); hesk_notifyCustomer($modsForHesk_settings, 'new_reply_by_staff');
} }
// Delete any existing drafts from this owner for this ticket // Delete any existing drafts from this owner for this ticket

@ -39,12 +39,14 @@ define('HESK_PATH','../');
require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php'); require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/admin_functions.inc.php'); require(HESK_PATH . 'inc/admin_functions.inc.php');
require(HESK_PATH . 'inc/email_functions.inc.php');
require(HESK_PATH . 'inc/setup_functions.inc.php'); require(HESK_PATH . 'inc/setup_functions.inc.php');
hesk_load_database_functions(); hesk_load_database_functions();
hesk_session_start(); hesk_session_start();
hesk_dbConnect(); hesk_dbConnect();
require(HESK_PATH . 'inc/email_functions.inc.php');
hesk_isLoggedIn(); hesk_isLoggedIn();
// Check permissions for this feature // Check permissions for this feature

@ -287,7 +287,7 @@ $ticket = hesk_newTicket($tmpvar);
// Notify the customer about the ticket? // Notify the customer about the ticket?
if ($notify) if ($notify)
{ {
hesk_notifyCustomer(); hesk_notifyCustomer($modsForHesk_settings);
} }
// If ticket is assigned to someone notify them? // If ticket is assigned to someone notify them?
@ -296,18 +296,18 @@ if ($ticket['owner'] && $ticket['owner'] != intval($_SESSION['id']))
// If we don't have info from auto-assign get it from database // If we don't have info from auto-assign get it from database
if ( ! isset($autoassign_owner['email']) ) if ( ! isset($autoassign_owner['email']) )
{ {
hesk_notifyAssignedStaff(false, 'ticket_assigned_to_you'); hesk_notifyAssignedStaff(false, 'ticket_assigned_to_you', $modsForHesk_settings);
} }
else else
{ {
hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you'); hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you', $modsForHesk_settings);
} }
} }
// Ticket unassigned, notify everyone that selected to be notified about unassigned tickets // Ticket unassigned, notify everyone that selected to be notified about unassigned tickets
elseif ( ! $ticket['owner']) elseif ( ! $ticket['owner'])
{ {
hesk_notifyStaff('new_ticket_staff', " `id` != ".intval($_SESSION['id'])." AND `notify_new_unassigned` = '1' "); hesk_notifyStaff('new_ticket_staff', " `id` != ".intval($_SESSION['id'])." AND `notify_new_unassigned` = '1' ", $modsForHesk_settings);
} }
// Unset temporary variables // Unset temporary variables

@ -457,14 +457,14 @@ if (isset($_POST['notemsg']) && hesk_token_check('POST'))
/* Format email subject and message for staff */ /* Format email subject and message for staff */
$subject = hesk_getEmailSubject('new_note',$ticket); $subject = hesk_getEmailSubject('new_note',$ticket);
$message = hesk_getEmailMessage('new_note',$ticket,1); $message = hesk_getEmailMessage('new_note',$ticket,$modsForHesk_settings,1);
$htmlMessage = hesk_getHtmlMessage('new_note',$ticket,1); $htmlMessage = hesk_getHtmlMessage('new_note',$ticket,$modsForHesk_settings, 1);
$hasMessage = hesk_doesTemplateHaveTag('new_note', '%%MESSAGE%%'); $hasMessage = hesk_doesTemplateHaveTag('new_note', '%%MESSAGE%%', $modsForHesk_settings);
/* Send email to staff */ /* Send email to staff */
while ($user = hesk_dbFetchAssoc($users)) { while ($user = hesk_dbFetchAssoc($users)) {
hesk_mail($user['email'], $subject, $message, $htmlMessage, array(), array(), $hasMessage); hesk_mail($user['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, array(), array(), $hasMessage);
} }
} }
} }

@ -0,0 +1,160 @@
<?php
/*******************************************************************************
* Title: Help Desk Software HESK
* Version: 2.6.1 from 26th February 2015
* Author: Klemen Stirn
* Website: http://www.hesk.com
********************************************************************************
* COPYRIGHT AND TRADEMARK NOTICE
* Copyright 2005-2015 Klemen Stirn. All Rights Reserved.
* HESK is a registered trademark of Klemen Stirn.
* The HESK may be used and modified free of charge by anyone
* AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
* By using this code you agree to indemnify Klemen Stirn from any
* liability that might arise from it's use.
* Selling the code for this program, in part or full, without prior
* written consent is expressly forbidden.
* Using this code, in part or full, to create derivate work,
* new scripts or products is expressly forbidden. Obtain permission
* before redistributing this software over the Internet or in
* any other medium. In all cases copyright and header must remain intact.
* This Copyright is in full effect in any country that has International
* Trade Agreements with the United States of America or
* with the European Union.
* Removing any of the copyright notices without purchasing a license
* is expressly forbidden. To remove HESK copyright notice you must purchase
* a license for this script. For more information on how to obtain
* a license please visit the page below:
* https://www.hesk.com/buy.php
*******************************************************************************/
define('IN_SCRIPT',1);
define('HESK_PATH','../');
/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/admin_functions.inc.php');
hesk_load_database_functions();
require(HESK_PATH . 'inc/email_functions.inc.php');
hesk_session_start();
hesk_dbConnect();
hesk_isLoggedIn();
$modsForHesk_settings = mfh_getSettings();
$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);
}
/* A security check */
hesk_token_check();
/* Ticket ID */
$trackingID = hesk_cleanID() or die($hesklang['int_error'].': '.$hesklang['no_trackID']);
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `trackid`='".hesk_dbEscape($trackingID)."' LIMIT 1");
if (hesk_dbNumRows($res) != 1)
{
hesk_error($hesklang['ticket_not_found']);
}
$ticket = hesk_dbFetchAssoc($res);
$_SERVER['PHP_SELF'] = 'admin_ticket.php?track='.$trackingID.'&Refresh='.rand(10000,99999);
/* New owner ID */
$owner = intval( hesk_REQUEST('owner') );
/* If ID is -1 the ticket will be unassigned */
if ($owner == -1)
{
$revision = sprintf($hesklang['thist2'],hesk_date(),'<i>'.$hesklang['unas'].'</i>',$_SESSION['name'].' ('.$_SESSION['user'].')');
$res = hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `owner`=0 , `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') WHERE `trackid`='".hesk_dbEscape($trackingID)."' LIMIT 1");
hesk_process_messages($hesklang['tunasi2'],$_SERVER['PHP_SELF'],'SUCCESS');
}
elseif ($owner < 1)
{
hesk_process_messages($hesklang['nose'],$_SERVER['PHP_SELF'],'NOTICE');
}
/* Verify the new owner and permissions */
$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");
$row = hesk_dbFetchAssoc($res);
/* Has new owner access to the category? */
if ( ! $row['isadmin'])
{
$row['categories']=explode(',',$row['categories']);
if (!in_array($ticket['category'],$row['categories']))
{
hesk_error($hesklang['unoa']);
}
}
/* Assigning to self? */
if ($can_assign_others || ($owner == $_SESSION['id'] && $can_assign_self))
{
$revision = sprintf($hesklang['thist2'],hesk_date(),$row['name'].' ('.$row['user'].')',$_SESSION['name'].' ('.$_SESSION['user'].')');
$res = hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `owner`={$owner} , `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') WHERE `trackid`='".hesk_dbEscape($trackingID)."' LIMIT 1");
if ($owner != $_SESSION['id'] && !hesk_checkPermission('can_view_ass_others',0))
{
$_SERVER['PHP_SELF']='admin_main.php';
}
}
else
{
hesk_error($hesklang['no_permission']);
}
$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'],
'lastreplier' => $ticket['lastreplier'],
'subject' => $ticket['subject'],
'message' => $ticket['message'],
'attachments' => $ticket['attachments'],
'dt' => hesk_date($ticket['dt'], true),
'lastchange' => hesk_date($ticket['lastchange'], true),
'id' => $ticket['id'],
);
// 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', $modsForHesk_settings);
}
$tmp = ($owner == $_SESSION['id']) ? $hesklang['tasy'] : $hesklang['taso'];
hesk_process_messages($tmp,$_SERVER['PHP_SELF'],'SUCCESS');
?>

@ -44,6 +44,7 @@ hesk_load_database_functions();
hesk_session_start(); hesk_session_start();
hesk_dbConnect(); hesk_dbConnect();
hesk_isLoggedIn(); hesk_isLoggedIn();
$modsForHesk_settings = mfh_getSettings();
/* Check permissions for this feature */ /* Check permissions for this feature */
if (!isset($_REQUEST['isManager']) || !$_REQUEST['isManager']) { if (!isset($_REQUEST['isManager']) || !$_REQUEST['isManager']) {
@ -103,7 +104,7 @@ if ($statusRow['IsClosed']) // Closed
// Notify customer // Notify customer
require(HESK_PATH . 'inc/email_functions.inc.php'); require(HESK_PATH . 'inc/email_functions.inc.php');
hesk_notifyCustomer('ticket_closed'); hesk_notifyCustomer($modsForHesk_settings,'ticket_closed');
} }
// Log who marked the ticket resolved // Log who marked the ticket resolved

@ -44,6 +44,7 @@ hesk_load_database_functions();
hesk_session_start(); hesk_session_start();
hesk_dbConnect(); hesk_dbConnect();
hesk_isLoggedIn(); hesk_isLoggedIn();
$modsForHesk_settings = mfh_getSettings();
/* Set correct return URL */ /* Set correct return URL */
if (isset($_SERVER['HTTP_REFERER'])) if (isset($_SERVER['HTTP_REFERER']))
@ -311,7 +312,7 @@ else
$ticket['dt'] = hesk_date($ticket['dt'], true); $ticket['dt'] = hesk_date($ticket['dt'], true);
$ticket['lastchange'] = hesk_date($ticket['lastchange'], true); $ticket['lastchange'] = hesk_date($ticket['lastchange'], true);
$ticket = hesk_ticketToPlain($ticket, 1, 0); $ticket = hesk_ticketToPlain($ticket, 1, 0);
hesk_notifyCustomer('ticket_closed'); hesk_notifyCustomer($modsForHesk_settings,'ticket_closed');
} }
} }

@ -43,6 +43,7 @@ hesk_load_database_functions();
hesk_session_start(); hesk_session_start();
hesk_dbConnect(); hesk_dbConnect();
$modsForHesk_settings = mfh_getSettings();
/* What should we do? */ /* What should we do? */
$action = hesk_REQUEST('a'); $action = hesk_REQUEST('a');
@ -70,7 +71,7 @@ exit();
/*** START FUNCTIONS ***/ /*** START FUNCTIONS ***/
function do_login() function do_login()
{ {
global $hesk_settings, $hesklang; global $hesk_settings, $hesklang, $modsForHesk_settings;
$hesk_error_buffer = array(); $hesk_error_buffer = array();
@ -285,7 +286,7 @@ function do_login()
$ticket['dt'] = hesk_date($ticket['dt'], true); $ticket['dt'] = hesk_date($ticket['dt'], true);
$ticket['lastchange'] = hesk_date($ticket['lastchange'], true); $ticket['lastchange'] = hesk_date($ticket['lastchange'], true);
$ticket = hesk_ticketToPlain($ticket, 1, 0); $ticket = hesk_ticketToPlain($ticket, 1, 0);
hesk_notifyCustomer('ticket_closed'); hesk_notifyCustomer($modsForHesk_settings,'ticket_closed');
} }
} }
} }

@ -44,6 +44,7 @@ hesk_load_database_functions();
hesk_session_start(); hesk_session_start();
hesk_dbConnect(); hesk_dbConnect();
hesk_isLoggedIn(); hesk_isLoggedIn();
$modsForHesk_settings = mfh_getSettings();
/* Check permissions for this feature */ /* Check permissions for this feature */
hesk_checkPermission('can_view_tickets'); hesk_checkPermission('can_view_tickets');
@ -98,7 +99,7 @@ else
$ticket['dt'] = hesk_date($ticket['dt'], true); $ticket['dt'] = hesk_date($ticket['dt'], true);
$ticket['lastchange'] = hesk_date($ticket['lastchange'], true); $ticket['lastchange'] = hesk_date($ticket['lastchange'], true);
hesk_notifyCustomer('ticket_closed'); hesk_notifyCustomer($modsForHesk_settings, 'ticket_closed');
} }
} }
} }

@ -40,12 +40,14 @@ require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php'); require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/admin_functions.inc.php'); require(HESK_PATH . 'inc/admin_functions.inc.php');
hesk_load_database_functions(); hesk_load_database_functions();
require(HESK_PATH . 'inc/email_functions.inc.php');
hesk_session_start(); hesk_session_start();
hesk_dbConnect(); hesk_dbConnect();
require(HESK_PATH . 'inc/email_functions.inc.php');
hesk_isLoggedIn(); hesk_isLoggedIn();
$modsForHesk_settings = mfh_getSettings();
/* List of staff */ /* List of staff */
$admins = array(); $admins = array();
$res = hesk_dbQuery("SELECT `id`,`name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ORDER BY `name` ASC"); $res = hesk_dbQuery("SELECT `id`,`name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ORDER BY `name` ASC");
@ -288,7 +290,7 @@ function mail_get_ids()
function mail_send() function mail_send()
{ {
global $hesk_settings, $hesklang; global $hesk_settings, $hesklang, $modsForHesk_settings;
/* A security check */ /* A security check */
hesk_token_check('POST'); hesk_token_check('POST');
@ -361,12 +363,12 @@ function mail_send()
/* Format email subject and message for recipient */ /* Format email subject and message for recipient */
$subject = hesk_getEmailSubject('new_pm',$pm,0); $subject = hesk_getEmailSubject('new_pm',$pm,0);
$message = hesk_getEmailMessage('new_pm',$pm,1,0); $message = hesk_getEmailMessage('new_pm',$pm,$modsForHesk_settings,1,0);
$htmlMessage = hesk_getHtmlMessage('new_pm',$pm,1,0); $htmlMessage = hesk_getHtmlMessage('new_pm',$pm,$modsForHesk_settings,1,0);
$hasMessage = hesk_doesTemplateHaveTag('new_pm','%%MESSAGE%%'); $hasMessage = hesk_doesTemplateHaveTag('new_pm','%%MESSAGE%%', $modsForHesk_settings);
/* Send e-mail */ /* Send e-mail */
hesk_mail($pm_recipient['email'], $subject, $message, $htmlMessage, array(), array(), $hasMessage); hesk_mail($pm_recipient['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, array(), array(), $hasMessage);
} }
unset($_SESSION['mail']); unset($_SESSION['mail']);

@ -59,6 +59,8 @@ if ( $action = hesk_REQUEST('a') )
elseif ($action == 'order') {order_saved();} elseif ($action == 'order') {order_saved();}
} }
$modsForHesk_settings = mfh_getSettings();
/* Print header */ /* Print header */
require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
@ -77,7 +79,7 @@ function hesk_insertTag(tag) {
var text_to_insert = '%%'+tag+'%%'; var text_to_insert = '%%'+tag+'%%';
var msg = ''; var msg = '';
<?php <?php
if (mfh_getSetting('rich_text_for_tickets')) { ?> if ($modsForHesk_settings['rich_text_for_tickets']) { ?>
msg = tinymce.get("message").getContent(); msg = tinymce.get("message").getContent();
tinymce.get("message").setContent(''); tinymce.get("message").setContent('');
tinymce.get("message").execCommand('mceInsertRawHTML', false, msg + text_to_insert); tinymce.get("message").execCommand('mceInsertRawHTML', false, msg + text_to_insert);
@ -159,7 +161,7 @@ function hesk_insertAtCursor(myField, myValue) {
$javascript_titles.='myTitle['.$mysaved['id'].']=\''.addslashes($mysaved['title'])."';\n"; $javascript_titles.='myTitle['.$mysaved['id'].']=\''.addslashes($mysaved['title'])."';\n";
if (mfh_getSetting('rich_text_for_tickets')) { if ($modsForHesk_settings['rich_text_for_tickets']) {
$javascript_messages.='myMsgTxt['.$mysaved['id'].']=\''.str_replace("\r\n","\\r\\n' + \r\n'", hesk_html_entity_decode($mysaved['message']) )."';\n"; $javascript_messages.='myMsgTxt['.$mysaved['id'].']=\''.str_replace("\r\n","\\r\\n' + \r\n'", hesk_html_entity_decode($mysaved['message']) )."';\n";
} else { } else {
$javascript_messages.='myMsgTxt['.$mysaved['id'].']=\''.str_replace("\r\n","\\r\\n' + \r\n'", addslashes($mysaved['message']) )."';\n"; $javascript_messages.='myMsgTxt['.$mysaved['id'].']=\''.str_replace("\r\n","\\r\\n' + \r\n'", addslashes($mysaved['message']) )."';\n";
@ -205,7 +207,7 @@ function hesk_insertAtCursor(myField, myValue) {
</div> </div>
</div> </div>
</div> </div>
<?php if (mfh_getSetting('rich_text_for_tickets')): ?> <?php if ($modsForHesk_settings['rich_text_for_tickets']): ?>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
tinyMCE.init({ tinyMCE.init({
@ -242,7 +244,7 @@ function hesk_insertAtCursor(myField, myValue) {
function setMessage(msgid) function setMessage(msgid)
{ {
var useHtmlEditor = <?php echo mfh_getSetting('rich_text_for_tickets'); ?>; var useHtmlEditor = <?php echo $modsForHesk_settings['rich_text_for_tickets']; ?>;
var myMsg=myMsgTxt[msgid]; var myMsg=myMsgTxt[msgid];
var mySubject=myTitle[msgid]; var mySubject=myTitle[msgid];
@ -351,7 +353,7 @@ function hesk_insertAtCursor(myField, myValue) {
{ {
if ($v['use']) if ($v['use'])
{ {
if (mfh_getSetting('custom_field_setting')) if ($modsForHesk_settings['custom_field_setting'])
{ {
$v['name'] = $hesklang[$v['name']]; $v['name'] = $hesklang[$v['name']];
} }

@ -71,6 +71,8 @@ if ( $action = hesk_REQUEST('a') )
elseif ($action == 'manager') {change_manager();} elseif ($action == 'manager') {change_manager();}
} }
$modsForHesk_settings = mfh_getSettings();
/* Print header */ /* Print header */
require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
@ -88,7 +90,7 @@ else {return false;}
</script> </script>
<?php <?php
$orderBy = mfh_getSetting('category_order_column'); $orderBy = $modsForHesk_settings['category_order_column'];
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ORDER BY `".$orderBy."` ASC"); $res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ORDER BY `".$orderBy."` ASC");
$options=''; $options='';
while ($mycat=hesk_dbFetchAssoc($res)) while ($mycat=hesk_dbFetchAssoc($res))

@ -373,7 +373,8 @@ if (!isset($_SESSION['hide']['new_article']))
$selectedIndex = -1; $selectedIndex = -1;
} else } else
{ {
$selectedIndex = mfh_getSetting('new_kb_article_visibility'); $modsForHesk_settings = mfh_getSettings();
$selectedIndex = $modsForHesk_settings['new_kb_article_visibility'];
} }
?> ?>
<div class="radio"> <div class="radio">

@ -74,14 +74,16 @@ else {return false;}
//--> //-->
</script> </script>
<?php <?php
$modsForHesk_settings = mfh_getSettings();
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` ORDER BY `name` ASC"); $res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."permission_templates` ORDER BY `name` ASC");
$templates = array(); $templates = array();
while ($row = hesk_dbFetchAssoc($res)) { while ($row = hesk_dbFetchAssoc($res)) {
array_push($templates, $row); array_push($templates, $row);
} }
$featureArray = hesk_getFeatureArray(); $featureArray = hesk_getFeatureArray();
$orderBy = mfh_getSetting('category_order_column'); $orderBy = $modsForHesk_settings['category_order_column'];
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ORDER BY `".$orderBy."` ASC"); $res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ORDER BY `".$orderBy."` ASC");
$categories = array(); $categories = array();
while ($row = hesk_dbFetchAssoc($res)) { while ($row = hesk_dbFetchAssoc($res)) {

@ -28,6 +28,8 @@ if (isset($_REQUEST['a'])) {
elseif ($_REQUEST['a'] == 'save') { save(); } elseif ($_REQUEST['a'] == 'save') { save(); }
} }
$modsForHesk_settings = mfh_getSettings();
/* Print header */ /* Print header */
require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
@ -147,7 +149,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
<i class="fa fa-pencil icon-link" style="color: orange" <i class="fa fa-pencil icon-link" style="color: orange"
data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i> data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i>
</span> </span>
<?php echoArrows($j, $numberOfStatuses, $row['ID']); ?> <?php echoArrows($j, $numberOfStatuses, $row['ID'], $modsForHesk_settings); ?>
<?php <?php
// Only show the delete button if (1) it's not a default action and (2) no tickets are set to that status // Only show the delete button if (1) it's not a default action and (2) no tickets are set to that status
$delete = canStatusBeDeleted($row['ID']); $delete = canStatusBeDeleted($row['ID']);
@ -378,10 +380,10 @@ function buildConfirmDeleteModal($statusId) {
<?php <?php
} }
function echoArrows($index, $numberOfStatuses, $statusId) { function echoArrows($index, $numberOfStatuses, $statusId, $modsForHesk_settings) {
global $hesklang; global $hesklang;
if (mfh_getSetting('statuses_order_column') == 'name') { if ($modsForHesk_settings['statuses_order_column'] == 'name') {
return; return;
} }

@ -45,13 +45,15 @@ hesk_session_start();
hesk_dbConnect(); hesk_dbConnect();
hesk_isLoggedIn(); hesk_isLoggedIn();
$modsForHesk_settings = mfh_getSettings();
/* Check permissions for this feature */ /* Check permissions for this feature */
hesk_checkPermission('can_man_ticket_tpl'); hesk_checkPermission('can_man_ticket_tpl');
// Define required constants // Define required constants
define('LOAD_TABS',1); define('LOAD_TABS',1);
if (mfh_getSetting('rich_text_for_tickets')) { if ($modsForHesk_settings['rich_text_for_tickets']) {
define('WYSIWYG', 1); define('WYSIWYG', 1);
} }
@ -65,6 +67,7 @@ if ( $action = hesk_REQUEST('a') )
elseif ($action == 'order') {order_saved();} elseif ($action == 'order') {order_saved();}
} }
/* Print header */ /* Print header */
require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
@ -131,7 +134,7 @@ $num = hesk_dbNumRows($result);
$options .= (isset($_SESSION['canned']['id']) && $_SESSION['canned']['id'] == $mysaved['id']) ? ' selected="selected" ' : ''; $options .= (isset($_SESSION['canned']['id']) && $_SESSION['canned']['id'] == $mysaved['id']) ? ' selected="selected" ' : '';
$options .= '>'.$mysaved['title'].'</option>'; $options .= '>'.$mysaved['title'].'</option>';
if (mfh_getSetting('rich_text_for_tickets')) { if ($modsForHesk_settings['rich_text_for_tickets']) {
$javascript_messages.='myMsgTxt['.$mysaved['id'].']=\''.str_replace("\r\n","\\r\\n' + \r\n'", html_entity_decode($mysaved['message'] ))."';\n"; $javascript_messages.='myMsgTxt['.$mysaved['id'].']=\''.str_replace("\r\n","\\r\\n' + \r\n'", html_entity_decode($mysaved['message'] ))."';\n";
} else { } else {
$javascript_messages.='myMsgTxt['.$mysaved['id'].']=\''.str_replace("\r\n","\\r\\n' + \r\n'", addslashes($mysaved['message']) )."';\n"; $javascript_messages.='myMsgTxt['.$mysaved['id'].']=\''.str_replace("\r\n","\\r\\n' + \r\n'", addslashes($mysaved['message']) )."';\n";
@ -242,7 +245,7 @@ $num = hesk_dbNumRows($result);
<textarea id="message" class="form-control htmlEditor" placeholder="<?php echo htmlspecialchars($hesklang['message']); ?>" name="msg" rows="15" cols="70"><?php <textarea id="message" class="form-control htmlEditor" placeholder="<?php echo htmlspecialchars($hesklang['message']); ?>" name="msg" rows="15" cols="70"><?php
if (isset($_SESSION['canned']['msg'])) if (isset($_SESSION['canned']['msg']))
{ {
if (mfh_getSetting('rich_text_for_tickets')) { if ($modsForHesk_settings['rich_text_for_tickets']) {
echo $_SESSION['canned']['msg']; echo $_SESSION['canned']['msg'];
} else { } else {
echo stripslashes($_SESSION['canned']['msg']); echo stripslashes($_SESSION['canned']['msg']);
@ -261,7 +264,7 @@ $num = hesk_dbNumRows($result);
</form> </form>
</div> </div>
</div> </div>
<?php if (mfh_getSetting('rich_text_for_tickets')): ?> <?php if ($modsForHesk_settings['rich_text_for_tickets']): ?>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
tinyMCE.init({ tinyMCE.init({
@ -298,7 +301,7 @@ $num = hesk_dbNumRows($result);
function setMessage(msgid) function setMessage(msgid)
{ {
var useHtmlEditor = <?php echo mfh_getSetting('rich_text_for_tickets'); ?>; var useHtmlEditor = <?php echo $modsForHesk_settings['rich_text_for_tickets']; ?>;
var myMsg=myMsgTxt[msgid]; var myMsg=myMsgTxt[msgid];
var mySubject=myTitle[msgid]; var mySubject=myTitle[msgid];

@ -92,8 +92,9 @@ $default_userdata = array(
'notify_note_unassigned' => 1, 'notify_note_unassigned' => 1,
); );
$modsForHesk_settings = mfh_getSettings();
/* A list of all categories */ /* A list of all categories */
$orderBy = mfh_getSetting('category_order_column'); $orderBy = $modsForHesk_settings['category_order_column'];
$hesk_settings['categories'] = array(); $hesk_settings['categories'] = array();
$res = hesk_dbQuery('SELECT `id`,`name` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'categories` ORDER BY `'.$orderBy.'` ASC'); $res = hesk_dbQuery('SELECT `id`,`name` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'categories` ORDER BY `'.$orderBy.'` ASC');
while ($row=hesk_dbFetchAssoc($res)) while ($row=hesk_dbFetchAssoc($res))

@ -0,0 +1,212 @@
<?php
/*******************************************************************************
* Title: Help Desk Software HESK
* Version: 2.6.1 from 26th February 2015
* Author: Klemen Stirn
* Website: http://www.hesk.com
********************************************************************************
* COPYRIGHT AND TRADEMARK NOTICE
* Copyright 2005-2015 Klemen Stirn. All Rights Reserved.
* HESK is a registered trademark of Klemen Stirn.
* The HESK may be used and modified free of charge by anyone
* AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
* By using this code you agree to indemnify Klemen Stirn from any
* liability that might arise from it's use.
* Selling the code for this program, in part or full, without prior
* written consent is expressly forbidden.
* Using this code, in part or full, to create derivate work,
* new scripts or products is expressly forbidden. Obtain permission
* before redistributing this software over the Internet or in
* any other medium. In all cases copyright and header must remain intact.
* This Copyright is in full effect in any country that has International
* Trade Agreements with the United States of America or
* with the European Union.
* Removing any of the copyright notices without purchasing a license
* is expressly forbidden. To remove HESK copyright notice you must purchase
* a license for this script. For more information on how to obtain
* a license please visit the page below:
* https://www.hesk.com/buy.php
*******************************************************************************/
define('IN_SCRIPT',1);
define('HESK_PATH','../');
/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/admin_functions.inc.php');
hesk_load_database_functions();
require(HESK_PATH . 'inc/email_functions.inc.php');
hesk_session_start();
hesk_dbConnect();
hesk_isLoggedIn();
$modsForHesk_settings = mfh_getSettings();
/* Check permissions for this feature */
hesk_checkPermission('can_change_cat');
/* A security check */
hesk_token_check('POST');
/* Ticket ID */
$trackingID = hesk_cleanID() or die($hesklang['int_error'].': '.$hesklang['no_trackID']);
/* Category ID */
$category = intval( hesk_POST('category', -1) );
if ($category < 1)
{
hesk_process_messages($hesklang['incat'],'admin_ticket.php?track='.$trackingID.'&Refresh='.rand(10000,99999),'NOTICE');
}
/* Get new category details */
$res = hesk_dbQuery("SELECT `name`,`autoassign` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` WHERE `id`='{$category}' LIMIT 1");
if (hesk_dbNumRows($res) != 1)
{
hesk_error("$hesklang[int_error]: $hesklang[kb_cat_inv].");
}
$row = hesk_dbFetchAssoc($res);
/* Should tickets in new category be auto-assigned if necessary? */
if ( ! $row['autoassign'])
{
$hesk_settings['autoassign'] = false;
}
/* Is user allowed to view tickets in new category? */
$category_ok = hesk_okCategory($category,0);
/* Get details about the original ticket */
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `trackid`='".hesk_dbEscape($trackingID)."' LIMIT 1");
if (hesk_dbNumRows($res) != 1)
{
hesk_error($hesklang['ticket_not_found']);
}
$ticket = hesk_dbFetchAssoc($res);
/* Log that ticket is being moved */
$history = sprintf($hesklang['thist1'],hesk_date(),$row['name'],$_SESSION['name'].' ('.$_SESSION['user'].')');
/* Is the ticket assigned to someone? If yes, check that the user has access to category or change to unassigned */
$need_to_reassign = 0;
if ($ticket['owner'])
{
if ($ticket['owner'] == $_SESSION['id'] && ! $category_ok )
{
$need_to_reassign = 1;
}
else
{
$res = hesk_dbQuery("SELECT `isadmin`,`categories` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`='".intval($ticket['owner'])."' LIMIT 1");
if (hesk_dbNumRows($res) != 1)
{
$need_to_reassign = 1;
}
else
{
$tmp = hesk_dbFetchAssoc($res);
if ( ! hesk_okCategory($category,0,$tmp['isadmin'], explode(',',$tmp['categories']) ) )
{
$need_to_reassign = 1;
}
}
}
}
/* Reassign automatically if possible */
if ($need_to_reassign || ! $ticket['owner'])
{
$need_to_reassign = 1;
$autoassign_owner = hesk_autoAssignTicket($category);
if ($autoassign_owner)
{
$ticket['owner'] = $autoassign_owner['id'];
$history .= sprintf($hesklang['thist10'],hesk_date(),$autoassign_owner['name'].' ('.$autoassign_owner['user'].')');
}
else
{
$ticket['owner'] = 0;
}
}
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `category`='".intval($category)."', `owner`='".intval($ticket['owner'])."' , `history`=CONCAT(`history`,'".hesk_dbEscape($history)."') WHERE `trackid`='".hesk_dbEscape($trackingID)."' LIMIT 1");
$ticket['category'] = $category;
/* --> 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'],
'lastreplier' => $ticket['lastreplier'],
'subject' => $ticket['subject'],
'message' => $ticket['message'],
'attachments' => $ticket['attachments'],
'dt' => hesk_date($ticket['dt'], true),
'lastchange' => hesk_date($ticket['lastchange'], true),
'id' => $ticket['id'],
);
// 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);
/* Need to notify any staff? */
/* --> From autoassign? */
if ($need_to_reassign && ! empty($autoassign_owner['email']) )
{
hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you', $modsForHesk_settings);
}
/* --> No autoassign, find and notify appropriate staff */
elseif ( ! $ticket['owner'] )
{
hesk_notifyStaff('category_moved', "`notify_new_unassigned`='1' AND `id`!=".intval($_SESSION['id']), $modsForHesk_settings);
}
/* Is the user allowed to view tickets in the new category? */
if ($category_ok)
{
/* Ticket has an owner */
if ($ticket['owner'])
{
/* Staff is owner or can view tickets assigned to others */
if ($ticket['owner'] == $_SESSION['id'] || hesk_checkPermission('can_view_ass_others',0) )
{
hesk_process_messages($hesklang['moved_to'],'admin_ticket.php?track='.$trackingID.'&Refresh='.rand(10000,99999),'SUCCESS');
}
else
{
hesk_process_messages($hesklang['moved_to'],'admin_main.php','SUCCESS');
}
}
/* Ticket is unassigned, staff can view unassigned tickets */
elseif (hesk_checkPermission('can_view_unassigned',0))
{
hesk_process_messages($hesklang['moved_to'],'admin_ticket.php?track='.$trackingID.'&Refresh='.rand(10000,99999),'SUCCESS');
}
/* Ticket is unassigned, staff cannot view unassigned tickets */
else
{
hesk_process_messages($hesklang['moved_to'],'admin_main.php','SUCCESS');
}
}
else
{
hesk_process_messages($hesklang['moved_to'],'admin_main.php','SUCCESS');
}
?>

@ -39,6 +39,13 @@ define('HESK_PATH','../');
require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php'); require(HESK_PATH . 'inc/common.inc.php');
// Connect to database and check for brute force attempts
hesk_load_database_functions();
hesk_dbConnect();
hesk_limitBfAttempts();
$modsForHesk_settings = mfh_getSettings();
// Is the password reset function enabled? // Is the password reset function enabled?
if ( ! $hesk_settings['reset_pass']) if ( ! $hesk_settings['reset_pass'])
{ {
@ -132,11 +139,6 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST')
} }
} }
// Connect to database and check for brute force attempts
hesk_load_database_functions();
hesk_dbConnect();
hesk_limitBfAttempts();
// Get email // Get email
$email = hesk_validateEmail( hesk_POST('email'), 'ERR', 0) or $hesk_error_buffer['email']=$hesklang['enter_valid_email']; $email = hesk_validateEmail( hesk_POST('email'), 'ERR', 0) or $hesk_error_buffer['email']=$hesklang['enter_valid_email'];
@ -179,8 +181,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST')
require(HESK_PATH . 'inc/email_functions.inc.php'); require(HESK_PATH . 'inc/email_functions.inc.php');
// Get the email message // Get the email message
$msg = hesk_getEmailMessage('reset_password',array(),1,0,1); $msg = hesk_getEmailMessage('reset_password',array(),$modsForHesk_settings,1,0,1);
$htmlMsg = hesk_getHtmlMessage('reset_password',array(),1,0,1); $htmlMsg = hesk_getHtmlMessage('reset_password',array(),$modsForHesk_settings,1,0,1);
// Replace message special tags // Replace message special tags
$msg = str_replace('%%NAME%%', hesk_msgToPlain($row['name'],1,1), $msg); $msg = str_replace('%%NAME%%', hesk_msgToPlain($row['name'],1,1), $msg);
@ -193,7 +195,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST')
$htmlMsg = str_replace('%%PASSWORD_RESET%%', $hesk_settings['hesk_url'].'/'.$hesk_settings['admin_dir'].'/password.php?h='.$hash, $htmlMsg); $htmlMsg = str_replace('%%PASSWORD_RESET%%', $hesk_settings['hesk_url'].'/'.$hesk_settings['admin_dir'].'/password.php?h='.$hash, $htmlMsg);
// Send email // Send email
hesk_mail($email, $hesklang['reset_password'], $msg, $htmlMsg); hesk_mail($email, $hesklang['reset_password'], $msg, $htmlMsg, $modsForHesk_settings);
// Show success // Show success
hesk_process_messages($hesklang['pemls'],'NOREDIRECT','SUCCESS'); hesk_process_messages($hesklang['pemls'],'NOREDIRECT','SUCCESS');

@ -498,7 +498,8 @@ function hesk_autoLogin($noredirect=0)
$ticket['dt'] = hesk_date($ticket['dt'], true); $ticket['dt'] = hesk_date($ticket['dt'], true);
$ticket['lastchange'] = hesk_date($ticket['lastchange'], true); $ticket['lastchange'] = hesk_date($ticket['lastchange'], true);
$ticket = hesk_ticketToPlain($ticket, 1, 0); $ticket = hesk_ticketToPlain($ticket, 1, 0);
hesk_notifyCustomer('ticket_closed'); $modsForHesk_settings = mfh_getSettings();
hesk_notifyCustomer($modsForHesk_settings, 'ticket_closed');
} }
} }
} }

@ -45,7 +45,7 @@ if ($hesk_settings['smtp'])
} }
} }
function hesk_notifyCustomerForVerifyEmail($email_template = 'verify_email', $activationKey) function hesk_notifyCustomerForVerifyEmail($email_template = 'verify_email', $activationKey, $modsForHesk_settings)
{ {
global $hesk_settings, $ticket; global $hesk_settings, $ticket;
@ -56,14 +56,14 @@ function hesk_notifyCustomerForVerifyEmail($email_template = 'verify_email', $ac
// Format email subject and message // Format email subject and message
$subject = hesk_getEmailSubject($email_template, $ticket); $subject = hesk_getEmailSubject($email_template, $ticket);
$message = hesk_getEmailMessage($email_template, $ticket); $message = hesk_getEmailMessage($email_template, $ticket, $modsForHesk_settings);
$htmlMessage = hesk_getHtmlMessage($email_template, $ticket); $htmlMessage = hesk_getHtmlMessage($email_template, $ticket, $modsForHesk_settings);
$activationUrl = $hesk_settings['hesk_url'] . '/verifyemail.php?key=%%ACTIVATIONKEY%%'; $activationUrl = $hesk_settings['hesk_url'] . '/verifyemail.php?key=%%ACTIVATIONKEY%%';
$message = str_replace('%%VERIFYURL%%', $activationUrl, $message); $message = str_replace('%%VERIFYURL%%', $activationUrl, $message);
$htmlMessage = str_replace('%%VERIFYURL%%', $activationUrl, $htmlMessage); $htmlMessage = str_replace('%%VERIFYURL%%', $activationUrl, $htmlMessage);
$message = str_replace('%%ACTIVATIONKEY%%', $activationKey, $message); $message = str_replace('%%ACTIVATIONKEY%%', $activationKey, $message);
$htmlMessage = str_replace('%%ACTIVATIONKEY%%', $activationKey, $htmlMessage); $htmlMessage = str_replace('%%ACTIVATIONKEY%%', $activationKey, $htmlMessage);
$hasMessage = hesk_doesTemplateHaveTag($email_template, '%%MESSAGE%%'); $hasMessage = hesk_doesTemplateHaveTag($email_template, '%%MESSAGE%%', $modsForHesk_settings);
// Add Cc / Bcc recipents if needed // Add Cc / Bcc recipents if needed
$ccEmails = array(); $ccEmails = array();
@ -82,11 +82,11 @@ function hesk_notifyCustomerForVerifyEmail($email_template = 'verify_email', $ac
} }
} }
hesk_mail($ticket['email'], $subject, $message, $htmlMessage, $ccEmails, $bccEmails, $hasMessage); hesk_mail($ticket['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, $ccEmails, $bccEmails, $hasMessage);
} }
function hesk_notifyCustomer($email_template = 'new_ticket') function hesk_notifyCustomer($modsForHesk_settings, $email_template = 'new_ticket')
{ {
global $hesk_settings, $hesklang, $ticket; global $hesk_settings, $hesklang, $ticket;
@ -106,9 +106,9 @@ function hesk_notifyCustomer($email_template = 'new_ticket')
// Format email subject and message // Format email subject and message
$subject = hesk_getEmailSubject($email_template,$ticket); $subject = hesk_getEmailSubject($email_template,$ticket);
$message = hesk_getEmailMessage($email_template,$ticket); $message = hesk_getEmailMessage($email_template,$ticket,$modsForHesk_settings);
$htmlMessage = hesk_getHtmlMessage($email_template,$ticket); $htmlMessage = hesk_getHtmlMessage($email_template,$ticket, $modsForHesk_settings);
$hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%'); $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%', $modsForHesk_settings);
// Add Cc / Bcc recipents if needed // Add Cc / Bcc recipents if needed
$ccEmails = array(); $ccEmails = array();
@ -126,7 +126,7 @@ function hesk_notifyCustomer($email_template = 'new_ticket')
} }
// Send e-mail // Send e-mail
hesk_mail($ticket['email'], $subject, $message, $htmlMessage, $ccEmails, $bccEmails, $hasMessage); hesk_mail($ticket['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, $ccEmails, $bccEmails, $hasMessage);
// Reset the language if it was changed // Reset the language if it was changed
if ($changedLanguage) if ($changedLanguage)
@ -139,7 +139,7 @@ function hesk_notifyCustomer($email_template = 'new_ticket')
} // END hesk_notifyCustomer() } // END hesk_notifyCustomer()
function hesk_notifyAssignedStaff($autoassign_owner, $email_template, $type = 'notify_assigned') function hesk_notifyAssignedStaff($autoassign_owner, $email_template, $modsForHesk_settings, $type = 'notify_assigned')
{ {
global $hesk_settings, $hesklang, $ticket; global $hesk_settings, $hesklang, $ticket;
@ -171,12 +171,12 @@ function hesk_notifyAssignedStaff($autoassign_owner, $email_template, $type = 'n
/* Format email subject and message for staff */ /* Format email subject and message for staff */
$subject = hesk_getEmailSubject($email_template,$ticket); $subject = hesk_getEmailSubject($email_template,$ticket);
$message = hesk_getEmailMessage($email_template,$ticket,1); $message = hesk_getEmailMessage($email_template,$ticket,$modsForHesk_settings,1);
$htmlMessage = hesk_getHtmlMessage($email_template,$ticket,1); $htmlMessage = hesk_getHtmlMessage($email_template,$ticket,$modsForHesk_settings,1);
$hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%'); $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%', $modsForHesk_settings);
/* Send email to staff */ /* Send email to staff */
hesk_mail($autoassign_owner['email'], $subject, $message, $htmlMessage, array(), array(), $hasMessage); hesk_mail($autoassign_owner['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, array(), array(), $hasMessage);
/* Reset language to original one */ /* Reset language to original one */
hesk_resetLanguage(); hesk_resetLanguage();
@ -186,7 +186,7 @@ function hesk_notifyAssignedStaff($autoassign_owner, $email_template, $type = 'n
} // END hesk_notifyAssignedStaff() } // END hesk_notifyAssignedStaff()
function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1) function hesk_notifyStaff($email_template,$sql_where,$modsForHesk_settings,$is_ticket=1)
{ {
global $hesk_settings, $hesklang, $ticket; global $hesk_settings, $hesklang, $ticket;
@ -222,7 +222,7 @@ function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1)
/* Make sure each user gets email in his/her preferred language */ /* Make sure each user gets email in his/her preferred language */
$current_language = 'NONE'; $current_language = 'NONE';
$recipients = array(); $recipients = array();
$hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%'); $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%', $modsForHesk_settings);
/* Loop through staff */ /* Loop through staff */
foreach ($admins as $admin) foreach ($admins as $admin)
@ -245,7 +245,7 @@ function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1)
if ($current_language != 'NONE') if ($current_language != 'NONE')
{ {
/* Send e-mail to staff */ /* Send e-mail to staff */
hesk_mail(implode(',',$recipients), $subject, $message, $htmlMessage, array(), array(), $hasMessage); hesk_mail(implode(',',$recipients), $subject, $message, $htmlMessage, $modsForHesk_settings, array(), array(), $hasMessage);
/* Reset list of email addresses */ /* Reset list of email addresses */
$recipients = array(); $recipients = array();
@ -256,9 +256,9 @@ function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1)
/* Format staff email subject and message for this language */ /* Format staff email subject and message for this language */
$subject = hesk_getEmailSubject($email_template,$ticket); $subject = hesk_getEmailSubject($email_template,$ticket);
$message = hesk_getEmailMessage($email_template,$ticket,$is_ticket); $message = hesk_getEmailMessage($email_template,$ticket,$modsForHesk_settings,$is_ticket);
$htmlMessage = hesk_getHtmlMessage($email_template,$ticket,$is_ticket); $htmlMessage = hesk_getHtmlMessage($email_template,$ticket,$modsForHesk_settings,$is_ticket);
$hasMessage = hesk_doesTemplateHaveTag($email_template, '%%MESSAGE%%'); $hasMessage = hesk_doesTemplateHaveTag($email_template, '%%MESSAGE%%', $modsForHesk_settings);
/* Add email to the recipients list */ /* Add email to the recipients list */
$recipients[] = $admin['email']; $recipients[] = $admin['email'];
@ -269,7 +269,7 @@ function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1)
} }
/* Send email messages to the remaining staff */ /* Send email messages to the remaining staff */
hesk_mail(implode(',',$recipients), $subject, $message, $htmlMessage, array(), array(), $hasMessage); hesk_mail(implode(',',$recipients), $subject, $message, $htmlMessage, $modsForHesk_settings, array(), array(), $hasMessage);
/* Reset language to original one */ /* Reset language to original one */
hesk_resetLanguage(); hesk_resetLanguage();
@ -331,7 +331,7 @@ function hesk_validEmails()
} // END hesk_validEmails() } // END hesk_validEmails()
function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array(),$hasMessageTag = false) function hesk_mail($to,$subject,$message,$htmlMessage,$modsForHesk_settings,$cc=array(),$bcc=array(),$hasMessageTag = false)
{ {
global $hesk_settings, $hesklang, $ticket; global $hesk_settings, $hesklang, $ticket;
@ -365,15 +365,15 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array(),$
# return true; # return true;
// Use mailgun // Use mailgun
if (mfh_getSetting('use_mailgun')) if ($modsForHesk_settings['use_mailgun'])
{ {
ob_start(); ob_start();
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.mailgun.net/v2/".mfh_getSetting('mailgun_domain')."/messages"); curl_setopt($ch, CURLOPT_URL, "https://api.mailgun.net/v2/".$modsForHesk_settings['mailgun_domain']."/messages");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'api:' . mfh_getSetting('mailgun_api_key')); curl_setopt($ch, CURLOPT_USERPWD, 'api:' . $modsForHesk_settings['mailgun_api_key']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
@ -397,11 +397,11 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array(),$
{ {
$postfields['bcc'] = implode(',',$bcc); $postfields['bcc'] = implode(',',$bcc);
} }
if (mfh_getSetting('html_emails')) if ($modsForHesk_settings['html_emails'])
{ {
$postfields['html'] = $htmlMessage; $postfields['html'] = $htmlMessage;
} }
if ($hasMessageTag && mfh_getSetting('attachments') && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments'])) if ($hasMessageTag && $modsForHesk_settings['attachments'] && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments']))
{ {
$postfields = processDirectAttachments('mailgun', $postfields); $postfields = processDirectAttachments('mailgun', $postfields);
} }
@ -430,7 +430,7 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array(),$
$message .= "Content-Type: text/plain; charset=".$hesklang['ENCODING']."\n\n"; $message .= "Content-Type: text/plain; charset=".$hesklang['ENCODING']."\n\n";
$message .= $plaintextMessage."\n\n"; $message .= $plaintextMessage."\n\n";
//Prepare the message for HTML or non-html //Prepare the message for HTML or non-html
if (mfh_getSetting('html_emails')) if ($modsForHesk_settings['html_emails'])
{ {
$message .= "--".$innerboundary."\n"; $message .= "--".$innerboundary."\n";
$message .= "Content-Type: text/html; charset=".$hesklang['ENCODING']."\n\n"; $message .= "Content-Type: text/html; charset=".$hesklang['ENCODING']."\n\n";
@ -461,7 +461,7 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array(),$
$headers.= "Content-Type: multipart/mixed;boundary=\"".$outerboundary."\""; $headers.= "Content-Type: multipart/mixed;boundary=\"".$outerboundary."\"";
// Add attachments if necessary // Add attachments if necessary
if ($hasMessageTag && mfh_getSetting('attachments') && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments'])) if ($hasMessageTag && $modsForHesk_settings['attachments'] && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments']))
{ {
$message .= processDirectAttachments('phpmail', NULL, $outerboundary); $message .= processDirectAttachments('phpmail', NULL, $outerboundary);
} }
@ -514,7 +514,7 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array(),$
} }
// Add attachments if necessary // Add attachments if necessary
if ($hasMessageTag && mfh_getSetting('attachments') && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments'])) if ($hasMessageTag && $modsForHesk_settings['attachments'] && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments']))
{ {
$message .= processDirectAttachments('smtp', NULL, $outerboundary); $message .= processDirectAttachments('smtp', NULL, $outerboundary);
} }
@ -621,12 +621,12 @@ function hesk_getEmailSubject($eml_file, $ticket='', $is_ticket=1, $strip=0)
} // hesk_getEmailSubject() } // hesk_getEmailSubject()
function hesk_getHtmlMessage($eml_file, $ticket, $is_admin=0, $is_ticket=1, $just_message=0) function hesk_getHtmlMessage($eml_file, $ticket, $modsForHesk_settings, $is_admin=0, $is_ticket=1, $just_message=0)
{ {
global $hesk_settings, $hesklang; global $hesk_settings, $hesklang;
// Demo mode // Demo mode
if ( defined('HESK_DEMO') || !mfh_getSetting('html_emails')) if ( defined('HESK_DEMO') || !$modsForHesk_settings['html_emails'])
{ {
return ''; return '';
} }
@ -652,11 +652,11 @@ function hesk_getHtmlMessage($eml_file, $ticket, $is_admin=0, $is_ticket=1, $jus
} }
//Perform logic common between hesk_getEmailMessage and hesk_getHtmlMessage //Perform logic common between hesk_getEmailMessage and hesk_getHtmlMessage
$msg = hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message, true); $msg = hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message, $modsForHesk_settings, true);
return $msg; return $msg;
} }
function hesk_getEmailMessage($eml_file, $ticket, $is_admin=0, $is_ticket=1, $just_message=0) function hesk_getEmailMessage($eml_file, $ticket, $modsForHesk_settings, $is_admin=0, $is_ticket=1, $just_message=0)
{ {
global $hesk_settings, $hesklang; global $hesk_settings, $hesklang;
@ -687,17 +687,17 @@ function hesk_getEmailMessage($eml_file, $ticket, $is_admin=0, $is_ticket=1, $ju
hesk_error($hesklang['emfm'].': '.$eml_file); hesk_error($hesklang['emfm'].': '.$eml_file);
} }
$msg = hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message); $msg = hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message, $modsForHesk_settings);
return $msg; return $msg;
} // END hesk_getEmailMessage } // END hesk_getEmailMessage
function hesk_doesTemplateHaveTag($eml_file, $tag) function hesk_doesTemplateHaveTag($eml_file, $tag, $modsForHesk_settings)
{ {
global $hesk_settings; global $hesk_settings;
$path = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/emails/'. $eml_file .'.txt'; $path = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/emails/'. $eml_file .'.txt';
$htmlHasTag = false; $htmlHasTag = false;
if (mfh_getSetting('html_emails')) { if ($modsForHesk_settings['html_emails']) {
$htmlPath = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/emails/html/'. $eml_file . '.txt'; $htmlPath = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/emails/html/'. $eml_file . '.txt';
$htmlContents = file_get_contents(HESK_PATH.$htmlPath); $htmlContents = file_get_contents(HESK_PATH.$htmlPath);
$htmlHasTag = !(strpos($htmlContents, $tag) === false); $htmlHasTag = !(strpos($htmlContents, $tag) === false);
@ -706,7 +706,7 @@ function hesk_doesTemplateHaveTag($eml_file, $tag)
return !(strpos($emailContents, $tag) === false) || $htmlHasTag; return !(strpos($emailContents, $tag) === false) || $htmlHasTag;
} }
function hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message, $isForHtml = 0) function hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message, $modsForHesk_settings, $isForHtml = 0)
{ {
global $hesk_settings, $hesklang; global $hesk_settings, $hesklang;
@ -830,7 +830,7 @@ function hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message
// Add direct links to any attachments at the bottom of the email message OR add them as attachments, depending on the settings // Add direct links to any attachments at the bottom of the email message OR add them as attachments, depending on the settings
if ($hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments']) ) if ($hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments']) )
{ {
if (!mfh_getSetting('attachments')) { if (!$modsForHesk_settings['attachments']) {
if ($isForHtml) { if ($isForHtml) {
$msg .= "<br><br><br>" . $hesklang['fatt']; $msg .= "<br><br><br>" . $hesklang['fatt'];
} else { } else {

@ -300,12 +300,13 @@ function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority
// --> If ticket is assigned just notify the owner // --> If ticket is assigned just notify the owner
if ($ticket['owner']) if ($ticket['owner'])
{ {
hesk_notifyAssignedStaff(false, 'new_reply_by_customer', 'notify_reply_my'); $modsForHesk_settings = mfh_getSettings();
hesk_notifyAssignedStaff(false, 'new_reply_by_customer', $modsForHesk_settings, 'notify_reply_my');
} }
// --> No owner assigned, find and notify appropriate staff // --> No owner assigned, find and notify appropriate staff
else else
{ {
hesk_notifyStaff('new_reply_by_customer',"`notify_reply_unassigned`='1'"); hesk_notifyStaff('new_reply_by_customer',"`notify_reply_unassigned`='1'", $modsForHesk_settings);
} }
return $ticket['trackid']; return $ticket['trackid'];
@ -362,7 +363,7 @@ function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority
// SPAM tags not found or not checked, send email // SPAM tags not found or not checked, send email
if ($possible_SPAM === false) if ($possible_SPAM === false)
{ {
hesk_notifyCustomer(); hesk_notifyCustomer($modsForHesk_settings);
} }
} }
@ -370,12 +371,12 @@ function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority
// --> From autoassign? // --> From autoassign?
if ($tmpvar['owner'] && $autoassign_owner['notify_assigned']) if ($tmpvar['owner'] && $autoassign_owner['notify_assigned'])
{ {
hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you'); hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you', $modsForHesk_settings);
} }
// --> No autoassign, find and notify appropriate staff // --> No autoassign, find and notify appropriate staff
elseif ( ! $tmpvar['owner'] ) elseif ( ! $tmpvar['owner'] )
{ {
hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' "); hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' ", $modsForHesk_settings);
} }
return $ticket['trackid']; return $ticket['trackid'];

@ -48,6 +48,8 @@ hesk_check_maintenance();
// Are we in "Knowledgebase only" mode? // Are we in "Knowledgebase only" mode?
hesk_check_kb_only(); hesk_check_kb_only();
$modsForHesk_settings = mfh_getSettings();
// What should we do? // What should we do?
$action = hesk_REQUEST('a'); $action = hesk_REQUEST('a');
@ -1273,7 +1275,7 @@ function print_start()
function forgot_tid() function forgot_tid()
{ {
global $hesk_settings, $hesklang; global $hesk_settings, $hesklang, $modsForHesk_settings;
require(HESK_PATH . 'inc/email_functions.inc.php'); require(HESK_PATH . 'inc/email_functions.inc.php');
@ -1337,18 +1339,18 @@ function forgot_tid()
$html_tid_list .= '</ul>'; $html_tid_list .= '</ul>';
/* Get e-mail message for customer */ /* Get e-mail message for customer */
$msg = hesk_getEmailMessage('forgot_ticket_id','',0,0,1); $msg = hesk_getEmailMessage('forgot_ticket_id','',$modsForHesk_settings,0,0,1);
$msg = processEmail($msg, $name, $num, $tid_list); $msg = processEmail($msg, $name, $num, $tid_list);
// Get HTML message for customer // Get HTML message for customer
$htmlMsg = hesk_getHtmlMessage('forgot_ticket_id','',0,0,1); $htmlMsg = hesk_getHtmlMessage('forgot_ticket_id','', $modsForHesk_settings, 0,0,1);
$htmlMsg = processEmail($htmlMsg, $name, $num, $html_tid_list); $htmlMsg = processEmail($htmlMsg, $name, $num, $html_tid_list);
$subject = hesk_getEmailSubject('forgot_ticket_id'); $subject = hesk_getEmailSubject('forgot_ticket_id');
/* Send e-mail */ /* Send e-mail */
hesk_mail($email, $subject, $msg, $htmlMsg); hesk_mail($email, $subject, $msg, $htmlMsg, $modsForHesk_settings);
/* Show success message */ /* Show success message */
$tmp = '<b>'.$hesklang['tid_sent'].'!</b>'; $tmp = '<b>'.$hesklang['tid_sent'].'!</b>';

@ -243,12 +243,12 @@ $ticket = hesk_ticketToPlain($info, 1, 0);
// --> If ticket is assigned just notify the owner // --> If ticket is assigned just notify the owner
if ($ticket['owner']) if ($ticket['owner'])
{ {
hesk_notifyAssignedStaff(false, 'new_reply_by_customer', 'notify_reply_my'); hesk_notifyAssignedStaff(false, 'new_reply_by_customer', $modsForHesk_settings, 'notify_reply_my');
} }
// --> No owner assigned, find and notify appropriate staff // --> No owner assigned, find and notify appropriate staff
else else
{ {
hesk_notifyStaff('new_reply_by_customer',"`notify_reply_unassigned`='1'"); hesk_notifyStaff('new_reply_by_customer',"`notify_reply_unassigned`='1'", $modsForHesk_settings);
} }
/* Clear unneeded session variables */ /* Clear unneeded session variables */

@ -470,7 +470,7 @@ if ($modsForHesk_settings['customer_email_verification_required'])
hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."pending_verification_emails` (`Email`, `ActivationKey`) hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."pending_verification_emails` (`Email`, `ActivationKey`)
VALUES ('".$escapedEmail."', '".$escapedKey."')"); VALUES ('".$escapedEmail."', '".$escapedKey."')");
hesk_notifyCustomerForVerifyEmail('verify_email', $key); hesk_notifyCustomerForVerifyEmail('verify_email', $key, $modsForHesk_settings);
$createTicket = false; $createTicket = false;
} }
} }
@ -482,19 +482,19 @@ if ($createTicket)
// Notify the customer // Notify the customer
if ($hesk_settings['notify_new']) if ($hesk_settings['notify_new'])
{ {
hesk_notifyCustomer(); hesk_notifyCustomer($modsForHesk_settings);
} }
// Need to notify staff? // Need to notify staff?
// --> From autoassign? // --> From autoassign?
if ($tmpvar['owner'] && $autoassign_owner['notify_assigned']) if ($tmpvar['owner'] && $autoassign_owner['notify_assigned'])
{ {
hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you'); hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you', $modsForHesk_settings);
} }
// --> No autoassign, find and notify appropriate staff // --> No autoassign, find and notify appropriate staff
elseif ( ! $tmpvar['owner'] ) elseif ( ! $tmpvar['owner'] )
{ {
hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' "); hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' ", $modsForHesk_settings);
} }
} }

@ -48,6 +48,9 @@ hesk_check_maintenance();
hesk_load_database_functions(); hesk_load_database_functions();
hesk_session_start(); hesk_session_start();
/* Connect to database */
hesk_dbConnect();
$modsForHesk_settings = mfh_getSettings();
$hesk_error_buffer = array(); $hesk_error_buffer = array();
$do_remember = ''; $do_remember = '';
@ -101,8 +104,6 @@ elseif ( empty($trackingID) || ( $hesk_settings['email_view_ticket'] && empty($m
print_form(); print_form();
} }
/* Connect to database */
hesk_dbConnect();
/* Limit brute force attempts */ /* Limit brute force attempts */
hesk_limitBfAttempts(); hesk_limitBfAttempts();

@ -45,7 +45,8 @@ require_once(HESK_PATH . 'inc/header.inc.php');
{ {
$ticket = hesk_newTicket($innerResult); $ticket = hesk_newTicket($innerResult);
// Notify the customer // Notify the customer
hesk_notifyCustomer(); $modsForHesk_settings = mfh_getSettings();
hesk_notifyCustomer($modsForHesk_settings);
// Need to notify staff? // Need to notify staff?
// --> From autoassign? // --> From autoassign?
@ -53,12 +54,12 @@ require_once(HESK_PATH . 'inc/header.inc.php');
$autoassign_owner = $getOwnerRs->fetch_assoc(); $autoassign_owner = $getOwnerRs->fetch_assoc();
if ($ticket['owner'] && $autoassign_owner['notify_assigned']) if ($ticket['owner'] && $autoassign_owner['notify_assigned'])
{ {
hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you'); hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you', $modsForHesk_settings);
} }
// --> No autoassign, find and notify appropriate staff // --> No autoassign, find and notify appropriate staff
elseif ( ! $ticket['owner'] ) elseif ( ! $ticket['owner'] )
{ {
hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' "); hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' ", $modsForHesk_settings);
} }
array_push($submittedTickets, $innerResult['trackid']); array_push($submittedTickets, $innerResult['trackid']);

Loading…
Cancel
Save