Project

General

Profile

1 560 Ruebenwurz
<?php
2 1375 FrankH
/**
3
 *
4
 * @category        module
5
 * @package         Form
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id$
14 1457 Luisehahne
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16 1375 FrankH
 * @description
17
 */
18 560 Ruebenwurz
19
require('../../config.php');
20 1457 Luisehahne
21
// suppress to print the header, so no new FTAN will be set
22
$admin_header = false;
23
// Tells script to update when this page was last updated
24
$update_when_modified = true;
25
// Include WB admin wrapper script
26 1375 FrankH
require(WB_PATH.'/modules/admin.php');
27 1457 Luisehahne
/* */
28 560 Ruebenwurz
29 1457 Luisehahne
// check FTAN
30
if (!$admin->checkFTAN())
31
{
32
	$admin->print_header();
33
	$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
34
}
35
// After check print the header
36
$admin->print_header();
37
38
39
/*  */
40 560 Ruebenwurz
// Get id
41 1457 Luisehahne
$field_id = intval($admin->checkIDKEY('field_id', false ));
42
if (!$field_id) {
43
 $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'].'::', ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
44
}
45
/*
46
// Get id
47 560 Ruebenwurz
if(!isset($_POST['field_id']) OR !is_numeric($_POST['field_id'])) {
48 1375 FrankH
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
49 560 Ruebenwurz
} else {
50 1457 Luisehahne
	$field_id = (int)$_POST['field_id'];
51 560 Ruebenwurz
}
52 1457 Luisehahne
/*
53 560 Ruebenwurz
// Include WB admin wrapper script
54
$update_when_modified = true; // Tells script to update when this page was last updated
55
56 1375 FrankH
if (!$admin->checkFTAN())
57
{
58
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
59
	exit();
60
}
61 1457 Luisehahne
*/
62 560 Ruebenwurz
// Validate all fields
63
if($admin->get_post('title') == '' OR $admin->get_post('type') == '') {
64 1375 FrankH
	$admin->print_error($MESSAGE['GENERIC']['FILL_IN_ALL'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'&section_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
65 560 Ruebenwurz
} else {
66 1407 FrankH
	$title = str_replace(array("[[", "]]"), '', htmlspecialchars($admin->get_post_escaped('title'), ENT_QUOTES));
67 656 thorn
	$type = $admin->add_slashes($admin->get_post('type'));
68 1355 FrankH
	$required = (int) $admin->add_slashes($admin->get_post('required'));
69 560 Ruebenwurz
}
70 618 thorn
$value = '';
71 560 Ruebenwurz
72
// Update row
73
$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET title = '$title', type = '$type', required = '$required' WHERE field_id = '$field_id'");
74
75
// If field type has multiple options, get all values and implode them
76
$list_count = $admin->get_post('list_count');
77
if(is_numeric($list_count)) {
78
	$values = array();
79
	for($i = 1; $i <= $list_count; $i++) {
80
		if($admin->get_post('value'.$i) != '') {
81
			$values[] = str_replace(",","&#44;",$admin->get_post('value'.$i));
82
		}
83
	}
84
	$value = implode(',', $values);
85
}
86
87
// Get extra fields for field-type-specific settings
88
if($admin->get_post('type') == 'textfield') {
89
	$length = $admin->get_post_escaped('length');
90 1407 FrankH
	$value = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('value'));
91 560 Ruebenwurz
	$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$length' WHERE field_id = '$field_id'");
92
} elseif($admin->get_post('type') == 'textarea') {
93 1407 FrankH
	$value = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('value'));
94 560 Ruebenwurz
	$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '' WHERE field_id = '$field_id'");
95
} elseif($admin->get_post('type') == 'heading') {
96 1407 FrankH
	$extra = str_replace(array("[[", "]]"), '', $admin->get_post('template'));
97 560 Ruebenwurz
	if(trim($extra) == '') $extra = '<tr><td class="field_heading" colspan="2">{TITLE}{FIELD}</td></tr>';
98
	$extra = $admin->add_slashes($extra);
99
	$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '', extra = '$extra' WHERE field_id = '$field_id'");
100
} elseif($admin->get_post('type') == 'select') {
101
	$extra = $admin->get_post_escaped('size').','.$admin->get_post_escaped('multiselect');
102
	$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$extra' WHERE field_id = '$field_id'");
103
} elseif($admin->get_post('type') == 'checkbox') {
104 1407 FrankH
	$extra = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('seperator'));
105 560 Ruebenwurz
	$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$extra' WHERE field_id = '$field_id'");
106
} elseif($admin->get_post('type') == 'radio') {
107 1407 FrankH
	$extra = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('seperator'));
108 560 Ruebenwurz
	$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$extra' WHERE field_id = '$field_id'");
109
}
110
111
// Check if there is a db error, otherwise say successful
112
if($database->is_error()) {
113 1375 FrankH
	$admin->print_error($database->get_error(), WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'&section_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
114 560 Ruebenwurz
} else {
115 1375 FrankH
	$admin->print_success($TEXT['SUCCESS'],     WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'&section_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
116 560 Ruebenwurz
}
117
118
// Print admin footer
119
$admin->print_footer();