Bootswatch, Summernote, and Captcheck mods for Mods for HESK (mods-for-hesk.com). In use at support.netsyms.com.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lock.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. *
  4. * This file is part of HESK - PHP Help Desk Software.
  5. *
  6. * (c) Copyright Klemen Stirn. All rights reserved.
  7. * https://www.hesk.com
  8. *
  9. * For the full copyright and license agreement information visit
  10. * https://www.hesk.com/eula.php
  11. *
  12. */
  13. define('IN_SCRIPT', 1);
  14. define('HESK_PATH', '../');
  15. /* Get all the required files and functions */
  16. require(HESK_PATH . 'hesk_settings.inc.php');
  17. require(HESK_PATH . 'inc/common.inc.php');
  18. require(HESK_PATH . 'inc/admin_functions.inc.php');
  19. hesk_load_database_functions();
  20. hesk_session_start();
  21. hesk_dbConnect();
  22. hesk_isLoggedIn();
  23. $modsForHesk_settings = mfh_getSettings();
  24. /* Check permissions for this feature */
  25. hesk_checkPermission('can_view_tickets');
  26. hesk_checkPermission('can_reply_tickets');
  27. hesk_checkPermission('can_edit_tickets');
  28. hesk_checkPermission('can_resolve');
  29. /* A security check */
  30. hesk_token_check();
  31. /* Ticket ID */
  32. $trackingID = hesk_cleanID() or die($hesklang['int_error'] . ': ' . $hesklang['no_trackID']);
  33. // Get ticket info
  34. $result = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE `trackid`='" . hesk_dbEscape($trackingID) . "' LIMIT 1");
  35. if (hesk_dbNumRows($result) != 1) {
  36. hesk_error($hesklang['ticket_not_found']);
  37. }
  38. $ticket = hesk_dbFetchAssoc($result);
  39. $audit_unlocked = null;
  40. $audit_locked = null;
  41. /* New locked status */
  42. if (empty($_GET['locked'])) {
  43. $status = 0;
  44. $tmp = $hesklang['tunlock'];
  45. $audit_unlocked = array(0 => $_SESSION['name'] . ' (' . $_SESSION['user'] . ')');
  46. $closedby_sql = ' , `closedat`=NULL, `closedby`=NULL ';
  47. } else {
  48. $status = 1;
  49. $tmp = $hesklang['tlock'];
  50. $audit_locked = array(0 => $_SESSION['name'] . ' (' . $_SESSION['user'] . ')');
  51. $closedby_sql = ' , `closedat`=NOW(), `closedby`=' . intval($_SESSION['id']) . ' ';
  52. // Notify customer of closed ticket?
  53. if ($hesk_settings['notify_closed']) {
  54. $closedStatusRS = hesk_dbQuery('SELECT `ID` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'statuses` WHERE `IsClosed` = 1');
  55. $ticketIsOpen = true;
  56. while ($row = hesk_dbFetchAssoc($closedStatusRS)) {
  57. if ($ticket['status'] == $row['ID']) {
  58. $ticketIsOpen = false;
  59. }
  60. }
  61. // Notify customer, but only if ticket is not already closed
  62. if ($ticketIsOpen) {
  63. require(HESK_PATH . 'inc/email_functions.inc.php');
  64. $ticket['dt'] = hesk_date($ticket['dt'], true);
  65. $ticket['lastchange'] = hesk_date($ticket['lastchange'], true);
  66. hesk_notifyCustomer($modsForHesk_settings, 'ticket_closed');
  67. }
  68. }
  69. }
  70. /* Update database */
  71. $statusSql = 'SELECT `ID` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'statuses` WHERE `LockedTicketStatus` = 1';
  72. $statusRs = hesk_dbQuery($statusSql);
  73. $statusRow = hesk_dbFetchAssoc($statusRs);
  74. $statusId = $statusRow['ID'];
  75. hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `status`= {$statusId},`locked`='{$status}' $closedby_sql WHERE `trackid`='" . hesk_dbEscape($trackingID) . "'");
  76. if ($audit_unlocked) {
  77. mfh_insert_audit_trail_record($ticket['id'], 'TICKET', 'audit_unlocked', hesk_date(),
  78. $audit_unlocked);
  79. }
  80. if ($audit_locked) {
  81. mfh_insert_audit_trail_record($ticket['id'], 'TICKET', 'audit_locked', hesk_date(),
  82. $audit_locked);
  83. }
  84. /* Back to ticket page and show a success message */
  85. hesk_process_messages($tmp, 'admin_ticket.php?track=' . $trackingID . '&Refresh=' . rand(10000, 99999), 'SUCCESS');