Revision 35
Added by stefan about 19 years ago
delete.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
// $Id: delete.php,v 1.7 2005/04/02 06:25:37 rdjurovich Exp $
|
|
3 |
// $Id$ |
|
4 | 4 |
|
5 | 5 |
/* |
6 | 6 |
|
... | ... | |
39 | 39 |
require_once(WB_PATH.'/framework/functions.php'); |
40 | 40 |
|
41 | 41 |
// Get perms |
42 |
$database = new database(); |
|
43 | 42 |
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"); |
44 | 43 |
$results_array = $results->fetchRow(); |
45 |
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups'])); |
|
46 |
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users'])); |
|
47 |
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) { |
|
48 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
49 |
} |
|
50 | 44 |
|
51 | 45 |
// Find out more about the page |
52 |
$database = new database(); |
|
53 |
$query = "SELECT page_id,menu_title,page_title,level,link,parent,modified_by,modified_when,visibility FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
46 |
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
54 | 47 |
$results = $database->query($query); |
55 | 48 |
if($database->is_error()) { |
56 | 49 |
$admin->print_error($database->get_error()); |
... | ... | |
59 | 52 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
60 | 53 |
} |
61 | 54 |
$results_array = $results->fetchRow(); |
62 |
$parent = $results_array['parent']; |
|
63 |
$level = $results_array['level']; |
|
64 |
$link = $results_array['link']; |
|
55 |
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups'])); |
|
56 |
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users'])); |
|
57 |
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) { |
|
58 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
59 |
} |
|
60 |
|
|
65 | 61 |
$visibility = $results_array['visibility']; |
66 |
$page_title = stripslashes($results_array['page_title']); |
|
67 |
$menu_title = stripslashes($results_array['menu_title']); |
|
68 | 62 |
|
69 | 63 |
// Check if we should delete it or just set the visibility to 'deleted' |
70 |
if(PAGE_TRASH != 'disabled') { |
|
71 |
if($visibility == 'deleted') { |
|
72 |
$delete_method = 'actual'; |
|
73 |
} else { |
|
74 |
$delete_method = 'visibility'; |
|
75 |
} |
|
76 |
} else { |
|
77 |
$delete_method = 'actual'; |
|
78 |
} |
|
79 |
|
|
80 |
if($delete_method == 'actual') { |
|
81 |
|
|
82 |
// Delete page subs |
|
83 |
$sub_pages = get_subs($page_id, array()); |
|
84 |
foreach($sub_pages AS $sub_page_id) { |
|
85 |
delete_page($sub_page_id); |
|
86 |
} |
|
87 |
// Delete page |
|
88 |
delete_page($page_id); |
|
89 |
|
|
90 |
} else { |
|
91 |
|
|
64 |
if(PAGE_TRASH != 'disabled' AND $visibility != 'deleted') { |
|
65 |
// Page trash is enabled and page has not yet been deleted |
|
92 | 66 |
// Function to change all child pages visibility to deleted |
93 | 67 |
function trash_subs($parent = 0) { |
94 |
global $database, $admin, $page_id, $page_trail, $private_sql, $private_where_sql;
|
|
68 |
global $database; |
|
95 | 69 |
// Query pages |
96 | 70 |
$query_menu = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC"); |
97 | 71 |
// Check if there are any pages to show |
... | ... | |
111 | 85 |
|
112 | 86 |
// Run trash subs for this page |
113 | 87 |
trash_subs($page_id); |
114 |
|
|
115 |
} |
|
88 |
} else { |
|
89 |
// Really dump the page |
|
90 |
// Delete page subs |
|
91 |
$sub_pages = get_subs($page_id, array()); |
|
92 |
foreach($sub_pages AS $sub_page_id) { |
|
93 |
delete_page($sub_page_id); |
|
94 |
} |
|
95 |
// Delete page |
|
96 |
delete_page($page_id); |
|
97 |
} |
|
116 | 98 |
|
117 | 99 |
// Check if there is a db error, otherwise say successful |
118 | 100 |
if($database->is_error()) { |
Also available in: Unified diff
Cleaned up code concerning deleting/restoring pages.