Copyright (C) 2004-2005, Ryan Djurovich Website Baker is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Website Baker is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Website Baker; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* The Website Baker Project would like to thank Rudolph Lartey for his contributions to this module - adding extra field types */ require('../../config.php'); // Get id if(!isset($_POST['field_id']) OR !is_numeric($_POST['field_id'])) { header("Location: ".ADMIN_URL."/pages/index.php"); } else { $field_id = $_POST['field_id']; $field_id = $field_id; } // Include WB admin wrapper script $update_when_modified = true; // Tells script to update when this page was last updated require(WB_PATH.'/modules/admin.php'); // Validate all fields if($admin->get_post('title') == '' OR $admin->get_post('type') == '') { $admin->print_error($MESSAGE['GENERIC']['FILL_IN_ALL'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$field_id); } else { $title = addslashes($admin->get_post('title')); $type = $admin->get_post('type'); $required = $admin->get_post('required'); } // Update row $database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET title = '$title', type = '$type', required = '$required' WHERE field_id = '$field_id'"); // If field type has multiple options, get all values and implode them $list_count = $admin->get_post('list_count'); if(is_numeric($list_count)) { $values = array(); for($i = 1; $i <= $list_count; $i++) { if($admin->get_post('value'.$i) != '') { $values[] = $admin->get_post('value'.$i); } } $value = implode(',', $values); } // Get extra fields for field-type-specific settings if($admin->get_post('type') == 'textfield') { $length = $admin->get_post('length'); $value = $admin->get_post('value'); $database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$length' WHERE field_id = '$field_id'"); } elseif($admin->get_post('type') == 'textarea') { $value = $admin->get_post('value'); $database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '' WHERE field_id = '$field_id'"); } elseif($admin->get_post('type') == 'heading') { $extra = $admin->get_post('template'); if(trim($extra) == '') $extra = '{TITLE}{FIELD}'; $extra = addslashes($extra); $database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '', extra = '$extra' WHERE field_id = '$field_id'"); } elseif($admin->get_post('type') == 'select') { $extra = $admin->get_post('size').','.$admin->get_post('multiselect'); $database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$extra' WHERE field_id = '$field_id'"); } elseif($admin->get_post('type') == 'checkbox') { $extra = $admin->get_post('seperator'); $database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$extra' WHERE field_id = '$field_id'"); } elseif($admin->get_post('type') == 'radio') { $extra = $admin->get_post('seperator'); $database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$extra' WHERE field_id = '$field_id'"); } // Check if there is a db error, otherwise say successful if($database->is_error()) { $admin->print_error($database->get_error(), WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$field_id); } else { $admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$field_id); } // Print admin footer $admin->print_footer(); ?>