// REMOVE from table if ($i > 0) { $sql .= ", "; } $sql .= remove_field($key); $change = 'Y'; } $i++; } if ($change == 'Y') { mysql_query($sql) or die(mysql_error()); echo "Database Structure Updated."; if (CACHE_ENABLED == 'YES') { $CACHE_ENABLED = 'NO'; if (!function_exists('generate_form_cache')) { include '../include/codegen_functions.php'; } generate_form_cache(1); $CACHE_ENABLED = 'YES'; } } else { //echo "No Changes need to be made."; } function add_field($field_id, $field_type) { return " ADD `{$field_id}` " . get_definition($field_type) . " "; } function remove_field($field_id) { return " DROP `{$field_id}` "; }
function save_field($error, $NEW_FIELD) { //print_r($_REQUEST); if ($NEW_FIELD == "YES") { $sql = "INSERT INTO `form_fields` ( `form_id` , `field_id` , `reg_expr` , `field_label` , `field_type` , `field_sort` , `is_required` , `display_in_list` , `error_message` , `field_init`, `field_width`, `field_height`, `is_in_search`, `list_sort_order`, `search_sort_order`, `template_tag`, `section`, `is_hidden`, `is_anon`, `field_comment`, `category_init_id`, `is_cat_multiple`, `cat_multiple_rows`, `is_blocked`, `multiple_sel_all`) VALUES ('{$_REQUEST['form_id']}', '', '{$_REQUEST['reg_expr']}', '{$_REQUEST['field_label']}', '{$_REQUEST['field_type']}', '{$_REQUEST['field_sort']}', '{$_REQUEST['is_required']}', '{$_REQUEST['display_in_list']}', '{$_REQUEST['error_message']}', '{$_REQUEST['field_init']}', '{$_REQUEST['field_width']}', '{$_REQUEST['field_height']}', '{$_REQUEST['is_in_search']}', '{$_REQUEST['list_sort_order']}', '{$_REQUEST['search_sort_order']}', '{$_REQUEST['template_tag']}', '{$_REQUEST['section']}', '{$_REQUEST['is_hidden']}', '{$_REQUEST['is_blcoked']}', '{$_REQUEST['field_comment']}', '{$_REQUEST['category_init_id']}', '{$_REQUEST['is_cat_multiple']}', '{$_REQUEST['cat_multiple_rows']}', '{$_REQUEST['is_blocked']}', '{$_REQUEST['multiple_sel_all']}' )"; } else { //if ($_SESSION['MDS_LANG'] == "EN") { $sql = "SELECT * FROM form_fields WHERE field_id='" . $_REQUEST['field_id'] . "' "; $result = mysql_query($sql) or die(mysql_error() . $sql); $row = mysql_fetch_array($result); if ($row['field_type'] != $_REQUEST['field_type']) { //echo "Cannot change this field type..."; } if (is_reserved_template_tag($_REQUEST['template_tag']) && true) { $tt = ""; // do not update template tag } elseif ($_REQUEST['template_tag'] != '') { $tt = "`template_tag` = '" . $_REQUEST['template_tag'] . "',"; } $sql = "UPDATE `form_fields` SET " . "`reg_expr` = '{$_REQUEST['reg_expr']}'," . "`field_label` = '{$_REQUEST['field_label']}'," . "`field_type` = '{$_REQUEST['field_type']}'," . "`field_init` = '{$_REQUEST['field_init']}'," . "`is_required` = '{$_REQUEST['is_required']}'," . "`field_width` = '{$_REQUEST['field_width']}'," . "`field_height` = '{$_REQUEST['field_height']}'," . "`is_in_search` = '{$_REQUEST['is_in_search']}'," . "`search_sort_order` = '{$_REQUEST['search_sort_order']}'," . "`section` = '{$_REQUEST['section']}'," . $tt . "`error_message` = '{$_REQUEST['error_message']}'," . "`is_hidden` = '{$_REQUEST['is_hidden']}', " . "`is_anon` = '{$_REQUEST['is_anon']}', " . "`is_cat_multiple` = '{$_REQUEST['is_cat_multiple']}', " . "`cat_multiple_rows` = '{$_REQUEST['cat_multiple_rows']}', " . "`field_comment` = '{$_REQUEST['field_comment']}', " . "`multiple_sel_all` = '{$_REQUEST['multiple_sel_all']}', " . "`is_blocked` = '{$_REQUEST['is_blocked']}', " . "`is_prefill` = '{$_REQUEST['is_prefill']}', " . "category_init_id = '{$_REQUEST['category_init_id']}' " . "WHERE `field_id` = '{$_REQUEST['field_id']}' ;"; //} //echo $sql."<br>"; //echo "<hr>"; //print_r($_REQUEST); if ($sql != '') { mysql_query($sql) or die($sql . mysql_error()); } mysql_query($sql) or die($sql . mysql_error()); // update translations $label = $_REQUEST['field_label']; $sql = "REPLACE INTO `form_field_translations` (`field_id`, `lang`, `field_label`, `error_message`, `field_comment`) VALUES ('" . $_REQUEST['field_id'] . "', '" . $_SESSION['MDS_LANG'] . "', '" . $label . "', '" . $_REQUEST['error_message'] . "', '" . $_REQUEST['field_comment'] . "' )"; mysql_query($sql) or die($sql . mysql_error()); // update template tag on the form_lists if ($_REQUEST['template_tag'] != '') { // sometimes template tag can be blank (reserved tags) $sql = "UPDATE form_lists SET `template_tag`='" . $_REQUEST['template_tag'] . "' WHERE `field_id`='" . $_REQUEST['field_id'] . "'"; mysql_query($sql) or die($sql . mysql_error()); } } $result = mysql_query($sql) or die(mysql_error() . $sql); //print_r($_REQUEST); if ($_REQUEST['field_type'] == 'RADIO' || $_REQUEST['field_type'] == 'CHECK' || $_REQUEST['field_type'] == 'MSELECT' || $_REQUEST['field_type'] == 'SELECT') { //echo 'formatting field..<br>'; if ($NEW_FIELD == 'YES') { $_REQUEST['field_id'] = mysql_insert_id(); } format_codes_translation_table($_REQUEST['field_id']); } if ($NEW_FIELD == 'YES') { $field_id = mysql_insert_id(); } else { $field_id = $_REQUEST['field_id']; } if (CACHE_ENABLED == 'YES') { global $CACHE_ENABLED; $CACHE_ENABLED = 'NO'; include '../include/codegen_functions.php'; generate_form_cache($_REQUEST['form_id']); $CACHE_ENABLED = 'YES'; } $_REQUEST['mode'] = 'EDIT'; global $NEW_FIELD; $NEW_FIELD = 'NO'; return $field_id; }