From 02d965e2d91da2161851a6f52f086bae335cb20d Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 5 Sep 2017 22:20:57 -0400 Subject: [PATCH] Localized some stuff, add descriptions to create ticket pages --- admin/manage_categories.php | 9 ++++- admin/new_ticket.php | 50 +++++++++++++++++++----- index.php | 47 ++++++++++++++++++---- install/mods-for-hesk/sql/installSql.php | 10 +++++ internal-api/js/lang.js | 3 ++ internal-api/js/manage-categories.js | 15 ++++--- language/en/text.php | 4 ++ 7 files changed, 112 insertions(+), 26 deletions(-) diff --git a/admin/manage_categories.php b/admin/manage_categories.php index 0acb4d09..6ddce2d4 100644 --- a/admin/manage_categories.php +++ b/admin/manage_categories.php @@ -375,8 +375,8 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) - - + + @@ -437,6 +437,11 @@ echo mfh_get_hidden_fields_for_language(array( 'cat_public', 'cat_removed', 'error_deleting_category', + 'error_retrieving_categories', + 'error_saving_updating_category', + 'copied_to_clipboard', + 'category_updated', + 'cat_name_added', 'enabled_title_case', 'disabled_title_case', 'geco', diff --git a/admin/new_ticket.php b/admin/new_ticket.php index 9233b35b..e831ec15 100644 --- a/admin/new_ticket.php +++ b/admin/new_ticket.php @@ -113,13 +113,13 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); $hesk_settings['categories'] = array(); if (hesk_checkPermission('can_submit_any_cat', 0)) { - $res = hesk_dbQuery("SELECT `id`, `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ORDER BY `cat_order` ASC"); + $res = hesk_dbQuery("SELECT `id`, `name`, `mfh_description` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ORDER BY `cat_order` ASC"); } else { - $res = hesk_dbQuery("SELECT `id`, `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` WHERE ".hesk_myCategories('id')." ORDER BY `cat_order` ASC"); + $res = hesk_dbQuery("SELECT `id`, `name`, `mfh_description` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` WHERE ".hesk_myCategories('id')." ORDER BY `cat_order` ASC"); } while ($row = hesk_dbFetchAssoc($res)) { - $hesk_settings['categories'][$row['id']] = $row['name']; + $hesk_settings['categories'][$row['id']] = $row; } $number_of_categories = count($hesk_settings['categories']); @@ -147,7 +147,7 @@ $show_quick_help = $show['show'];
  • 1): ?>
  • -
  • +
  • @@ -1038,9 +1038,10 @@ function print_select_category($number_of_categories) { // Print a select box if number of categories is large if ($number_of_categories > $hesk_settings['cat_show_select']) { + $firstDescription = null; ?>
    - $v) { - echo ''; + if ($firstDescription === null) { + $firstDescription = $v['mfh_description']; + } + echo ''; } ?> + - + if (!$hesk_settings['select_cat'] && $firstDescription !== null && trim($firstDescription) !== '') { + $display = ''; + } + ?> + > + + + +
    + » '.$v.''; $new_row = 1; foreach ($hesk_settings['categories'] as $k=>$v): @@ -1079,7 +1102,14 @@ function print_select_category($number_of_categories) {
    - + '; + } + ?>
    diff --git a/index.php b/index.php index 61eba1f7..8ab81bd9 100644 --- a/index.php +++ b/index.php @@ -87,9 +87,10 @@ function print_select_category($number_of_categories) // Print a select box if number of categories is large if ($number_of_categories > $hesk_settings['cat_show_select']) { + $firstDescription = null; ?>
    - $v) { - echo ''; + if ($firstDescription === null) { + $firstDescription = $v['mfh_description']; + } + echo ''; } ?> + - + if (!$hesk_settings['select_cat'] && $firstDescription !== null && trim($firstDescription) !== '') { + $display = ''; + } + ?> + > + + + +
    +
    - + '; + } + ?>
    @@ -220,9 +251,9 @@ function print_add_ticket() // Get categories $hesk_settings['categories'] = array(); - $res = hesk_dbQuery("SELECT `id`, `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` WHERE `type`='0' ORDER BY `cat_order` ASC"); + $res = hesk_dbQuery("SELECT `id`, `name`, `mfh_description` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` WHERE `type`='0' ORDER BY `cat_order` ASC"); while ($row=hesk_dbFetchAssoc($res)) { - $hesk_settings['categories'][$row['id']] = $row['name']; + $hesk_settings['categories'][$row['id']] = $row; } $number_of_categories = count($hesk_settings['categories']); @@ -254,7 +285,7 @@ function print_add_ticket() -
  • +
  • diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 2970c923..c8922f46 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -1130,4 +1130,14 @@ function execute311Scripts() { hesk_dbConnect(); updateVersion('3.1.1'); +} + +function execute320Scripts() { + global $hesk_settings; + hesk_dbConnect(); + + executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` + ADD COLUMN `mfh_description` VARCHAR(255)"); + + updateVersion('3.2.0'); } \ No newline at end of file diff --git a/internal-api/js/lang.js b/internal-api/js/lang.js index d0f232cc..c87c5184 100644 --- a/internal-api/js/lang.js +++ b/internal-api/js/lang.js @@ -1,5 +1,8 @@ var mfhLang = { text: function(key) { return $('#lang_' + key).text(); + }, + html: function(key) { + return $('#lang_' + key).html() } }; \ No newline at end of file diff --git a/internal-api/js/manage-categories.js b/internal-api/js/manage-categories.js index 767be236..521198d8 100644 --- a/internal-api/js/manage-categories.js +++ b/internal-api/js/manage-categories.js @@ -25,7 +25,7 @@ function loadTable() { $tableBody.html(''); if (data.length === 0) { - mfhAlert.error("I couldn't find any categories :(", "No categories found"); + mfhAlert.error("No categories were found. This shouldn't happen.", "No categories found"); $('#overlay').hide(); return; } @@ -138,7 +138,7 @@ function loadTable() { } }, error: function(data) { - mfhAlert.errorWithLog(mfhLang.text('Something bad happened...'), data.responseJSON); + mfhAlert.errorWithLog(mfhLang.text('error_retrieving_categories'), data.responseJSON); console.error(data); }, complete: function() { @@ -288,16 +288,19 @@ function bindFormSubmit() { }, data: JSON.stringify(data), success: function(data) { + var format = undefined; if (categoryId === -1) { - mfhAlert.success('CREATED'); + format = mfhLang.html('cat_name_added'); + mfhAlert.success(format.replace('%s', data.name)); } else { - mfhAlert.success('SAVED'); + format = mfhLang.html('category_updated'); + mfhAlert.success(format.replace('%s', data.name)); } $modal.modal('hide'); loadTable(); }, error: function(data) { - mfhAlert.errorWithLog('ERROR SAVING/CREATING', data.responseJSON); + mfhAlert.errorWithLog(mfhLang.text('error_saving_updating_category'), data.responseJSON); console.error(data); }, complete: function(data) { @@ -340,7 +343,7 @@ function bindGenerateLinkModal() { $modal.find('.input-group-addon').click(function() { clipboard.copy($modal.find('input[type="text"]').val()); - mfhAlert.success('Copied to clipboard', 'Success'); + mfhAlert.success(mfhLang.text('copied_to_clipboard')); }); $(document).on('click', '[data-property="generate-link"] i.fa-code', function () { diff --git a/language/en/text.php b/language/en/text.php index a58ba6fe..743ed201 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -2178,6 +2178,10 @@ $hesklang['cat_private'] = 'Private'; $hesklang['cat_public'] = 'Public'; $hesklang['cat_name_description'] = 'Name / Description'; $hesklang['error_sorting_categories'] = 'An error occurred sorting categories!'; +$hesklang['error_retrieving_categories'] = 'An error occurred retrieving categories!'; +$hesklang['error_saving_updating_category'] = 'An error occurred creating / saving the category!'; +$hesklang['description_colon'] = 'Description:'; // Same as 'description', but with a colon (:) afterwards +$hesklang['copied_to_clipboard'] = 'Copied to clipboard'; // DO NOT CHANGE BELOW if (!defined('IN_SCRIPT')) die('PHP syntax OK!');