1 |
2
|
Manuela
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category module
|
5 |
|
|
* @package Form
|
6 |
|
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7 |
|
|
* @copyright WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://websitebaker.org/
|
9 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
|
|
* @platform WebsiteBaker 2.8.3
|
11 |
|
|
* @requirements PHP 5.3.6 and higher
|
12 |
|
|
* @version $Id$
|
13 |
|
|
* @filesource $HeadURL$
|
14 |
|
|
* @lastmodified $Date$
|
15 |
|
|
* @description
|
16 |
|
|
*/
|
17 |
|
|
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
|
18 |
|
|
// suppress to print the header, so no new FTAN will be set
|
19 |
|
|
$admin_header = false;
|
20 |
|
|
// Tells script to update when this page was last updated
|
21 |
|
|
$update_when_modified = true;
|
22 |
|
|
// Include WB admin wrapper script
|
23 |
|
|
require(WB_PATH.'/modules/admin.php');
|
24 |
|
|
$sSectionIdPrefix = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? SEC_ANCHOR : 'Sec' );
|
25 |
|
|
$backUrl = ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id;
|
26 |
|
|
// check FTAN
|
27 |
|
|
if (!$admin->checkFTAN())
|
28 |
|
|
{
|
29 |
|
|
$admin->print_header();
|
30 |
|
|
$admin->print_error( 'checkFTAN'.$MESSAGE['GENERIC_SECURITY_ACCESS'], $backUrl );
|
31 |
|
|
}
|
32 |
|
|
// Get id
|
33 |
|
|
$field_id = intval($admin->checkIDKEY('field_id', false ));
|
34 |
|
|
if (!$field_id) {
|
35 |
|
|
$admin->print_header();
|
36 |
|
|
$admin->print_error( '$field_id'.$MESSAGE['GENERIC_SECURITY_ACCESS'].'', $backUrl );
|
37 |
|
|
}
|
38 |
|
|
$backModuleUrl = WB_URL.'/modules/'.basename(__DIR__).'/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id);
|
39 |
|
|
// After check print the header to get a new FTAN
|
40 |
|
|
$admin->print_header();
|
41 |
|
|
// Validate all fields
|
42 |
|
|
if( ($admin->get_post('title') == '') || ($admin->get_post('type') == '') ) {
|
43 |
|
|
$admin->print_error($MESSAGE['GENERIC_FILL_IN_ALL'], $backModuleUrl );
|
44 |
|
|
} else {
|
45 |
|
|
$title = $admin->StripCodeFromText(($admin->get_post('title')));
|
46 |
|
|
$type = ($admin->get_post('type'));
|
47 |
|
|
$required = (int) ($admin->get_post('required'));
|
48 |
|
|
}
|
49 |
|
|
// If field type has multiple options, get all values and implode them
|
50 |
|
|
$value = $extra = '';
|
51 |
|
|
$list_count = intval($admin->get_post('list_count'));
|
52 |
|
|
if(is_numeric($list_count)) {
|
53 |
|
|
$values = array();
|
54 |
|
|
for($i = 1; $i <= $list_count; $i++) {
|
55 |
|
|
if($admin->get_post('value'.$i) != '') {
|
56 |
|
|
$values[] = str_replace(",",",",$admin->get_post('value'.$i));
|
57 |
|
|
}
|
58 |
|
|
}
|
59 |
|
|
$value = implode(',', $values);
|
60 |
|
|
} else {
|
61 |
|
|
$admin->print_error( ''.$MESSAGE['GENERIC_SECURITY_ACCESS'].''.$list_count, $backUrl );
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
// prepare sql-update
|
65 |
|
|
switch($admin->get_post('type')):
|
66 |
|
|
case 'textfield':
|
67 |
|
|
$value = $admin->StripCodeFromText($admin->get_post('value'));
|
68 |
|
|
$extra = intval($admin->get_post('length'));
|
69 |
|
|
break;
|
70 |
|
|
case 'textarea':
|
71 |
|
|
$value = $admin->StripCodeFromText($admin->get_post('value'));
|
72 |
|
|
$extra = '';
|
73 |
|
|
break;
|
74 |
|
|
case 'heading':
|
75 |
|
|
$extra = $admin->StripCodeFromText( $admin->get_post('template'));
|
76 |
|
|
if(trim($extra) == '') $extra = '<tr><td class="frm-field_heading" colspan="2">{TITLE}{FIELD}</td></tr>';
|
77 |
|
|
break;
|
78 |
|
|
case 'select':
|
79 |
|
|
$extra = intval($admin->get_post('size')).','.$admin->get_post('multiselect');
|
80 |
|
|
break;
|
81 |
|
|
case 'checkbox':
|
82 |
|
|
$extra = $admin->StripCodeFromText( $admin->get_post('seperator'));
|
83 |
|
|
break;
|
84 |
|
|
case 'radio':
|
85 |
|
|
$extra = $admin->StripCodeFromText( $admin->get_post('seperator'));
|
86 |
|
|
break;
|
87 |
|
|
default:
|
88 |
|
|
$value = '';
|
89 |
|
|
$extra = '';
|
90 |
|
|
break;
|
91 |
|
|
endswitch;
|
92 |
|
|
// Update row
|
93 |
|
|
$sql = 'UPDATE `'.TABLE_PREFIX.'mod_form_fields` SET '
|
94 |
|
|
. '`title`=\''.$database->escapeString($title).'\', '
|
95 |
|
|
. '`type`=\''.$database->escapeString($type).'\', '
|
96 |
|
|
. '`required`=\''.$database->escapeString($required).'\', '
|
97 |
|
|
. '`extra`=\''.$database->escapeString($extra).'\', '
|
98 |
|
|
. '`value`=\''.$database->escapeString($value).'\' '
|
99 |
|
|
. 'WHERE field_id = '.(int)$field_id.' ';
|
100 |
|
|
if( $database->query($sql) ) {
|
101 |
|
|
$admin->print_success($TEXT['SUCCESS'], $backModuleUrl );
|
102 |
|
|
}else {
|
103 |
|
|
$admin->print_error($database->get_error(), $backModuleUrl );
|
104 |
|
|
}
|
105 |
|
|
// Print admin footer
|
106 |
|
|
$admin->print_footer();
|