1 |
560
|
Ruebenwurz
|
<?php
|
2 |
1375
|
FrankH
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category module
|
5 |
|
|
* @package Form
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
1919
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker.org/
|
9 |
1375
|
FrankH
|
* @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$
|
13 |
1919
|
Luisehahne
|
* @filesource $HeadURL$
|
14 |
1457
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
1538
|
Luisehahne
|
* @description
|
16 |
1375
|
FrankH
|
*/
|
17 |
560
|
Ruebenwurz
|
|
18 |
1919
|
Luisehahne
|
// Include config file
|
19 |
|
|
$config_file = realpath('../../config.php');
|
20 |
|
|
if(file_exists($config_file) && !defined('WB_URL'))
|
21 |
|
|
{
|
22 |
|
|
require($config_file);
|
23 |
560
|
Ruebenwurz
|
|
24 |
1919
|
Luisehahne
|
}
|
25 |
|
|
|
26 |
560
|
Ruebenwurz
|
// Include WB admin wrapper script
|
27 |
|
|
require(WB_PATH.'/modules/admin.php');
|
28 |
|
|
|
29 |
|
|
// Include the ordering class
|
30 |
|
|
require(WB_PATH.'/framework/class.order.php');
|
31 |
|
|
// Get new order
|
32 |
|
|
$order = new order(TABLE_PREFIX.'mod_form_fields', 'position', 'field_id', 'section_id');
|
33 |
|
|
$position = $order->get_new($section_id);
|
34 |
|
|
|
35 |
1919
|
Luisehahne
|
$field_id = 0;
|
36 |
|
|
try {
|
37 |
560
|
Ruebenwurz
|
// Insert new row into database
|
38 |
1919
|
Luisehahne
|
$sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_form_fields` '
|
39 |
|
|
. 'SET `section_id`='.$section_id.', '
|
40 |
|
|
. '`page_id`='.$page_id.', '
|
41 |
|
|
. '`position`='.$position.', '
|
42 |
|
|
. '`required`=0';
|
43 |
|
|
$database->query($sql);
|
44 |
|
|
$field_id = $database->LastInsertId;
|
45 |
|
|
} catch(WbDatabaseException $e) {
|
46 |
|
|
$admin->print_error($database->get_error(), WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
|
47 |
|
|
}
|
48 |
560
|
Ruebenwurz
|
|
49 |
1919
|
Luisehahne
|
// Insert new row into database
|
50 |
|
|
//$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_fields (section_id,page_id,position,required) VALUES ('$section_id','$page_id','$position','0')");
|
51 |
|
|
|
52 |
560
|
Ruebenwurz
|
// Get the id
|
53 |
1919
|
Luisehahne
|
//$field_id = $database->get_one("SELECT LAST_INSERT_ID()");
|
54 |
560
|
Ruebenwurz
|
|
55 |
|
|
// Say that a new record has been added, then redirect to modify page
|
56 |
1919
|
Luisehahne
|
//if($database->is_error()) {
|
57 |
|
|
// $admin->print_error($database->get_error(), WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
|
58 |
|
|
//} else {
|
59 |
|
|
// $admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
|
60 |
|
|
//}
|
61 |
560
|
Ruebenwurz
|
|
62 |
1919
|
Luisehahne
|
$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
|
63 |
560
|
Ruebenwurz
|
// Print admin footer
|
64 |
|
|
$admin->print_footer();
|