commit | author | age
|
d4d985
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
436ed8
|
4 |
Copyright (c) 2007, Till Brehm, projektfarm Gmbh |
d4d985
|
5 |
All rights reserved. |
T |
6 |
|
|
7 |
Redistribution and use in source and binary forms, with or without modification, |
|
8 |
are permitted provided that the following conditions are met: |
|
9 |
|
|
10 |
* Redistributions of source code must retain the above copyright notice, |
|
11 |
this list of conditions and the following disclaimer. |
|
12 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
13 |
this list of conditions and the following disclaimer in the documentation |
|
14 |
and/or other materials provided with the distribution. |
|
15 |
* Neither the name of ISPConfig nor the names of its contributors |
|
16 |
may be used to endorse or promote products derived from this software without |
|
17 |
specific prior written permission. |
|
18 |
|
|
19 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
20 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
23 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
24 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
26 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
27 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
28 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
*/ |
|
30 |
|
|
31 |
class tform_actions { |
|
32 |
|
7fe908
|
33 |
public $id; |
MC |
34 |
public $activeTab; |
|
35 |
public $dataRecord; |
|
36 |
public $plugins = array(); |
|
37 |
public $oldDataRecord; // This array is only filled during updates and when db_history is enabled. |
d4d985
|
38 |
|
7fe908
|
39 |
function onLoad() { |
MC |
40 |
global $app, $conf, $tform_def_file; |
d4d985
|
41 |
|
7fe908
|
42 |
// Loading template classes and initialize template |
MC |
43 |
if(!is_object($app->tpl)) $app->uses('tpl'); |
|
44 |
if(!is_object($app->tform)) $app->uses('tform'); |
d4d985
|
45 |
|
7fe908
|
46 |
$app->tpl->newTemplate("tabbed_form.tpl.htm"); |
d4d985
|
47 |
|
7fe908
|
48 |
// Load table definition from file |
MC |
49 |
$app->tform->loadFormDef($tform_def_file); |
d4d985
|
50 |
|
7fe908
|
51 |
// Importing ID |
MC |
52 |
$this->id = (isset($_REQUEST["id"]))?$app->functions->intval($_REQUEST["id"]):0; |
d4d985
|
53 |
|
7fe908
|
54 |
// show print version of the form |
MC |
55 |
if(isset($_GET["print_form"]) && $_GET["print_form"] == 1) { |
|
56 |
die('Function disabled.'); |
|
57 |
$this->onPrintForm(); |
|
58 |
} |
d4d985
|
59 |
|
7fe908
|
60 |
// send this form by email |
MC |
61 |
if(isset($_GET["send_form_by_mail"]) && $_GET["send_form_by_mail"] == 1) { |
|
62 |
die('Function disabled.'); |
|
63 |
$this->onMailSendForm(); |
|
64 |
} |
d4d985
|
65 |
|
7fe908
|
66 |
if(count($_POST) > 1) { |
MC |
67 |
$this->dataRecord = $_POST; |
|
68 |
$this->onSubmit(); |
|
69 |
} else { |
|
70 |
$this->onShow(); |
|
71 |
} |
|
72 |
} |
d4d985
|
73 |
|
7fe908
|
74 |
/** |
MC |
75 |
* Function called on page submit |
|
76 |
*/ |
d4d985
|
77 |
|
T |
78 |
|
7fe908
|
79 |
function onSubmit() { |
MC |
80 |
global $app, $conf; |
|
81 |
|
|
82 |
// check if the client is locked - he may not change anything, then. |
|
83 |
if(!$app->auth->is_admin()) { |
35509d
|
84 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
7fe908
|
85 |
$client = $app->db->queryOneRecord("SELECT client.locked FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".$app->functions->intval($client_group_id)); |
MC |
86 |
if(is_array($client) && $client['locked'] == 'y') { |
|
87 |
$app->tform->errorMessage .= $app->lng("client_you_are_locked")."<br />"; |
d4d985
|
88 |
} |
T |
89 |
} |
|
90 |
|
7fe908
|
91 |
// Calling the action functions |
MC |
92 |
if($this->id > 0) { |
|
93 |
$app->tform->action == 'EDIT'; |
|
94 |
$this->onUpdate(); |
|
95 |
} else { |
|
96 |
$app->tform->action == 'NEW'; |
|
97 |
$this->onInsert(); |
d4d985
|
98 |
} |
7fe908
|
99 |
} |
d4d985
|
100 |
|
T |
101 |
|
7fe908
|
102 |
/** |
MC |
103 |
* Function called on data update |
|
104 |
*/ |
|
105 |
function onUpdate() { |
|
106 |
global $app, $conf; |
d4d985
|
107 |
|
7fe908
|
108 |
$this->onBeforeUpdate(); |
d4d985
|
109 |
|
7fe908
|
110 |
$ext_where = ''; |
MC |
111 |
$sql = $app->tform->getSQL($this->dataRecord, $app->tform->getCurrentTab(), 'UPDATE', $this->id, $ext_where); |
|
112 |
if($app->tform->errorMessage == '') { |
d4d985
|
113 |
|
61f738
|
114 |
$this->oldDataRecord = $app->tform->getDataRecord($this->id); |
d4d985
|
115 |
|
7fe908
|
116 |
// Save record in database |
MC |
117 |
$this->onUpdateSave($sql); |
|
118 |
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_update_save', array('page_form'=>$this, 'sql'=>$sql)); |
d4d985
|
119 |
|
7fe908
|
120 |
// loading plugins |
MC |
121 |
$next_tab = $app->tform->getCurrentTab(); |
|
122 |
$this->loadPlugins($next_tab); |
d4d985
|
123 |
|
7fe908
|
124 |
// Call plugin |
MC |
125 |
foreach($this->plugins as $plugin) { |
|
126 |
$plugin->onUpdate(); |
|
127 |
} |
d4d985
|
128 |
|
7fe908
|
129 |
$this->onAfterUpdate(); |
MC |
130 |
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_update', $this); |
d4d985
|
131 |
|
7fe908
|
132 |
// Write data history (sys_datalog) |
MC |
133 |
if($app->tform->formDef['db_history'] == 'yes') { |
|
134 |
$new_data_record = $app->tform->getDataRecord($this->id); |
|
135 |
$app->tform->datalogSave('UPDATE', $this->id, $this->oldDataRecord, $new_data_record); |
|
136 |
unset($new_data_record); |
|
137 |
unset($old_data_record); |
|
138 |
} |
d4d985
|
139 |
|
7fe908
|
140 |
if($_REQUEST["next_tab"] == '') { |
MC |
141 |
$list_name = $_SESSION["s"]["form"]["return_to"]; |
|
142 |
// When a list is embedded inside of a form |
d4d985
|
143 |
|
7fe908
|
144 |
//if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { |
MC |
145 |
if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { |
|
146 |
$redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; |
|
147 |
$_SESSION["s"]["form"]["return_to"] = ''; |
|
148 |
session_write_close(); |
|
149 |
header($redirect); |
|
150 |
// When a returnto variable is set |
|
151 |
} elseif (isset($_SESSION["s"]["form"]["return_to_url"]) && $_SESSION["s"]["form"]["return_to_url"] != '') { |
|
152 |
$redirect = $_SESSION["s"]["form"]["return_to_url"]; |
|
153 |
$_SESSION["s"]["form"]["return_to_url"] = ''; |
|
154 |
session_write_close(); |
|
155 |
header("Location: ".$redirect); |
|
156 |
exit; |
|
157 |
// Use the default list of the form |
|
158 |
} else { |
|
159 |
header("Location: ".$app->tform->formDef['list_default']); |
|
160 |
} |
d4d985
|
161 |
exit; |
T |
162 |
} else { |
7fe908
|
163 |
$this->onShow(); |
d4d985
|
164 |
} |
7fe908
|
165 |
} else { |
MC |
166 |
$this->onError(); |
|
167 |
} |
|
168 |
} |
d4d985
|
169 |
|
7fe908
|
170 |
/* |
MC |
171 |
Save record in database |
|
172 |
*/ |
|
173 |
|
|
174 |
function onUpdateSave($sql) { |
|
175 |
global $app; |
|
176 |
if(!empty($sql) && !$app->tform->isReadonlyTab($app->tform->getCurrentTab(), $this->id)) { |
|
177 |
$app->db->query($sql); |
|
178 |
if($app->db->errorMessage != '') die($app->db->errorMessage); |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
/** |
|
187 |
* Function called on data insert |
|
188 |
*/ |
|
189 |
function onInsert() { |
|
190 |
global $app, $conf; |
|
191 |
|
|
192 |
$this->onBeforeInsert(); |
|
193 |
|
|
194 |
$ext_where = ''; |
|
195 |
$sql = $app->tform->getSQL($this->dataRecord, $app->tform->getCurrentTab(), 'INSERT', $this->id, $ext_where); |
|
196 |
if($app->tform->errorMessage == '') { |
|
197 |
|
|
198 |
$this->id = $this->onInsertSave($sql); |
|
199 |
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_insert_save', array('page_form'=>$this, 'sql'=>$sql)); |
|
200 |
|
|
201 |
// loading plugins |
|
202 |
$next_tab = $app->tform->getCurrentTab(); |
|
203 |
$this->loadPlugins($next_tab); |
|
204 |
|
|
205 |
// Call plugin |
|
206 |
foreach($this->plugins as $plugin) { |
|
207 |
$plugin->onInsert(); |
|
208 |
} |
|
209 |
|
|
210 |
$this->onAfterInsert(); |
|
211 |
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_insert', $this); |
|
212 |
|
|
213 |
// Write data history (sys_datalog) |
|
214 |
if($app->tform->formDef['db_history'] == 'yes') { |
|
215 |
$new_data_record = $app->tform->getDataRecord($this->id); |
|
216 |
$app->tform->datalogSave('INSERT', $this->id, array(), $new_data_record); |
|
217 |
unset($new_data_record); |
|
218 |
} |
|
219 |
|
|
220 |
|
|
221 |
if($_REQUEST["next_tab"] == '') { |
|
222 |
$list_name = $_SESSION["s"]["form"]["return_to"]; |
|
223 |
// if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { |
|
224 |
if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { |
|
225 |
$redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; |
|
226 |
$_SESSION["s"]["form"]["return_to"] = ''; |
|
227 |
session_write_close(); |
|
228 |
header($redirect); |
|
229 |
exit; |
|
230 |
} elseif ($_SESSION["s"]["form"]["return_to_url"] != '') { |
|
231 |
$redirect = $_SESSION["s"]["form"]["return_to_url"]; |
|
232 |
$_SESSION["s"]["form"]["return_to_url"] = ''; |
|
233 |
session_write_close(); |
|
234 |
header("Location: ".$redirect); |
|
235 |
exit; |
|
236 |
} else { |
|
237 |
header("Location: ".$app->tform->formDef['list_default']); |
|
238 |
} |
|
239 |
exit; |
|
240 |
} else { |
|
241 |
$this->onShow(); |
|
242 |
} |
|
243 |
} else { |
|
244 |
$this->onError(); |
|
245 |
} |
|
246 |
} |
|
247 |
|
|
248 |
/* |
|
249 |
Save record in database |
|
250 |
*/ |
|
251 |
|
|
252 |
function onInsertSave($sql) { |
|
253 |
global $app, $conf; |
|
254 |
$app->db->query($sql); |
|
255 |
if($app->db->errorMessage != '') die($app->db->errorMessage); |
|
256 |
return $app->db->insertID(); |
|
257 |
} |
|
258 |
|
|
259 |
function onBeforeUpdate() { |
|
260 |
global $app, $conf; |
|
261 |
} |
|
262 |
|
|
263 |
function onBeforeInsert() { |
|
264 |
global $app, $conf; |
|
265 |
} |
|
266 |
|
|
267 |
function onAfterUpdate() { |
|
268 |
global $app, $conf; |
|
269 |
} |
|
270 |
|
|
271 |
function onAfterInsert() { |
|
272 |
global $app, $conf; |
|
273 |
} |
|
274 |
|
|
275 |
|
|
276 |
/** |
|
277 |
* Function called on data insert or update error |
|
278 |
*/ |
|
279 |
function onError() { |
|
280 |
global $app, $conf; |
|
281 |
|
|
282 |
$app->tpl->setVar("error", "<li>".$app->tform->errorMessage."</li>"); |
|
283 |
$app->tpl->setVar($this->dataRecord); |
|
284 |
$this->onShow(); |
|
285 |
} |
|
286 |
|
|
287 |
|
|
288 |
/** |
|
289 |
* Function called on data delete |
|
290 |
*/ |
|
291 |
function onDelete() { |
|
292 |
global $app, $conf, $list_def_file, $tform_def_file; |
|
293 |
|
|
294 |
include_once $list_def_file; |
|
295 |
|
|
296 |
// Loading tform framework |
|
297 |
if(!is_object($app->tform)) $app->uses('tform'); |
|
298 |
|
|
299 |
// Load table definition from file |
|
300 |
$app->tform->loadFormDef($tform_def_file); |
|
301 |
|
|
302 |
// importing ID |
|
303 |
$this->id = $app->functions->intval($_REQUEST["id"]); |
|
304 |
|
|
305 |
if($this->id > 0) { |
|
306 |
|
|
307 |
// checking permissions |
|
308 |
if($app->tform->formDef['auth'] == 'yes' && $_SESSION["s"]["user"]["typ"] != 'admin') { |
|
309 |
if($app->tform->checkPerm($this->id, 'd') == false) $app->error($app->lng('error_no_delete_permission')); |
|
310 |
} |
|
311 |
|
|
312 |
//$this->dataRecord = $app->db->queryOneRecord("SELECT * FROM ".$liste["table"]." WHERE ".$liste["table_idx"]." = ".$this->id); |
|
313 |
$this->dataRecord = $app->tform->getDataRecord($this->id); |
|
314 |
|
5f29df
|
315 |
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_check_delete', $this); |
7fe908
|
316 |
$this->onBeforeDelete(); |
MC |
317 |
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_before_delete', $this); |
|
318 |
|
|
319 |
// Saving record to datalog when db_history enabled |
|
320 |
if($app->tform->formDef["db_history"] == 'yes') { |
|
321 |
//$old_data_record = $app->tform->getDataRecord($this->id); |
|
322 |
$app->tform->datalogSave('DELETE', $this->id, $this->dataRecord, array()); |
|
323 |
} |
|
324 |
|
|
325 |
$app->db->query("DELETE FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." LIMIT 1"); |
|
326 |
|
|
327 |
|
|
328 |
// loading plugins |
|
329 |
$next_tab = $app->tform->getCurrentTab(); |
|
330 |
$this->loadPlugins($next_tab); |
|
331 |
|
|
332 |
|
|
333 |
// Call plugin |
|
334 |
foreach($this->plugins as $plugin) { |
|
335 |
$plugin->onDelete(); |
|
336 |
} |
|
337 |
|
|
338 |
$this->onAfterDelete(); |
|
339 |
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_delete', $this); |
|
340 |
} |
|
341 |
|
|
342 |
//header("Location: ".$liste["file"]."?PHPSESSID=".$_SESSION["s"]["id"]); |
|
343 |
$list_name = $_SESSION["s"]["form"]["return_to"]; |
|
344 |
if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { |
|
345 |
$redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; |
|
346 |
$_SESSION["s"]["form"]["return_to"] = ''; |
|
347 |
session_write_close(); |
|
348 |
header($redirect); |
|
349 |
} else { |
|
350 |
header("Location: ".$liste["file"]); |
|
351 |
} |
|
352 |
exit; |
|
353 |
|
|
354 |
} |
|
355 |
|
|
356 |
function onBeforeDelete() { |
|
357 |
global $app, $conf; |
|
358 |
} |
|
359 |
|
|
360 |
function onAfterDelete() { |
|
361 |
global $app, $conf; |
|
362 |
} |
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
/** |
|
369 |
* Function to print the form content |
|
370 |
*/ |
|
371 |
function onPrintForm() { |
|
372 |
global $app, $conf; |
|
373 |
|
|
374 |
if($app->tform->formDef['template_print'] == '') die('No print template available.'); |
|
375 |
|
|
376 |
$app->tpl->newTemplate("print.tpl.htm"); |
|
377 |
$app->tpl->setInclude("content_tpl", $app->tform->formDef['template_print']); |
|
378 |
|
|
379 |
if($app->tform->formDef['auth'] == 'no') { |
|
380 |
$sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; |
|
381 |
} else { |
|
382 |
$sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); |
|
383 |
} |
|
384 |
if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); |
|
385 |
|
|
386 |
$record["datum"] = date("d.m.Y"); |
|
387 |
|
|
388 |
$app->tpl->setVar($app->tform->wordbook); |
|
389 |
|
|
390 |
$app->tpl->setVar($record); |
|
391 |
$app->tpl_defaults(); |
|
392 |
$app->tpl->pparse(); |
|
393 |
exit; |
|
394 |
|
|
395 |
} |
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
/** |
|
402 |
* Function to print the form content |
|
403 |
*/ |
|
404 |
function onMailSendForm() { |
|
405 |
global $app, $conf; |
|
406 |
|
|
407 |
if($app->tform->formDef['template_mailsend'] == '') die('No print template available.'); |
|
408 |
|
|
409 |
if($_POST["email"] == '' && $_POST["sender"] == '') { |
|
410 |
// Zeige Formular zum versenden an. |
|
411 |
$app->tpl->newTemplate("form.tpl.htm"); |
|
412 |
$app->tpl->setInclude("content_tpl", $app->tform->formDef['template_mailsend']); |
|
413 |
$app->tpl->setVar('show_form', 1); |
|
414 |
$app->tpl->setVar("form_action", $app->tform->formDef['action'].'?send_form_by_mail=1'); |
|
415 |
$app->tpl->setVar("id", $this->id); |
|
416 |
$app->tpl_defaults(); |
|
417 |
$app->tpl->pparse(); |
|
418 |
exit; |
|
419 |
} else { |
|
420 |
$app->tpl->newTemplate("mail.tpl.htm"); |
|
421 |
$app->tpl->setInclude("content_tpl", $app->tform->formDef['template_mailsend']); |
|
422 |
$app->tpl->setVar('show_mail', 1); |
d4d985
|
423 |
if($app->tform->formDef['auth'] == 'no') { |
7fe908
|
424 |
$sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; |
MC |
425 |
} else { |
|
426 |
$sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); |
|
427 |
} |
|
428 |
if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); |
|
429 |
|
d4d985
|
430 |
$record["datum"] = date("d.m.Y"); |
7fe908
|
431 |
$record["mailmessage"] = $_POST["message"]; |
MC |
432 |
|
d4d985
|
433 |
$app->tpl->setVar($app->tform->wordbook); |
T |
434 |
|
|
435 |
$app->tpl->setVar($record); |
|
436 |
$app->tpl_defaults(); |
7fe908
|
437 |
|
MC |
438 |
$email_message = $app->tpl->grab(); |
|
439 |
$email = $_POST["email"]; |
|
440 |
$sender = $_POST["sender"]; |
|
441 |
|
|
442 |
$headers = "MIME-Version: 1.0\n"; |
|
443 |
$headers .= "Content-type: text/html; charset=iso-8859-1\n"; |
|
444 |
$headers .= "From: $sender\n"; |
|
445 |
|
|
446 |
if (!preg_match('/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+' . '@' . '([-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.)+' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/', $sender)) { |
|
447 |
$sender = 'noreply@iprguard.de'; |
|
448 |
} |
|
449 |
|
|
450 |
if (preg_match('/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+' . '@' . '([-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.)+' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/', $email)) { |
|
451 |
mail($email, 'Domainrecherche Statement '.$record["domain"], $email_message, $headers); |
|
452 |
} |
|
453 |
echo "<p> </p><p>Email wurde versand.</p>"; |
d4d985
|
454 |
exit; |
T |
455 |
} |
|
456 |
|
|
457 |
|
|
458 |
|
7fe908
|
459 |
if($app->tform->formDef['auth'] == 'no') { |
MC |
460 |
$sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; |
|
461 |
} else { |
|
462 |
$sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); |
d4d985
|
463 |
} |
7fe908
|
464 |
if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); |
MC |
465 |
|
|
466 |
$record["datum"] = date("d.m.Y"); |
|
467 |
|
|
468 |
$app->tpl->setVar($app->tform->wordbook); |
|
469 |
|
|
470 |
$app->tpl->setVar($record); |
|
471 |
$app->tpl_defaults(); |
|
472 |
$app->tpl->pparse(); |
|
473 |
exit; |
|
474 |
|
|
475 |
} |
|
476 |
|
|
477 |
|
|
478 |
/** |
|
479 |
* Function called on page show |
|
480 |
*/ |
|
481 |
function onShow() { |
|
482 |
global $app, $conf; |
|
483 |
|
|
484 |
// Which tab do we render |
|
485 |
$this->active_tab = $app->tform->getNextTab(); |
|
486 |
|
|
487 |
if($this->id > 0) { |
|
488 |
$this->onShowEdit(); |
|
489 |
} else { |
|
490 |
$this->onShowNew(); |
|
491 |
} |
|
492 |
|
|
493 |
// make Form and Tabs |
|
494 |
$app->tform->showForm(); |
|
495 |
|
|
496 |
// Setting default values |
|
497 |
$app->tpl_defaults(); |
|
498 |
|
|
499 |
// Show the navigation bar of the form |
|
500 |
if(isset($app->tform->formDef['navibar']) && $app->tform->formDef['navibar'] == 'yes') { |
|
501 |
$navibar = ''; |
|
502 |
if($app->tform->formDef['template_print'] != '') { |
|
503 |
$navibar .= '<a href="'.$app->tform->formDef['action'].'?id='.$this->id.'&print_form=1" target="_blank"><img src="../themes/iprg/icons/printer.png" border="0" alt="Drucken" /></a> '; |
|
504 |
} |
|
505 |
if($app->tform->formDef['template_mailsend'] != '') { |
|
506 |
$navibar .= "<a href=\"#\" onclick=\"window.open('".$app->tform->formDef['action'].'?id='.$this->id."&send_form_by_mail=1','send','width=370,height=240')\"><img src=\"../themes/iprg/icons/mail.png\" border=\"0\" alt=\"Als E-Mail versenden\" /></a>"; |
|
507 |
} |
|
508 |
$app->tpl->setVar('form_navibar', $navibar); |
|
509 |
} |
|
510 |
|
|
511 |
if(isset($_SESSION['show_info_msg'])) { |
|
512 |
$app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']); |
|
513 |
unset($_SESSION['show_info_msg']); |
|
514 |
} |
|
515 |
if(isset($_SESSION['show_error_msg'])) { |
|
516 |
$app->tpl->setVar('show_error_msg', $_SESSION['show_error_msg']); |
|
517 |
unset($_SESSION['show_error_msg']); |
|
518 |
} |
|
519 |
|
|
520 |
// loading plugins |
|
521 |
$this->loadPlugins($this->active_tab); |
|
522 |
|
|
523 |
// Calling the Plugin onShow Events and set the data in the |
|
524 |
// plugins placeholder in the template |
|
525 |
foreach($this->plugins as $plugin_name => $plugin) { |
|
526 |
$app->tpl->setVar($plugin_name, $plugin->onShow()); |
|
527 |
} |
|
528 |
|
|
529 |
// Parse the templates and send output to the browser |
|
530 |
$this->onShowEnd(); |
|
531 |
|
|
532 |
} |
|
533 |
|
|
534 |
|
|
535 |
/** |
|
536 |
* Function called on new record |
|
537 |
*/ |
|
538 |
function onShowNew() { |
|
539 |
global $app, $conf; |
|
540 |
|
|
541 |
if($app->tform->errorMessage == '') { |
|
542 |
$record = array(); |
|
543 |
$record = $app->tform->getHTML($record, $app->tform->formDef['tab_default'], 'NEW'); |
|
544 |
} else { |
|
545 |
$record = $app->tform->getHTML($app->tform->encode($_POST, $this->active_tab), $this->active_tab, 'EDIT'); |
|
546 |
} |
|
547 |
|
|
548 |
$app->tpl->setVar($record); |
|
549 |
} |
|
550 |
|
|
551 |
|
|
552 |
/** |
|
553 |
* Function called on edit record |
|
554 |
*/ |
|
555 |
function onShowEdit() { |
|
556 |
global $app, $conf; |
|
557 |
|
|
558 |
// bestehenden Datensatz anzeigen |
|
559 |
if($app->tform->errorMessage == '') { |
|
560 |
if($app->tform->formDef['auth'] == 'yes' && $_SESSION["s"]["user"]["typ"] != 'admin') { |
|
561 |
$sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); |
|
562 |
} else { |
|
563 |
$sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; |
|
564 |
} |
|
565 |
if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); |
|
566 |
} else { |
|
567 |
// $record = $app->tform->encode($_POST,$this->active_tab); |
|
568 |
$record = $app->tform->encode($this->dataRecord, $this->active_tab, false); |
|
569 |
} |
|
570 |
|
|
571 |
$this->dataRecord = $record; |
|
572 |
|
|
573 |
// Userdaten umwandeln |
|
574 |
$record = $app->tform->getHTML($record, $this->active_tab, 'EDIT'); |
|
575 |
$record['id'] = $this->id; |
|
576 |
|
|
577 |
$app->tpl->setVar($record); |
|
578 |
} |
|
579 |
|
|
580 |
function onShowEnd() { |
|
581 |
global $app, $conf; |
|
582 |
|
|
583 |
// Template parsen |
|
584 |
$app->tpl->pparse(); |
|
585 |
} |
|
586 |
|
|
587 |
function loadPlugins($next_tab) { |
|
588 |
global $app; |
|
589 |
if(@is_array($app->tform->formDef["tabs"][$next_tab]["plugins"])) { |
|
590 |
$app->load('plugin_base'); |
|
591 |
foreach($app->tform->formDef["tabs"][$next_tab]["plugins"] as $plugin_name => $plugin_settings) { |
|
592 |
$plugin_class = $plugin_settings["class"]; |
|
593 |
$app->load($plugin_class); |
|
594 |
$this->plugins[$plugin_name] = new $plugin_class; |
|
595 |
$this->plugins[$plugin_name]->setOptions($plugin_name, $plugin_settings['options']); |
|
596 |
// Make the data of the form easily accessible for the plugib |
|
597 |
$this->plugins[$plugin_name]->form = $this; |
|
598 |
$this->plugins[$plugin_name]->onLoad(); |
|
599 |
} |
|
600 |
} |
|
601 |
} |
d4d985
|
602 |
|
T |
603 |
|
|
604 |
} |
|
605 |
|
7fe908
|
606 |
?> |