Project

General

Profile

1
<?php
2

    
3
// $Id: modify.php 1074 2009-07-16 19:07:23Z Ruebenwurzel $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
/*
27
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
28
for his contributions to this module - adding extra field types
29
*/
30

    
31
// Must include code to stop this file being access directly
32
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
33

    
34
//Delete all form fields with no title
35
$database->query("DELETE FROM ".TABLE_PREFIX."mod_form_fields  WHERE page_id = '$page_id' and section_id = '$section_id' and title=''");
36

    
37
?>
38
<table cellpadding="0" cellspacing="0" border="0" width="100%">
39
<tr>
40
	<td align="left" width="33%">
41
		<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%;" />
42
	</td>
43
	<td align="right" width="33%">
44
		<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%;" />
45
	</td>
46
</tr>
47
</table>
48

    
49
<br />
50

    
51
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['FIELD']; ?></h2>
52
<?php
53

    
54
// Loop through existing fields
55
$query_fields = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_form_fields` WHERE section_id = '$section_id' ORDER BY position ASC");
56
if($query_fields->numRows() > 0) {
57
	$num_fields = $query_fields->numRows();
58
	$row = 'a';
59
	?>
60
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
61
	<?php
62
	while($field = $query_fields->fetchRow()) {
63
		?>
64
		<tr class="row_<?php echo $row; ?>">
65
			<td width="20" style="padding-left: 5px;">
66
				<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 $field['field_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
67
					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
68
				</a>
69
			</td>		
70
			<td>
71
				<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 $field['field_id']; ?>">
72
					<?php echo $field['title']; ?>
73
				</a>
74
			</td>
75
			<td width="175">
76
				<?php
77
				echo $TEXT['TYPE'].':';
78
				if($field['type'] == 'textfield') {
79
					echo $TEXT['SHORT_TEXT'];
80
				} elseif($field['type'] == 'textarea') {
81
					echo $TEXT['LONG_TEXT'];
82
				} elseif($field['type'] == 'heading') {
83
					echo $TEXT['HEADING'];
84
				} elseif($field['type'] == 'select') {
85
					echo $TEXT['SELECT_BOX'];
86
				} elseif($field['type'] == 'checkbox') {
87
					echo $TEXT['CHECKBOX_GROUP'];
88
				} elseif($field['type'] == 'radio') {
89
					echo $TEXT['RADIO_BUTTON_GROUP'];
90
				} elseif($field['type'] == 'email') {
91
					echo $TEXT['EMAIL_ADDRESS'];
92
				}
93
				?>
94
			</td>
95
			<td width="95">		
96
			<?php 
97
			if ($field['type'] != 'group_begin') {
98
				echo $TEXT['REQUIRED'].': '; if($field['required'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
99
			}
100
			?>
101
			</td>
102
			<td width="110">
103
			<?php
104
			if ($field['type'] == 'select') {
105
				$field['extra'] = explode(',',$field['extra']);
106
				echo $TEXT['MULTISELECT'].': '; if($field['extra'][1] == 'multiple') { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
107
			}
108
			?>
109
			</td>
110
			<td width="20">
111
			<?php if($field['position'] != 1) { ?>
112
				<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 $field['field_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
113
					<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
114
				</a>
115
			<?php } ?>
116
			</td>
117
			<td width="20">
118
			<?php if($field['position'] != $num_fields) { ?>
119
				<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 $field['field_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
120
					<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
121
				</a>
122
			<?php } ?>
123
			</td>
124
			<td width="20">
125
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/form/delete_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&field_id=<?php echo $field['field_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
126
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
127
				</a>
128
			</td>
129
		</tr>
130
		<?php
131
		// Alternate row color
132
		if($row == 'a') {
133
			$row = 'b';
134
		} else {
135
			$row = 'a';
136
		}
137
	}
138
	?>
139
	</table>
140
	<?php
141
} else {
142
	echo $TEXT['NONE_FOUND'];
143
}
144

    
145
?>
146

    
147
<br /><br />
148

    
149
<h2><?php echo $TEXT['SUBMISSIONS']; ?></h2>
150

    
151
<?php
152

    
153
// Query submissions table
154
$query_submissions = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_form_submissions` WHERE section_id = '$section_id' ORDER BY submitted_when ASC");
155
if($query_submissions->numRows() > 0) {
156
	?>
157
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
158
	<?php
159
	// List submissions
160
	$row = 'a';
161
	while($submission = $query_submissions->fetchRow()) {
162
		?>
163
		<tr class="row_<?php echo $row; ?>">
164
			<td width="20" style="padding-left: 5px;">
165
				<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 $submission['submission_id']; ?>" title="<?php echo $TEXT['OPEN']; ?>">
166
					<img src="<?php echo THEME_URL; ?>/images/folder_16.png" alt="<?php echo $TEXT['OPEN']; ?>" border="0" />
167
				</a>
168
			</td>
169
			<td width="237"><?php echo $TEXT['SUBMISSION_ID'].': '.$submission['submission_id']; ?></td>
170
			<td><?php echo $TEXT['SUBMITTED'].': '.gmdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']+TIMEZONE); ?></td>
171
			<td width="20">
172
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/form/delete_submission.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&submission_id=<?php echo $submission['submission_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
173
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
174
				</a>
175
			</td>
176
		</tr>
177
		<?php
178
		// Alternate row color
179
		if($row == 'a') {
180
			$row = 'b';
181
		} else {
182
			$row = 'a';
183
		}
184
	}
185
	?>
186
	</table>
187
	<?php
188
} else {
189
	echo $TEXT['NONE_FOUND'];
190
}
191

    
192
?>
(11-11/21)