1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package Form
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2009-2012, WebsiteBaker 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 1772 2012-09-27 23:31:16Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/form/modify.php $
|
14
|
* @lastmodified $Date: 2012-09-28 01:31:16 +0200 (Fri, 28 Sep 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('<h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2>');
|
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', '&');
|
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'] : 'section_'.$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
|
// later in upgrade.php
|
50
|
$table_name = TABLE_PREFIX.'mod_form_settings';
|
51
|
$field_name = 'perpage_submissions';
|
52
|
$description = "INT NOT NULL DEFAULT '10' AFTER `max_submissions`";
|
53
|
if(!$database->field_exists($table_name,$field_name)) {
|
54
|
$database->field_add($table_name, $field_name, $description);
|
55
|
}
|
56
|
?>
|
57
|
<table summary="" width="100%" cellpadding="0" cellspacing="0" border="0">
|
58
|
<tr>
|
59
|
<td align="left" width="50%">
|
60
|
<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%;" />
|
61
|
</td>
|
62
|
<td align="right" width="50%">
|
63
|
<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%;" />
|
64
|
</td>
|
65
|
</tr>
|
66
|
</table>
|
67
|
|
68
|
<br />
|
69
|
|
70
|
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['FIELD']; ?></h2>
|
71
|
<?php
|
72
|
|
73
|
// Loop through existing fields
|
74
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_fields` ';
|
75
|
$sql .= 'WHERE `section_id` = '.(int)$section_id.' ';
|
76
|
$sql .= 'ORDER BY `position` ASC';
|
77
|
if($query_fields = $database->query($sql)) {
|
78
|
if($query_fields->numRows() > 0) {
|
79
|
$num_fields = $query_fields->numRows();
|
80
|
$row = 'a';
|
81
|
?>
|
82
|
<table summary="" width="100%" cellpadding="2" cellspacing="0" border="0">
|
83
|
<thead>
|
84
|
<tr style="background-color: #dddddd; font-weight: bold;">
|
85
|
<th width="20" style="padding-left: 5px;"> </th>
|
86
|
<th width="30" style="text-align: right;">ID</th>
|
87
|
<th width="400"><?php print $TEXT['FIELD']; ?></th>
|
88
|
<th width="175"><?php print $TEXT['TYPE']; ?></th>
|
89
|
<th width="100"><?php print $TEXT['REQUIRED']; ?></th>
|
90
|
<th width="175">
|
91
|
<?php
|
92
|
echo $TEXT['MULTISELECT'];
|
93
|
?>
|
94
|
</th>
|
95
|
<th width="175" colspan="3">
|
96
|
<?php
|
97
|
echo $TEXT['ACTIONS'];
|
98
|
?>
|
99
|
</th>
|
100
|
</tr>
|
101
|
</thead>
|
102
|
<tbody>
|
103
|
<?php
|
104
|
while($field = $query_fields->fetchRow(MYSQL_ASSOC)) {
|
105
|
?>
|
106
|
<tr class="row_<?php echo $row; ?>">
|
107
|
<td style="padding-left: 5px;">
|
108
|
<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']; ?>">
|
109
|
<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
|
110
|
</a>
|
111
|
</td>
|
112
|
<td style="text-align: right;">
|
113
|
<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']); ?>">
|
114
|
<?php echo $field['field_id']; ?>
|
115
|
</a>
|
116
|
</td>
|
117
|
<td>
|
118
|
<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']); ?>">
|
119
|
<?php echo $field['title']; ?>
|
120
|
</a>
|
121
|
</td>
|
122
|
<td>
|
123
|
<?php
|
124
|
if($field['type'] == 'textfield') {
|
125
|
echo $TEXT['SHORT_TEXT'];
|
126
|
} elseif($field['type'] == 'textarea') {
|
127
|
echo $TEXT['LONG_TEXT'];
|
128
|
} elseif($field['type'] == 'heading') {
|
129
|
echo $TEXT['HEADING'];
|
130
|
} elseif($field['type'] == 'select') {
|
131
|
echo $TEXT['SELECT_BOX'];
|
132
|
} elseif($field['type'] == 'checkbox') {
|
133
|
echo $TEXT['CHECKBOX_GROUP'];
|
134
|
} elseif($field['type'] == 'radio') {
|
135
|
echo $TEXT['RADIO_BUTTON_GROUP'];
|
136
|
} elseif($field['type'] == 'email') {
|
137
|
echo $TEXT['EMAIL_ADDRESS'];
|
138
|
}
|
139
|
?>
|
140
|
</td>
|
141
|
<td style="text-align: center;">
|
142
|
<?php
|
143
|
if ($field['type'] != 'group_begin') {
|
144
|
if($field['required'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
|
145
|
}
|
146
|
?>
|
147
|
</td>
|
148
|
<td>
|
149
|
<?php
|
150
|
if ($field['type'] == 'select') {
|
151
|
$field['extra'] = explode(',',$field['extra']);
|
152
|
if($field['extra'][1] == 'multiple') { echo $TEXT['YES']; } else { echo $TEXT['NO']; }
|
153
|
}
|
154
|
?>
|
155
|
</td>
|
156
|
<td width="20" style="text-align: center;">
|
157
|
<?php if($field['position'] != 1) { ?>
|
158
|
<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']; ?>">
|
159
|
<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
|
160
|
</a>
|
161
|
<?php } ?>
|
162
|
</td>
|
163
|
<td width="20" style="text-align: center;">
|
164
|
<?php if($field['position'] != $num_fields) { ?>
|
165
|
<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']; ?>">
|
166
|
<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
|
167
|
</a>
|
168
|
<?php } ?>
|
169
|
</td>
|
170
|
<td width="20" style="text-align: center;">
|
171
|
<?php
|
172
|
$url = (WB_URL.'/modules/form/delete_field.php?page_id='.$page_id.'&section_id='.$section_id.'&field_id='.$admin->getIDKEY($field['field_id']))
|
173
|
?>
|
174
|
<a href="javascript:confirm_link('<?php echo url_encode($TEXT['ARE_YOU_SURE']); ?>','<?php echo $url; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
|
175
|
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
|
176
|
</a>
|
177
|
</td>
|
178
|
</tr>
|
179
|
<?php
|
180
|
// Alternate row color
|
181
|
if($row == 'a') {
|
182
|
$row = 'b';
|
183
|
} else {
|
184
|
$row = 'a';
|
185
|
}
|
186
|
}
|
187
|
?>
|
188
|
</tbody>
|
189
|
</table>
|
190
|
<?php
|
191
|
} else {
|
192
|
echo $TEXT['NONE_FOUND'];
|
193
|
}
|
194
|
}
|
195
|
// Query overview submissions table
|
196
|
/*
|
197
|
*/
|
198
|
$sql = 'SELECT `perpage_submissions` FROM `'.TABLE_PREFIX.'mod_form_settings` ';
|
199
|
$sql .= 'WHERE `section_id` = '.(int)$section_id.' ';
|
200
|
//$sql .= 'ORDER BY `submitted_when` ASC ';
|
201
|
$limit = $database->get_one($sql);
|
202
|
|
203
|
$page = 1;
|
204
|
if(isset($_GET['page']) && is_numeric(trim($_GET['page'])))
|
205
|
{
|
206
|
$page = intval(mysql_real_escape_string($_GET['page']));
|
207
|
}
|
208
|
|
209
|
// How many adjacent pages should be shown on each side?
|
210
|
$adjacents = 1;
|
211
|
|
212
|
$startrow = ($page * $limit) - ($limit);
|
213
|
|
214
|
$sql = 'SELECT s.*, u.`display_name`, u.`email` ';
|
215
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_form_submissions` s ';
|
216
|
$sql .= 'LEFT OUTER JOIN `'.TABLE_PREFIX.'users` u ';
|
217
|
$sql .= 'ON u.`user_id` = s.`submitted_by` ';
|
218
|
$sql .= 'WHERE s.`section_id` = '.(int)$section_id.' ';
|
219
|
$sql .= 'ORDER BY s.`submitted_when` DESC ';
|
220
|
//$sql .= "LIMIT $startrow,$limit ";
|
221
|
|
222
|
if($query_submissions = $database->query($sql)) {
|
223
|
$totalrows = $query_submissions->numRows();
|
224
|
|
225
|
// set template file and assign module and template block
|
226
|
$oTpl = new Template(dirname(__FILE__).'/htt','keep');
|
227
|
$oTpl->set_file('page', 'OverviewSubmission.htt');
|
228
|
$oTpl->debug = false; // false, true
|
229
|
$oTpl->set_block('page', 'main_block', 'main');
|
230
|
// generell vars
|
231
|
$oTpl->set_var(array(
|
232
|
'TEXT_SUBMISSIONS' => $TEXT['SUBMISSIONS'],
|
233
|
'WB_URL' => WB_URL,
|
234
|
'THEME_URL' => THEME_URL,
|
235
|
'MESSAGE_VALUE' => '',
|
236
|
'PAGINATION' => '',
|
237
|
'PAGE_ID' => $page_id,
|
238
|
'SECTION_ID' => $section_id,
|
239
|
'TEXT_SUBMITTED' => $TEXT['SUBMITTED'],
|
240
|
'TEXT_USER' => $TEXT['USER'],
|
241
|
'TEXT_EMAIL' => $TEXT['EMAIL'],
|
242
|
'MOD_FORM_FROM' => $MOD_FORM['FROM'],
|
243
|
'TEXT_NONE_FOUND' => '',
|
244
|
'SUBMISSION_ID' => '',
|
245
|
'SUBMISSION_CREATE_WHEN' => '',
|
246
|
'SUBMISSION_BY' => '',
|
247
|
'SUBMISSION_EMAIL' => '',
|
248
|
'loop_submmission' => '',
|
249
|
)
|
250
|
);
|
251
|
|
252
|
// $oTpl->set_block('main_block', 'language_list_block', 'language_list');
|
253
|
$oTpl->set_block('main_block', 'loop_submmission_block', 'loop_submmission');
|
254
|
if($query_submissions->numRows() > 0) {
|
255
|
//print '<pre style="text-align: left;"><strong>function '.__FUNCTION__.'( '.''.' );</strong> basename: '.basename(__FILE__).' line: '.__LINE__.' -> <br />';
|
256
|
//print_r( $_SERVER ); print '</pre>'; // flush ();sleep(10); die();
|
257
|
if($startrow > 0 ){
|
258
|
$query_submissions->seekRow($startrow);
|
259
|
} else {
|
260
|
$query_submissions->rewind();
|
261
|
}
|
262
|
// List submissions
|
263
|
$currentrow = 0;
|
264
|
$row = 'a';
|
265
|
// $oTpl->set_block('main_block', 'loop_submmission_block', 'loop_submmission');
|
266
|
while($submission = $query_submissions->fetchRow(MYSQL_ASSOC) )
|
267
|
{
|
268
|
$currentrow++;
|
269
|
$submission['display_name'] = (($submission['display_name']!=null) ? $submission['display_name'] : '');
|
270
|
$sBody = $submission['body'];
|
271
|
$regex = "/[a-z0-9\-_]?[a-z0-9.\-_]+[a-z0-9\-_]?@[a-z0-9.-]+\.[a-z]{2,}/i";
|
272
|
preg_match ($regex, $sBody, $output);
|
273
|
// workout if output is empty
|
274
|
$submission['email'] = (isset($output['0']) ? $output['0'] : '');
|
275
|
$querystr = 'page='.$page.'&page_id='.$page_id.'&section_id='.$section_id.'&submission_id='.$admin->getIDKEY($submission['submission_id']);
|
276
|
$row = $row=='a' ? 'b' : 'a';
|
277
|
|
278
|
$oTpl->set_var('ROW_BIT',$row);
|
279
|
$oTpl->set_var('QUERYSTR', $querystr);
|
280
|
$oTpl->set_var('TEXT_ARE_YOU_SURE', url_encode($TEXT['ARE_YOU_SURE']));
|
281
|
$oTpl->set_var('SUBMISSION_IDKEY', $admin->getIDKEY($submission['submission_id']));
|
282
|
$oTpl->set_var('TEXT_DELETE', $TEXT['DELETE']);
|
283
|
$oTpl->set_var('PAGE', $page);
|
284
|
$oTpl->set_var('TEXT_OPEN', $TEXT['OPEN']);
|
285
|
$oTpl->set_var('SUBMISSION_ID', $submission['submission_id']);
|
286
|
$oTpl->set_var('SUBMISSION_CREATE_WHEN', gmdate(DATE_FORMAT.', '.TIME_FORMAT, $submission['submitted_when']+TIMEZONE ));
|
287
|
$oTpl->set_var('SUBMISSION_BY', $submission['display_name']);
|
288
|
$oTpl->set_var('SUBMISSION_EMAIL', $submission['email']);
|
289
|
|
290
|
$oTpl->parse('loop_submmission', 'loop_submmission_block', true);
|
291
|
|
292
|
if ($currentrow==$limit) { break;}
|
293
|
}
|
294
|
$script_name = $_SERVER['SCRIPT_NAME'];
|
295
|
//include_once((dirname(__FILE__)) .'/DiggPagination.php');
|
296
|
$pagination = m_form_DiggPagination::Pager($page,$totalrows,$limit,$adjacents,$script_name);
|
297
|
$oTpl->set_var(array(
|
298
|
'PAGINATION' => $pagination,
|
299
|
)
|
300
|
);
|
301
|
|
302
|
} else {
|
303
|
$oTpl->set_block('loop_submmission_block', '');
|
304
|
$oTpl->set_var('TEXT_NONE_FOUND', $TEXT['NONE_FOUND']);
|
305
|
}
|
306
|
} else {
|
307
|
echo $database->get_error().'<br />';
|
308
|
echo $sql;
|
309
|
|
310
|
}
|
311
|
|
312
|
// Parse template object
|
313
|
$oTpl->parse('main', 'main_block', false);
|
314
|
$output = $oTpl->finish($oTpl->parse('output', 'page'));
|
315
|
unset($oTpl);
|
316
|
print $output;
|
317
|
$output = '';
|