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_reply_ticket.php b/admin/admin_reply_ticket.php index fc59ae36..98e459cb 100644 --- a/admin/admin_reply_ticket.php +++ b/admin/admin_reply_ticket.php @@ -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_save.php b/admin/admin_settings_save.php index d5becdad..52e04dea 100644 --- a/admin/admin_settings_save.php +++ b/admin/admin_settings_save.php @@ -39,12 +39,14 @@ define('HESK_PATH','../'); require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'inc/common.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'); hesk_load_database_functions(); hesk_session_start(); hesk_dbConnect(); + +require(HESK_PATH . 'inc/email_functions.inc.php'); + hesk_isLoggedIn(); // Check permissions for this feature diff --git a/admin/admin_submit_ticket.php b/admin/admin_submit_ticket.php index 89310eff..0e844100 100644 --- a/admin/admin_submit_ticket.php +++ b/admin/admin_submit_ticket.php @@ -287,7 +287,7 @@ $ticket = hesk_newTicket($tmpvar); // Notify the customer about the ticket? if ($notify) { - hesk_notifyCustomer(); + hesk_notifyCustomer($modsForHesk_settings); } // 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 ( ! isset($autoassign_owner['email']) ) { - hesk_notifyAssignedStaff(false, 'ticket_assigned_to_you'); + hesk_notifyAssignedStaff(false, 'ticket_assigned_to_you', $modsForHesk_settings); } 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 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 diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index 999c91af..f99b717d 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -457,14 +457,14 @@ if (isset($_POST['notemsg']) && hesk_token_check('POST')) /* Format email subject and message for staff */ $subject = hesk_getEmailSubject('new_note',$ticket); - $message = hesk_getEmailMessage('new_note',$ticket,1); - $htmlMessage = hesk_getHtmlMessage('new_note',$ticket,1); - $hasMessage = hesk_doesTemplateHaveTag('new_note', '%%MESSAGE%%'); + $message = hesk_getEmailMessage('new_note',$ticket,$modsForHesk_settings,1); + $htmlMessage = hesk_getHtmlMessage('new_note',$ticket,$modsForHesk_settings, 1); + $hasMessage = hesk_doesTemplateHaveTag('new_note', '%%MESSAGE%%', $modsForHesk_settings); /* Send email to staff */ 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); } } } diff --git a/admin/assign_owner.php b/admin/assign_owner.php new file mode 100755 index 00000000..174b12a6 --- /dev/null +++ b/admin/assign_owner.php @@ -0,0 +1,160 @@ +'.$hesklang['unas'].'',$_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'); +?> diff --git a/admin/change_status.php b/admin/change_status.php index d645859e..f7049a8e 100644 --- a/admin/change_status.php +++ b/admin/change_status.php @@ -44,6 +44,7 @@ hesk_load_database_functions(); hesk_session_start(); hesk_dbConnect(); hesk_isLoggedIn(); +$modsForHesk_settings = mfh_getSettings(); /* Check permissions for this feature */ if (!isset($_REQUEST['isManager']) || !$_REQUEST['isManager']) { @@ -103,7 +104,7 @@ if ($statusRow['IsClosed']) // Closed // Notify customer require(HESK_PATH . 'inc/email_functions.inc.php'); - hesk_notifyCustomer('ticket_closed'); + hesk_notifyCustomer($modsForHesk_settings,'ticket_closed'); } // Log who marked the ticket resolved diff --git a/admin/delete_tickets.php b/admin/delete_tickets.php index c65be8a3..165cb151 100644 --- a/admin/delete_tickets.php +++ b/admin/delete_tickets.php @@ -44,6 +44,7 @@ hesk_load_database_functions(); hesk_session_start(); hesk_dbConnect(); hesk_isLoggedIn(); +$modsForHesk_settings = mfh_getSettings(); /* Set correct return URL */ if (isset($_SERVER['HTTP_REFERER'])) @@ -311,7 +312,7 @@ else $ticket['dt'] = hesk_date($ticket['dt'], true); $ticket['lastchange'] = hesk_date($ticket['lastchange'], true); $ticket = hesk_ticketToPlain($ticket, 1, 0); - hesk_notifyCustomer('ticket_closed'); + hesk_notifyCustomer($modsForHesk_settings,'ticket_closed'); } } diff --git a/admin/index.php b/admin/index.php index 4b0ba816..e465a720 100644 --- a/admin/index.php +++ b/admin/index.php @@ -43,6 +43,7 @@ hesk_load_database_functions(); hesk_session_start(); hesk_dbConnect(); +$modsForHesk_settings = mfh_getSettings(); /* What should we do? */ $action = hesk_REQUEST('a'); @@ -70,7 +71,7 @@ exit(); /*** START FUNCTIONS ***/ function do_login() { - global $hesk_settings, $hesklang; + global $hesk_settings, $hesklang, $modsForHesk_settings; $hesk_error_buffer = array(); @@ -285,7 +286,7 @@ function do_login() $ticket['dt'] = hesk_date($ticket['dt'], true); $ticket['lastchange'] = hesk_date($ticket['lastchange'], true); $ticket = hesk_ticketToPlain($ticket, 1, 0); - hesk_notifyCustomer('ticket_closed'); + hesk_notifyCustomer($modsForHesk_settings,'ticket_closed'); } } } diff --git a/admin/lock.php b/admin/lock.php index e214ee02..b446348d 100644 --- a/admin/lock.php +++ b/admin/lock.php @@ -44,6 +44,7 @@ hesk_load_database_functions(); hesk_session_start(); hesk_dbConnect(); hesk_isLoggedIn(); +$modsForHesk_settings = mfh_getSettings(); /* Check permissions for this feature */ hesk_checkPermission('can_view_tickets'); @@ -98,7 +99,7 @@ else $ticket['dt'] = hesk_date($ticket['dt'], true); $ticket['lastchange'] = hesk_date($ticket['lastchange'], true); - hesk_notifyCustomer('ticket_closed'); + hesk_notifyCustomer($modsForHesk_settings, 'ticket_closed'); } } } diff --git a/admin/mail.php b/admin/mail.php index 96333f90..dada2c0c 100644 --- a/admin/mail.php +++ b/admin/mail.php @@ -40,12 +40,14 @@ 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(); +require(HESK_PATH . 'inc/email_functions.inc.php'); hesk_isLoggedIn(); +$modsForHesk_settings = mfh_getSettings(); + /* List of staff */ $admins = array(); $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() { - global $hesk_settings, $hesklang; + global $hesk_settings, $hesklang, $modsForHesk_settings; /* A security check */ hesk_token_check('POST'); @@ -361,12 +363,12 @@ function mail_send() /* Format email subject and message for recipient */ $subject = hesk_getEmailSubject('new_pm',$pm,0); - $message = hesk_getEmailMessage('new_pm',$pm,1,0); - $htmlMessage = hesk_getHtmlMessage('new_pm',$pm,1,0); - $hasMessage = hesk_doesTemplateHaveTag('new_pm','%%MESSAGE%%'); + $message = hesk_getEmailMessage('new_pm',$pm,$modsForHesk_settings,1,0); + $htmlMessage = hesk_getHtmlMessage('new_pm',$pm,$modsForHesk_settings,1,0); + $hasMessage = hesk_doesTemplateHaveTag('new_pm','%%MESSAGE%%', $modsForHesk_settings); /* 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']); diff --git a/admin/manage_canned.php b/admin/manage_canned.php index 59ca054b..bb600a98 100644 --- a/admin/manage_canned.php +++ b/admin/manage_canned.php @@ -59,6 +59,8 @@ if ( $action = hesk_REQUEST('a') ) elseif ($action == 'order') {order_saved();} } +$modsForHesk_settings = mfh_getSettings(); + /* Print header */ require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); @@ -77,7 +79,7 @@ function hesk_insertTag(tag) { var text_to_insert = '%%'+tag+'%%'; var msg = ''; + if ($modsForHesk_settings['rich_text_for_tickets']) { ?> msg = tinymce.get("message").getContent(); tinymce.get("message").setContent(''); 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"; - 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"; } else { $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) { - +
diff --git a/admin/manage_permission_templates.php b/admin/manage_permission_templates.php index c590b32f..99f5142f 100644 --- a/admin/manage_permission_templates.php +++ b/admin/manage_permission_templates.php @@ -74,14 +74,16 @@ else {return false;} //--> -"> - + '.$mysaved['title'].''; - 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"; } else { $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);