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 |
|
|
// Must include code to stop this file being access directly
|
19 |
1538
|
Luisehahne
|
/* -------------------------------------------------------- */
|
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 |
560
|
Ruebenwurz
|
|
27 |
1079
|
Ruebenwurz
|
//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 |
1582
|
Luisehahne
|
|
32 |
1584
|
Luisehahne
|
// 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 |
1553
|
Luisehahne
|
include_once(WB_PATH.'/framework/functions.php');
|
37 |
1079
|
Ruebenwurz
|
|
38 |
1553
|
Luisehahne
|
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' );
|
39 |
|
|
|
40 |
560
|
Ruebenwurz
|
//Delete all form fields with no title
|
41 |
1553
|
Luisehahne
|
$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 |
560
|
Ruebenwurz
|
|
49 |
|
|
?>
|
50 |
1585
|
Luisehahne
|
<table summary="" width="100%" cellpadding="0" cellspacing="0" border="0">
|
51 |
560
|
Ruebenwurz
|
<tr>
|
52 |
1585
|
Luisehahne
|
<td align="left" width="50%">
|
53 |
1079
|
Ruebenwurz
|
<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 |
560
|
Ruebenwurz
|
</td>
|
55 |
1585
|
Luisehahne
|
<td align="right" width="50%">
|
56 |
1079
|
Ruebenwurz
|
<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 |
560
|
Ruebenwurz
|
</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 |
1553
|
Luisehahne
|
$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 |
560
|
Ruebenwurz
|
?>
|
75 |
1584
|
Luisehahne
|
<table summary="" width="100%" cellpadding="2" cellspacing="0" border="0">
|
76 |
1582
|
Luisehahne
|
<thead>
|
77 |
1553
|
Luisehahne
|
<tr style="background-color: #dddddd; font-weight: bold;">
|
78 |
1582
|
Luisehahne
|
<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 |
560
|
Ruebenwurz
|
<?php
|
85 |
1553
|
Luisehahne
|
echo $TEXT['MULTISELECT'];
|
86 |
|
|
?>
|
87 |
1582
|
Luisehahne
|
</th>
|
88 |
|
|
<th width="175" colspan="3">
|
89 |
1553
|
Luisehahne
|
<?php
|
90 |
|
|
echo $TEXT['ACTIONS'];
|
91 |
|
|
?>
|
92 |
1582
|
Luisehahne
|
</th>
|
93 |
1553
|
Luisehahne
|
</tr>
|
94 |
1582
|
Luisehahne
|
</thead>
|
95 |
|
|
<tbody>
|
96 |
1553
|
Luisehahne
|
<?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 |
1582
|
Luisehahne
|
<td style="text-align: center;">
|
135 |
1553
|
Luisehahne
|
<?php
|
136 |
|
|
if ($field['type'] != 'group_begin') {
|
137 |
|
|
if($field['required'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
|
138 |
560
|
Ruebenwurz
|
}
|
139 |
|
|
?>
|
140 |
1553
|
Luisehahne
|
</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 |
1582
|
Luisehahne
|
<td width="20" style="text-align: center;">
|
150 |
1553
|
Luisehahne
|
<?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 |
1582
|
Luisehahne
|
<td width="20" style="text-align: center;">
|
157 |
1553
|
Luisehahne
|
<?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 |
1582
|
Luisehahne
|
<td width="20" style="text-align: center;">
|
164 |
1553
|
Luisehahne
|
<?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 |
1582
|
Luisehahne
|
?>
|
167 |
1553
|
Luisehahne
|
<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 |
1582
|
Luisehahne
|
<?php
|
173 |
1553
|
Luisehahne
|
// Alternate row color
|
174 |
|
|
if($row == 'a') {
|
175 |
|
|
$row = 'b';
|
176 |
|
|
} else {
|
177 |
|
|
$row = 'a';
|
178 |
560
|
Ruebenwurz
|
}
|
179 |
1553
|
Luisehahne
|
}
|
180 |
1582
|
Luisehahne
|
?>
|
181 |
|
|
</tbody>
|
182 |
1553
|
Luisehahne
|
</table>
|
183 |
560
|
Ruebenwurz
|
<?php
|
184 |
1553
|
Luisehahne
|
} else {
|
185 |
|
|
echo $TEXT['NONE_FOUND'];
|
186 |
560
|
Ruebenwurz
|
}
|
187 |
|
|
}
|
188 |
|
|
?>
|
189 |
|
|
|
190 |
|
|
<br /><br />
|
191 |
|
|
|
192 |
|
|
<h2><?php echo $TEXT['SUBMISSIONS']; ?></h2>
|
193 |
|
|
|
194 |
|
|
<?php
|
195 |
|
|
// Query submissions table
|
196 |
1582
|
Luisehahne
|
/*
|
197 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_submissions` ';
|
198 |
1553
|
Luisehahne
|
$sql .= 'WHERE `section_id` = '.(int)$section_id.' ';
|
199 |
|
|
$sql .= 'ORDER BY `submitted_when` ASC ';
|
200 |
1582
|
Luisehahne
|
*/
|
201 |
1584
|
Luisehahne
|
$sql = 'SELECT s.*, u.`display_name`, u.`email` ';
|
202 |
1582
|
Luisehahne
|
$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 |
1553
|
Luisehahne
|
if($query_submissions = $database->query($sql)) {
|
209 |
1582
|
Luisehahne
|
?>
|
210 |
|
|
<!-- submissions -->
|
211 |
1584
|
Luisehahne
|
<table summary="" width="100%" cellpadding="2" cellspacing="0" border="0" class="" id="frm-ScrollTable" >
|
212 |
1582
|
Luisehahne
|
<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 |
1584
|
Luisehahne
|
<th width="250"><?php echo $TEXT['EMAIL'].' '.$MOD_FORM['FROM'] ?></th>
|
219 |
1582
|
Luisehahne
|
<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 |
1553
|
Luisehahne
|
if($query_submissions->numRows() > 0) {
|
228 |
|
|
// List submissions
|
229 |
|
|
$row = 'a';
|
230 |
|
|
while($submission = $query_submissions->fetchRow(MYSQL_ASSOC)) {
|
231 |
1584
|
Luisehahne
|
$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 |
1582
|
Luisehahne
|
?>
|
237 |
1553
|
Luisehahne
|
<tr class="row_<?php echo $row; ?>">
|
238 |
1582
|
Luisehahne
|
<td width="20" style="padding-left: 5px;text-align: center;">
|
239 |
1553
|
Luisehahne
|
<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 |
1582
|
Luisehahne
|
<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 |
1584
|
Luisehahne
|
<td width="240"><?php echo $submission['email']; ?></td>
|
247 |
1582
|
Luisehahne
|
<td width="20" style="text-align: center;"> </td>
|
248 |
|
|
<td width="20"> </td>
|
249 |
|
|
<td width="20" style="text-align: center;">
|
250 |
1553
|
Luisehahne
|
<?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 |
1582
|
Luisehahne
|
?>
|
253 |
1553
|
Luisehahne
|
<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 |
1582
|
Luisehahne
|
<td width="20"> </td>
|
258 |
1553
|
Luisehahne
|
</tr>
|
259 |
1582
|
Luisehahne
|
<?php
|
260 |
1553
|
Luisehahne
|
// Alternate row color
|
261 |
|
|
if($row == 'a') {
|
262 |
|
|
$row = 'b';
|
263 |
|
|
} else {
|
264 |
|
|
$row = 'a';
|
265 |
|
|
}
|
266 |
560
|
Ruebenwurz
|
}
|
267 |
1553
|
Luisehahne
|
} else {
|
268 |
1582
|
Luisehahne
|
?>
|
269 |
|
|
<tr><td><?php echo $TEXT['NONE_FOUND'] ?></td></tr>
|
270 |
|
|
<?php
|
271 |
560
|
Ruebenwurz
|
}
|
272 |
1582
|
Luisehahne
|
?>
|
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 |
1584
|
Luisehahne
|
<th width="250"><?php echo $TEXT['EMAIL'].' '.$MOD_FORM['FROM'] ?></th>
|
281 |
1582
|
Luisehahne
|
<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 |
|
|
}
|