From 379d096f88e95ed3cabccc990469de9521c653a0 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sat, 29 Aug 2015 21:29:01 -0400 Subject: [PATCH] #331 Update admin_settings_save --- admin/admin_settings_save.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/admin/admin_settings_save.php b/admin/admin_settings_save.php index cd9e186c..54f38115 100644 --- a/admin/admin_settings_save.php +++ b/admin/admin_settings_save.php @@ -35,6 +35,12 @@ define('IN_SCRIPT',1); define('HESK_PATH','../'); +// Make sure OPcache is reset when modifying settings +if ( function_exists('opcache_reset') ) +{ + opcache_reset(); +} + /* Get all the required files and functions */ require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'modsForHesk_settings.inc.php'); @@ -108,7 +114,7 @@ else /* --> Helpdesk settings */ $set['hesk_title'] = hesk_input( hesk_POST('s_hesk_title'), $hesklang['err_htitle']); $set['hesk_title'] = str_replace('\\"','"',$set['hesk_title']); -$set['hesk_url'] = hesk_input( hesk_POST('s_hesk_url'), $hesklang['err_hurl']); +$set['hesk_url'] = rtrim( hesk_input( hesk_POST('s_hesk_url'), $hesklang['err_hurl']), '/'); // ---> check admin folder $set['admin_dir'] = isset($_POST['s_admin_dir']) && ! is_array($_POST['s_admin_dir']) ? preg_replace('/[^a-zA-Z0-9_-]/', '', $_POST['s_admin_dir']) : 'admin'; @@ -487,6 +493,19 @@ for ($i=1;$i<=20;$i++) { $set['custom_fields'][$this_field]['type'] = 'text'; } + + // Try to detect if field type changed to anything except "select" + if ($set['custom_fields'][$this_field]['type'] != 'select') + { + // If type is "radio" or "checkbox" remove "please select", keep other options + $set['custom_fields'][$this_field]['value'] = str_replace('{HESK_SELECT}', '', $set['custom_fields'][$this_field]['value']); + + // Field type changed to "text" or "textarea", clear default value if it contains "#HESK#" separator + if ( in_array($set['custom_fields'][$this_field]['type'], array('text','textarea')) && ! in_array($hesk_settings['custom_fields'][$this_field]['type'], array('text','textarea')) && strpos($set['custom_fields'][$this_field]['value'], '#HESK#') !== false ) + { + $set['custom_fields'][$this_field]['value'] = ''; + } + } } else {