Project

General

Profile

« Previous | Next » 

Revision 1919

Added by Dietmar about 11 years ago

! /modules/form/ beginning recoding

View differences:

add_field.php
4 4
 * @category        module
5 5
 * @package         Form
6 6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2011, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.org/
9 9
 * @license         http://www.gnu.org/licenses/gpl.html
10 10
 * @platform        WebsiteBaker 2.8.x
11 11
 * @requirements    PHP 5.2.2 and higher
12 12
 * @version         $Id$
13
 * @filesource		$HeadURL$
13
 * @filesource      $HeadURL$
14 14
 * @lastmodified    $Date$
15 15
 * @description
16 16
 */
17 17

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

  
24
}
25

  
20 26
// Include WB admin wrapper script
21 27
require(WB_PATH.'/modules/admin.php');
22 28

  
23
$sec_anchor = '#'.(defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR.$section_id : 'section_'.$section_id );
24

  
25 29
// Include the ordering class
26 30
require(WB_PATH.'/framework/class.order.php');
27 31
// Get new order
28 32
$order = new order(TABLE_PREFIX.'mod_form_fields', 'position', 'field_id', 'section_id');
29 33
$position = $order->get_new($section_id);
30 34

  
35
$field_id = 0;
36
try {
31 37
// Insert new row into database
32
$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_fields (section_id,page_id,position,required) VALUES ('$section_id','$page_id','$position','0')");
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
}
33 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

  
34 52
// Get the id
35
$field_id = $database->get_one("SELECT LAST_INSERT_ID()");
53
//$field_id = $database->get_one("SELECT LAST_INSERT_ID()");
36 54

  
37 55
// Say that a new record has been added, then redirect to modify page
38
if($database->is_error()) {
39
	$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));
40
} else {
41
	$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));
42
}
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
//}
43 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));
44 63
// Print admin footer
45 64
$admin->print_footer();

Also available in: Unified diff