} echo ' ' . htmlspecialchars($create_user['email']); } })); $fieldset_data['elements'][] = array('title' => _l('Type/Department'), 'fields' => array(array('type' => 'select', 'name' => 'ticket_type_id', 'value' => $ticket['ticket_type_id'], 'options' => module_ticket::get_types(), 'blank' => module_ticket::can_edit_tickets(), 'options_array_id' => 'name'))); if (class_exists('module_faq', false) && module_config::c('ticket_faq_link', 1) && module_faq::get_faq_products() > 0) { $fieldset_data['elements'][] = array('title' => _l('Product'), 'fields' => array(function () use($ticket, $ticket_id) { if (module_ticket::can_edit_tickets()) { echo print_select_box(module_faq::get_faq_products_rel(), 'faq_product_id', $ticket['faq_product_id']); _h('Use this to link a ticket to a product. Set products in Settings > FAQ. This allows you to have different FAQ items for different products. Users are shown the FAQ items before submitting a support ticket.'); } else { echo friendly_key(module_faq::get_faq_products_rel(), $ticket['faq_product_id']); } // show a button that does a jquery popup with the list of faq items and an option to create new one. //if(module_faq::can_i('edit','FAQ')){ echo ' '; echo popup_link('<a href="' . module_faq::link_open_list($ticket['faq_product_id']) . '">' . _l('FAQ') . '</a>', array('force' => true, 'width' => 1100, 'height' => 600)); //} })); } if (module_config::c('ticket_support_accounts', 1) && module_ticket::get_accounts_rel()) { $fieldset_data['elements'][] = array('title' => _l('Account'), 'fields' => array(array('type' => module_ticket::can_edit_tickets() ? 'select' : 'html', 'name' => 'ticket_account_id', 'value' => module_ticket::can_edit_tickets() ? $ticket['ticket_account_id'] : friendly_key(module_ticket::get_accounts_rel(), $ticket['ticket_account_id']), 'options' => module_ticket::get_accounts_rel()))); } $fieldset_data['elements'][] = array('title' => _l('Status'), 'fields' => array(array('type' => module_ticket::can_edit_tickets() ? 'select' : 'html', 'name' => 'status_id', 'value' => module_ticket::can_edit_tickets() ? $ticket['status_id'] : friendly_key(module_ticket::get_statuses(), $ticket['status_id']), 'options' => module_ticket::get_statuses()))); if (module_ticket::can_edit_tickets() || module_config::c('ticket_allow_priority_selection', 0)) { $priorities = module_ticket::get_ticket_priorities(); if (!module_ticket::can_edit_tickets() && isset($priorities[_TICKET_PRIORITY_STATUS_ID]) && $ticket['priority'] != _TICKET_PRIORITY_STATUS_ID) { unset($priorities[_TICKET_PRIORITY_STATUS_ID]); } $fieldset_data['elements'][] = array('title' => _l('Priority'), 'fields' => array(array('type' => 'select', 'name' => 'priority', 'value' => $ticket['priority'], 'blank' => false, 'options' => $priorities))); } $fieldset_data['extra_settings'] = array('owner_table' => 'ticket', 'owner_key' => 'ticket_id', 'owner_id' => $ticket['ticket_id'], 'layout' => 'table_row', 'allow_new' => module_extra::can_i('create', 'Tickets'), 'allow_edit' => module_extra::can_i('edit', 'Tickets'));
/** * This is where all the magic happens. * We take a page name (ie: the name of the 'plugin_extra' block like 'customer') and the html_data for that page (or block, or single input element) * We check each of the input elements (there may be more than 1 in the html data!) to see if any of them are marked for encryption (see encrypt_field table) * * @static * @param $page_name * @param $html_data */ public static function parse_html_input($page_name, $html_data, $edit = true) { // find out what field names are encrypted against thie 'page_name' $fields = get_multiple('encrypt_field', array('page_name' => $page_name), 'field_name'); // convert any of these encrypted fields into a ****** [lock] block. // first look for all text input fields (could also be date input fields!) if (preg_match_all('#<input[^>]*type="text"[^>]*>#imsU', $html_data, $matches)) { foreach ($matches[0] as $match) { if (preg_match('#display\\s*:\\s*none#', $match)) { continue; } if (preg_match('#\\[new\\]#', $match)) { continue; } // find the id or the name of each element. $encrypt_field_id = false; $encrypt_field_name = ''; if (preg_match('#id="([^"]*)"#', $match, $name_matches)) { $encrypt_field_name = $name_matches[1]; } else { if (preg_match('#name="([^"]*)"#', $match, $name_matches)) { $encrypt_field_name = $name_matches[1]; } } if (isset($fields[$encrypt_field_name])) { // this is an encryptable field! $encrypt_field_id = $fields[$encrypt_field_name]['encrypt_field_id']; } $existing_value = ''; if (preg_match('#value="([^"]+)#', $match, $value_matches)) { if (strpos($value_matches[1], 'encrypt:') === false) { $existing_value = $value_matches[1]; } } if ($encrypt_field_id) { // find the "vlaue" of this input box. // the value will be the id in the encrypt table. // it should look something like this: // encrypt:123 $encrypt_id = 0; // new value $replace = ''; // what we are going to replace this with. if (preg_match('#value="encrypt:([^"]*)"#', $match, $value_matches)) { $encrypt_id = (int) $value_matches[1]; // remove the value from the input box and display our empty box on the page. // rename our real box to a hidden input and give it an id so we can load our // encrypt:123 value into it for submission. $dummy_input = preg_replace('#value="[^"]+"#', 'value="*********"', $match); $dummy_input = preg_replace('#id="[^"]+"#', '', $dummy_input); $dummy_input = preg_replace('#name="[^"]+"#', 'name="nothing" disabled="disabled"', $dummy_input); $replace .= $dummy_input; // add our hidden input back so normal form submits work. // give our hidden input an id that we can work with, so we can update it's value after saving. $hidden_input = preg_replace('#id="[^"]+"#', '', $match); $hidden_input = preg_replace('#type="text"#i', 'type="hidden" id="encrypt_hidden_' . $encrypt_field_id . '"', $hidden_input); $replace .= $hidden_input; } else { // no encrypted value within this field yet. // we leave the box as is, but give the user the option to encrypt whatever is in it. //$dummy_input = preg_replace('#value="[^"]+"#','value=""',$match); // remove any id from the box. $dummy_input = preg_replace('#id="[^"]+"#', '', $match); $dummy_input = preg_replace('#type="text"#i', 'type="text" id="encrypt_hidden_' . $encrypt_field_id . '"', $dummy_input); $replace .= $dummy_input; } if (!$edit) { $replace = '*********'; } // put our hidden field in here. if (self::can_i('view', 'Encrypts')) { $link = link_generate(array('raw' => true, array('full' => true, 'text' => '<img src="' . full_link('includes/plugin_encrypt/images/' . (!$encrypt_id ? 'un' : '') . 'lock.png') . '" style="vertical-align:top;" border="0"> ', 'module' => 'encrypt', 'page' => 'encrypt_popup', 'arguments' => array('encrypt_id' => $encrypt_id, 'encrypt_field_id' => $encrypt_field_id, 'page_name' => $page_name, 'value' => base64_encode($existing_value), 'callback_id' => 'encrypt_hidden_' . $encrypt_field_id, 'editable' => $edit)))); $button = '<span class="encrypt_popup">' . popup_link($link, array('width' => 600, 'height' => 400, 'force' => true, 'hide_close' => true, 'title' => _l('Encryption'))) . '</span>'; $replace .= ' ' . $button; } $html_data = preg_replace('#' . preg_quote($match, '#') . '#msU', str_replace('$', '\\$', $replace), $html_data); } else { if (self::can_i('create', 'Encrypts') && $edit) { // no encrypt field for this one. $element_id = ''; if (preg_match('#id="([^"]+)"#', $match, $id_matches)) { $element_id = $id_matches[1]; } // give them an option to encrypt this field. $link = link_generate(array('raw' => true, array('full' => true, 'text' => '<img src="' . full_link('includes/plugin_encrypt/images/unlock.png') . '" style="vertical-align:top;" border="0"> ', 'module' => 'encrypt', 'page' => 'encrypt_popup', 'arguments' => array('encrypt_field_name' => $encrypt_field_name, 'page_name' => $page_name, 'value' => base64_encode($existing_value), 'callback_id' => $element_id, 'editable' => $edit)))); $button = '<span class="encrypt_create">' . popup_link($link, array('width' => 600, 'height' => 300, 'force' => true, 'hide_close' => false)) . '</span>'; $html_data = preg_replace('#' . preg_quote($match, '#') . '#msU', str_replace('$', '\\$', $match) . ' ' . $button, $html_data); } } } } // now all textareas: // now all select fields: return $html_data; }