Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        module
5
 * @package         Form
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.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: add_field.php 1919 2013-06-07 04:21:49Z Luisehahne $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/form/add_field.php $
14
 * @lastmodified    $Date: 2013-06-07 06:21:49 +0200 (Fri, 07 Jun 2013) $
15
 * @description
16
 */
17

    
18
// Include config file
19
$config_file = realpath('../../config.php');
20
if(file_exists($config_file) && !defined('WB_URL'))
21
{
22
	require($config_file);
23

    
24
}
25

    
26
// 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
$field_id = 0;
36
try {
37
// Insert new row into database
38
	$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.'&section_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
47
}
48

    
49
// 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
// Get the id
53
//$field_id = $database->get_one("SELECT LAST_INSERT_ID()");
54

    
55
// Say that a new record has been added, then redirect to modify page
56
//if($database->is_error()) {
57
//	$admin->print_error($database->get_error(), WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'&section_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.'&section_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
60
//}
61

    
62
$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'&section_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id));
63
// Print admin footer
64
$admin->print_footer();
(4-4/25)