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: restore.php 2 2017-07-02 15:14:29Z Manuela $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/admin/pages/restore.php $
|
15
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
// Get page id
|
20
|
if(!isset($_GET['page_id']) OR !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
|
// Get perms
|
36
|
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
|
37
|
$results_array = $results->fetchRow();
|
38
|
|
39
|
// Find out more about the page
|
40
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
|
41
|
$results = $database->query($query);
|
42
|
if($database->is_error()) {
|
43
|
$admin->print_error($database->get_error());
|
44
|
}
|
45
|
if($results->numRows() == 0) {
|
46
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
47
|
}
|
48
|
$results_array = $results->fetchRow();
|
49
|
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
|
50
|
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
|
51
|
|
52
|
$in_old_group = FALSE;
|
53
|
foreach($admin->get_groups_id() as $cur_gid){
|
54
|
if (in_array($cur_gid, $old_admin_groups)) {
|
55
|
$in_old_group = TRUE;
|
56
|
}
|
57
|
}
|
58
|
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
59
|
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
60
|
}
|
61
|
|
62
|
$visibility = $results_array['visibility'];
|
63
|
|
64
|
if(PAGE_TRASH) {
|
65
|
if($visibility == 'deleted') {
|
66
|
// Function to change all child pages visibility to deleted
|
67
|
function restore_subs($parent = 0) {
|
68
|
global $database;
|
69
|
// Query pages
|
70
|
$query_menu = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC");
|
71
|
// Check if there are any pages to show
|
72
|
if($query_menu->numRows() > 0) {
|
73
|
// Loop through pages
|
74
|
while($page = $query_menu->fetchRow()) {
|
75
|
// Update the page visibility to 'deleted'
|
76
|
$database->query("UPDATE ".TABLE_PREFIX."pages SET visibility = 'public' WHERE page_id = '".$page['page_id']."' LIMIT 1");
|
77
|
// Run this function again for all sub-pages
|
78
|
restore_subs($page['page_id']);
|
79
|
}
|
80
|
}
|
81
|
}
|
82
|
|
83
|
// Update the page visibility to 'deleted'
|
84
|
$database->query("UPDATE ".TABLE_PREFIX."pages SET visibility = 'public' WHERE page_id = '$page_id.' LIMIT 1");
|
85
|
|
86
|
// Run trash subs for this page
|
87
|
restore_subs($page_id);
|
88
|
|
89
|
}
|
90
|
}
|
91
|
|
92
|
// Check if there is a db error, otherwise say successful
|
93
|
if($database->is_error()) {
|
94
|
$admin->print_error($database->get_error());
|
95
|
} else {
|
96
|
$admin->print_success($MESSAGE['PAGES']['RESTORED']);
|
97
|
}
|
98
|
|
99
|
// Print admin footer
|
100
|
$admin->print_footer();
|
101
|
|
102
|
?>
|