Project

General

Profile

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