if ($v['type'] == 'checkbox') { $tmpvar[$k] = ''; if (isset($_POST[$k])) { if (is_array($_POST[$k])) { foreach ($_POST[$k] as $myCB) { $tmpvar[$k] .= (is_array($myCB) ? '' : hesk_input($myCB)) . '<br />'; } $tmpvar[$k] = substr($tmpvar[$k], 0, -6); } } else { if ($v['req']) { $hesk_error_buffer[$k] = $hesklang['fill_all'] . ': ' . $v['name']; } $_POST[$k] = ''; } $_SESSION["c_{$k}"] = hesk_POST_array($k); } elseif ($v['req']) { $tmpvar[$k] = hesk_makeURL(nl2br(hesk_input(hesk_POST($k)))); if (!strlen($tmpvar[$k])) { $hesk_error_buffer[$k] = $hesklang['fill_all'] . ': ' . $v['name']; } $_SESSION["c_{$k}"] = hesk_POST($k); } else { $tmpvar[$k] = hesk_makeURL(nl2br(hesk_input(hesk_POST($k)))); $_SESSION["c_{$k}"] = hesk_POST($k); } } else { $tmpvar[$k] = ''; } } // Check bans
if ($set['custom_fields'][$this_field]['type'] == 'email' && $set['custom_fields'][$this_field]['value'] == '') { // New custom field without any options set. Default to Cc $set['custom_fields'][$this_field]['value'] = 'cc'; } if (!in_array($set['custom_fields'][$this_field]['type'], array('text', 'textarea', 'select', 'radio', 'checkbox', 'date', 'multiselect', 'email'))) { $set['custom_fields'][$this_field]['type'] = 'text'; } } else { $set['custom_fields'][$this_field] = array('use' => 0, 'place' => 0, 'type' => 'text', 'req' => 0, 'name' => 'Custom field ' . $i, 'maxlen' => 255, 'value' => ''); } } $set['hesk_version'] = $hesk_settings['hesk_version']; // Process quick help sections hesk_dbConnect(); hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` SET `show` = '0'"); $postArray = hesk_POST_array('quick_help_sections'); foreach ($postArray as $value) { hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` SET `show` = '1' WHERE `id` = '" . intval($value) . "'"); } // Save the modsForHesk_settings.inc.php file $set['rtl'] = empty($_POST['rtl']) ? 0 : 1; $set['show-icons'] = empty($_POST['show-icons']) ? 0 : 1; $set['custom-field-setting'] = empty($_POST['custom-field-setting']) ? 0 : 1; $set['customer-email-verification-required'] = empty($_POST['email-verification']) ? 0 : 1; $set['html_emails'] = empty($_POST['html_emails']) ? 0 : 1; $set['use_bootstrap_theme'] = empty($_POST['use_bootstrap_theme']) ? 0 : 1; $set['new_kb_article_visibility'] = hesk_checkMinMax(intval(hesk_POST('new_kb_article_visibility')), 0, 2, 2); $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';
$tmpvar['attachments'] = ''; // If we have any errors lets store info in session to avoid re-typing everything if (count($hesk_error_buffer) != 0) { $_SESSION['iserror'] = array_keys($hesk_error_buffer); $_SESSION['as_name'] = hesk_POST('name'); $_SESSION['as_email'] = hesk_POST('email'); $_SESSION['as_category'] = hesk_POST('category'); $_SESSION['as_priority'] = $tmpvar['priority']; $_SESSION['as_subject'] = hesk_POST('subject'); $_SESSION['as_message'] = hesk_POST('message'); $_SESSION['as_owner'] = $tmpvar['owner']; $_SESSION['as_notify'] = $notify; $_SESSION['as_show'] = $show; foreach ($hesk_settings['custom_fields'] as $k => $v) { if ($v['use']) { $_SESSION["as_{$k}"] = $v['type'] == 'checkbox' ? hesk_POST_array($k) : hesk_POST($k); } } $tmp = ''; foreach ($hesk_error_buffer as $error) { $tmp .= "<li>{$error}</li>\n"; } $hesk_error_buffer = $tmp; // Remove any successfully uploaded attachments if ($hesk_settings['attachments']['use']) { hesk_removeAttachments($attachments); } $hesk_error_buffer = $hesklang['pcer'] . '<br /><br /><ul>' . $hesk_error_buffer . '</ul>'; hesk_process_messages($hesk_error_buffer, 'new_ticket.php'); } if ($hesk_settings['attachments']['use'] && !empty($attachments)) {
function create() { global $hesk_settings, $hesklang; // Add 'can ban emails' if 'can unban emails' is set (but not added). Same with 'can ban ips' $catArray = hesk_POST_array('categories'); $featArray = hesk_POST_array('features'); $name = hesk_POST('name'); validate($featArray, $catArray, true, $name); if (in_array('can_unban_emails', $featArray) && !in_array('can_ban_emails', $featArray)) { array_push($catArray, 'can_ban_emails'); } if (in_array('can_unban_ips', $featArray) && !in_array('can_ban_ips', $featArray)) { array_push($featArray, 'can_ban_ips'); } $categories = implode(',', $catArray); $features = implode(',', $featArray); hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`name`, `heskprivileges`, `categories`)\n VALUES ('" . hesk_dbEscape($name) . "', '" . hesk_dbEscape($features) . "', '" . hesk_dbEscape($categories) . "')"); hesk_process_messages($hesklang['template_created'], $_SERVER['PHP_SELF'], 'SUCCESS'); }