📄 ticket_fields.php
字号:
ticket_start = '".mysql_escape_string($_REQUEST['ticket_start'])."',
user_viewable = '".mysql_escape_string($_REQUEST['user_viewable'])."',
user_editable = '".mysql_escape_string($_REQUEST['user_editable'])."',
tech_viewable = '".mysql_escape_string($_REQUEST['tech_viewable'])."',
tech_editable = '".mysql_escape_string($_REQUEST['tech_editable'])."',
displayorder = '".mysql_escape_string($_REQUEST['displayorder'])."',
extrainput = '".mysql_escape_string($_REQUEST['extrainput'])."',
perline = '".mysql_escape_string($_REQUEST['perline'])."',
extrainput_location = '".mysql_escape_string($_REQUEST['extrainput_location'])."',
extrainput_text = '".mysql_escape_string($_REQUEST['extrainput_text'])."',
minlength = '".mysql_escape_string($_REQUEST['minlength'])."',
maxlength = '".mysql_escape_string($_REQUEST['maxlength'])."',
regex = '".mysql_escape_string($_REQUEST['regex'])."',
error_message = '".mysql_escape_string($_REQUEST['error_message'])."',
length = '".mysql_escape_string($_REQUEST['length'])."',
formtype = 'radio'
";
############################### SELECT ###############################
} elseif ($user_field[formtype] == "select") {
$query .= "
name = '$name',
data = '".mysql_escape_string($data)."',
display_name = '".mysql_escape_string($_REQUEST['display_name'])."',
description = '".mysql_escape_string($_REQUEST['description'])."',
required = '".mysql_escape_string($_REQUEST['required'])."',
ticket_start = '".mysql_escape_string($_REQUEST['ticket_start'])."',
user_viewable = '".mysql_escape_string($_REQUEST['user_viewable'])."',
user_editable = '".mysql_escape_string($_REQUEST['user_editable'])."',
tech_viewable = '".mysql_escape_string($_REQUEST['tech_viewable'])."',
tech_editable = '".mysql_escape_string($_REQUEST['tech_editable'])."',
displayorder = '".mysql_escape_string($_REQUEST['displayorder'])."',
extrainput = '".mysql_escape_string($_REQUEST['extrainput'])."',
extrainput_location = '".mysql_escape_string($_REQUEST['extrainput_location'])."',
extrainput_text = '".mysql_escape_string($_REQUEST['extrainput_text'])."',
minlength = '".mysql_escape_string($_REQUEST['minlength'])."',
maxlength = '".mysql_escape_string($_REQUEST['maxlength'])."',
maxoptions = '".mysql_escape_string($_REQUEST['maxoptions'])."',
minoptions = '".mysql_escape_string($_REQUEST['minoptions'])."',
multiselect = '".mysql_escape_string($_REQUEST['multiselect'])."',
height = '".mysql_escape_string($_REQUEST['height'])."',
regex = '".mysql_escape_string($_REQUEST['regex'])."',
error_message = '".mysql_escape_string($_REQUEST['error_message'])."',
length = '".mysql_escape_string($_REQUEST['length'])."',
formtype = 'select'
";
############################### CHECKBOX ###############################
} elseif ($user_field[formtype] == "checkbox") {
$query .= "
name = '$name',
data = '".mysql_escape_string($data)."',
display_name = '".mysql_escape_string($_REQUEST['display_name'])."',
description = '".mysql_escape_string($_REQUEST['description'])."',
minoptions = '".mysql_escape_string($_REQUEST['minoptions'])."',
maxoptions = '".mysql_escape_string($_REQUEST['maxoptions'])."',
ticket_start = '".mysql_escape_string($_REQUEST['ticket_start'])."',
user_viewable = '".mysql_escape_string($_REQUEST['user_viewable'])."',
user_editable = '".mysql_escape_string($_REQUEST['user_editable'])."',
tech_viewable = '".mysql_escape_string($_REQUEST['tech_viewable'])."',
tech_editable = '".mysql_escape_string($_REQUEST['tech_editable'])."',
displayorder = '".mysql_escape_string($_REQUEST['displayorder'])."',
extrainput = '".mysql_escape_string($_REQUEST['extrainput'])."',
multiselect = '".mysql_escape_string($_REQUEST['multiselect'])."',
minlength = '".mysql_escape_string($_REQUEST['minlength'])."',
maxlength = '".mysql_escape_string($_REQUEST['maxlength'])."',
perline = '".mysql_escape_string($_REQUEST['perline'])."',
error_message = '".mysql_escape_string($_REQUEST['error_message'])."',
length = '".mysql_escape_string($_REQUEST['length'])."',
formtype = 'checkbox'
";
############################### SYSTEM ###############################
} elseif ($user_field[formtype] == "system") {
unset($data);
$data[when][reg1] = $_REQUEST['reg1'];
$data[when][reg2] = $_REQUEST['reg2'];
$data[when][usermod] = $_REQUEST['usermod'];
$data[when][techmod] = $_REQUEST['techmod'];
$data[when][technew] = $_REQUEST['technew'];
$data[code][code] = $_REQUEST['code'];
$data[code][variable] = $_REQUEST['variable'];
$data = serialize($data);
$query .= "
name = '$name',
data = '".mysql_escape_string($data)."',
display_name = '".mysql_escape_string($_REQUEST['display_name'])."',
description = '".mysql_escape_string($_REQUEST['description'])."',
user_viewable = '".mysql_escape_string($_REQUEST['user_viewable'])."',
tech_viewable = '".mysql_escape_string($_REQUEST['tech_viewable'])."',
formtype = 'system'
";
}
############################### FINISH AND REDIRECT ###############################
if ($_REQUEST['do'] == "new3") {
$db->query($query);
$id = $db->last_id();
jump("ticket_fields.php?do=edit&id=$id", 'New field has been created<br />Redirecting you to your new field');
} else {
$db->query($query . "WHERE id = " . intval($id));
jump("ticket_fields.php?do=edit&id=$id", 'Field has been updated<br />Redirecting you to the updated field');
}
}
############################### EDIT PROFILE FIELDS ###############################
if (($_REQUEST['do'] == "edit") OR ($_REQUEST['do'] == "new2")) {
// set form action for field editing
if ($_REQUEST['do'] == "edit") {
$user_field = $db->query_return("
SELECT * FROM ticket_def
WHERE id = '$id'
");
echo "
<form do=\"ticket_fields.php\" method=\"post\" name=\"fields\">
<input type=\"hidden\" name=\"do\" value=\"update\">
<input type=\"hidden\" name=\"id\" value=\"$user_field[id]\">
";
// set form action for new field creation
} else {
$user_field[formtype] = $type;
echo "
<form do=\"ticket_fields.php\" method=\"post\" name=\"fields\">
<input type=\"hidden\" name=\"do\" value=\"new3\">
<input type=\"hidden\" name=\"type\" value=\"$user_field[formtype]\">
";
}
############################### LANGUAGE BITS ###############################
$user_field[display_name] = unserialize($user_field[display_name]);
$user_field[description] = unserialize($user_field[description]);
$user_field[error_message] = unserialize($user_field[error_message]);
if ($settings[language_on]) {
$name = "<div id=\"name\"><table cellpadding=\"2\" cellspacing=\"0\">";
$description = "<div id=\"description\"><table cellpadding=\"2\" cellspacing=\"0\">";
$error = "<div id=\"error\"><table cellpadding=\"2\" cellspacing=\"0\">";
$db->query("SELECT * FROM languages WHERE is_selectable = 1");
while ($lang = $db->row_array()) {
$name .= "<tr><td><b>$lang[name]</b>:</td><td>" . form_input($lang[id], $user_field[display_name][$lang[id]], 30, 'display_name') . "</td></tr>";
$description .= "<tr><td><b>$lang[name]</b>:</td><td>" . form_textarea($lang[id], 40, 5, $user_field[description][$lang[id]], 'description') . "</td></tr>";
$error .= "<tr><td><b>$lang[name]</b>:</td><td>" . form_textarea($lang[id], 40, 5, $user_field[error_message][$lang[id]], 'error_message') . "</td></tr>";
}
$name .= "</table><input type=\"button\" value=\"Hide Language Options\" onclick=\"oc('name');oc('name2')\"></div><div id=\"name2\"><input type=\"button\" value=\"View Language Options\" onclick=\"oc('name');oc('name2');\"><div><script>oc('name')</script>";
$description .= "</table><input type=\"button\" value=\"Hide Language Options\" onclick=\"oc('description');oc('description2')\"></div><div id=\"description2\"><input type=\"button\" value=\"View Language Options\" onclick=\"oc('description');oc('description2');\"><div><script>oc('description')</script>";
$error .= "</table><input type=\"button\" value=\"Hide Language Options\" onclick=\"oc('error');oc('error2')\"></div><div id=\"error2\"><input type=\"button\" value=\"View Language Options\" onclick=\"oc('error');oc('error2');\"><div><script>oc('error')</script>";
} else {
$name = form_input('display_name', $user_field[display_name][$settings[default_language]]);
$description = form_textarea('description', 50, 5, $user_field[description][$settings[default_language]]);
$error = form_textarea('error_message', 50, 5, $user_field[error_message][$settings[default_language]]);
}
############################### STANDARD FOR ALL ###############################
// display options
$table[] = array('<b>Display Name</b><br />This is the name of the field that will be presented to technicians and users', $name);
// show different message if new/edit
if ($_REQUEST['do'] == "edit") {
$table[] = array('<b>Database Name</b><br />This is the name of the field as it is in the database. This is the name you would use to call the value in your templates', $user_field[name]);
} else {
$table[] = array('<b>Database Name</b><br />This is the name of the field as it is in the database. This is the name you would use to call the value in your templates', '<I>Generated upon field creation</I>');
}
$table[] = array('<b>Description</b><br />The description that will be presented for this field to your users', $description);
if ($user_field[formtype] != "system") {
$table[] = array('<b>Display During Ticket Creation</b><br />Do you wish this field to be presented to the user during new ticket creation?', form_radio_yn('ticket_start', '', $user_field[ticket_start]));
}
$width = array('60%', '40%');
table_header('Field Details');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table, $width);
// field permissions
$table[] = array('<b>User Viewable</b><br />Do you wish to allow your users to view this field?', form_radio_yn('user_viewable', '', $user_field[user_viewable]));
if ($user_field[formtype] != "system") {
$table[] = array('<b>User Editable</b><br />Do you wish to allow your users to edit the data held in this field?', form_radio_yn('user_editable', '', $user_field[user_editable]));
}
$table[] = array('<b>Tech Viewable</b><br />Do you wish to allow your staff to view this field?', form_radio_yn('tech_viewable', '', $user_field[tech_viewable]));
if ($user_field[formtype] != "system") {
$table[] = array('<b>Tech Editable</b><br />Do you wish to allow your staff to edit this field?', form_radio_yn('tech_editable', '', $user_field[tech_editable]));
}
$width = array('60%', '40%');
table_header('Field Permissions');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table, $width);
############################### INPUT ###############################
if ($user_field[formtype] == "input") {
echo form_hidden('formtype', 'input');
// regex
$table[] = array('<b>Minimum Characters</b><br />You can set a minimum number of characters that the user must enter in this field. Set to 0 for no stipulation (and to allow the field to be left empty)', form_input('minlength', $user_field[minlength], '3'));
$table[] = array('<b>Maximum Characters</b><br />You can set a maximum number of characters that the user may enter. Set to 0 to allow for unlimited entry', form_input('maxlength', $user_field[maxlength], '3'));
$table[] = array('<b>Custom Regex</b><br />You may use a custom regex to validate the input. You can find details about creating these in PHP\'s manual. A custom regex overrides any stipulations on minimum or maximum field length', form_input('regex', $user_field[regex], '45'));
$table[] = array('<b>Error Message</b><br />If the user enters text that fails the criteria you have specified above, this is the error that will be presented', $error);
$width = array('60%', '40%');
table_header('Field Criteria');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table, $width);
// default value
$table[] = array('<b>Default Value</b><br />You may specify a default starting value here', form_input('default_value', $user_field[default_value], '45'));
$table[] = array('<b>Parsed Default Value</b><br />You may specify a parsed default value. This overrides any default value you may have set.', form_input('parsed_default_value', $user_field[parsed_default_value], '45'));
$width = array('60%', '40%');
table_header('Default Value');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table, $width);
// display properties
$table[] = array('<b>Length</b><br />How long do you wish the INPUT field to be?', form_input('length', $user_field[length], '4'));
$table[] = array('<b>Order</b><br />What order you wish the field to be displayed in relation to your other fields?', form_input('displayorder', $user_field[displayorder], '4'));
$width = array('60%', '40%');
table_header('Field Display Properties');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table, $width);
############################### TEXTAREA ###############################
} elseif ($user_field[formtype] == "textarea") {
echo form_hidden('formtype', 'textarea');
// regex
$table[] = array('<b>Minimum Characters</b><br />You can set a minimum number of characters that the user must enter in this field. Set to 0 for no stipulation (and to allow the field to be left empty)', form_input('minlength', $user_field[minlength], '3'));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -