Project

General

Profile

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 1655 2012-03-31 23:41:19Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/form/modify.php $
14
 * @lastmodified    $Date: 2012-04-01 01:41:19 +0200 (Sun, 01 Apr 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', '&amp;');
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; ?>&amp;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; ?>&amp;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;">&nbsp;</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; ?>&amp;section_id=<?php echo $section_id; ?>&amp;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; ?>&amp;section_id=<?php echo $section_id; ?>&amp;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; ?>&amp;section_id=<?php echo $section_id; ?>&amp;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; ?>&amp;section_id=<?php echo $section_id; ?>&amp;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; ?>&amp;section_id=<?php echo $section_id; ?>&amp;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.'&amp;section_id='.$section_id.'&amp;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;">&nbsp;</th>
215
			<th width="33" style="text-align: right;"> ID </th>
216
			<th width="200" style="padding-left: 10px;"><?php echo $TEXT['SUBMITTED'] ?></th>
217
			<th width="200" style="padding-left: 10px;"><?php echo $TEXT['USER']; ?></th>
218
			<th width="350"><?php echo $TEXT['EMAIL'].' '.$MOD_FORM['FROM'] ?></th>
219
			<th width="20">&nbsp;</th>
220
			<th width="20">&nbsp;</th>
221
			<th width="20">&nbsp;</th>
222
			<th width="20">&nbsp;</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
// workout if output is empty
236
			$submission['email'] = (isset($output['0']) ? $output['0'] : '');
237
?>
238
			<tr class="row_<?php echo $row; ?>">
239
				<td width="20" style="padding-left: 5px;text-align: center;">
240
					<a href="<?php echo WB_URL; ?>/modules/form/view_submission.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;submission_id=<?php echo $admin->getIDKEY($submission['submission_id']); ?>" title="<?php echo $TEXT['OPEN']; ?>">
241
						<img src="<?php echo THEME_URL; ?>/images/folder_16.png" alt="<?php echo $TEXT['OPEN']; ?>" border="0" />
242
					</a>
243
				</td>
244
				<td width="30" style="padding-right: 5px;text-align: right;"><?php echo $submission['submission_id']; ?></td>
245
				<td width="200" style="padding-left: 10px;"><?php echo gmdate(DATE_FORMAT.', '.TIME_FORMAT, $submission['submitted_when']+TIMEZONE ); ?></td>
246
				<td width="200" style="padding-left: 10px;"><?php echo $submission['display_name']; ?></td>
247
				<td width="350"><?php echo $submission['email']; ?></td>
248
				<td width="20" style="text-align: center;">&nbsp;</td>
249
				<td width="20">&nbsp;</td>
250
				<td width="20" style="text-align: center;">
251
<?php
252
				$url = (WB_URL.'/modules/form/delete_submission.php?page_id='.$page_id.'&amp;section_id='.$section_id.'&amp;submission_id='.$admin->getIDKEY($submission['submission_id']))
253
?>
254
					<a href="javascript: confirm_link('<?php echo url_encode($TEXT['ARE_YOU_SURE']); ?>', '<?php echo $url; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
255
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
256
					</a>
257
				</td>
258
				<td width="20">&nbsp;</td>
259
			</tr>
260
<?php
261
			// Alternate row color
262
			if($row == 'a') {
263
				$row = 'b';
264
			} else {
265
				$row = 'a';
266
			}
267
		}
268
	} else {
269
?>
270
<tr><td colspan="8"><?php echo $TEXT['NONE_FOUND'] ?></td></tr>
271
<?php
272
	}
273
?>
274
		</tbody>
275
		<tfoot>
276
		<tr style="background-color: #dddddd; font-weight: bold;">
277
			<th width="23" style="text-align: center;">&nbsp;</th>
278
			<th width="33" style="text-align: right;"> ID </th>
279
			<th width="200" style="padding-left: 10px;"><?php echo $TEXT['SUBMITTED'] ?></th>
280
			<th width="200" style="padding-left: 10px;"><?php echo $TEXT['USER']; ?></th>
281
			<th width="350"><?php echo $TEXT['EMAIL'].' '.$MOD_FORM['FROM'] ?></th>
282
			<th width="20">&nbsp;</th>
283
			<th width="20">&nbsp;</th>
284
			<th width="20">&nbsp;</th>
285
			<th width="20">&nbsp;</th>
286
		</tr>
287
		</tfoot>
288
		</table>
289
<?php
290
} else {
291
	echo $database->get_error().'<br />';
292
	echo $sql;
293
}
(12-12/24)