From 01964b61b8e63132fda239f5e6c7276507134707 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 12 Jul 2015 11:27:00 -0400 Subject: [PATCH 01/27] Closes #281 Always show custom field selection when editing canned response --- admin/manage_canned.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/manage_canned.php b/admin/manage_canned.php index 8e1dc9f7..3bb1fef5 100644 --- a/admin/manage_canned.php +++ b/admin/manage_canned.php @@ -277,7 +277,8 @@ myField.value += myValue; echo stripslashes($_SESSION['canned']['msg']); } ?> - : + + : | | | @@ -296,8 +297,7 @@ myField.value += myValue; echo '| '.$v['name'].' '; } } - ?> - + ?>
From f19f204534c64fea06d66d3308a59e8194cf0e65 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Thu, 16 Jul 2015 22:04:42 -0400 Subject: [PATCH 02/27] #284 Add recaptchalib to repo --- .gitignore | 1 - inc/recaptcha/recaptchalib_v2.php | 140 ++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100755 inc/recaptcha/recaptchalib_v2.php diff --git a/.gitignore b/.gitignore index 39da1146..7b12609a 100644 --- a/.gitignore +++ b/.gitignore @@ -269,7 +269,6 @@ attachments img/ban.png img/banned.png img/ico_tools.png -inc/recaptcha/recaptchalib_v2.php ip_whois.php language/en/emails/reset_password.txt language/en/help_files/ticket_list.html diff --git a/inc/recaptcha/recaptchalib_v2.php b/inc/recaptcha/recaptchalib_v2.php new file mode 100755 index 00000000..ae467a28 --- /dev/null +++ b/inc/recaptcha/recaptchalib_v2.php @@ -0,0 +1,140 @@ +" . self::$_signupUrl . ""); + } + $this->_secret=$secret; + } + + /** + * Encodes the given data into a query string format. + * + * @param array $data array of string elements to be encoded. + * + * @return string - encoded request. + */ + private function _encodeQS($data) + { + $req = ""; + foreach ($data as $key => $value) { + $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; + } + + // Cut the last '&' + $req=substr($req, 0, strlen($req)-1); + return $req; + } + + /** + * Submits an HTTP GET to a reCAPTCHA server. + * + * @param string $path url path to recaptcha server. + * @param array $data array of parameters to be sent. + * + * @return array response + */ + private function _submitHTTPGet($path, $data) + { + $req = $this->_encodeQS($data); + $response = file_get_contents($path . $req); + return $response; + } + + /** + * Calls the reCAPTCHA siteverify API to verify whether the user passes + * CAPTCHA test. + * + * @param string $remoteIp IP address of end user. + * @param string $response response string from recaptcha verification. + * + * @return ReCaptchaResponse + */ + public function verifyResponse($remoteIp, $response) + { + // Discard empty solution submissions + if ($response == null || strlen($response) == 0) { + $recaptchaResponse = new ReCaptchaResponse(); + $recaptchaResponse->success = false; + $recaptchaResponse->errorCodes = 'missing-input'; + return $recaptchaResponse; + } + + $getResponse = $this->_submitHttpGet( + self::$_siteVerifyUrl, + array ( + 'secret' => $this->_secret, + 'remoteip' => $remoteIp, + 'v' => self::$_version, + 'response' => $response + ) + ); + $answers = json_decode($getResponse, true); + $recaptchaResponse = new ReCaptchaResponse(); + + if (trim($answers ['success']) == true) { + $recaptchaResponse->success = true; + } else { + $recaptchaResponse->success = false; + $recaptchaResponse->errorCodes = $answers [error-codes]; + } + + return $recaptchaResponse; + } +} + +?> From bab50e059f5c8816deafb97860dacec790700fde Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Thu, 16 Jul 2015 22:04:59 -0400 Subject: [PATCH 03/27] #284 Add cURL support for recaptchalib_v2 --- inc/recaptcha/recaptchalib_v2.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/inc/recaptcha/recaptchalib_v2.php b/inc/recaptcha/recaptchalib_v2.php index ae467a28..9b035ada 100755 --- a/inc/recaptcha/recaptchalib_v2.php +++ b/inc/recaptcha/recaptchalib_v2.php @@ -91,6 +91,27 @@ class ReCaptcha private function _submitHTTPGet($path, $data) { $req = $this->_encodeQS($data); + // Try using cURL first. If that fails, fallback to file_get_contents + if (function_exists('curl_init')) { + $handle = curl_init($path); + $queryString = http_build_query($data, '', '&'); + $options = array( + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $queryString, + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/x-www-form-urlencoded' + ), + CURLINFO_HEADER_OUT => false, + CURLOPT_HEADER => false, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_SSL_VERIFYPEER => true + ); + curl_setopt_array($handle, $options); + $response = curl_exec($handle); + curl_close($handle); + return $response; + } + $response = file_get_contents($path . $req); return $response; } From 98e589dfb48dc9d4e35d1742cae492a066bc4dfe Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 19 Jul 2015 22:20:18 -0400 Subject: [PATCH 04/27] #209 Tweak the statuses UI - Remove "Language Key" input field - Add panels to separate content - Add pencil icon w/tooltip that will soon hold a way to edit the name --- admin/manage_statuses.php | 337 ++++++++++++++++++++------------------ language/en/text.php | 1 + 2 files changed, 175 insertions(+), 163 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index b69aee79..15c1615e 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -77,10 +77,6 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); /* This will handle error, success and notice messages */ hesk_handle_messages(); - ?> -
-
-
-
+
+
+

+
- - - - - - + + + + + @@ -119,172 +117,185 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); elseif ($row['Closable'] == 'conly') { $customersOnlySelected = 'selected'; } elseif ($row['Closable'] == 'sonly') { $staffOnlySelected = 'selected'; } else { $noSelected = 'selected'; } - - echo ''; - echo ''; //Name - echo ''; // Language File Key - echo ''; // Text Color - echo ''; - echo ''; // Resolved Status? - echo ''; //Delete status? - echo ''; + ?> + + + + + + + + '; echo ''; - echo ''; // Language File Key echo ''; // Text Color echo ''; + + '; echo ''; // Resolved Status? - echo ''; //Empty placeholder where the delete row is. + echo ''; // Placeholder where delete is echo ''; ?>
'.$hesklang[$row['Key']].' - - '; - if ($isDisabled) - { - echo ''; - } else - { - echo ''; - } - echo '
+ + + + + + + + + + + + + + +
'.$hesklang['addNew'].' - -
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- +
+
+

-
-
- -
- +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
diff --git a/language/en/text.php b/language/en/text.php index a934805c..00dbb578 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -32,6 +32,7 @@ $hesklang['quick_help_sections_help'] = 'Check the checkbox to show the "Quick H $hesklang['create_ticket'] = 'Create ticket'; $hesklang['view_ticket_form'] = 'View ticket form'; $hesklang['knowledgebase'] = 'Knowledgebase section'; +$hesklang['click_to_edit_name'] = 'Click to edit name'; // ADDED OR MODIFIED IN Mods for HESK 2.3.0 $hesklang['sm_icon'] = 'Icon'; From 2e3d9ccded4dcca5c1665ad103c01733f8d80dbc Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 22 Jul 2015 22:04:10 -0400 Subject: [PATCH 05/27] #209 Remove form-related fields from the table --- admin/manage_statuses.php | 101 ++++++++++++++------------------------ 1 file changed, 37 insertions(+), 64 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 15c1615e..7a630f30 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -86,88 +86,61 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
-

+

- - - - + + + - fetch_assoc()) - { - $checkedEcho = ($row['IsClosed'] == 1) ? 'checked="checked"' : ''; - $isDisabled = false; - if ($row['IsNewTicketStatus'] || $row['IsClosedByClient'] || $row['IsCustomerReplyStatus'] || - $row['IsStaffClosedOption'] || $row['IsStaffReopenedStatus'] || $row['IsDefaultStaffReplyStatus'] || - $row['LockedTicketStatus'] || $row['IsAutocloseOption']) - { - $isDisabled = true; - } - - $yesSelected = $customersOnlySelected = $staffOnlySelected = $noSelected = ''; - if ($row['Closable'] == 'yes') { $yesSelected = 'selected'; } - elseif ($row['Closable'] == 'conly') { $customersOnlySelected = 'selected'; } - elseif ($row['Closable'] == 'sonly') { $staffOnlySelected = 'selected'; } - else { $noSelected = 'selected'; } - ?> + - - - '; - echo ''; - echo ''; // Text Color - echo ''; - echo ''; // Resolved Status? - echo ''; // Placeholder where delete is - echo ''; - ?> +
+ + + +
- + - - - + - + - - - - - + + + + +
'.$hesklang['addNew'].' - -
From 35a3f808905f3c77518b79a1ec38e13a62ae71a2 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Thu, 23 Jul 2015 21:25:27 -0400 Subject: [PATCH 06/27] #209 Only show move up/down if at the right point --- admin/manage_statuses.php | 49 +++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 7a630f30..4409150c 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -78,6 +78,9 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); hesk_handle_messages(); //-- We need to get all of the statuses and dump the information to the page. + $numOfStatusesRS = hesk_dbQuery('SELECT 1 FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'); + $numberOfStatuses = hesk_dbNumRows($numOfStatusesRS); + $statusesSql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'; $closedStatusesSql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 1'; $openStatusesSql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 0'; @@ -92,22 +95,16 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); - - - - - - + + - + @@ -134,13 +131,14 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); - - - - + + + + + - +
@@ -285,6 +283,23 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); require_once(HESK_PATH . 'inc/footer.inc.php'); exit(); +function echoArrows($index, $numberOfStatuses) { + if ($index !== 1) { + // Display move up + echo ' '; + } else { + echo ' '; + } + + if ($index !== $numberOfStatuses) { + // Display move down + echo ''; + } else { + echo ''; + } + +} + function save() { global $hesklang, $hesk_settings; From 84e2be3a8c7d5ec20723bb6a19d09b86c4f30e45 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Thu, 23 Jul 2015 21:39:34 -0400 Subject: [PATCH 07/27] #209 Remove unused save actions --- admin/manage_statuses.php | 142 +++++++------------------------------- 1 file changed, 24 insertions(+), 118 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 4409150c..8928d8b8 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -303,134 +303,40 @@ function echoArrows($index, $numberOfStatuses) { function save() { global $hesklang, $hesk_settings; - //-- Before we do anything, make sure the statuses are valid. - $rows = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'); - while ($row = $rows->fetch_assoc()) - { - if (!isset($_POST['s'.$row['ID'].'_delete'])) - { - validateStatus($_POST['s'.$row['ID'].'_key'], $_POST['s'.$row['ID'].'_textColor']); - } - } - - //-- Validate the new one if at least one of the fields are used / checked - if ($_POST['sN_key'] != null || $_POST['sN_textColor'] != null || isset($_POST['sN_isClosed'])) - { - validateStatus($_POST['sN_key'], $_POST['sN_textColor']); - } - - hesk_dbConnect(); - $wasStatusDeleted = false; - //-- Get all the status IDs - $statusesSql = 'SELECT * FROM `'.$hesk_settings['db_pfix'].'statuses`'; - $results = hesk_dbQuery($statusesSql); - while ($row = $results->fetch_assoc()) - { - //-- If the status is marked for deletion, delete it and skip everything below. - if (isset($_POST['s'.$row['ID'].'_delete'])) - { - $delete = "DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($delete); - $stmt->bind_param('i', $row['ID']); - $stmt->execute(); - $wasStatusDeleted = true; - } else - { - //-- Update the information in the database with what is on the page - $query = "UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `Key` = ?, `TextColor` = ?, `IsClosed` = ?, `Closable` = ? WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($query); - $isStatusClosed = (isset($_POST['s'.$row['ID'].'_isClosed']) ? 1 : 0); - $stmt->bind_param('sssisi', $_POST['s'.$row['ID'].'_key'], $_POST['s'.$row['ID'].'_textColor'], $isStatusClosed, $_POST['s'.$row['ID'].'_closable'], $row['ID']); - $stmt->execute(); - } - } - - //-- If any statuses were deleted, re-index them before adding a new one - if ($wasStatusDeleted) { - //-- First drop and re-add the ID column - hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` DROP COLUMN `ID`"); - hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` ADD `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"); - - //-- Since statuses should be zero-based, but are now one-based, subtract one from each ID - hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `ID` = `ID`-1"); - } - - //-- Insert the addition if there is anything to add - if ($_POST['sN_key'] != null && $_POST['sN_textColor'] != null) - { - //-- The next ID is equal to the number of rows, since the IDs are zero-indexed. - $nextValue = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`')->num_rows; - $isClosed = isset($_POST['sN_isClosed']) ? 1 : 0; - $insert = "INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` (`ID`, `Key`, `TextColor`, `IsClosed`, `Closable`) - VALUES (".$nextValue.", '".hesk_dbEscape($_POST['sN_key'])."', '".hesk_dbEscape($_POST['sN_textColor'])."', ".$isClosed.", '".hesk_dbEscape($_POST['sN_closable'])."')"; - hesk_dbQuery($insert); - } - //-- Update default status for actions $defaultQuery = "UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET "; - hesk_dbConnect()->query($defaultQuery . "`IsNewTicketStatus` = 0"); - $updateQuery = $defaultQuery . "`IsNewTicketStatus` = 1 WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($updateQuery); - $stmt->bind_param('i', $_POST['newTicket']); - $stmt->execute(); + hesk_dbQuery($defaultQuery . "`IsNewTicketStatus` = 0"); + $updateQuery = $defaultQuery . "`IsNewTicketStatus` = 1 WHERE `ID` = ".intval($_POST['newTicket']); + hesk_dbQuery($updateQuery); + hesk_dbQuery($defaultQuery . "`IsClosedByClient` = 0"); + $updateQuery = $defaultQuery . "`IsClosedByClient` = 1 WHERE `ID` = ".intval($_POST['closedByClient']); + hesk_dbQuery($updateQuery); - hesk_dbConnect()->query($defaultQuery . "`IsClosedByClient` = 0"); - $updateQuery = $defaultQuery . "`IsClosedByClient` = 1 WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($updateQuery); - $stmt->bind_param('i', $_POST['closedByClient']); - $stmt->execute(); + hesk_dbQuery($defaultQuery . "`IsCustomerReplyStatus` = 0"); + $updateQuery = $defaultQuery . "`IsCustomerReplyStatus` = 1 WHERE `ID` = ".intval($_POST['replyFromClient']); + hesk_dbQuery($updateQuery); - hesk_dbConnect()->query($defaultQuery . "`IsCustomerReplyStatus` = 0"); - $updateQuery = $defaultQuery . "`IsCustomerReplyStatus` = 1 WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($updateQuery); - $stmt->bind_param('i', $_POST['replyFromClient']); - $stmt->execute(); + hesk_dbQuery($defaultQuery . "`IsStaffClosedOption` = 0"); + $updateQuery = $defaultQuery . "`IsStaffClosedOption` = 1 WHERE `ID` = ".intval($_POST['staffClosedOption']); + hesk_dbQuery($updateQuery); - hesk_dbConnect()->query($defaultQuery . "`IsStaffClosedOption` = 0"); - $updateQuery = $defaultQuery . "`IsStaffClosedOption` = 1 WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($updateQuery); - $stmt->bind_param('i', $_POST['staffClosedOption']); - $stmt->execute(); + hesk_dbQuery($defaultQuery . "`IsStaffReopenedStatus` = 0"); + $updateQuery = $defaultQuery . "`IsStaffReopenedStatus` = 1 WHERE `ID` = ".intval($_POST['staffReopenedStatus']); + hesk_dbQuery($updateQuery); - hesk_dbConnect()->query($defaultQuery . "`IsStaffReopenedStatus` = 0"); - $updateQuery = $defaultQuery . "`IsStaffReopenedStatus` = 1 WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($updateQuery); - $stmt->bind_param('i', $_POST['staffReopenedStatus']); - $stmt->execute(); + hesk_dbQuery($defaultQuery . "`IsDefaultStaffReplyStatus` = 0"); + $updateQuery = $defaultQuery . "`IsDefaultStaffReplyStatus` = 1 WHERE `ID` = ".intval($_POST['defaultStaffReplyStatus']); + hesk_dbQuery($updateQuery); - hesk_dbConnect()->query($defaultQuery . "`IsDefaultStaffReplyStatus` = 0"); - $updateQuery = $defaultQuery . "`IsDefaultStaffReplyStatus` = 1 WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($updateQuery); - $stmt->bind_param('i', $_POST['defaultStaffReplyStatus']); - $stmt->execute(); + hesk_dbQuery($defaultQuery . "`LockedTicketStatus` = 0"); + $updateQuery = $defaultQuery . "`LockedTicketStatus` = 1 WHERE `ID` = ".intval($_POST['lockedTicketStatus']); + hesk_dbQuery($updateQuery); - hesk_dbConnect()->query($defaultQuery . "`LockedTicketStatus` = 0"); - $updateQuery = $defaultQuery . "`LockedTicketStatus` = 1 WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($updateQuery); - $stmt->bind_param('i', $_POST['lockedTicketStatus']); - $stmt->execute(); - - hesk_dbConnect()->query($defaultQuery . "`IsAutocloseOption` = 0"); - $updateQuery = $defaultQuery . "`IsAutocloseOption` = 1 WHERE `ID` = ?"; - $stmt = hesk_dbConnect()->prepare($updateQuery); - $stmt->bind_param('i', $_POST['autocloseTicketOption']); - $stmt->execute(); + hesk_dbQuery($defaultQuery . "`IsAutocloseOption` = 0"); + $updateQuery = $defaultQuery . "`IsAutocloseOption` = 1 WHERE `ID` = ".intval($_POST['autocloseTicketOption']); + hesk_dbQuery($updateQuery); hesk_process_messages($hesklang['statuses_saved'],'manage_statuses.php','SUCCESS'); -} - -function validateStatus($key, $textColor) -{ - global $hesklang; - - //-- Validation logic - if ($key == '') - { - hesk_process_messages($hesklang['key_required'], 'manage_statuses.php'); - } elseif ($textColor == '') - { - hesk_process_messages($hesklang['textColorRequired'], 'manage_statuses.php'); - } } \ No newline at end of file From e64eebad81180da9a5cdb40885ffeeb27812e85c Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Thu, 23 Jul 2015 22:06:02 -0400 Subject: [PATCH 08/27] #209 Some more UI changes. Still need to setup modals. --- admin/manage_statuses.php | 29 ++++++++++++++++++++++++----- language/en/text.php | 1 + 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 8928d8b8..dc775daa 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -89,7 +89,18 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
-

+

+ + + + + + + +

@@ -132,10 +143,12 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); @@ -284,22 +297,28 @@ require_once(HESK_PATH . 'inc/footer.inc.php'); exit(); function echoArrows($index, $numberOfStatuses) { + global $hesklang; + if ($index !== 1) { // Display move up - echo ' '; + echo ' '; } else { echo ' '; } if ($index !== $numberOfStatuses) { // Display move down - echo ''; + echo ''; } else { echo ''; } } +function buildCreateStatusModal() { + echo ''; +} + function save() { global $hesklang, $hesk_settings; diff --git a/language/en/text.php b/language/en/text.php index 00dbb578..fca2987a 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -33,6 +33,7 @@ $hesklang['create_ticket'] = 'Create ticket'; $hesklang['view_ticket_form'] = 'View ticket form'; $hesklang['knowledgebase'] = 'Knowledgebase section'; $hesklang['click_to_edit_name'] = 'Click to edit name'; +$hesklang['new_status'] = 'New Status'; // ADDED OR MODIFIED IN Mods for HESK 2.3.0 $hesklang['sm_icon'] = 'Icon'; From 15c2e7d983b42a7d32698e2364de6db3ee708e65 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sat, 25 Jul 2015 01:11:08 -0400 Subject: [PATCH 09/27] #209 Mockup for create status modal is complete, add table for status text --- admin/manage_statuses.php | 89 ++++++++++++++++++++++-- install/mods-for-hesk/sql/installSql.php | 7 ++ language/en/text.php | 4 ++ 3 files changed, 94 insertions(+), 6 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index dc775daa..579a2744 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -92,13 +92,12 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');

- +

@@ -141,7 +140,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); ?>
@@ -168,7 +169,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); while ($row = $statusesRS->fetch_assoc()) { $selectedEcho = ($row['IsNewTicketStatus'] == 1) ? 'selected="selected"' : ''; - echo ''; + echo ''; } ?> @@ -183,7 +184,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); while ($row = $statusesRS->fetch_assoc()) { $selectedEcho = ($row['IsClosedByClient'] == 1) ? 'selected="selected"' : ''; - echo ''; + echo ''; } ?> @@ -198,7 +199,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); while ($row = $statusesRS->fetch_assoc()) { $selectedEcho = ($row['IsCustomerReplyStatus'] == 1) ? 'selected="selected"' : ''; - echo ''; + echo ''; } ?> @@ -213,7 +214,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); while ($row = $statusesRS->fetch_assoc()) { $selectedEcho = ($row['IsStaffClosedOption'] == 1) ? 'selected="selected"' : ''; - echo ''; + echo ''; } ?> @@ -228,7 +229,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); while ($row = $statusesRS->fetch_assoc()) { $selectedEcho = ($row['IsStaffReopenedStatus'] == 1) ? 'selected="selected"' : ''; - echo ''; + echo ''; } ?> @@ -243,7 +244,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); while ($row = $statusesRS->fetch_assoc()) { $selectedEcho = ($row['IsDefaultStaffReplyStatus'] == 1) ? 'selected="selected"' : ''; - echo ''; + echo ''; } ?> @@ -258,7 +259,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); while ($row = $statusesRS->fetch_assoc()) { $selectedEcho = ($row['LockedTicketStatus'] == 1) ? 'selected="selected"' : ''; - echo ''; + echo ''; } ?> @@ -273,7 +274,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); while ($row = $statusesRS->fetch_assoc()) { $selectedEcho = ($row['IsAutocloseOption'] == 1) ? 'selected' : ''; - echo ''; + echo ''; } ?> diff --git a/inc/common.inc.php b/inc/common.inc.php index 6365983d..65843184 100644 --- a/inc/common.inc.php +++ b/inc/common.inc.php @@ -1952,17 +1952,16 @@ function hesk_getFeatureArray() { function mfh_getDisplayTextForStatusId($statusId) { global $hesklang, $hesk_settings; - $xrefRs = hesk_dbQuery("SELECT `text` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."text_to_status_xref` - WHERE `status_id` = ".intval($statusId)." - AND `language` = '".hesk_dbEscape($hesk_settings['language'])."'"); - if (hesk_dbNumRows($xrefRs) == 1) { + $statusRs = hesk_dbQuery("SELECT `text`, `Key`, `language` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` AS `statuses` + LEFT JOIN `".hesk_dbEscape($hesk_settings['db_pfix'])."text_to_status_xref` ON `status_id` = `statuses`.`ID` + WHERE `statuses`.`ID` = ".intval($statusId)); + + $statusRec = hesk_dbFetchAssoc($statusRs); + if ($statusRec['language'] == $hesk_settings['language'] && $statusRec['text'] != NULL) { // We found a record. Use the text field - $xrefRecord = hesk_dbFetchAssoc($xrefRs); - return $xrefRecord['text']; + return $statusRec['text']; } else { // Fallback to the language key - $statusRs = hesk_dbQuery("SELECT `Key` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE `ID` = ".intval($statusId)); - $statusRec = hesk_dbFetchAssoc($statusRs); return $hesklang[$statusRec['Key']]; } } \ No newline at end of file From 1a825b81afcc04024358867456e0c2955859cb29 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 26 Jul 2015 21:23:04 -0400 Subject: [PATCH 13/27] #209 Statuses can now be edited --- admin/manage_statuses.php | 158 +++++++++++++++++++++++++++++++++++++- inc/common.inc.php | 8 ++ language/en/text.php | 4 + 3 files changed, 167 insertions(+), 3 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 0336575c..3c0a3ccc 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -21,8 +21,12 @@ define('WYSIWYG',1); if (isset($_POST['a'])) { if ($_POST['a'] == 'create') { createStatus(); + } elseif ($_POST['a'] == 'update') { + updateStatus(); } } + + /* Print header */ require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); @@ -142,16 +146,17 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); - +
- + - +
- + @@ -293,6 +292,8 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); $value) { + $languages[$key] = $hesk_settings['languages'][$key]['folder']; + } +?> + + Date: Sat, 25 Jul 2015 16:33:44 -0400 Subject: [PATCH 10/27] #209 New statuses can be created to the xref table --- admin/manage_statuses.php | 37 +++++++++++++++++++++++++++++++------ language/en/text.php | 1 + 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 579a2744..4962e819 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -18,9 +18,9 @@ hesk_checkPermission('can_man_ticket_statuses'); define('WYSIWYG',1); // Are we performing an action? -if (isset($_POST['action'])) { - if ($_POST['action'] == 'save') { - save(); +if (isset($_POST['a'])) { + if ($_POST['a'] == 'create') { + createStatus(); } } /* Print header */ @@ -327,7 +327,7 @@ function buildCreateModal() {
- + Date: Sun, 26 Jul 2015 12:17:41 -0400 Subject: [PATCH 12/27] #209 Some performance tweaks; also use function for rest of page --- admin/manage_statuses.php | 25 +++++++++++++------------ inc/common.inc.php | 15 +++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index cf555d26..0336575c 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -81,9 +81,10 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); $numOfStatusesRS = hesk_dbQuery('SELECT 1 FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'); $numberOfStatuses = hesk_dbNumRows($numOfStatusesRS); - $statusesSql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'; - $closedStatusesSql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 1'; - $openStatusesSql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 0'; + $statusesSql = 'SELECT `ID`, `IsAutocloseOption`, `TextColor`, `Closable`, `IsClosed` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'; + $closedStatusesSql = 'SELECT `ID`, `IsClosedByClient` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 1'; + $openStatusesSql = 'SELECT `ID`, `IsNewTicketStatus`, `IsStaffReopenedStatus`, `IsDefaultStaffReplyStatus` FROM + `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 0'; $statusesRS = hesk_dbQuery($statusesSql); ?> @@ -135,7 +136,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); '; } ?> - + + data-toggle="tooltip" title=""> +
@@ -397,6 +402,129 @@ function buildCreateModal() { $value) { + $languages[$key] = $hesk_settings['languages'][$key]['folder']; + } + ?> + + '; +} + function createStatus() { global $hesklang, $hesk_settings; @@ -421,6 +549,30 @@ function createStatus() { hesk_process_messages($hesklang['new_status_created'],'manage_statuses.php','SUCCESS'); } +function updateStatus() { + global $hesklang, $hesk_settings; + + $statusId = hesk_POST('status-id'); + $isClosed = hesk_POST('closed'); + $closable = hesk_POST('closable'); + $textColor = hesk_POST('text-color'); + $update = "UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` + SET `TextColor` = '".hesk_dbEscape($textColor)."', + `IsClosed` = ".intval($isClosed).", + `Closable` = '".hesk_dbEscape($closable)."' + WHERE `ID` = ".intval($statusId); + hesk_dbQuery($update); + + // For each language, delete the xref record and insert the new ones + hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."text_to_status_xref` WHERE `status_id` = ".intval($statusId)); + foreach (hesk_POST_array('name') as $language => $translation) { + hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."text_to_status_xref` (`language`, `text`, `status_id`) + VALUES ('".hesk_dbEscape($language)."', '".hesk_dbEscape($translation)."', ".intval($newStatusId).")"); + } + + hesk_process_messages($hesklang['ticket_status_updated'],'manage_statuses.php','SUCCESS'); +} + function save() { global $hesklang, $hesk_settings; diff --git a/inc/common.inc.php b/inc/common.inc.php index 65843184..5a6a7074 100644 --- a/inc/common.inc.php +++ b/inc/common.inc.php @@ -1949,6 +1949,14 @@ function hesk_getFeatureArray() { ); } +function mfh_doesStatusHaveXrefRecord($statusId, $language) { + global $hesk_settings; + + $rs = hesk_dbQuery("SELECT 1 FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."text_to_status_xref` + WHERE `language` = '".hesk_dbEscape($language)."' AND `status_id` = ".intval($statusId)); + return hesk_dbNumRows($rs) > 0; +} + function mfh_getDisplayTextForStatusId($statusId) { global $hesklang, $hesk_settings; diff --git a/language/en/text.php b/language/en/text.php index b98e82c1..fa4dff3e 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -39,6 +39,10 @@ $hesklang['status_name_title'] = 'Status Name'; $hesklang['properties'] = 'Properties'; $hesklang['closable'] = 'Closable'; // Same as $hesklang['closable_question'], but without punctuation $hesklang['new_status_created'] = 'New status successfully created'; +$hesklang['editing_status_x'] = 'Editing status %s'; // 1st %s: text color, 2nd %s: status name +$hesklang['status_not_in_database'] = 'The status text for this language was not found in the database, so a suggested translation has been filled for you. + Please click "Save Changes" to save this translation to the database and to remove this warning.'; +$hesklang['ticket_status_updated'] = 'Ticket status successfully updated!'; // ADDED OR MODIFIED IN Mods for HESK 2.3.0 $hesklang['sm_icon'] = 'Icon'; From 14ad6cd4f215e0e74fbc4956dbf03100c76d1eec Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 26 Jul 2015 21:47:05 -0400 Subject: [PATCH 14/27] #209 Statuses can now be deleted --- admin/manage_statuses.php | 66 +++++++++++++++++++++++++++++++++------ language/en/text.php | 3 ++ 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 3c0a3ccc..ccc496b3 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -18,12 +18,10 @@ hesk_checkPermission('can_man_ticket_statuses'); define('WYSIWYG',1); // Are we performing an action? -if (isset($_POST['a'])) { - if ($_POST['a'] == 'create') { - createStatus(); - } elseif ($_POST['a'] == 'update') { - updateStatus(); - } +if (isset($_REQUEST['a'])) { + if ($_POST['a'] == 'create') { createStatus(); } + elseif ($_POST['a'] == 'update') { updateStatus(); } + elseif ($_GET['a'] == 'delete') { deleteStatus(); } } @@ -145,18 +143,22 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); ?> - - + + data-toggle="tooltip" title=""> + - +
@@ -303,6 +305,39 @@ buildCreateModal(); require_once(HESK_PATH . 'inc/footer.inc.php'); exit(); +function buildConfirmDeleteModal($statusId) { + global $hesklang; + + ?> + + Date: Sun, 26 Jul 2015 22:17:30 -0400 Subject: [PATCH 15/27] #209 Start implementing move up/down --- admin/manage_statuses.php | 23 ++++++++++++++++++++--- install/mods-for-hesk/sql/installSql.php | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index ccc496b3..36a5f168 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -22,6 +22,7 @@ if (isset($_REQUEST['a'])) { if ($_POST['a'] == 'create') { createStatus(); } elseif ($_POST['a'] == 'update') { updateStatus(); } elseif ($_GET['a'] == 'delete') { deleteStatus(); } + elseif ($_GET['a'] == 'up') { moveStatus('up'); } } @@ -147,7 +148,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); - + @@ -338,12 +339,14 @@ function buildConfirmDeleteModal($statusId) { '; + echo ' + '; } else { echo ' '; } @@ -619,6 +622,20 @@ function deleteStatus() { hesk_process_messages($hesklang['ticket_status_deleted'],'manage_statuses.php','SUCCESS'); } +function moveStatus($direction) { + die(var_dump($_GET)); + + // Get the current position of the status + $statusId = hesk_GET('id'); + $rs = hesk_dbQuery("SELECT `sort` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE `ID` = ".intval($statusId)); + $record = hesk_dbFetchAssoc($rs); + + if ($direction == 'up') { + $newSort = intval($record['sort']) - 1; + } else { + $newSort = intval($record['sort']) + 1; + } +} function save() { global $hesklang, $hesk_settings; diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 71cdcbb7..a11fbd26 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -568,6 +568,8 @@ function execute240Scripts() { `text` VARCHAR(200) NOT NULL, `status_id` INT NOT NULL, PRIMARY KEY (`id`)) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); + executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` ADD COLUMN `sort` INT"); + executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `sort` = `ID`"); } function execute240FileUpdate() { From bb00445ae2870c5da8e8127aea1dec37aee6152a Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 26 Jul 2015 23:45:50 -0400 Subject: [PATCH 16/27] #209 Build modals at end to prevent nested forms, provide suggestions from language file --- admin/manage_statuses.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 36a5f168..1337ef2a 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -89,6 +89,10 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); $openStatusesSql = 'SELECT `ID`, `IsNewTicketStatus`, `IsStaffReopenedStatus`, `IsDefaultStaffReplyStatus` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 0'; $statusesRS = hesk_dbQuery($statusesSql); + $statuses = array(); + while ($row = hesk_dbFetchAssoc($statusesRS)) { + array_push($statuses, $row); + } ?>
@@ -117,7 +121,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); @@ -156,10 +160,8 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); + endforeach; ?>
@@ -301,6 +303,10 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
From f056e83b408a84caaba8696e32e1ea3621141beb Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 27 Jul 2015 00:06:57 -0400 Subject: [PATCH 17/27] #209 Statuses can now be sorted --- admin/manage_statuses.php | 44 +++++++++++++++--------- install/mods-for-hesk/sql/installSql.php | 8 ++++- language/en/text.php | 1 + 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 1337ef2a..00963f41 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -22,7 +22,7 @@ if (isset($_REQUEST['a'])) { if ($_POST['a'] == 'create') { createStatus(); } elseif ($_POST['a'] == 'update') { updateStatus(); } elseif ($_GET['a'] == 'delete') { deleteStatus(); } - elseif ($_GET['a'] == 'up') { moveStatus('up'); } + elseif ($_GET['a'] == 'sort') { moveStatus(); } } @@ -84,10 +84,10 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); $numOfStatusesRS = hesk_dbQuery('SELECT 1 FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'); $numberOfStatuses = hesk_dbNumRows($numOfStatusesRS); - $statusesSql = 'SELECT `ID`, `IsAutocloseOption`, `TextColor`, `Closable`, `IsClosed` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'; - $closedStatusesSql = 'SELECT `ID`, `IsClosedByClient` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 1'; + $statusesSql = 'SELECT `ID`, `IsAutocloseOption`, `TextColor`, `Closable`, `IsClosed` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` ORDER BY `sort` ASC'; + $closedStatusesSql = 'SELECT `ID`, `IsClosedByClient` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 1 ORDER BY `sort` ASC'; $openStatusesSql = 'SELECT `ID`, `IsNewTicketStatus`, `IsStaffReopenedStatus`, `IsDefaultStaffReplyStatus` FROM - `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 0'; + `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 0 ORDER BY `sort` ASC'; $statusesRS = hesk_dbQuery($statusesSql); $statuses = array(); while ($row = hesk_dbFetchAssoc($statusesRS)) { @@ -350,7 +350,7 @@ function echoArrows($index, $numberOfStatuses, $statusId) { if ($index !== 1) { // Display move up - echo ' + echo ' '; } else { @@ -359,7 +359,9 @@ function echoArrows($index, $numberOfStatuses, $statusId) { if ($index !== $numberOfStatuses) { // Display move down - echo ''; + echo ' + '; } else { echo ''; } @@ -613,7 +615,7 @@ function updateStatus() { hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."text_to_status_xref` WHERE `status_id` = ".intval($statusId)); foreach (hesk_POST_array('name') as $language => $translation) { hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."text_to_status_xref` (`language`, `text`, `status_id`) - VALUES ('".hesk_dbEscape($language)."', '".hesk_dbEscape($translation)."', ".intval($newStatusId).")"); + VALUES ('".hesk_dbEscape($language)."', '".hesk_dbEscape($translation)."', ".intval($statusId).")"); } hesk_process_messages($hesklang['ticket_status_updated'],'manage_statuses.php','SUCCESS'); @@ -630,19 +632,27 @@ function deleteStatus() { hesk_process_messages($hesklang['ticket_status_deleted'],'manage_statuses.php','SUCCESS'); } -function moveStatus($direction) { - die(var_dump($_GET)); +function moveStatus() { + global $hesk_settings, $hesklang; - // Get the current position of the status - $statusId = hesk_GET('id'); - $rs = hesk_dbQuery("SELECT `sort` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE `ID` = ".intval($statusId)); - $record = hesk_dbFetchAssoc($rs); + $statusId = intval(hesk_GET('id')); + $statusMove = intval(hesk_GET('move')); - if ($direction == 'up') { - $newSort = intval($record['sort']) - 1; - } else { - $newSort = intval($record['sort']) + 1; + hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `sort` = `sort`+".intval($statusMove)." + WHERE `ID` = '".intval($statusId)."' LIMIT 1"); + + /* Update all category fields with new order */ + $res = hesk_dbQuery("SELECT `ID` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` ORDER BY `sort` ASC"); + + $i = 10; + while ($myStatus = hesk_dbFetchAssoc($res)) + { + hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `sort`=".intval($i)." + WHERE `ID`='".intval($myStatus['ID'])."' LIMIT 1"); + $i += 10; } + + hesk_process_messages($hesklang['status_sort_updated'],'manage_statuses.php','SUCCESS'); } function save() { diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index a11fbd26..3e6c38ad 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -569,7 +569,13 @@ function execute240Scripts() { `status_id` INT NOT NULL, PRIMARY KEY (`id`)) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); executeQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` ADD COLUMN `sort` INT"); - executeQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `sort` = `ID`"); + $statusesRs = executeQuery("SELECT `ID` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` ORDER BY `ID` ASC"); + $i = 10; + while ($myStatus = hesk_dbFetchAssoc($statusesRs)) { + hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `sort`=".intval($i)." + WHERE `id`='".intval($myStatus['ID'])."' LIMIT 1"); + $i += 10; + } } function execute240FileUpdate() { diff --git a/language/en/text.php b/language/en/text.php index b07347c8..7735f7f0 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -46,6 +46,7 @@ $hesklang['ticket_status_updated'] = 'Ticket status successfully updated!'; $hesklang['ticket_status_deleted'] = 'Ticket status deleted!'; $hesklang['confirm_delete_status_question'] = 'Delete status?'; $hesklang['confirm_delete_status'] = 'Are you sure you want to delete this status? This cannot be undone!'; +$hesklang['status_sort_updated'] = 'Ticket status sort updated!'; // ADDED OR MODIFIED IN Mods for HESK 2.3.0 $hesklang['sm_icon'] = 'Icon'; From 6be1d32a54ed59448e9216935e6961442d8103d4 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 27 Jul 2015 22:11:53 -0400 Subject: [PATCH 18/27] #209 Start migration logic --- install/mods-for-hesk/sql/installSql.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 3e6c38ad..a9a0af49 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -1,5 +1,8 @@ Date: Tue, 28 Jul 2015 12:27:12 -0400 Subject: [PATCH 19/27] #209 Write migration to populate the xref table --- install/mods-for-hesk/ajax/task-ajax.php | 2 ++ install/mods-for-hesk/installModsForHesk.php | 4 +++ install/mods-for-hesk/js/version-scripts.js | 29 ++++++++++++++++++-- install/mods-for-hesk/sql/installSql.php | 18 ++++++++---- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/install/mods-for-hesk/ajax/task-ajax.php b/install/mods-for-hesk/ajax/task-ajax.php index b5e3d503..4d855688 100644 --- a/install/mods-for-hesk/ajax/task-ajax.php +++ b/install/mods-for-hesk/ajax/task-ajax.php @@ -23,6 +23,8 @@ if ($task == 'ip-email-bans') { print json_encode($jsonToSend); } elseif ($task == 'migrate-bans') { migrateBans($_POST['user']); +} elseif ($task == 'initialize-statuses') { + initializeXrefTable(); } else { $response = 'The task "'.$task.'" was not recognized. Check your spelling and try again.'; print $response; diff --git a/install/mods-for-hesk/installModsForHesk.php b/install/mods-for-hesk/installModsForHesk.php index b41431db..5e576af3 100644 --- a/install/mods-for-hesk/installModsForHesk.php +++ b/install/mods-for-hesk/installModsForHesk.php @@ -120,6 +120,10 @@ function printRow($version) { Migrate IP / Email Bans Waiting... + + Initialize Statuses + Waiting... + diff --git a/install/mods-for-hesk/js/version-scripts.js b/install/mods-for-hesk/js/version-scripts.js index bee321ec..f55b3614 100644 --- a/install/mods-for-hesk/js/version-scripts.js +++ b/install/mods-for-hesk/js/version-scripts.js @@ -62,7 +62,9 @@ function executeUpdate(version, cssclass, formattedVersion) { success: function(data) { markUpdateAsSuccess(cssclass, formattedVersion); if (version == 200) { - migrateIpEmailBans('banmigrate', cssclass); + migrateIpEmailBans('banmigrate', 'banmigrate'); + } else if (version == 240) { + initializeStatuses('initialize-statuses', 'initialize-statuses'); } else { processUpdates(version); } @@ -83,7 +85,6 @@ function migrateIpEmailBans(version, cssclass) { data: { task: 'ip-email-bans' }, success: function(data) { var parsedData = $.parseJSON(data); - console.info(parsedData); if (parsedData.status == 'ATTENTION') { appendToInstallConsole('WARNINGYour response is needed. Please check above.'); markUpdateAsAttention(version); @@ -94,11 +95,33 @@ function migrateIpEmailBans(version, cssclass) { }, error: function(data) { appendToInstallConsole('ERROR' + data.responseText + ''); - markUpdateAsFailure(cssclass); + markUpdateAsFailure(version); } }); } +function initializeStatuses(version, cssclass) { + startVersionUpgrade(version); + appendToInstallConsole('INFOInitializing Statuses'); + $.ajax({ + type: 'POST', + url: 'ajax/task-ajax.php', + data: { task: 'initialize-statuses' }, + success: function(data) { + markUpdateAsSuccess(cssclass, 'Initializing Statuses'); + statusesInitialized(); + }, + error: function(data) { + appendToInstallConsole('ERROR' + data.responseText + ''); + markUpdateAsFailure(version); + } + }); +} + +function statusesInitialized() { + processUpdates(240); +} + function runMigration() { // Get user ID that is selected diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index a9a0af49..9f249996 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -584,11 +584,19 @@ function execute240Scripts() { function initializeXrefTable() { global $hesk_settings, $hesklang; - /* - * TODO: - * 1. Get each key from the DB - * 2. For each language, insert a xref record for the key - */ + $languages = array(); + foreach ($hesk_settings['languages'] as $key => $value) { + $languages[$key] = $hesk_settings['languages'][$key]['folder']; + } + + $statusesRs = executeQuery("SELECT `ID`, `Key` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`"); + while ($row = hesk_dbFetchAssoc($statusesRs)) { + foreach ($languages as $language => $languageCode) { + $sql = "INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."text_to_status_xref` (`language`, `text`, `status_id`) + VALUES ('".hesk_dbEscape($language)."', '".hesk_dbEscape($hesklang[$row['Key']])."', ".intval($row['ID']).")"; + executeQuery($sql); + } + } } function execute240FileUpdate() { From 22e8a8efe9550c9ca9a9ee475423228f8b3a1d3c Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 28 Jul 2015 12:47:13 -0400 Subject: [PATCH 20/27] #209 View ticket on admin side now supports new statuses --- admin/admin_ticket.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index cf9d1a84..a677176b 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -677,9 +677,9 @@ if($ticket['email'] != '') { $recentTicketsWithStatuses = array(); foreach ($recentTickets as $recentTicket) { $newRecentTicket = $recentTicket; - $thisTicketStatusRS = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` WHERE `ID` = " . intval($recentTicket['status'])); + $thisTicketStatusRS = hesk_dbQuery("SELECT `ID`, `TextColor` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` WHERE `ID` = " . intval($recentTicket['status'])); $theStatusRow = hesk_dbFetchAssoc($thisTicketStatusRS); - $newRecentTicket['statusText'] = $hesklang[$theStatusRow['Key']]; + $newRecentTicket['statusText'] = mfh_getDisplayTextForStatusId($theStatusRow['ID']); $newRecentTicket['statusColor'] = $theStatusRow['TextColor']; array_push($recentTicketsWithStatuses, $newRecentTicket); } @@ -975,11 +975,11 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); fetch_assoc()) + while ($statusRow = hesk_dbFetchAssoc($statusRs)) { if ($statusRow['IsStaffReopenedStatus'] == 1) { @@ -1079,11 +1079,11 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); echo '

'.$hesklang['status'].'

'; $status_options = array(); - $results = hesk_dbQuery("SELECT `ID`, `Key` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`"); - while ($row = $results->fetch_assoc()) + $results = hesk_dbQuery("SELECT `ID`FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`"); + while ($row = hesk_dbFetchAssoc($results)) { $selected = $ticket['status'] == $row['ID'] ? 'selected' : ''; - $status_options[$row['ID']] = ''; + $status_options[$row['ID']] = ''; } echo ' @@ -2033,7 +2033,7 @@ function hesk_printReplyForm() {
  • '; } From 6b83e852d074463d0894b037245ef3ccff628545 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 28 Jul 2015 12:52:30 -0400 Subject: [PATCH 21/27] #209 Support new status table --- admin/change_status.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/change_status.php b/admin/change_status.php index bfd4ffc6..d645859e 100644 --- a/admin/change_status.php +++ b/admin/change_status.php @@ -58,13 +58,13 @@ hesk_token_check(); $trackingID = hesk_cleanID() or die($hesklang['int_error'].': '.$hesklang['no_trackID']); /* Valid statuses */ -$statusSql = "SELECT `ID`, `Key` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`"; +$statusSql = "SELECT `ID` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`"; $status_options = array(); $results = hesk_dbQuery($statusSql); while ($row = $results->fetch_assoc()) { - $status_options[$row['ID']] = $hesklang[$row['Key']]; + $status_options[$row['ID']] = mfh_getDisplayTextForStatusId($row['ID']); } /* New status */ From 50778c02ddc52d82dfac760c842bcf8c2b359544 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 28 Jul 2015 12:52:42 -0400 Subject: [PATCH 22/27] #209 Customer view ticket now supports new status table --- ticket.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ticket.php b/ticket.php index 2ba4df15..ea87a4bf 100644 --- a/ticket.php +++ b/ticket.php @@ -315,8 +315,7 @@ if (!$show['show']) { $repliesColumnWidth = 3; } echo '

    '.$hesklang['status'].'

    '; - $ticketStatusKey = $status['Key']; - echo '

    '.$hesklang[$ticketStatusKey].'

    '; + echo '

    '.mfh_getDisplayTextForStatusId($status['ID']).'

    '; echo '
    '; echo '

    '.$hesklang['last_replier'].'

    '.$ticket['repliername'].'

    '; From c9360fd538b4e9317ce8a868d3488c8ffb5900e7 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 28 Jul 2015 13:00:26 -0400 Subject: [PATCH 23/27] #209 Update search and export pages to show new status table Still need to fix searching and need to test exporting --- admin/export.php | 10 ++++------ inc/show_search_form.inc.php | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/admin/export.php b/admin/export.php index c9a2db84..946c094a 100644 --- a/admin/export.php +++ b/admin/export.php @@ -243,12 +243,12 @@ $fid = 1; require(HESK_PATH . 'inc/assignment_search.inc.php'); // --> TICKET STATUS -$possibleStatusSql = 'SELECT `ID`, `Key` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'; +$possibleStatusSql = 'SELECT `ID` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'; $possibleStatusRS = hesk_dbQuery($possibleStatusSql); $possible_status = array(); while ($row = $possibleStatusRS->fetch_assoc()) { - $possible_status[$row['ID']] = $hesklang[$row['Key']]; + $possible_status[$row['ID']] = mfh_getDisplayTextForStatusId($row['ID']); } $status = $possible_status; @@ -507,9 +507,7 @@ if (isset($_GET['w'])) $result = hesk_dbQuery($sql); while ($ticket=hesk_dbFetchAssoc($result)) { - $statusContentKeySql = 'SELECT `Key` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `ID` = '.$ticket['status']; - $statusContentKeyRow = hesk_dbQuery($statusContentKeySql)->fetch_assoc(); - $ticket['status'] = $hesklang[$statusContentKeyRow['Key']]; + $ticket['status'] = mfh_getDisplayTextForStatusId($ticket['status']); switch ($ticket['priority']) { @@ -788,7 +786,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); ?>
    - +
    fetch_assoc()) { - $status[$row['ID']] = $row['Key']; + $status[$row['ID']] = mfh_getDisplayTextForStatusId($row['ID']); } } @@ -131,7 +131,7 @@ $more2 = empty($_GET['more2']) ? 0 : 1; fetch_assoc()) { if ($rowCounter > 3) @@ -149,7 +149,7 @@ $more2 = empty($_GET['more2']) ? 0 : 1; } echo ''; + echo '/> '.mfh_getDisplayTextForStatusId($row['ID']).''; $rowCounter++; } From 05063218c4bff419bd681bb94177a984525ca1a9 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 28 Jul 2015 22:09:34 -0400 Subject: [PATCH 24/27] #209 Fix checkboxes on search screen and use correct status on ticket table --- inc/print_tickets.inc.php | 5 ++--- inc/show_search_form.inc.php | 2 +- inc/ticket_list.inc.php | 5 +++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/inc/print_tickets.inc.php b/inc/print_tickets.inc.php index de70e6ae..c1f87798 100644 --- a/inc/print_tickets.inc.php +++ b/inc/print_tickets.inc.php @@ -118,17 +118,16 @@ $possible_status = array(); $results = hesk_dbQuery($statusSql); while ($row = $results->fetch_assoc()) { - array_push($possible_status, $row['ID']); + $possible_status[$row['ID']] = $row['ID']; $totalStatuses++; } $status = $possible_status; - // Process statuses unless overridden with "s_all" variable if ( ! hesk_GET('s_all') ) { foreach ($status as $k => $v) { - if (empty($_GET['s' . $k])) + if (empty($_GET['s' . $v])) { unset($status[$k]); } diff --git a/inc/show_search_form.inc.php b/inc/show_search_form.inc.php index f4a944cf..d9b5f985 100644 --- a/inc/show_search_form.inc.php +++ b/inc/show_search_form.inc.php @@ -132,7 +132,7 @@ $more2 = empty($_GET['more2']) ? 0 : 1; fetch_assoc()) + while ($row = hesk_dbFetchAssoc($statusRS)) { if ($rowCounter > 3) { diff --git a/inc/ticket_list.inc.php b/inc/ticket_list.inc.php index 762c6896..4c191dee 100644 --- a/inc/ticket_list.inc.php +++ b/inc/ticket_list.inc.php @@ -404,8 +404,9 @@ if ($total > 0) // Print ticket status if ( hesk_show_column('status') ) { - $statusName = hesk_dbFetchAssoc(hesk_dbQuery("SELECT `Key`, `TextColor` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE ID = ".$ticket['status'])); - $ticket['status']=''.$hesklang[$statusName['Key']].''; + $statusRS = hesk_dbQuery("SELECT `ID`, `TextColor` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE ID = ".$ticket['status']); + $statusName = hesk_dbFetchAssoc($statusRS); + $ticket['status']=''.mfh_getDisplayTextForStatusId($statusName['ID']).''; echo ''.$ticket['status'].' '; } From a131b7842ef11c2992e2ddb20cf08e40bbe85fea Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 29 Jul 2015 22:27:00 -0400 Subject: [PATCH 25/27] #209 Add sort property, and statuses page honors sort --- admin/manage_statuses.php | 76 ++++++++++++++++++++++++------------ modsForHesk_settings.inc.php | 5 ++- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/admin/manage_statuses.php b/admin/manage_statuses.php index 00963f41..de4a728d 100644 --- a/admin/manage_statuses.php +++ b/admin/manage_statuses.php @@ -5,6 +5,7 @@ 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(); @@ -84,15 +85,18 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); $numOfStatusesRS = hesk_dbQuery('SELECT 1 FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses`'); $numberOfStatuses = hesk_dbNumRows($numOfStatusesRS); - $statusesSql = 'SELECT `ID`, `IsAutocloseOption`, `TextColor`, `Closable`, `IsClosed` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` ORDER BY `sort` ASC'; - $closedStatusesSql = 'SELECT `ID`, `IsClosedByClient` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 1 ORDER BY `sort` ASC'; - $openStatusesSql = 'SELECT `ID`, `IsNewTicketStatus`, `IsStaffReopenedStatus`, `IsDefaultStaffReplyStatus` FROM - `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsClosed` = 0 ORDER BY `sort` ASC'; + $statusesSql = 'SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` ORDER BY `sort` ASC'; $statusesRS = hesk_dbQuery($statusesSql); $statuses = array(); while ($row = hesk_dbFetchAssoc($statusesRS)) { - array_push($statuses, $row); + $row['text'] = mfh_getDisplayTextForStatusId($row['ID']); + $statuses[$row['text']] = $row; } + + if ($modsForHesk_settings['statuses_order_column'] == 'name') { + ksort($statuses); + } + ?>
    @@ -121,11 +125,11 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); $row): ?> - + fetch_assoc()) + foreach ($statuses as $key => $row) { + if ($row['IsClosed'] == 0) { + continue; + } + $selectedEcho = ($row['IsClosedByClient'] == 1) ? 'selected="selected"' : ''; echo ''; } @@ -205,9 +215,12 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
    fetch_assoc()) + foreach ($statuses as $key => $row) { + if ($row['IsClosed'] == 0) { + continue; + } + $selectedEcho = ($row['IsStaffClosedOption'] == 1) ? 'selected="selected"' : ''; echo ''; } @@ -235,9 +251,12 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
    fetch_assoc()) + foreach ($statuses as $key => $row) { + if ($row['IsClosed'] == 1) { + continue; + } + $selectedEcho = ($row['IsDefaultStaffReplyStatus'] == 1) ? 'selected="selected"' : ''; echo ''; } @@ -265,8 +287,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
    fetch_assoc()) + foreach ($statuses as $key => $row) { + if ($row['IsClosed'] == 0) { + continue; + } + $selectedEcho = ($row['IsAutocloseOption'] == 1) ? 'selected' : ''; echo ''; } @@ -346,7 +370,11 @@ function buildConfirmDeleteModal($statusId) { } function echoArrows($index, $numberOfStatuses, $statusId) { - global $hesklang; + global $hesklang, $modsForHesk_settings; + + if ($modsForHesk_settings['statuses_order_column'] == 'name') { + return; + } if ($index !== 1) { // Display move up diff --git a/modsForHesk_settings.inc.php b/modsForHesk_settings.inc.php index 0c68bc26..0e7ea545 100644 --- a/modsForHesk_settings.inc.php +++ b/modsForHesk_settings.inc.php @@ -49,4 +49,7 @@ $modsForHesk_settings['show_number_merged'] = 1; $modsForHesk_settings['request_location'] = 0; //-- Column to sort categories by. Can be either 'name' or 'cat_order' -$modsForHesk_settings['category_order_column'] = 'cat_order'; \ No newline at end of file +$modsForHesk_settings['category_order_column'] = 'cat_order'; + +//-- Column to sort statuses by. Can be either 'sort' or 'name' +$modsForHesk_settings['statuses_order_column'] = 'sort'; \ No newline at end of file From 9db20734ca759ebf03f50db6c9f478a3c4d19686 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Thu, 30 Jul 2015 12:35:30 -0400 Subject: [PATCH 26/27] #209 Everything uses the new status_functions --- admin/admin_main.php | 2 ++ admin/admin_ticket.php | 17 +++-------- admin/export.php | 17 +++++------ admin/manage_statuses.php | 14 ++------- admin/show_tickets.php | 2 ++ inc/print_tickets.inc.php | 13 +++++---- inc/show_search_form.inc.php | 12 +++++--- inc/status_functions.inc.php | 55 ++++++++++++++++++++++++++++++++++++ 8 files changed, 87 insertions(+), 45 deletions(-) create mode 100644 inc/status_functions.inc.php diff --git a/admin/admin_main.php b/admin/admin_main.php index bad21451..111ed08a 100644 --- a/admin/admin_main.php +++ b/admin/admin_main.php @@ -40,8 +40,10 @@ 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'); hesk_load_database_functions(); hesk_session_start(); diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index a677176b..1a7604d2 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -40,6 +40,7 @@ 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'); hesk_load_database_functions(); hesk_session_start(); @@ -1079,8 +1080,8 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); echo '

    '.$hesklang['status'].'

    '; $status_options = array(); - $results = hesk_dbQuery("SELECT `ID`FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses`"); - while ($row = hesk_dbFetchAssoc($results)) + $results = mfh_getAllStatuses(); + foreach ($results as $row) { $selected = $ticket['status'] == $row['ID'] ? 'selected' : ''; $status_options[$row['ID']] = ''; @@ -1991,11 +1992,6 @@ function hesk_printReplyForm() { } } - $statusSql = 'SELECT `ID` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsStaffClosedOption` = 1'; - $statusRow = hesk_dbQuery($statusSql)->fetch_assoc(); - $staffClosedOptionStatus = array(); - $staffClosedOptionStatus['ID'] = $statusRow['ID']; - ?>
    diff --git a/admin/admin_settings_save.php b/admin/admin_settings_save.php index 597fff54..500c0633 100644 --- a/admin/admin_settings_save.php +++ b/admin/admin_settings_save.php @@ -516,6 +516,7 @@ $set['mfh_attachments'] = empty($_POST['email_attachments']) ? 0 : 1; $set['show_number_merged'] = empty($_POST['show_number_merged']) ? 0 : 1; $set['request_location'] = empty($_POST['request_location']) ? 0 : 1; $set['category_order_column'] = empty($_POST['category_order_column']) ? 'cat_order' : 'name'; +$set['statuses_order_column'] = empty($_POST['statuses_order_column']) ? 'sort' : 'name'; if ($set['customer-email-verification-required']) { @@ -584,7 +585,10 @@ $modsForHesk_settings[\'show_number_merged\'] = '.$set['show_number_merged'].'; $modsForHesk_settings[\'request_location\'] = '.$set['request_location'].'; //-- Column to sort categories by. Can be either \'name\' or \'cat_order\' -$modsForHesk_settings[\'category_order_column\'] = \''.$set['category_order_column'].'\';'; +$modsForHesk_settings[\'category_order_column\'] = \''.$set['category_order_column'].'\'; + +//-- Column to sort statuses by. Can be either \'sort\' or \'name\' +$modsForHesk_settings[\'statuses_order_column\'] = \''.$set['statuses_order_column'].'\';'; // Write the file if ( ! file_put_contents(HESK_PATH . 'modsForHesk_settings.inc.php', $modsForHesk_file_content) ) diff --git a/language/en/text.php b/language/en/text.php index 7735f7f0..00d67d00 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -47,6 +47,8 @@ $hesklang['ticket_status_deleted'] = 'Ticket status deleted!'; $hesklang['confirm_delete_status_question'] = 'Delete status?'; $hesklang['confirm_delete_status'] = 'Are you sure you want to delete this status? This cannot be undone!'; $hesklang['status_sort_updated'] = 'Ticket status sort updated!'; +$hesklang['status_sort'] = 'Status Sorting'; +$hesklang['status_sort_help'] = 'Determines if statuses shown on the manage statuses page and all dropdowns are sorted by the user-defined order (default), or sorted alphabetically.'; // ADDED OR MODIFIED IN Mods for HESK 2.3.0 $hesklang['sm_icon'] = 'Icon';