📄 user_fields.php
字号:
unset($table, $width);
$field_data = unserialize($user_field[data]);
// get max number for creating new fields
if (is_array($field_data)) {
while (list ($key, $val) = each ($field_data)) {
$array_count[] = $field_data[$key][0];
}
$max = max($array_count);
reset($field_data);
}
$field_data[] = array($max+1, '', '', '');
$field_data[] = array($max+2, '', '', '');
$field_data[] = array($max+3, '', '', '');
$field_data[] = array($max+4, '', '', '');
$field_data[] = array($max+5, '', '', '');
while (list ($key, $val) = each ($field_data)) {
$table[] = array(
$val[0] . form_hidden($val[0], '1', $arrayto='elementid'),
form_input($val[0], $val[1], '3', 'order'),
iff($val[2], "<B>$val[2]</B>", "<I>n/a</I>"),
form_input($val[0], $val[2], '45', 'name'),
form_radio_yn($val[0], 'start', $val[3])
);
}
$table[] = array('<I>To delete a field, empty its New / Edit value. Note this will also delete any
data associated with that field.</I>');
$columns = array('ID', 'Order', 'Current Value', 'New / Edit Value', 'Select by Default');
table_header('Field Data');
table_content($columns, $table);
table_footer();
unset($table);
// javascript to control options
?>
<SCRIPT>
function extrainput2() {
var value;
for (value = 0; value < document.fields.extrainput.length; value++)
{
if (document.fields.extrainput[value].checked == true)
{
yesno = document.fields.extrainput[value].value;
}
}
if (yesno == '1')
{
document.fields.minlength.disabled=false;
document.fields.maxlength.disabled=false;
document.fields.regex.disabled=false;
document.fields.length.disabled=false;
document.fields.extrainput_location[0].disabled=false;
document.fields.extrainput_location[1].disabled=false;
document.fields.extrainput_text.disabled=false;
} else {
document.fields.minlength.disabled=true;
document.fields.maxlength.disabled=true;
document.fields.regex.disabled=true;
document.fields.length.disabled=true;
document.fields.extrainput_location[0].disabled=true;
document.fields.extrainput_location[1].disabled=true;
document.fields.extrainput_text.disabled=true;
}
}
function multipleselect() {
var value;
for (value = 0; value < document.fields.multiselect.length; value++)
{
if (document.fields.multiselect[value].checked == true)
{
yesno = document.fields.multiselect[value].value;
}
}
if (yesno == '1') {
document.fields.maxoptions.disabled=false;
document.fields.minoptions.disabled=false;
document.fields.required[0].disabled=true;
document.fields.required[1].disabled=true;
document.fields.extrainput[1].checked=true;
extrainput2();
document.fields.extrainput[0].disabled=true;
} else {
document.fields.maxoptions.disabled=true;
document.fields.minoptions.disabled=true;
document.fields.required[0].disabled=false;
document.fields.required[1].disabled=false;
document.fields.extrainput[0].disabled=false;
}
}
extrainput2();
multipleselect();
</SCRIPT>
<?
############################### CHECKBOX ###############################
} elseif ($user_field[formtype] == "checkbox") {
echo form_hidden('formtype', 'checkbox');
// regex
$table[] = array('<b>Maximum Options</b><br />The maximum amount of options that can be selected. (Set a 0 to have no maximum.)', form_input('maxoptions', $user_field[maxoptions], '3'));
$table[] = array('<b>Minimum Options</b><br />The minimum amount of options that must be selected. (Set as 0 to require no minimum number of options.)', form_input('minoptions', $user_field[minoptions], '3'));
$table[] = array('<b>Error Message</b><br />The error message to be displayed if the user does not select an option. If you are enabling the extra INPUT field and have a custom regex which is not satisfied then this message would then be displayed.', $error);
$width = array('60%', '40%');
table_header('Field Criteria');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table, $width);
// display properties
$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], '3'));
$table[] = array('<b>Checkboxes Per line</b><br />How many checkboxes do you want to display per line?', form_input('perline', $user_field[perline], '3'));
$width = array('60%', '40%');
table_header('Field Display Properties');
table_content('', $table, '', '', '', '', $width);
table_footer();
unset($table, $width);
$field_data = unserialize($user_field[data]);
// get max number for creating new fields
if (is_array($field_data)) {
while (list ($key, $val) = each ($field_data)) {
$array_count[] = $field_data[$key][0];
}
$max = max($array_count);
reset($field_data);
}
$field_data[] = array($max+1, '', '', '', '');
$field_data[] = array($max+2, '', '', '', '');
$field_data[] = array($max+3, '', '', '', '');
$field_data[] = array($max+4, '', '', '', '');
$field_data[] = array($max+5, '', '', '', '');
while (list ($key, $val) = each ($field_data)) {
$table[] = array(
$val[0] . form_hidden($key, '1', $arrayto='elementid'),
form_input($val[0], $val[1], '3', 'order'),
iff($val[2], "<B>$val[2]</B>", "<I>n/a</I>"),
form_input($val[0], $val[2], '45', 'name'),
form_radio_yn($val[0], 'start', $val[4])
);
}
$table[] = array('<I>To delete a field, empty its New / Edit value. Note this will also delete any
data associated with that field.</I>');
$columns = array('ID', 'Order', 'Current Value', 'New / Edit Value', 'Select by Default');
table_header('Field Data');
table_content($columns, $table);
table_footer();
unset($table);
}
############################### FINISH OFF ###############################
// show different form button if new/edit
if ($_REQUEST['do'] == "edit") {
echo "<br /><center><input type=\"submit\" name=\"submit\" value=\"Update Field Options\"></center></form>";
} else {
echo "<br /><center><input type=\"submit\" name=\"submit\" value=\"Create New Field\"></center></form>";
}
}
############################### SELECT TYPE OF NEW FIELD TO CREATE ###############################
if ($_REQUEST['do'] == "add") {
admin_header('User Fields', 'Add New Field');
$table[] = array('<b>INPUT</b>', 'This field allows the user to enter text on one line. Useful for words and short sentences', '<a href="user_fields.php?do=new2&type=input">create</a>');
$table[] = array('<b>TEXTAREA</b>', 'Allows for text input across a number of lines. Useful for where more information is required.', '<a href="user_fields.php?do=new2&type=textarea">create</a>');
$table[] = array('<b>SELECT</b>', 'This field allows the user to select from a number of options contained in a list', '<a href="user_fields.php?do=new2&type=select">create</a>');
$table[] = array('<b>RADIO</b>', 'Allows the user from pick one from a number of options where the options are displayed as radio buttons', '<a href="user_fields.php?do=new2&type=radio">create</a>');
$table[] = array('<b>CHECKBOX</b>', 'Allows the user to select a number of options where the options are displayed as checkboxes', '<a href="user_fields.php?do=new2&type=checkbox">create</a>');
table_header('Create New Field');
table_content('', $table);
table_footer();
unset($table, $width);
}
############################### DELETE CUSTOM PROFILE FIELDS ###############################
if ($_REQUEST['do'] == "delete") {
$field = $db->query_return("SELECT name FROM user_def WHERE id = " . intval($id));
// delete the field and column
$db->query("DELETE FROM user_def WHERE id = " . intval($id));
$db->query("ALTER TABLE user DROP $field[name]");
jump('user_fields.php?action=view', 'Custom Profile Field Deleted');
}
############################### LIST CUSTOM PROFILE FIELDS ###############################
if ($_REQUEST['do'] == "view") {
admin_header('User Fields', 'View Fields');
// Fetch indexes
$db->query("SHOW INDEX FROM user");
while ($index = $db->row_array()) {
$indexed[$index['Column_name']] = 1;
}
// Fetch custom fields
$db->query("
SELECT * FROM user_def
ORDER BY displayorder
");
while ($user_fields = $db->row_array()) {
$user_fields['display_name'] = unserialize($user_fields['display_name']);
$user_fields['display_name'] = $user_fields['display_name'][$settings['default_language']];
if ($indexed[$user_fields['name']]) {
$index = jprompt('This will remove the index for this field. Searches on this field may take longer, but changes to the users table that involve this field may be faster after this change. This operation may take some time if there are many users.',
"user_fields.php?do=dropindex&id=$user_fields[id]",
'Remove Index');
} else {
$index = jprompt('This will create an index for this field. Searches on this field may be faster, but changes to the users table that involve this field may take longer after this change. This operation may take some time if there are many users.',
"user_fields.php?do=createindex&id=$user_fields[id]",
'Create Index');
}
${"table_$user_fields[formtype]"}[] = array(
$user_fields['display_name'],
$user_fields['name'].'</center>',
ifynb($user_fields['user_viewable']),
ifynb($user_fields['user_editable']),
ifynb($user_fields['tech_viewable']),
ifynb($user_fields['tech_editable']),
$index,
$user_fields['displayorder'],
"<a href=\"user_fields.php?do=edit&id=$user_fields[id]\">Edit</a>",
jprompt('Are you sure you want to delete this custom field?', "user_fields.php?do=delete&id=$user_fields[id]", 'Delete')
);
}
// build the row headings
$columns = array('Display name', 'SQL name', 'User Viewable', 'User Editable', 'Tech Viewable', 'Tech Editable', 'Index', 'Order', 'Edit', 'Delete');
table_header('Input Fields');
table_content($columns, $table_input);
table_footer();
table_header('Select Fields');
table_content($columns, $table_select);
table_footer();
table_header('Textarea Fields');
table_content($columns, $table_textarea);
table_footer();
table_header('Radio Fields');
table_content($columns, $table_radio);
table_footer();
table_header('Checkbox Fields');
table_content($columns, $table_checkbox);
table_footer();
$columns = array('Display name', 'SQL name', 'User Viewable', 'Tech Viewable', 'Indexed', 'Order', 'Edit', 'Delete');
}
##############################################################
admin_footer();
php?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -