Project

General

Profile

« Previous | Next » 

Revision 35

Added by stefan about 19 years ago

Cleaned up code concerning deleting/restoring pages.

View differences:

restore.php
1 1
<?php
2 2

  
3
// $Id: restore.php,v 1.2 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
// Check if we should delete it or just set the visibility to 'deleted'
70 63
if(PAGE_TRASH) {
71 64
	if($visibility == 'deleted') {	
72
		
73 65
		// Function to change all child pages visibility to deleted
74 66
		function restore_subs($parent = 0) {
75
			global $database, $admin, $page_id, $page_trail, $private_sql, $private_where_sql;
67
			global $database;
76 68
			// Query pages
77 69
			$query_menu = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC");
78 70
			// Check if there are any pages to show

Also available in: Unified diff