1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package pages
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: delete.php 1384 2011-01-16 08:39:00Z Luisehahne $
|
14
|
* @filesource $HeadURL: http://svn.websitebaker2.org/branches/2.8.x/wb/admin/pages/add.php $
|
15
|
* @lastmodified $Date: 2011-01-10 13:14:10 +0100 (Mo, 10. Jan 2011) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
// Get page id
|
20
|
if(!isset($_GET['page_id']) || !is_numeric($_GET['page_id'])) {
|
21
|
header("Location: index.php");
|
22
|
exit(0);
|
23
|
} else {
|
24
|
$page_id = $_GET['page_id'];
|
25
|
}
|
26
|
|
27
|
// Create new admin object and print admin header
|
28
|
require('../../config.php');
|
29
|
require_once(WB_PATH.'/framework/class.admin.php');
|
30
|
$admin = new admin('Pages', 'pages_delete');
|
31
|
|
32
|
// Include the WB functions file
|
33
|
require_once(WB_PATH.'/framework/functions.php');
|
34
|
/*
|
35
|
if (!$admin->checkIDKEY('page_id', 0, 'GET'))
|
36
|
{
|
37
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
38
|
exit();
|
39
|
}
|
40
|
*/
|
41
|
// Get perms
|
42
|
if (!$admin->get_page_permission($page_id,'admin')) {
|
43
|
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
44
|
}
|
45
|
|
46
|
// Find out more about the page
|
47
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
|
48
|
$results = $database->query($query);
|
49
|
if($database->is_error()) {
|
50
|
$admin->print_error($database->get_error());
|
51
|
}
|
52
|
if($results->numRows() == 0) {
|
53
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
54
|
}
|
55
|
|
56
|
$results_array = $results->fetchRow();
|
57
|
|
58
|
$visibility = $results_array['visibility'];
|
59
|
|
60
|
// Check if we should delete it or just set the visibility to 'deleted'
|
61
|
if(PAGE_TRASH != 'disabled' AND $visibility != 'deleted') {
|
62
|
// Page trash is enabled and page has not yet been deleted
|
63
|
// Function to change all child pages visibility to deleted
|
64
|
function trash_subs($parent = 0) {
|
65
|
global $database;
|
66
|
// Query pages
|
67
|
$query_menu = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC");
|
68
|
// Check if there are any pages to show
|
69
|
if($query_menu->numRows() > 0) {
|
70
|
// Loop through pages
|
71
|
while($page = $query_menu->fetchRow()) {
|
72
|
// Update the page visibility to 'deleted'
|
73
|
$database->query("UPDATE ".TABLE_PREFIX."pages SET visibility = 'deleted' WHERE page_id = '".$page['page_id']."' LIMIT 1");
|
74
|
// Run this function again for all sub-pages
|
75
|
trash_subs($page['page_id']);
|
76
|
}
|
77
|
}
|
78
|
}
|
79
|
|
80
|
// Update the page visibility to 'deleted'
|
81
|
$database->query("UPDATE ".TABLE_PREFIX."pages SET visibility = 'deleted' WHERE page_id = '$page_id.' LIMIT 1");
|
82
|
|
83
|
// Run trash subs for this page
|
84
|
trash_subs($page_id);
|
85
|
} else {
|
86
|
// Really dump the page
|
87
|
// Delete page subs
|
88
|
$sub_pages = get_subs($page_id, array());
|
89
|
foreach($sub_pages AS $sub_page_id) {
|
90
|
delete_page($sub_page_id);
|
91
|
}
|
92
|
// Delete page
|
93
|
delete_page($page_id);
|
94
|
}
|
95
|
|
96
|
// Check if there is a db error, otherwise say successful
|
97
|
if($database->is_error()) {
|
98
|
$admin->print_error($database->get_error());
|
99
|
} else {
|
100
|
$admin->print_success($MESSAGE['PAGES']['DELETED']);
|
101
|
}
|
102
|
|
103
|
// Print admin footer
|
104
|
$admin->print_footer();
|
105
|
|
106
|
?>
|