diff --git a/.gitignore b/.gitignore index e4ef0e68..274e3a3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ admin/admin_suggest_articles.php admin/archive.php -admin/assign_owner.php admin/generate_spam_question.php -admin/move_category.php admin/priority.php admin/test_connection.php attachments/index.htm diff --git a/admin/admin_main.php b/admin/admin_main.php index c6bb29ce..d80ecf5a 100644 --- a/admin/admin_main.php +++ b/admin/admin_main.php @@ -40,7 +40,6 @@ if (is_dir(HESK_PATH . 'install')) {die('Please delete the install folder /* Get all the required files and functions */ require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); require(HESK_PATH . 'inc/admin_functions.inc.php'); require(HESK_PATH . 'inc/status_functions.inc.php'); diff --git a/admin/admin_reply_ticket.php b/admin/admin_reply_ticket.php index 71ce4992..7c2805a6 100644 --- a/admin/admin_reply_ticket.php +++ b/admin/admin_reply_ticket.php @@ -37,7 +37,6 @@ define('HESK_PATH','../'); /* Get all the required files and functions */ require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); require(HESK_PATH . 'inc/admin_functions.inc.php'); hesk_load_database_functions(); @@ -90,6 +89,7 @@ $message = hesk_input(hesk_POST('message')); // Submit as customer? $submit_as_customer = isset($_POST['submit_as_customer']) ? true : false; +$modsForHesk_settings = mfh_getSettings(); if (strlen($message)) { // Save message for later and ignore the rest? @@ -388,13 +388,13 @@ if ($submit_as_customer) { 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? 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 diff --git a/admin/admin_settings.php b/admin/admin_settings.php index 51bc8e27..53d5e075 100644 --- a/admin/admin_settings.php +++ b/admin/admin_settings.php @@ -42,7 +42,6 @@ if (is_dir(HESK_PATH . 'install')) {die('Please delete the install folder // Get all the required files and functions require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.inc.php'); // Save the default language for the settings page before choosing user's preferred one $hesk_settings['language_default'] = $hesk_settings['language']; @@ -254,25 +253,6 @@ if ( defined('HESK_DEMO') ) ?> - - - /modsForHesk_settings.inc.php - - - - '.$hesklang['exists'].', '.$hesklang['writable'].''; - } else { - echo ''.$hesklang['exists'].', '.$hesklang['not_writable'].'
'.$hesklang['e_mfh_settings']; - } - ?> - - @@ -348,6 +328,7 @@ if ( defined('HESK_DEMO') ) $hesklang['err_custname'] = addslashes($hesklang['err_custname']); + $modsForHesk_settings = mfh_getSettings(); ?> -"> - + 1, ); +$modsForHesk_settings = mfh_getSettings(); /* A list of all categories */ $orderBy = $modsForHesk_settings['category_order_column']; $hesk_settings['categories'] = array(); diff --git a/admin/move_category.php b/admin/move_category.php new file mode 100755 index 00000000..9ea06c9e --- /dev/null +++ b/admin/move_category.php @@ -0,0 +1,212 @@ + 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'); +} +?> diff --git a/admin/password.php b/admin/password.php index 509df002..71237b91 100644 --- a/admin/password.php +++ b/admin/password.php @@ -37,9 +37,15 @@ define('HESK_PATH','../'); /* Get all the required files and functions */ require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.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? if ( ! $hesk_settings['reset_pass']) { @@ -133,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 $email = hesk_validateEmail( hesk_POST('email'), 'ERR', 0) or $hesk_error_buffer['email']=$hesklang['enter_valid_email']; @@ -180,8 +181,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') require(HESK_PATH . 'inc/email_functions.inc.php'); // Get the email message - $msg = hesk_getEmailMessage('reset_password',array(),1,0,1); - $htmlMsg = hesk_getHtmlMessage('reset_password',array(),1,0,1); + $msg = hesk_getEmailMessage('reset_password',array(),$modsForHesk_settings,1,0,1); + $htmlMsg = hesk_getHtmlMessage('reset_password',array(),$modsForHesk_settings,1,0,1); // Replace message special tags $msg = str_replace('%%NAME%%', hesk_msgToPlain($row['name'],1,1), $msg); @@ -194,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); // Send email - hesk_mail($email, $hesklang['reset_password'], $msg, $htmlMsg); + hesk_mail($email, $hesklang['reset_password'], $msg, $htmlMsg, $modsForHesk_settings); // Show success hesk_process_messages($hesklang['pemls'],'NOREDIRECT','SUCCESS'); diff --git a/admin/show_tickets.php b/admin/show_tickets.php index f770ba92..45337f43 100644 --- a/admin/show_tickets.php +++ b/admin/show_tickets.php @@ -37,7 +37,6 @@ define('HESK_PATH','../'); /* Get all the required files and functions */ require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); require(HESK_PATH . 'inc/admin_functions.inc.php'); require(HESK_PATH . 'inc/status_functions.inc.php'); diff --git a/css/hesk_newStyle.php b/css/hesk_newStyle.css similarity index 70% rename from css/hesk_newStyle.php rename to css/hesk_newStyle.css index 0369b512..4749b50c 100644 --- a/css/hesk_newStyle.php +++ b/css/hesk_newStyle.css @@ -1,23 +1,3 @@ - - .nu-rtlFloatLeft { /* Don't do anything; the pager looks good already */ } @@ -89,47 +69,6 @@ .navbar { margin-bottom: 0; } -.navbar-default { - background-color: ; - background-image: none; - filter: none; -} -.navbar-default .navbar-brand { - color: ; -} -.navbar-default .navbar-brand:focus, .navbar-default .navbar-brand:hover { - color: ; - background-color: transparent; -} -.navbar-default .navbar-nav>li>a { - color: ; -} -.navbar-default .navbar-nav>li>a:focus, .navbar-default .navbar-nav>li>a:hover { - color: ; - background-color: transparent; -} -.dropdown-menu>li>a { - color: ; -} -.dropdown-menu>li>a:focus, .dropdown-menu>li>a:hover { - color: ; - text-decoration: none; - background-color: ; -} -.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:focus, .navbar-default .navbar-nav>.open>a:hover { - color: ; - background-color: ; - background-image: none; -} -.settingsquestionmark { - color: ; - font-size: 14px; - cursor: pointer; -} -.h3questionmark { - color: ; - font-size: 14px; -} .h3questionmark:hover { text-decoration: underline; } diff --git a/css/hesk_newStyleRTL.php b/css/hesk_newStyleRTL.php index 86541710..4ced1251 100644 --- a/css/hesk_newStyleRTL.php +++ b/css/hesk_newStyleRTL.php @@ -1,6 +1,5 @@ 'modsForHeskVersion'"); + while ($row = hesk_dbFetchAssoc($res)) { + $settings[$row['Key']] = $row['Value']; + } + return $settings; } \ No newline at end of file diff --git a/inc/email_functions.inc.php b/inc/email_functions.inc.php index 474a8cec..f2627b8c 100644 --- a/inc/email_functions.inc.php +++ b/inc/email_functions.inc.php @@ -35,12 +35,6 @@ /* Check if this is a valid include */ if (!defined('IN_SCRIPT')) {die('Invalid attempt');} -// Include modsForHesk_settings.inc.php if it hasn't been included already -if (!isset($modsForHesk_settings)) -{ - include(HESK_PATH . 'modsForHesk_settings.inc.php'); -} - /* Get includes for SMTP */ if ($hesk_settings['smtp']) { @@ -51,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; @@ -62,14 +56,14 @@ function hesk_notifyCustomerForVerifyEmail($email_template = 'verify_email', $ac // Format email subject and message $subject = hesk_getEmailSubject($email_template, $ticket); - $message = hesk_getEmailMessage($email_template, $ticket); - $htmlMessage = hesk_getHtmlMessage($email_template, $ticket); + $message = hesk_getEmailMessage($email_template, $ticket, $modsForHesk_settings); + $htmlMessage = hesk_getHtmlMessage($email_template, $ticket, $modsForHesk_settings); $activationUrl = $hesk_settings['hesk_url'] . '/verifyemail.php?key=%%ACTIVATIONKEY%%'; $message = str_replace('%%VERIFYURL%%', $activationUrl, $message); $htmlMessage = str_replace('%%VERIFYURL%%', $activationUrl, $htmlMessage); $message = str_replace('%%ACTIVATIONKEY%%', $activationKey, $message); $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 $ccEmails = array(); @@ -88,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; @@ -112,9 +106,9 @@ function hesk_notifyCustomer($email_template = 'new_ticket') // Format email subject and message $subject = hesk_getEmailSubject($email_template,$ticket); - $message = hesk_getEmailMessage($email_template,$ticket); - $htmlMessage = hesk_getHtmlMessage($email_template,$ticket); - $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%'); + $message = hesk_getEmailMessage($email_template,$ticket,$modsForHesk_settings); + $htmlMessage = hesk_getHtmlMessage($email_template,$ticket, $modsForHesk_settings); + $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%', $modsForHesk_settings); // Add Cc / Bcc recipents if needed $ccEmails = array(); @@ -132,7 +126,7 @@ function hesk_notifyCustomer($email_template = 'new_ticket') } // 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 hesk_resetLanguage(); @@ -142,7 +136,7 @@ function hesk_notifyCustomer($email_template = 'new_ticket') } // 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; @@ -174,12 +168,12 @@ function hesk_notifyAssignedStaff($autoassign_owner, $email_template, $type = 'n /* Format email subject and message for staff */ $subject = hesk_getEmailSubject($email_template,$ticket); - $message = hesk_getEmailMessage($email_template,$ticket,1); - $htmlMessage = hesk_getHtmlMessage($email_template,$ticket,1); - $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%'); + $message = hesk_getEmailMessage($email_template,$ticket,$modsForHesk_settings,1); + $htmlMessage = hesk_getHtmlMessage($email_template,$ticket,$modsForHesk_settings,1); + $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%', $modsForHesk_settings); /* 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 */ hesk_resetLanguage(); @@ -189,7 +183,7 @@ function hesk_notifyAssignedStaff($autoassign_owner, $email_template, $type = 'n } // 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; @@ -225,7 +219,7 @@ function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1) /* Make sure each user gets email in his/her preferred language */ $current_language = 'NONE'; $recipients = array(); - $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%'); + $hasMessage = hesk_doesTemplateHaveTag($email_template,'%%MESSAGE%%', $modsForHesk_settings); /* Loop through staff */ foreach ($admins as $admin) @@ -248,7 +242,7 @@ function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1) if ($current_language != 'NONE') { /* 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 */ $recipients = array(); @@ -259,9 +253,9 @@ function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1) /* Format staff email subject and message for this language */ $subject = hesk_getEmailSubject($email_template,$ticket); - $message = hesk_getEmailMessage($email_template,$ticket,$is_ticket); - $htmlMessage = hesk_getHtmlMessage($email_template,$ticket,$is_ticket); - $hasMessage = hesk_doesTemplateHaveTag($email_template, '%%MESSAGE%%'); + $message = hesk_getEmailMessage($email_template,$ticket,$modsForHesk_settings,$is_ticket); + $htmlMessage = hesk_getHtmlMessage($email_template,$ticket,$modsForHesk_settings,$is_ticket); + $hasMessage = hesk_doesTemplateHaveTag($email_template, '%%MESSAGE%%', $modsForHesk_settings); /* Add email to the recipients list */ $recipients[] = $admin['email']; @@ -272,7 +266,7 @@ function hesk_notifyStaff($email_template,$sql_where,$is_ticket=1) } /* 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 */ hesk_resetLanguage(); @@ -334,9 +328,9 @@ function 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, $modsForHesk_settings, $ticket; + global $hesk_settings, $hesklang, $ticket; // Are we in demo mode or are all email fields blank? If so, don't send an email. if ( defined('HESK_DEMO') @@ -624,9 +618,9 @@ function hesk_getEmailSubject($eml_file, $ticket='', $is_ticket=1, $strip=0) } // 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, $modsForHesk_settings; + global $hesk_settings, $hesklang; // Demo mode if ( defined('HESK_DEMO') || !$modsForHesk_settings['html_emails']) @@ -655,11 +649,11 @@ function hesk_getHtmlMessage($eml_file, $ticket, $is_admin=0, $is_ticket=1, $jus } //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; } -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; @@ -690,14 +684,14 @@ function hesk_getEmailMessage($eml_file, $ticket, $is_admin=0, $is_ticket=1, $ju 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; } // END hesk_getEmailMessage -function hesk_doesTemplateHaveTag($eml_file, $tag) +function hesk_doesTemplateHaveTag($eml_file, $tag, $modsForHesk_settings) { - global $hesk_settings, $modsForHesk_settings; + global $hesk_settings; $path = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/emails/'. $eml_file .'.txt'; $htmlHasTag = false; if ($modsForHesk_settings['html_emails']) { @@ -709,9 +703,9 @@ function hesk_doesTemplateHaveTag($eml_file, $tag) 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, $modsForHesk_settings; + global $hesk_settings, $hesklang; /* Return just the message without any processing? */ if ($just_message) @@ -833,7 +827,6 @@ 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 - // if ($modsForHesk_settings['attachments'] == 'inline' (other is 'attachment') {...} if ($hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments']) ) { if (!$modsForHesk_settings['attachments']) { diff --git a/inc/header.inc.php b/inc/header.inc.php index 19be86aa..eb880ae7 100644 --- a/inc/header.inc.php +++ b/inc/header.inc.php @@ -34,7 +34,11 @@ /* Check if this is a valid include */ if (!defined('IN_SCRIPT')) {die('Invalid attempt');} -require(HESK_PATH . 'modsForHesk_settings.inc.php'); +if (!function_exists('mfh_getSettings')) { + die('Mods for HESK settings are not accessible!'); +} + +$modsForHesk_settings = mfh_getSettings(); ?> @@ -42,7 +46,7 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); <?php echo (isset($hesk_settings['tmp_title']) ? $hesk_settings['tmp_title'] : $hesk_settings['hesk_title']); ?> - + @@ -55,7 +59,7 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); - + @@ -70,6 +74,47 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); + @@ -42,7 +43,7 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); <?php echo (isset($hesk_settings['tmp_title']) ? $hesk_settings['tmp_title'] : $hesk_settings['hesk_title']); ?> - + @@ -55,7 +56,7 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); - + @@ -70,6 +71,47 @@ require(HESK_PATH . 'modsForHesk_settings.inc.php'); + If ticket is assigned just notify the 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 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']; @@ -363,7 +363,7 @@ function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority // SPAM tags not found or not checked, send email if ($possible_SPAM === false) { - hesk_notifyCustomer(); + hesk_notifyCustomer($modsForHesk_settings); } } @@ -371,12 +371,12 @@ function hesk_email2ticket($results, $pop3 = 0, $set_category = 1, $set_priority // --> From autoassign? 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 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']; diff --git a/inc/show_search_form.inc.php b/inc/show_search_form.inc.php index d9426e70..79e1a05d 100644 --- a/inc/show_search_form.inc.php +++ b/inc/show_search_form.inc.php @@ -41,7 +41,7 @@ if ( ! isset($status) ) //-- We don't want to check statuses that are considered "closed" foreach ($allStatuses as $row) { - if ($status['IsClosed'] == 1) { + if ($row['IsClosed'] == 1) { continue; } diff --git a/index.php b/index.php index 17ca937c..90de1e19 100644 --- a/index.php +++ b/index.php @@ -38,16 +38,18 @@ define('WYSIWYG',1); // Get all the required files and functions require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); +hesk_load_database_functions(); +hesk_dbConnect(); // Are we in maintenance mode? hesk_check_maintenance(); -hesk_load_database_functions(); // Are we in "Knowledgebase only" mode? hesk_check_kb_only(); +$modsForHesk_settings = mfh_getSettings(); + // What should we do? $action = hesk_REQUEST('a'); @@ -1273,7 +1275,7 @@ function print_start() function forgot_tid() { - global $hesk_settings, $hesklang; + global $hesk_settings, $hesklang, $modsForHesk_settings; require(HESK_PATH . 'inc/email_functions.inc.php'); @@ -1337,18 +1339,18 @@ function forgot_tid() $html_tid_list .= ''; /* 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); // 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); $subject = hesk_getEmailSubject('forgot_ticket_id'); /* Send e-mail */ - hesk_mail($email, $subject, $msg, $htmlMsg); + hesk_mail($email, $subject, $msg, $htmlMsg, $modsForHesk_settings); /* Show success message */ $tmp = ''.$hesklang['tid_sent'].'!'; diff --git a/install/mods-for-hesk/modsForHesk.php b/install/mods-for-hesk/modsForHesk.php index 33b658b6..925125ff 100644 --- a/install/mods-for-hesk/modsForHesk.php +++ b/install/mods-for-hesk/modsForHesk.php @@ -65,24 +65,6 @@ hesk_dbConnect(); CREATE, ALTER, DROP Permissions: Please check before continuing!* - - - modsForHesk_settings.inc.php - - - > - Success'; - } else { - echo ' CHMOD to 0666, yours is '.$fileperm; - $allowInstallation = false; - } - ?> - - * Mods for HESK is unable to check database permissions automatically. diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 8d477b71..29629970 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -686,4 +686,108 @@ function execute242Scripts() { hesk_dbConnect(); executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` SET `Value` = '2.4.2' WHERE `Key` = 'modsForHeskVersion'"); +} + +// BEGIN Version 2.5.0 +function migrateSettings() { + global $hesk_settings; + + if (file_exists(HESK_PATH . 'modsForHesk_settings.inc.php')) { + require_once(HESK_PATH . 'modsForHesk_settings.inc.php'); + + $rtl = getSettingValue($modsForHesk_settings, 'rtl', 0); + $show_icons = getSettingValue($modsForHesk_settings, 'show_icons', 0); + $custom_field_setting = getSettingValue($modsForHesk_settings, 'custom_field_setting', 0); + $customer_email_verification_required = getSettingValue($modsForHesk_settings, 'customer_email_verification_required', 0); + $html_emails = getSettingValue($modsForHesk_settings, 'html_emails', 1); + $use_mailgun = getSettingValue($modsForHesk_settings, 'use_mailgun', 0); + $mailgun_api_key = getSettingValue($modsForHesk_settings, 'mailgun_api_key', ''); + $mailgun_domain = getSettingValue($modsForHesk_settings, 'mailgun_domain', ''); + $use_bootstrap_theme = getSettingValue($modsForHesk_settings, 'use_bootstrap_theme', 1); + $new_kb_article_visibility = getSettingValue($modsForHesk_settings, 'new_kb_article_visibility', 0); + $attachments = getSettingValue($modsForHesk_settings, 'attachments', 0); + $show_number_merged = getSettingValue($modsForHesk_settings, 'show_number_merged', 1); + $request_location = getSettingValue($modsForHesk_settings, 'request_location', 0); + $category_order_column = getSettingValue($modsForHesk_settings, 'category_order_column', 'cat_order'); + $rich_text_for_tickets = getSettingValue($modsForHesk_settings, 'rich_text_for_tickets', 0); + $statuses_order_column = getSettingValue($modsForHesk_settings, 'statuses_order_column', 'sort'); + $kb_attach_dir = getSettingValue($modsForHesk_settings, 'kb_attach_dir', 'attachments'); + $rich_text_for_tickets_for_customers = getSettingValue($modsForHesk_settings, 'rich_text_for_tickets_for_customers', 0); + + $navbar_background_color = getSettingValue($modsForHesk_settings, 'navbarBackgroundColor', '#414a5c'); + $navbar_brand_color = getSettingValue($modsForHesk_settings, 'navbarBrandColor', '#d4dee7'); + $navbar_brand_hover_color = getSettingValue($modsForHesk_settings, 'navbarBrandHoverColor', '#ffffff'); + $navbar_item_text_color = getSettingValue($modsForHesk_settings, 'navbarItemTextColor', '#d4dee7'); + $navbar_item_text_hover_color = getSettingValue($modsForHesk_settings, 'navbarItemTextHoverColor', '#ffffff'); + $navbar_item_text_selected_color = getSettingValue($modsForHesk_settings, 'navbarItemTextSelectedColor', '#ffffff'); + $navbar_item_selected_background_color = getSettingValue($modsForHesk_settings, 'navbarItemSelectedBackgroundColor', '#2d3646'); + $dropdown_item_text_color = getSettingValue($modsForHesk_settings, 'dropdownItemTextColor', '#333333'); + $dropdown_item_text_hover_color = getSettingValue($modsForHesk_settings, 'dropdownItemTextHoverColor', '#262626'); + $dropdown_item_text_hover_background_color = getSettingValue($modsForHesk_settings, 'dropdownItemTextHoverBackgroundColor', '#f5f5f5'); + $question_mark_color = getSettingValue($modsForHesk_settings, 'questionMarkColor', '#000000'); + + + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('rtl', ".intval($rtl).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('show_icons', ".intval($show_icons).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('custom_field_setting', ".intval($custom_field_setting).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('customer_email_verification_required', ".intval($customer_email_verification_required).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('html_emails', ".intval($html_emails).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('use_mailgun', ".intval($use_mailgun).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('mailgun_api_key', '".hesk_dbEscape($mailgun_api_key)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('mailgun_domain', '".hesk_dbEscape($mailgun_domain)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('use_bootstrap_theme', ".intval($use_bootstrap_theme).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('new_kb_article_visibility', ".intval($new_kb_article_visibility).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('attachments', ".intval($attachments).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('show_number_merged', ".intval($show_number_merged).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('request_location', ".intval($request_location).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('category_order_column', '".hesk_dbEscape($category_order_column)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('rich_text_for_tickets', ".intval($rich_text_for_tickets).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('statuses_order_column', '".hesk_dbEscape($statuses_order_column)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('kb_attach_dir', '".hesk_dbEscape($kb_attach_dir)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('rich_text_for_tickets_for_customers', ".intval($rich_text_for_tickets_for_customers).")"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('navbarBackgroundColor', '".hesk_dbEscape($navbar_background_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('navbarBrandColor', '".hesk_dbEscape($navbar_brand_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('navbarBrandHoverColor', '".hesk_dbEscape($navbar_brand_hover_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('navbarItemTextColor', '".hesk_dbEscape($navbar_item_text_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('navbarItemTextHoverColor', '".hesk_dbEscape($navbar_item_text_hover_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('navbarItemTextSelectedColor', '".hesk_dbEscape($navbar_item_text_selected_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('navbarItemSelectedBackgroundColor', '".hesk_dbEscape($navbar_item_selected_background_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('dropdownItemTextColor', '".hesk_dbEscape($dropdown_item_text_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('dropdownItemTextHoverColor', '".hesk_dbEscape($dropdown_item_text_hover_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('dropdownItemTextHoverBackgroundColor', '".hesk_dbEscape($dropdown_item_text_hover_background_color)."')"); + executeQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."settings` (`Key`, `Value`) + VALUES ('questionMarkColor', '".hesk_dbEscape($question_mark_color)."')"); + } +} + +function getSettingValue($settings, $setting, $default) { + return isset($settings[$setting]) ? $settings[$setting] : $default; } \ No newline at end of file diff --git a/modsForHesk_settings.inc.php b/modsForHesk_settings.inc.php deleted file mode 100644 index ea14f874..00000000 --- a/modsForHesk_settings.inc.php +++ /dev/null @@ -1,64 +0,0 @@ - diff --git a/reply_ticket.php b/reply_ticket.php index 6c267ee2..f0d4f1d4 100644 --- a/reply_ticket.php +++ b/reply_ticket.php @@ -37,7 +37,6 @@ define('HESK_PATH','./'); /* Get all the required files and functions */ require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); // Are we in maintenance mode? @@ -66,6 +65,9 @@ hesk_session_start(); /* A security check */ # hesk_token_check('POST'); + +/* Connect to database */ +hesk_dbConnect(); $hesk_error_buffer = array(); // Tracking ID @@ -135,9 +137,6 @@ if (count($hesk_error_buffer)!=0) hesk_process_messages($hesk_error_buffer,'ticket.php?track='.$trackingID.$hesk_settings['e_param'].'&Refresh='.rand(10000,99999)); } -/* Connect to database */ -hesk_dbConnect(); - // Check if this IP is temporarily locked out $res = hesk_dbQuery("SELECT `number` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."logins` WHERE `ip`='".hesk_dbEscape($_SERVER['REMOTE_ADDR'])."' AND `last_attempt` IS NOT NULL AND DATE_ADD(`last_attempt`, INTERVAL ".intval($hesk_settings['attempt_banmin'])." MINUTE ) > NOW() LIMIT 1"); if (hesk_dbNumRows($res) == 1) @@ -205,6 +204,7 @@ $ticket['status'] = $ticket['status'] == $defaultNewTicketStatus['ID'] ? $defaul $res = hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `lastchange`=NOW(), `status`='{$ticket['status']}', `replies`=`replies`+1, `lastreplier`='0' WHERE `id`='{$ticket['id']}' LIMIT 1"); // Insert reply into database +$modsForHesk_settings = mfh_getSettings(); $html = $modsForHesk_settings['rich_text_for_tickets_for_customers']; hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."replies` (`replyto`,`name`,`message`,`dt`,`attachments`, `html`) VALUES ({$ticket['id']},'".hesk_dbEscape($ticket['name'])."','".hesk_dbEscape($message)."',NOW(),'".hesk_dbEscape($myattachments)."','".$html."')"); @@ -243,12 +243,12 @@ $ticket = hesk_ticketToPlain($info, 1, 0); // --> If ticket is assigned just notify the 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 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 */ diff --git a/submit_ticket.php b/submit_ticket.php index 5e1fb7aa..9a763cea 100644 --- a/submit_ticket.php +++ b/submit_ticket.php @@ -44,7 +44,6 @@ if ( ! isset($_POST['hx']) || $_POST['hx'] != 3 || ! isset($_POST['hy']) || $_PO // Get all the required files and functions require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); // Are we in maintenance mode? @@ -272,6 +271,7 @@ if ($tmpvar['category']) } // Custom fields +$modsForHesk_settings = mfh_getSettings(); foreach ($hesk_settings['custom_fields'] as $k=>$v) { if ($v['use']) @@ -472,7 +472,7 @@ if ($modsForHesk_settings['customer_email_verification_required']) hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."pending_verification_emails` (`Email`, `ActivationKey`) VALUES ('".$escapedEmail."', '".$escapedKey."')"); - hesk_notifyCustomerForVerifyEmail('verify_email', $key); + hesk_notifyCustomerForVerifyEmail('verify_email', $key, $modsForHesk_settings); $createTicket = false; } } @@ -484,19 +484,19 @@ if ($createTicket) // Notify the customer if ($hesk_settings['notify_new']) { - hesk_notifyCustomer(); + hesk_notifyCustomer($modsForHesk_settings); } // Need to notify staff? // --> From autoassign? 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 elseif ( ! $tmpvar['owner'] ) { - hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' "); + hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' ", $modsForHesk_settings); } } diff --git a/ticket.php b/ticket.php index 1d66e1bc..a3649af5 100644 --- a/ticket.php +++ b/ticket.php @@ -48,6 +48,9 @@ hesk_check_maintenance(); hesk_load_database_functions(); hesk_session_start(); +/* Connect to database */ +hesk_dbConnect(); +$modsForHesk_settings = mfh_getSettings(); $hesk_error_buffer = array(); $do_remember = ''; @@ -101,8 +104,6 @@ elseif ( empty($trackingID) || ( $hesk_settings['email_view_ticket'] && empty($m print_form(); } -/* Connect to database */ -hesk_dbConnect(); /* Limit brute force attempts */ hesk_limitBfAttempts(); diff --git a/verifyemail.php b/verifyemail.php index c4d28db8..7f5fb934 100644 --- a/verifyemail.php +++ b/verifyemail.php @@ -4,7 +4,6 @@ define('HESK_PATH','./'); // Get all the required files and functions require(HESK_PATH . 'hesk_settings.inc.php'); -require(HESK_PATH . 'modsForHesk_settings.inc.php'); require(HESK_PATH . 'inc/common.inc.php'); hesk_load_database_functions(); require(HESK_PATH . 'inc/posting_functions.inc.php'); @@ -46,7 +45,8 @@ require_once(HESK_PATH . 'inc/header.inc.php'); { $ticket = hesk_newTicket($innerResult); // Notify the customer - hesk_notifyCustomer(); + $modsForHesk_settings = mfh_getSettings(); + hesk_notifyCustomer($modsForHesk_settings); // Need to notify staff? // --> From autoassign? @@ -54,12 +54,12 @@ require_once(HESK_PATH . 'inc/header.inc.php'); $autoassign_owner = $getOwnerRs->fetch_assoc(); 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 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']);