1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package Form
|
6
|
* @author 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: modify.php 2 2017-07-02 15:14:29Z Manuela $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/form/modify.php $
|
14
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
15
|
* @description
|
16
|
*/
|
17
|
/* -------------------------------------------------------- */
|
18
|
// Must include code to stop this file being accessed directly
|
19
|
if(defined('WB_PATH') == false) { die('Illegale file access /'.basename(__DIR__).'/'.basename(__FILE__).''); }
|
20
|
/* -------------------------------------------------------- */
|
21
|
|
22
|
//overwrite php.ini on Apache servers for valid SESSION ID Separator
|
23
|
$sQuerySep = ini_get('arg_separator.output');
|
24
|
//if(function_exists('ini_set')) {
|
25
|
// ini_set('arg_separator.output', '&');
|
26
|
//}
|
27
|
|
28
|
$sModulName = basename(__DIR__);
|
29
|
$sModulName = $sModulName;
|
30
|
$ModuleRel = '/modules/'.basename(__DIR__).'/';
|
31
|
$ModuleUrl = WB_URL.'/modules/'.basename(__DIR__).'/';
|
32
|
$ModulePath = WB_PATH.'/modules/'.basename(__DIR__).'/';
|
33
|
|
34
|
// load module language file
|
35
|
$sAddonName = basename(__DIR__);
|
36
|
require(__DIR__.'/languages/EN.php');
|
37
|
if(file_exists(__DIR__.'/languages/'.LANGUAGE .'.php')) {
|
38
|
require(__DIR__.'/languages/'.LANGUAGE .'.php');
|
39
|
}
|
40
|
|
41
|
if( !function_exists( 'make_dir' ) ) { require(WB_PATH.'/framework/functions.php'); }
|
42
|
|
43
|
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' );
|
44
|
|
45
|
//Delete all form fields with no title
|
46
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'mod_form_fields` ';
|
47
|
$sql .= 'WHERE page_id = '.(int)$page_id.' ';
|
48
|
$sql .= 'AND section_id = '.(int)$section_id.' ';
|
49
|
$sql .= 'AND title=\'\' ';
|
50
|
if( !$database->query($sql) ) {
|
51
|
// error msg
|
52
|
}
|
53
|
|
54
|
// later in upgrade.php
|
55
|
$table_name = TABLE_PREFIX.'mod_form_settings';
|
56
|
$field_name = 'perpage_submissions';
|
57
|
$description = "INT NOT NULL DEFAULT '10' AFTER `max_submissions`";
|
58
|
if(!$database->field_exists($table_name,$field_name)) {
|
59
|
$database->field_add($table_name, $field_name, $description);
|
60
|
}
|
61
|
$FTAN = $admin->getFTAN('');
|
62
|
|
63
|
?><table class="mod_form" style="width: 100%;">
|
64
|
<tbody>
|
65
|
<tr>
|
66
|
<td style="width: 33.336%;">
|
67
|
<form action="<?php echo $ModuleUrl; ?>add_field.php" method="post" class="mod_form" >
|
68
|
<input type="hidden" value="<?php echo $page_id; ?>" name="page_id">
|
69
|
<input type="hidden" value="<?php echo $section_id; ?>" name="section_id">
|
70
|
<input type="hidden" value="<?php echo $FTAN['value'];?>" name="<?php echo $FTAN['name'];?>">
|
71
|
<input type="submit" value="<?php echo $TEXT['ADD'].' '.$TEXT['FIELD']; ?>" class="btn btn-default w3-blue-wb w3-round-small w3-hover-green w3-medium w3-padding-4" style="width: 100%;" />
|
72
|
</form>
|
73
|
</td>
|
74
|
<td style="width: 33.336%;">
|
75
|
<form action="<?php echo $ModuleUrl; ?>modify_settings.php" method="post" class="mod_form" >
|
76
|
<input type="hidden" value="<?php echo $page_id; ?>" name="page_id">
|
77
|
<input type="hidden" value="<?php echo $section_id; ?>" name="section_id">
|
78
|
<input type="hidden" value="<?php echo $FTAN['value'];?>" name="<?php echo $FTAN['name'];?>">
|
79
|
<input type="submit" value="<?php echo $TEXT['SETTINGS']; ?>" class="btn btn-default w3-blue-wb w3-round-small w3-hover-green w3-medium w3-padding-4" style="width: 100%;" />
|
80
|
</form>
|
81
|
</td>
|
82
|
<?php if(@DEBUG && $admin->ami_group_member('1') ) { ?>
|
83
|
<td style="width: 33.336%;">
|
84
|
<form action="<?php echo WB_URL; ?>/modules/form/reorgPosition.php" method="post" class="mod_form" >
|
85
|
<input type="hidden" value="<?php echo $page_id; ?>" name="page_id">
|
86
|
<input type="hidden" value="<?php echo $section_id; ?>" name="section_id">
|
87
|
<input type="hidden" value="<?php echo $FTAN['value'];?>" name="<?php echo $FTAN['name'];?>">
|
88
|
<input type="submit" value="Reorg Position" class="btn btn-default w3-blue-wb w3-round-small w3-hover-green w3-medium w3-padding-4" style="width: 100%;" />
|
89
|
</form>
|
90
|
</td>
|
91
|
<?php } ?>
|
92
|
</tr>
|
93
|
</tbody>
|
94
|
</table>
|
95
|
<p id="tablecontent" ></p>
|
96
|
<br />
|
97
|
|
98
|
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['FIELD']; ?></h2>
|
99
|
<?php
|
100
|
|
101
|
// Loop through existing fields
|
102
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_fields` '
|
103
|
. 'WHERE `section_id` = '.(int)$section_id.' '
|
104
|
. 'ORDER BY `position` ASC';
|
105
|
if($oFields = $database->query($sql)) {
|
106
|
$num_fields = $oFields->numRows();
|
107
|
if($num_fields) {
|
108
|
?><div class="jsadmin hide"></div>
|
109
|
<table class="mod_form w3-table" id="tableData" >
|
110
|
<thead>
|
111
|
<tr class="w3-header-blue-wb">
|
112
|
<th style="padding-left: 5px; width: 3%;" > </th>
|
113
|
<th style="text-align: right; width: 3%;" >ID</th>
|
114
|
<th style=" width: 50%;" ><?php print $TEXT['FIELD']; ?></th>
|
115
|
<th style=" width: 20%;" ><?php print $TEXT['TYPE']; ?></th>
|
116
|
<th style=" width: 5%;" ><?php print $TEXT['REQUIRED']; ?></th>
|
117
|
<th style=" width: 5%;" >
|
118
|
<?php
|
119
|
echo $TEXT['MULTISELECT'];
|
120
|
?>
|
121
|
</th>
|
122
|
<th style=" width: 10%;" colspan="3" >
|
123
|
<?php
|
124
|
echo $TEXT['ACTIONS'];
|
125
|
?></th>
|
126
|
<th style=" width: 3%;" >POS</th>
|
127
|
</tr>
|
128
|
</thead>
|
129
|
<tbody>
|
130
|
<?php
|
131
|
while($aFields = $oFields->fetchRow(MYSQLI_ASSOC)) {
|
132
|
$sFielIdkey = $admin->getIDKEY($aFields['field_id']);
|
133
|
?><tr class=" sectionrow">
|
134
|
<td style="padding-left: 5px;">
|
135
|
<a href="<?php echo $ModuleUrl; ?>modify_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $sFielIdkey; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
|
136
|
<img src="<?php echo THEME_URL; ?>/images/modify_16.png" alt="^" />
|
137
|
</a>
|
138
|
</td>
|
139
|
<td style="text-align: right;">
|
140
|
<a style=" font-weight: normal;" href="<?php echo $ModuleUrl; ?>modify_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $sFielIdkey; ?>">
|
141
|
<?php echo $aFields['field_id']; ?>
|
142
|
</a>
|
143
|
</td>
|
144
|
<td>
|
145
|
<a href="<?php echo $ModuleUrl; ?>modify_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $sFielIdkey; ?>">
|
146
|
<?php echo $aFields['title']; ?>
|
147
|
</a>
|
148
|
</td>
|
149
|
<td>
|
150
|
<?php
|
151
|
$key = $aFields['type'];
|
152
|
switch ($key):
|
153
|
case 'textfield':
|
154
|
$sTitle = $TEXT['SHORT_TEXT'];
|
155
|
break;
|
156
|
case 'textarea':
|
157
|
$sTitle = $TEXT['LONG_TEXT'];
|
158
|
break;
|
159
|
case 'heading':
|
160
|
$sTitle = $TEXT['HEADING'];
|
161
|
break;
|
162
|
case 'select':
|
163
|
$sTitle = $TEXT['SELECT_BOX'];
|
164
|
break;
|
165
|
case 'checkbox':
|
166
|
$sTitle = $TEXT['CHECKBOX_GROUP'];
|
167
|
break;
|
168
|
case 'radio':
|
169
|
$sTitle = $TEXT['RADIO_BUTTON_GROUP'];
|
170
|
break;
|
171
|
case 'email':
|
172
|
$sTitle = $TEXT['EMAIL_ADDRESS'];
|
173
|
break;
|
174
|
default:
|
175
|
break;
|
176
|
endswitch;
|
177
|
echo $sTitle;
|
178
|
?></td>
|
179
|
<td style="text-align: center;">
|
180
|
<?php
|
181
|
if ($aFields['type'] != 'group_begin') {
|
182
|
if($aFields['required'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
|
183
|
}
|
184
|
?>
|
185
|
</td>
|
186
|
<td>
|
187
|
<?php
|
188
|
if ($aFields['type'] == 'select') {
|
189
|
$aFields['extra'] = explode(',',$aFields['extra']);
|
190
|
if($aFields['extra'][1] == 'multiple') { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
|
191
|
}
|
192
|
?>
|
193
|
</td>
|
194
|
<td style="text-align: center;">
|
195
|
<?php if($aFields['position'] != 1) { ?>
|
196
|
<a href="<?php echo $ModuleUrl; ?>move_up.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $sFielIdkey; ?>&move_id=<?php echo $aFields['field_id']; ?>&position=<?php echo $aFields['position']; ?>&module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
|
197
|
<img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="up" />
|
198
|
</a>
|
199
|
<?php } ?>
|
200
|
</td>
|
201
|
<td style="text-align: center;">
|
202
|
<?php if($aFields['position'] != $num_fields) { ?>
|
203
|
<a href="<?php echo $ModuleUrl; ?>move_down.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $sFielIdkey; ?>&move_id=<?php echo $aFields['field_id']; ?>&position=<?php echo $aFields['position']; ?>&module=<?php echo $sModulName; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
|
204
|
<img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="down" />
|
205
|
</a>
|
206
|
<?php } ?>
|
207
|
</td>
|
208
|
<td style="text-align: center;">
|
209
|
<?php
|
210
|
$url = ($ModuleUrl.'delete_field.php?page_id='.$page_id.'&section_id='.$section_id.'&field_id='.$sFielIdkey)
|
211
|
?>
|
212
|
<a href="javascript:confirm_link('<?php echo url_encode($TEXT['ARE_YOU_SURE']); ?>','<?php echo $url; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
|
213
|
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="X" />
|
214
|
</a>
|
215
|
</td>
|
216
|
<td style="text-align: right; padding-right: 5px;">
|
217
|
<?php
|
218
|
echo $aFields['position'];
|
219
|
if ( DEBUG ) {
|
220
|
}
|
221
|
?>
|
222
|
</td>
|
223
|
</tr>
|
224
|
<?php
|
225
|
// Alternate row color
|
226
|
}
|
227
|
?>
|
228
|
</tbody>
|
229
|
</table>
|
230
|
<?php
|
231
|
// include the required file for Javascript admin
|
232
|
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
|
233
|
{
|
234
|
// $js_buttonCell = 6;
|
235
|
include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
|
236
|
}
|
237
|
} else {
|
238
|
echo $TEXT['NONE_FOUND'];
|
239
|
}
|
240
|
}
|
241
|
?>
|
242
|
|
243
|
<br /><br />
|
244
|
|
245
|
<h2><?php echo $TEXT['SUBMISSIONS']; ?></h2>
|
246
|
|
247
|
<?php
|
248
|
// Query submissions table
|
249
|
/*
|
250
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_submissions` ';
|
251
|
$sql .= 'WHERE `section_id` = '.(int)$section_id.' ';
|
252
|
$sql .= 'ORDER BY `submitted_when` ASC ';
|
253
|
*/
|
254
|
$sql = 'SELECT s.*, u.`display_name`, u.`email` ';
|
255
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_form_submissions` s ';
|
256
|
$sql .= 'LEFT OUTER JOIN `'.TABLE_PREFIX.'users` u ';
|
257
|
$sql .= 'ON u.`user_id` = s.`submitted_by` ';
|
258
|
$sql .= 'WHERE s.`section_id` = '.(int)$section_id.' ';
|
259
|
$sql .= 'ORDER BY s.`submitted_when` DESC ';
|
260
|
|
261
|
if($oSubmissions = $database->query($sql)) {
|
262
|
?>
|
263
|
<!-- submissions -->
|
264
|
<div class="frm-ScrollTableDiv">
|
265
|
<table id="frm-ScrollTable" class=" w3-table">
|
266
|
<thead class="frm-Scroll w3-header-blue-wb">
|
267
|
<tr id="frm-Scroll" class="w3-header-blue-wb">
|
268
|
<th style="text-align: center; width: 3%;"> </th>
|
269
|
<th style="text-align: center; width: 3%;"> ID </th>
|
270
|
<th style=" width: 19%;"><?php echo $TEXT['SUBMITTED'] ?></th>
|
271
|
<th style=" width: 19%;"><?php echo $TEXT['USER']; ?></th>
|
272
|
<th style=" width: 10%;"><?php echo $TEXT['EMAIL'].' '.$MOD_FORM['FROM'] ?></th>
|
273
|
<th style="text-align: center; width: 5%;"> </th>
|
274
|
<th style="text-align: center; width: 5%;"> </th>
|
275
|
<th style="text-align: center; width: 3%;"> </th>
|
276
|
<th style="text-align: center; width: 3%;"> </th>
|
277
|
</tr>
|
278
|
</thead>
|
279
|
<tfoot>
|
280
|
<tr class="w3-header-blue-wb"><td colspan="9"></td></tr>
|
281
|
</tfoot>
|
282
|
<tbody class="scrolling">
|
283
|
<?php
|
284
|
if($oSubmissions->numRows() > 0) {
|
285
|
// List submissions
|
286
|
$emailUser = (function ($userid=0) use ($database)
|
287
|
{
|
288
|
$retval = '';
|
289
|
if ($userid!='0') {
|
290
|
$sql = 'SELECT `email` FROM `'.TABLE_PREFIX.'users` '
|
291
|
. 'WHERE `user_id`=\' '.$userid.'\' ';
|
292
|
$retval = $database->get_one($sql);
|
293
|
}
|
294
|
return $retval;
|
295
|
});
|
296
|
while($submission = $oSubmissions->fetchRow(MYSQLI_ASSOC)) {
|
297
|
$submission['display_name'] = (($submission['display_name']!=null) ? $submission['display_name'] : $TEXT['GUEST']);
|
298
|
$sBody = $submission['body'];
|
299
|
$submission['email'] = $emailUser($submission['submitted_by']);
|
300
|
if ($submission['email']==''){
|
301
|
$regex = "/[a-z0-9\-_]?[a-z0-9.\-_]+[a-z0-9\-_]?@[a-z0-9.-]+\.[a-z]{2,}/i";
|
302
|
preg_match ($regex, $sBody, $output);
|
303
|
// workout if output is empty
|
304
|
$submission['email'] = (isset($output['0']) ? $output['0'] : '');
|
305
|
}
|
306
|
$sSubmissionIdkey = $admin->getIDKEY($submission['submission_id']);
|
307
|
?>
|
308
|
<tr class="frm-Scroll" >
|
309
|
<td class="frm-Scroll" style="text-align: center; width: 3%;">
|
310
|
<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 $sSubmissionIdkey; ?>" title="<?php echo $TEXT['OPEN']; ?>">
|
311
|
<img src="<?php echo THEME_URL; ?>/images/folder_16.png" alt="<?php echo $TEXT['OPEN']; ?>" />
|
312
|
</a>
|
313
|
</td>
|
314
|
<td class="frm-Scroll" style="padding-right: 15px;text-align: right; width: 3%; font-weight: normal;"><?php echo $submission['submission_id']; ?></td>
|
315
|
<td class="frm-Scroll" style=" width: 16%;"><?php echo gmdate(DATE_FORMAT.', '.TIME_FORMAT, $submission['submitted_when']+TIMEZONE ); ?></td>
|
316
|
<td class="frm-Scroll" style=" width: 33%;"><?php echo $submission['display_name']; ?></td>
|
317
|
<td class="frm-Scroll" style=" width: 30%;" ><?php echo $submission['email']; ?></td>
|
318
|
<td class="frm-Scroll" style="text-align: center; width: 5%;"> </td>
|
319
|
<td class="frm-Scroll" style=" width: 5%;" > </td>
|
320
|
<td class="frm-Scroll" style="text-align: center; width: 5%;">
|
321
|
<?php
|
322
|
$url = (WB_URL.'/modules/form/delete_submission.php?page_id='.$page_id.'&section_id='.$section_id.'&submission_id='.$sSubmissionIdkey)
|
323
|
?>
|
324
|
<a href="javascript:confirm_link('<?php echo url_encode($TEXT['ARE_YOU_SURE']); ?>', '<?php echo $url; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
|
325
|
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="X" />
|
326
|
</a>
|
327
|
</td>
|
328
|
<?php
|
329
|
if ( DEBUG ) { ?>
|
330
|
<td class="frm-Scroll" style=" width: 3%;" ><?php echo $sSubmissionIdkey; ?></td>
|
331
|
<?php } else { ?>
|
332
|
<td class="frm-Scroll" style=" width: 3%;" > </td>
|
333
|
<?php } ?>
|
334
|
|
335
|
</tr>
|
336
|
<?php
|
337
|
}
|
338
|
} else {
|
339
|
?>
|
340
|
<tr><td colspan="8"><?php echo $TEXT['NONE_FOUND'] ?></td></tr>
|
341
|
<?php
|
342
|
}
|
343
|
?>
|
344
|
</tbody>
|
345
|
</table><br />
|
346
|
</div>
|
347
|
<?php
|
348
|
} else {
|
349
|
echo $database->get_error().'<br />';
|
350
|
echo $sql;
|
351
|
}
|