1 |
1425
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category modules
|
5 |
|
|
* @package menu_link
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
1911
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker.org/
|
9 |
1425
|
Luisehahne
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
1911
|
Luisehahne
|
* @platform WebsiteBaker 2.8.4
|
11 |
1425
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher
|
12 |
|
|
* @version $Id$
|
13 |
1911
|
Luisehahne
|
* @filesource $HeadURL$
|
14 |
1425
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
|
|
require_once('../../config.php');
|
19 |
|
|
|
20 |
1457
|
Luisehahne
|
$admin_header = false;
|
21 |
|
|
// Tells script to update when this page was last updated
|
22 |
|
|
$update_when_modified = true;
|
23 |
1425
|
Luisehahne
|
// Include WB admin wrapper script
|
24 |
|
|
require(WB_PATH.'/modules/admin.php');
|
25 |
1473
|
Luisehahne
|
$backlink = ADMIN_URL.'/pages/modify.php?page_id='.(int)$page_id;
|
26 |
1425
|
Luisehahne
|
if (!$admin->checkFTAN())
|
27 |
|
|
{
|
28 |
1457
|
Luisehahne
|
$admin->print_header();
|
29 |
1473
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink );
|
30 |
1425
|
Luisehahne
|
}
|
31 |
1457
|
Luisehahne
|
$admin->print_header();
|
32 |
1425
|
Luisehahne
|
|
33 |
|
|
// Update id, anchor and target
|
34 |
|
|
if(isset($_POST['menu_link'])) {
|
35 |
1911
|
Luisehahne
|
$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 |
1425
|
Luisehahne
|
if(isset($_POST['extern']))
|
40 |
1911
|
Luisehahne
|
$extern = $admin->StripCodeFromText($_POST['extern']);
|
41 |
1425
|
Luisehahne
|
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 |
1911
|
Luisehahne
|
// $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 |
1425
|
Luisehahne
|
}
|
67 |
|
|
|
68 |
|
|
// Check if there is a database error, otherwise say successful
|
69 |
1911
|
Luisehahne
|
if($database->query($sql)) {
|
70 |
|
|
$admin->print_success($MESSAGE['PAGES_SAVED'],$backlink );
|
71 |
|
|
} else {
|
72 |
1425
|
Luisehahne
|
$admin->print_error($database->get_error(), $js_back);
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
// Print admin footer
|
76 |
|
|
$admin->print_footer();
|