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 1582 2012-01-19 03:07:05Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/form/modify.php $
14
 * @lastmodified    $Date: 2012-01-19 04:07:05 +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', '&amp;');
30
}
31

    
32
include_once(WB_PATH.'/framework/functions.php');
33

    
34
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? '#'.SEC_ANCHOR.$section['section_id'] : '' );
35

    
36
//Delete all form fields with no title
37
$sql  = 'DELETE FROM `'.TABLE_PREFIX.'mod_form_fields` ';
38
$sql .= 'WHERE page_id = '.(int)$page_id.' ';
39
$sql .=   'AND section_id = '.(int)$section_id.' ';
40
$sql .=   'AND title=\'\' ';
41
if( !$database->query($sql) ) {
42
// error msg
43
}
44

    
45
?>
46
<table summary="" cellpadding="0" cellspacing="0" border="0" width="916">
47
<tr>
48
	<td align="left" width="33%">
49
		<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%;" />
50
	</td>
51
	<td align="right" width="33%">
52
		<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%;" />
53
	</td>
54
</tr>
55
</table>
56

    
57
<br />
58

    
59
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['FIELD']; ?></h2>
60
<?php
61

    
62
// Loop through existing fields
63
$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_fields` ';
64
$sql .= 'WHERE `section_id` = '.(int)$section_id.' ';
65
$sql .= 'ORDER BY `position` ASC';
66
if($query_fields = $database->query($sql)) {
67
	if($query_fields->numRows() > 0) {
68
		$num_fields = $query_fields->numRows();
69
		$row = 'a';
70
		?>
71
		<table summary="" cellpadding="2" cellspacing="0" border="0">
72
		<thead>
73
			<tr style="background-color: #dddddd; font-weight: bold;">
74
				<th width="20" style="padding-left: 5px;">&nbsp;</th>
75
				<th width="30" style="text-align: right;">ID</th>
76
				<th width="400"><?php print $TEXT['FIELD']; ?></th>
77
				<th width="175"><?php print $TEXT['TYPE']; ?></th>
78
				<th width="100"><?php print $TEXT['REQUIRED']; ?></th>
79
				<th width="175">
80
				<?php
81
					echo $TEXT['MULTISELECT'];
82
				?>
83
				</th>
84
				<th width="175" colspan="3">
85
				<?php
86
					echo $TEXT['ACTIONS'];
87
				?>
88
				</th>
89
			</tr>
90
		</thead>
91
		<tbody>
92
		<?php
93
		while($field = $query_fields->fetchRow(MYSQL_ASSOC)) {
94
			?>
95
			<tr class="row_<?php echo $row; ?>">
96
				<td style="padding-left: 5px;">
97
					<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']; ?>">
98
						<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
99
					</a>
100
				</td>
101
				<td style="text-align: right;">
102
					<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']); ?>">
103
						<?php echo $field['field_id']; ?>
104
					</a>
105
				</td>
106
				<td>
107
					<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']); ?>">
108
						<?php echo $field['title']; ?>
109
					</a>
110
				</td>
111
				<td>
112
					<?php
113
					if($field['type'] == 'textfield') {
114
						echo $TEXT['SHORT_TEXT'];
115
					} elseif($field['type'] == 'textarea') {
116
						echo $TEXT['LONG_TEXT'];
117
					} elseif($field['type'] == 'heading') {
118
						echo $TEXT['HEADING'];
119
					} elseif($field['type'] == 'select') {
120
						echo $TEXT['SELECT_BOX'];
121
					} elseif($field['type'] == 'checkbox') {
122
						echo $TEXT['CHECKBOX_GROUP'];
123
					} elseif($field['type'] == 'radio') {
124
						echo $TEXT['RADIO_BUTTON_GROUP'];
125
					} elseif($field['type'] == 'email') {
126
						echo $TEXT['EMAIL_ADDRESS'];
127
					}
128
					?>
129
				</td>
130
				<td style="text-align: center;">
131
				<?php
132
				if ($field['type'] != 'group_begin') {
133
					if($field['required'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
134
				}
135
				?>
136
				</td>
137
				<td>
138
				<?php
139
				if ($field['type'] == 'select') {
140
					$field['extra'] = explode(',',$field['extra']);
141
					 if($field['extra'][1] == 'multiple') { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
142
				}
143
				?>
144
				</td>
145
				<td width="20" style="text-align: center;">
146
				<?php if($field['position'] != 1) { ?>
147
					<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']; ?>">
148
						<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
149
					</a>
150
				<?php } ?>
151
				</td>
152
				<td width="20" style="text-align: center;">
153
				<?php if($field['position'] != $num_fields) { ?>
154
					<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']; ?>">
155
						<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
156
					</a>
157
				<?php } ?>
158
				</td>
159
				<td width="20" style="text-align: center;">
160
<?php
161
				$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']))
162
?>
163
					<a href="javascript: confirm_link('<?php echo url_encode($TEXT['ARE_YOU_SURE']); ?>', '<?php echo $url; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
164
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
165
					</a>
166
				</td>
167
			</tr>
168
<?php
169
			// Alternate row color
170
			if($row == 'a') {
171
				$row = 'b';
172
			} else {
173
				$row = 'a';
174
			}
175
		}
176
?>
177
		</tbody>
178
		</table>
179
		<?php
180
	} else {
181
		echo $TEXT['NONE_FOUND'];
182
	}
183
}
184
?>
185

    
186
<br /><br />
187

    
188
<h2><?php echo $TEXT['SUBMISSIONS']; ?></h2>
189

    
190
<?php
191
// Query submissions table
192
/*
193
$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_submissions`  ';
194
$sql .= 'WHERE `section_id` = '.(int)$section_id.' ';
195
$sql .= 'ORDER BY `submitted_when` ASC ';
196
*/
197
$sql  = 'SELECT s.*, u.`display_name` ';
198
$sql .=            'FROM `'.TABLE_PREFIX.'mod_form_submissions` s ';
199
$sql .= 'LEFT OUTER JOIN `'.TABLE_PREFIX.'users` u ';
200
$sql .= 'ON u.`user_id` = s.`submitted_by` ';
201
$sql .= 'WHERE s.`section_id` = '.(int)$section_id.' ';
202
$sql .= 'ORDER BY s.`submitted_when` ASC ';
203

    
204
if($query_submissions = $database->query($sql)) {
205
?>
206
<!-- submissions -->
207
		<table summary="" cellpadding="2" cellspacing="0" border="0" class="" id="frm-ScrollTable" >
208
		<thead>
209
		<tr style="background-color: #dddddd; font-weight: bold;">
210
			<th width="23" style="text-align: center;">&nbsp;</th>
211
			<th width="33" style="text-align: right;"> ID </th>
212
			<th width="250" style="padding-left: 10px;"><?php echo $TEXT['SUBMITTED'] ?></th>
213
			<th width="240" style="padding-left: 10px;"><?php echo $TEXT['USER']; ?></th>
214
			<th width="250">&nbsp;</th>
215
			<th width="20">&nbsp;</th>
216
			<th width="20">&nbsp;</th>
217
			<th width="20">&nbsp;</th>
218
			<th width="20">&nbsp;</th>
219
		</tr>
220
		</thead>
221
		<tbody>
222
<?php
223
	if($query_submissions->numRows() > 0) {
224
		// List submissions
225
		$row = 'a';
226
		while($submission = $query_submissions->fetchRow(MYSQL_ASSOC)) {
227
        $submission['display_name'] = (($submission['display_name']!=null) ? $submission['display_name'] : $TEXT['UNKNOWN']);
228
?>
229
			<tr class="row_<?php echo $row; ?>">
230
				<td width="20" style="padding-left: 5px;text-align: center;">
231
					<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']; ?>">
232
						<img src="<?php echo THEME_URL; ?>/images/folder_16.png" alt="<?php echo $TEXT['OPEN']; ?>" border="0" />
233
					</a>
234
				</td>
235
				<td width="30" style="padding-right: 5px;text-align: right;"><?php echo $submission['submission_id']; ?></td>
236
				<td width="250" style="padding-left: 10px;"><?php echo gmdate(DATE_FORMAT.', '.TIME_FORMAT, $submission['submitted_when']+TIMEZONE ); ?></td>
237
				<td width="250" style="padding-left: 10px;"><?php echo $submission['display_name']; ?></td>
238
				<td width="240">&nbsp;</td>
239
				<td width="20" style="text-align: center;">&nbsp;</td>
240
				<td width="20">&nbsp;</td>
241
				<td width="20" style="text-align: center;">
242
<?php
243
				$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']))
244
?>
245
					<a href="javascript: confirm_link('<?php echo url_encode($TEXT['ARE_YOU_SURE']); ?>', '<?php echo $url; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
246
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
247
					</a>
248
				</td>
249
				<td width="20">&nbsp;</td>
250
			</tr>
251
<?php
252
			// Alternate row color
253
			if($row == 'a') {
254
				$row = 'b';
255
			} else {
256
				$row = 'a';
257
			}
258
		}
259
	} else {
260
?>
261
<tr><td><?php echo $TEXT['NONE_FOUND'] ?></td></tr>
262
<?php
263
	}
264
?>
265
		</tbody>
266
		<tfoot>
267
		<tr style="background-color: #dddddd; font-weight: bold;">
268
			<th width="23" style="text-align: center;">&nbsp;</th>
269
			<th width="33" style="text-align: right;"> ID </th>
270
			<th width="250" style="padding-left: 10px;"><?php echo $TEXT['SUBMITTED'] ?></th>
271
			<th width="250" style="padding-left: 10px;"><?php echo $TEXT['USER']; ?></th>
272
			<th width="250">&nbsp;</th>
273
			<th width="20">&nbsp;</th>
274
			<th width="20">&nbsp;</th>
275
			<th width="20">&nbsp;</th>
276
			<th width="20">&nbsp;</th>
277
		</tr>
278
		</tfoot>
279
		</table>
280
<?php
281
} else {
282
	echo $database->get_error().'<br />';
283
	echo $sql;
284
}
285
?>
286
<script type="text/javascript">
287
var t = new ScrollableTable(document.getElementById('frm-ScrollTable'), 30, 916);
288
</script>
(13-13/25)