Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         menu_link
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.4
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: save.php 1911 2013-06-07 03:21:56Z Luisehahne $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/menu_link/save.php $
14
 * @lastmodified    $Date: 2013-06-07 05:21:56 +0200 (Fri, 07 Jun 2013) $
15
 *
16
*/
17

    
18
require_once('../../config.php');
19

    
20
$admin_header = false;
21
// Tells script to update when this page was last updated
22
$update_when_modified = true;
23
// Include WB admin wrapper script
24
require(WB_PATH.'/modules/admin.php');
25
$backlink = ADMIN_URL.'/pages/modify.php?page_id='.(int)$page_id;
26
if (!$admin->checkFTAN())
27
{
28
	$admin->print_header();
29
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink );
30
}
31
$admin->print_header();
32

    
33
// Update id, anchor and target
34
if(isset($_POST['menu_link'])) {
35
	$foreign_page_id = intval($_POST['menu_link']);
36
	$url_target = $admin->StripCodeFromText($_POST['target']);
37
	$r_type = intval($_POST['r_type']);
38
	$page_target = $admin->StripCodeFromText($_POST['page_target']);
39
	if(isset($_POST['extern']))
40
		$extern = $admin->StripCodeFromText($_POST['extern']);
41
	else
42
		$extern='';
43

    
44
	$table_pages = TABLE_PREFIX.'pages';
45
	$table_mod = TABLE_PREFIX.'mod_menu_link';
46
	$database->query("UPDATE `$table_pages` SET `target` = '$url_target' WHERE `page_id` = '$page_id'");
47
//	$database->query("UPDATE `$table_mod` SET `target_page_id` = '$foreign_page_id', `anchor` = '$page_target', `extern` = '$extern', `redirect_type` = '$r_type' WHERE `page_id` = '$page_id'");
48

    
49
	// Check that it doesn't already exist
50
	$sqlwhere = 'WHERE `page_id`='.$page_id.'';
51
	$sqlOne  = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_menu_link` '.$sqlwhere;
52
	if( $database->get_one($sqlOne) ) {
53
		$sql  = 'UPDATE `'.TABLE_PREFIX.'mod_menu_link`  SET';
54
	}else{
55
		// Load into DB
56
		$sql  = 'INSERT INTO `'.TABLE_PREFIX.'mod_menu_link`  SET ';
57
		$sqlwhere = '';
58
		$sql .= '`section_id`='.$section_id.', '
59
		      . '`page_id`='.$page_id.', ';
60
	}
61
	$sql .= '`target_page_id` = \''.$foreign_page_id.'\', '
62
	      . '`anchor` =  \''.$database->escapeString($page_target).'\', '
63
	      . '`extern` = \''.$database->escapeString($extern).'\', '
64
	      . '`redirect_type` = \''.$r_type.'\' '
65
	      . $sqlwhere;
66
}
67

    
68
// Check if there is a database error, otherwise say successful
69
if($database->query($sql)) {
70
	$admin->print_success($MESSAGE['PAGES_SAVED'],$backlink );
71
} else {
72
	$admin->print_error($database->get_error(), $js_back);
73
}
74

    
75
// Print admin footer
76
$admin->print_footer();
(7-7/10)