From 59cc8498cfe2dbe9bac6a71a60275afd4e154c7c Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 8 Nov 2016 13:09:54 -0500 Subject: [PATCH] More custom field fixes --- admin/custom_fields.php | 20 ++++++--- admin/new_ticket.php | 93 ++++++++++++++++------------------------- index.php | 4 +- 3 files changed, 53 insertions(+), 64 deletions(-) diff --git a/admin/custom_fields.php b/admin/custom_fields.php index bdfc69ab..3876d5a8 100755 --- a/admin/custom_fields.php +++ b/admin/custom_fields.php @@ -214,13 +214,22 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
+
+ +
+ +
+
- +
@@ -1188,8 +1197,9 @@ function cf_validate() break; case 'readonly': - $value = hesk_POST('value'); - $cf['value'] = array('value' => $value); + $max_length = hesk_POST('max_length'); + $value = hesk_POST('default_value'); + $cf['value'] = array('default_value' => $value, 'max_length' => $max_length); break; default: diff --git a/admin/new_ticket.php b/admin/new_ticket.php index 0f74cb87..26fa3968 100644 --- a/admin/new_ticket.php +++ b/admin/new_ticket.php @@ -503,11 +503,6 @@ $show_quick_help = $show['show']; $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; - if ($v['type'] == 'readonly') { - $v['value']['max_length'] = 0; - $v['value']['default_value'] = $v['value']['value']; - } - echo '
@@ -727,46 +722,43 @@ $show_quick_help = $show['show']; foreach ($hesk_settings['custom_fields'] as $k => $v) { if ($v['use'] && $v['place'] == 1 && hesk_is_custom_field_in_category($k, $category)) { - if ($modsForHesk_settings['custom_field_setting']) { - $v['name'] = $hesklang[$v['name']]; - } - - $v['req'] = $v['req'] == 2 ? '*' : ''; + $v['req'] = $v['req']==2 ? '*' : ''; if ($v['type'] == 'checkbox') { $k_value = array(); - if (isset($_SESSION["c_$k"]) && is_array($_SESSION["c_$k"])) { - foreach ($_SESSION["c_$k"] as $myCB) { + if (isset($_SESSION["as_$k"]) && is_array($_SESSION["as_$k"])) { + foreach ($_SESSION["as_$k"] as $myCB) { $k_value[] = stripslashes(hesk_input($myCB)); } } - } elseif (isset($_SESSION["c_$k"])) { - $k_value = stripslashes(hesk_input($_SESSION["c_$k"])); + } elseif (isset($_SESSION["as_$k"])) { + $k_value = stripslashes(hesk_input($_SESSION["as_$k"])); } else { - $k_value = ''; + $k_value = ''; } switch ($v['type']) { /* Radio box */ case 'radio': - echo '
'; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; + + echo '
'; - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; foreach ($v['value']['radio_options'] as $option) { if (strlen($k_value) == 0 || $k_value == $option) { $k_value = $option; - $checked = 'checked="checked"'; + $checked = 'checked'; } else { $checked = ''; } //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - echo '
'; + echo '
'; } echo '
'; @@ -777,12 +769,12 @@ $show_quick_help = $show['show']; //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; - echo '
-
'; // Show "Click to select"? if (!empty($v['value']['show_select'])) { @@ -792,7 +784,7 @@ $show_quick_help = $show['show']; foreach ($v['value']['select_options'] as $option) { if ($k_value == $option) { $k_value = $option; - $selected = 'selected="selected"'; + $selected = 'selected'; } else { $selected = ''; } @@ -807,19 +799,19 @@ $show_quick_help = $show['show']; case 'checkbox': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - echo '
'; - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; + echo '
'; foreach ($v['value']['checkbox_options'] as $option) { if (in_array($option, $k_value)) { - $checked = 'checked="checked"'; + $checked = 'checked'; } else { $checked = ''; } - echo '
'; + echo '
'; } echo '
'; break; @@ -828,11 +820,11 @@ $show_quick_help = $show['show']; case 'textarea': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; - echo '
+ echo '
'; @@ -841,44 +833,31 @@ $show_quick_help = $show['show']; case 'date': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); - - if (strlen($k_value) != 0) { - $v['value'] = $k_value; - } + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - $cls = in_array($k, $_SESSION['iserror']) ? ' isError ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; echo ' -
- +
+
- +
'; break; case 'email': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); $suggest = $hesk_settings['detect_typos'] ? 'onblur="Javascript:hesk_suggestEmail(\''.$k.'\', \''.$k.'_suggestions\', 0, 1'.($v['value']['multiple'] ? ',1' : '').')"' : ''; - if (strlen($k_value) != 0) { - $v['value'] = $k_value; - } - - if ($v['value'] == 'cc' || $v['value'] == 'bcc') { - // (b)cc isn't a valid email but is the "value" used by settings. Just remove it. - $v['value'] = ''; - } - - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; echo '
-
+
'; break; @@ -888,7 +867,7 @@ $show_quick_help = $show['show']; default: //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); if (strlen($k_value) != 0 || isset($_SESSION["as_$k"])) { $v['value']['default_value'] = $k_value; @@ -898,7 +877,7 @@ $show_quick_help = $show['show']; echo '
-
+
'; } } diff --git a/index.php b/index.php index 8629bac0..d391fdf4 100644 --- a/index.php +++ b/index.php @@ -619,7 +619,7 @@ function print_add_ticket()
- +
'; break; @@ -927,7 +927,7 @@ function print_add_ticket()
- +
'; break;