1
|
<?php
|
2
|
/**
|
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: save_field.php 1457 2011-06-25 17:18:50Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/tags/2.8.2/wb/modules/form/save_field.php $
|
15
|
* @lastmodified $Date: 2011-06-25 19:18:50 +0200 (Sat, 25 Jun 2011) $
|
16
|
* @description
|
17
|
*/
|
18
|
|
19
|
require('../../config.php');
|
20
|
|
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
|
require(WB_PATH.'/modules/admin.php');
|
27
|
/* */
|
28
|
|
29
|
// 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
|
// Get id
|
41
|
$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
|
if(!isset($_POST['field_id']) OR !is_numeric($_POST['field_id'])) {
|
48
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
49
|
} else {
|
50
|
$field_id = (int)$_POST['field_id'];
|
51
|
}
|
52
|
/*
|
53
|
// Include WB admin wrapper script
|
54
|
$update_when_modified = true; // Tells script to update when this page was last updated
|
55
|
|
56
|
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
|
*/
|
62
|
// Validate all fields
|
63
|
if($admin->get_post('title') == '' OR $admin->get_post('type') == '') {
|
64
|
$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='.$admin->getIDKEY($field_id));
|
65
|
} else {
|
66
|
$title = str_replace(array("[[", "]]"), '', htmlspecialchars($admin->get_post_escaped('title'), ENT_QUOTES));
|
67
|
$type = $admin->add_slashes($admin->get_post('type'));
|
68
|
$required = (int) $admin->add_slashes($admin->get_post('required'));
|
69
|
}
|
70
|
$value = '';
|
71
|
|
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(",",",",$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
|
$value = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('value'));
|
91
|
$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
|
$value = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('value'));
|
94
|
$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
|
$extra = str_replace(array("[[", "]]"), '', $admin->get_post('template'));
|
97
|
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
|
$extra = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('seperator'));
|
105
|
$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
|
$extra = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('seperator'));
|
108
|
$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
|
$admin->print_error($database->get_error(), WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
|
114
|
} else {
|
115
|
$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
|
116
|
}
|
117
|
|
118
|
// Print admin footer
|
119
|
$admin->print_footer();
|