1
|
<?php
|
2
|
/**
|
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: modify.php 1585 2012-01-19 21:55:45Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/tags/2.8.3/wb/modules/form/modify.php $
|
14
|
* @lastmodified $Date: 2012-01-19 22:55:45 +0100 (Thu, 19 Jan 2012) $
|
15
|
* @description
|
16
|
*/
|
17
|
|
18
|
// Must include code to stop this file being access directly
|
19
|
/* -------------------------------------------------------- */
|
20
|
if(defined('WB_PATH') == false)
|
21
|
{
|
22
|
// Stop this file being access directly
|
23
|
die('<head><title>Access denied</title></head><body><h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2></body></html>');
|
24
|
}
|
25
|
/* -------------------------------------------------------- */
|
26
|
|
27
|
//overwrite php.ini on Apache servers for valid SESSION ID Separator
|
28
|
if(function_exists('ini_set')) {
|
29
|
ini_set('arg_separator.output', '&');
|
30
|
}
|
31
|
|
32
|
// load module language file
|
33
|
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php';
|
34
|
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang );
|
35
|
|
36
|
include_once(WB_PATH.'/framework/functions.php');
|
37
|
|
38
|
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' );
|
39
|
|
40
|
//Delete all form fields with no title
|
41
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'mod_form_fields` ';
|
42
|
$sql .= 'WHERE page_id = '.(int)$page_id.' ';
|
43
|
$sql .= 'AND section_id = '.(int)$section_id.' ';
|
44
|
$sql .= 'AND title=\'\' ';
|
45
|
if( !$database->query($sql) ) {
|
46
|
// error msg
|
47
|
}
|
48
|
|
49
|
?>
|
50
|
<table summary="" width="100%" cellpadding="0" cellspacing="0" border="0">
|
51
|
<tr>
|
52
|
<td align="left" width="50%">
|
53
|
<input type="button" value="<?php echo $TEXT['ADD'].' '.$TEXT['FIELD']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/form/add_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
|
54
|
</td>
|
55
|
<td align="right" width="50%">
|
56
|
<input type="button" value="<?php echo $TEXT['SETTINGS']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/form/modify_settings.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
|
57
|
</td>
|
58
|
</tr>
|
59
|
</table>
|
60
|
|
61
|
<br />
|
62
|
|
63
|
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['FIELD']; ?></h2>
|
64
|
<?php
|
65
|
|
66
|
// Loop through existing fields
|
67
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_fields` ';
|
68
|
$sql .= 'WHERE `section_id` = '.(int)$section_id.' ';
|
69
|
$sql .= 'ORDER BY `position` ASC';
|
70
|
if($query_fields = $database->query($sql)) {
|
71
|
if($query_fields->numRows() > 0) {
|
72
|
$num_fields = $query_fields->numRows();
|
73
|
$row = 'a';
|
74
|
?>
|
75
|
<table summary="" width="100%" cellpadding="2" cellspacing="0" border="0">
|
76
|
<thead>
|
77
|
<tr style="background-color: #dddddd; font-weight: bold;">
|
78
|
<th width="20" style="padding-left: 5px;"> </th>
|
79
|
<th width="30" style="text-align: right;">ID</th>
|
80
|
<th width="400"><?php print $TEXT['FIELD']; ?></th>
|
81
|
<th width="175"><?php print $TEXT['TYPE']; ?></th>
|
82
|
<th width="100"><?php print $TEXT['REQUIRED']; ?></th>
|
83
|
<th width="175">
|
84
|
<?php
|
85
|
echo $TEXT['MULTISELECT'];
|
86
|
?>
|
87
|
</th>
|
88
|
<th width="175" colspan="3">
|
89
|
<?php
|
90
|
echo $TEXT['ACTIONS'];
|
91
|
?>
|
92
|
</th>
|
93
|
</tr>
|
94
|
</thead>
|
95
|
<tbody>
|
96
|
<?php
|
97
|
while($field = $query_fields->fetchRow(MYSQL_ASSOC)) {
|
98
|
?>
|
99
|
<tr class="row_<?php echo $row; ?>">
|
100
|
<td style="padding-left: 5px;">
|
101
|
<a href="<?php echo WB_URL; ?>/modules/form/modify_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $admin->getIDKEY($field['field_id']); ?>" title="<?php echo $TEXT['MODIFY']; ?>">
|
102
|
<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
|
103
|
</a>
|
104
|
</td>
|
105
|
<td style="text-align: right;">
|
106
|
<a href="<?php echo WB_URL; ?>/modules/form/modify_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $admin->getIDKEY($field['field_id']); ?>">
|
107
|
<?php echo $field['field_id']; ?>
|
108
|
</a>
|
109
|
</td>
|
110
|
<td>
|
111
|
<a href="<?php echo WB_URL; ?>/modules/form/modify_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $admin->getIDKEY($field['field_id']); ?>">
|
112
|
<?php echo $field['title']; ?>
|
113
|
</a>
|
114
|
</td>
|
115
|
<td>
|
116
|
<?php
|
117
|
if($field['type'] == 'textfield') {
|
118
|
echo $TEXT['SHORT_TEXT'];
|
119
|
} elseif($field['type'] == 'textarea') {
|
120
|
echo $TEXT['LONG_TEXT'];
|
121
|
} elseif($field['type'] == 'heading') {
|
122
|
echo $TEXT['HEADING'];
|
123
|
} elseif($field['type'] == 'select') {
|
124
|
echo $TEXT['SELECT_BOX'];
|
125
|
} elseif($field['type'] == 'checkbox') {
|
126
|
echo $TEXT['CHECKBOX_GROUP'];
|
127
|
} elseif($field['type'] == 'radio') {
|
128
|
echo $TEXT['RADIO_BUTTON_GROUP'];
|
129
|
} elseif($field['type'] == 'email') {
|
130
|
echo $TEXT['EMAIL_ADDRESS'];
|
131
|
}
|
132
|
?>
|
133
|
</td>
|
134
|
<td style="text-align: center;">
|
135
|
<?php
|
136
|
if ($field['type'] != 'group_begin') {
|
137
|
if($field['required'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
|
138
|
}
|
139
|
?>
|
140
|
</td>
|
141
|
<td>
|
142
|
<?php
|
143
|
if ($field['type'] == 'select') {
|
144
|
$field['extra'] = explode(',',$field['extra']);
|
145
|
if($field['extra'][1] == 'multiple') { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
|
146
|
}
|
147
|
?>
|
148
|
</td>
|
149
|
<td width="20" style="text-align: center;">
|
150
|
<?php if($field['position'] != 1) { ?>
|
151
|
<a href="<?php echo WB_URL; ?>/modules/form/move_up.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $admin->getIDKEY($field['field_id']); ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
|
152
|
<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
|
153
|
</a>
|
154
|
<?php } ?>
|
155
|
</td>
|
156
|
<td width="20" style="text-align: center;">
|
157
|
<?php if($field['position'] != $num_fields) { ?>
|
158
|
<a href="<?php echo WB_URL; ?>/modules/form/move_down.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $admin->getIDKEY($field['field_id']); ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
|
159
|
<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
|
160
|
</a>
|
161
|
<?php } ?>
|
162
|
</td>
|
163
|
<td width="20" style="text-align: center;">
|
164
|
<?php
|
165
|
$url = (WB_URL.'/modules/form/delete_field.php?page_id='.$page_id.'&section_id='.$section_id.'&field_id='.$admin->getIDKEY($field['field_id']))
|
166
|
?>
|
167
|
<a href="javascript: confirm_link('<?php echo url_encode($TEXT['ARE_YOU_SURE']); ?>', '<?php echo $url; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
|
168
|
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
|
169
|
</a>
|
170
|
</td>
|
171
|
</tr>
|
172
|
<?php
|
173
|
// Alternate row color
|
174
|
if($row == 'a') {
|
175
|
$row = 'b';
|
176
|
} else {
|
177
|
$row = 'a';
|
178
|
}
|
179
|
}
|
180
|
?>
|
181
|
</tbody>
|
182
|
</table>
|
183
|
<?php
|
184
|
} else {
|
185
|
echo $TEXT['NONE_FOUND'];
|
186
|
}
|
187
|
}
|
188
|
?>
|
189
|
|
190
|
<br /><br />
|
191
|
|
192
|
<h2><?php echo $TEXT['SUBMISSIONS']; ?></h2>
|
193
|
|
194
|
<?php
|
195
|
// Query submissions table
|
196
|
/*
|
197
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_submissions` ';
|
198
|
$sql .= 'WHERE `section_id` = '.(int)$section_id.' ';
|
199
|
$sql .= 'ORDER BY `submitted_when` ASC ';
|
200
|
*/
|
201
|
$sql = 'SELECT s.*, u.`display_name`, u.`email` ';
|
202
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_form_submissions` s ';
|
203
|
$sql .= 'LEFT OUTER JOIN `'.TABLE_PREFIX.'users` u ';
|
204
|
$sql .= 'ON u.`user_id` = s.`submitted_by` ';
|
205
|
$sql .= 'WHERE s.`section_id` = '.(int)$section_id.' ';
|
206
|
$sql .= 'ORDER BY s.`submitted_when` ASC ';
|
207
|
|
208
|
if($query_submissions = $database->query($sql)) {
|
209
|
?>
|
210
|
<!-- submissions -->
|
211
|
<table summary="" width="100%" cellpadding="2" cellspacing="0" border="0" class="" id="frm-ScrollTable" >
|
212
|
<thead>
|
213
|
<tr style="background-color: #dddddd; font-weight: bold;">
|
214
|
<th width="23" style="text-align: center;"> </th>
|
215
|
<th width="33" style="text-align: right;"> ID </th>
|
216
|
<th width="250" style="padding-left: 10px;"><?php echo $TEXT['SUBMITTED'] ?></th>
|
217
|
<th width="240" style="padding-left: 10px;"><?php echo $TEXT['USER']; ?></th>
|
218
|
<th width="250"><?php echo $TEXT['EMAIL'].' '.$MOD_FORM['FROM'] ?></th>
|
219
|
<th width="20"> </th>
|
220
|
<th width="20"> </th>
|
221
|
<th width="20"> </th>
|
222
|
<th width="20"> </th>
|
223
|
</tr>
|
224
|
</thead>
|
225
|
<tbody>
|
226
|
<?php
|
227
|
if($query_submissions->numRows() > 0) {
|
228
|
// List submissions
|
229
|
$row = 'a';
|
230
|
while($submission = $query_submissions->fetchRow(MYSQL_ASSOC)) {
|
231
|
$submission['display_name'] = (($submission['display_name']!=null) ? $submission['display_name'] : '');
|
232
|
$sBody = $submission['body'];
|
233
|
$regex = "/[a-z0-9\-_]?[a-z0-9.\-_]+[a-z0-9\-_]?@[a-z0-9.-]+\.[a-z]{2,}/iU";
|
234
|
preg_match ($regex, $sBody, $output);
|
235
|
$submission['email'] = $output['0'];
|
236
|
?>
|
237
|
<tr class="row_<?php echo $row; ?>">
|
238
|
<td width="20" style="padding-left: 5px;text-align: center;">
|
239
|
<a href="<?php echo WB_URL; ?>/modules/form/view_submission.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&submission_id=<?php echo $admin->getIDKEY($submission['submission_id']); ?>" title="<?php echo $TEXT['OPEN']; ?>">
|
240
|
<img src="<?php echo THEME_URL; ?>/images/folder_16.png" alt="<?php echo $TEXT['OPEN']; ?>" border="0" />
|
241
|
</a>
|
242
|
</td>
|
243
|
<td width="30" style="padding-right: 5px;text-align: right;"><?php echo $submission['submission_id']; ?></td>
|
244
|
<td width="250" style="padding-left: 10px;"><?php echo gmdate(DATE_FORMAT.', '.TIME_FORMAT, $submission['submitted_when']+TIMEZONE ); ?></td>
|
245
|
<td width="250" style="padding-left: 10px;"><?php echo $submission['display_name']; ?></td>
|
246
|
<td width="240"><?php echo $submission['email']; ?></td>
|
247
|
<td width="20" style="text-align: center;"> </td>
|
248
|
<td width="20"> </td>
|
249
|
<td width="20" style="text-align: center;">
|
250
|
<?php
|
251
|
$url = (WB_URL.'/modules/form/delete_submission.php?page_id='.$page_id.'&section_id='.$section_id.'&submission_id='.$admin->getIDKEY($submission['submission_id']))
|
252
|
?>
|
253
|
<a href="javascript: confirm_link('<?php echo url_encode($TEXT['ARE_YOU_SURE']); ?>', '<?php echo $url; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
|
254
|
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
|
255
|
</a>
|
256
|
</td>
|
257
|
<td width="20"> </td>
|
258
|
</tr>
|
259
|
<?php
|
260
|
// Alternate row color
|
261
|
if($row == 'a') {
|
262
|
$row = 'b';
|
263
|
} else {
|
264
|
$row = 'a';
|
265
|
}
|
266
|
}
|
267
|
} else {
|
268
|
?>
|
269
|
<tr><td><?php echo $TEXT['NONE_FOUND'] ?></td></tr>
|
270
|
<?php
|
271
|
}
|
272
|
?>
|
273
|
</tbody>
|
274
|
<tfoot>
|
275
|
<tr style="background-color: #dddddd; font-weight: bold;">
|
276
|
<th width="23" style="text-align: center;"> </th>
|
277
|
<th width="33" style="text-align: right;"> ID </th>
|
278
|
<th width="250" style="padding-left: 10px;"><?php echo $TEXT['SUBMITTED'] ?></th>
|
279
|
<th width="250" style="padding-left: 10px;"><?php echo $TEXT['USER']; ?></th>
|
280
|
<th width="250"><?php echo $TEXT['EMAIL'].' '.$MOD_FORM['FROM'] ?></th>
|
281
|
<th width="20"> </th>
|
282
|
<th width="20"> </th>
|
283
|
<th width="20"> </th>
|
284
|
<th width="20"> </th>
|
285
|
</tr>
|
286
|
</tfoot>
|
287
|
</table>
|
288
|
<?php
|
289
|
} else {
|
290
|
echo $database->get_error().'<br />';
|
291
|
echo $sql;
|
292
|
}
|