Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        backend
5
 * @package         modules
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2010, 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: admin.php 1396 2011-01-19 14:53:30Z DarkViper $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/admin.php $
15
 * @lastmodified    $Date: 2011-01-19 15:53:30 +0100 (Wed, 19 Jan 2011) $
16
 *
17
*/
18

    
19
// Stop this file being access directly
20
if(!defined('WB_PATH')) { die('Direct access to this file is not allowed'); }
21

    
22
// Get page id
23
if(isset($_GET['page_id']) && is_numeric($_GET['page_id'])) {
24
	$page_id = (int)$_GET['page_id'];
25
} elseif(isset($_POST['page_id']) && is_numeric($_POST['page_id'])) {
26
	$page_id = (int)$_POST['page_id'];
27
} else {
28
	header("Location: index.php");
29
	exit(0);
30
}
31

    
32
// Get section id if there is one
33
if(isset($_GET['section_id']) && is_numeric($_GET['section_id'])) {
34
	$section_id = (int)$_GET['section_id'];
35
} elseif(isset($_POST['section_id']) && is_numeric($_POST['section_id'])) {
36
	$section_id = (int)$_POST['section_id'];
37
} else {
38
	// Check if we should redirect the user if there is no section id
39
	if(!isset($section_required)) {
40
		$section_id = 0;
41
	} else {
42
		header("Location: $section_required");
43
		exit(0);
44
	}
45
}
46

    
47
// Create js back link
48
$js_back = 'javascript: history.go(-1);';
49

    
50
// Create new admin object
51
require(WB_PATH.'/framework/class.admin.php');
52
$admin = new admin('Pages', 'pages_modify');
53

    
54
// Get perms
55
// $database = new database();
56
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
57
$results_array = $results->fetchRow();
58
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
59
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
60

    
61
$in_group = FALSE;
62
foreach($admin->get_groups_id() as $cur_gid){
63
    if (in_array($cur_gid, $old_admin_groups)) {
64
        $in_group = TRUE;
65
    }
66
}
67
if((!$in_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
68
	echo $admin->get_group_id().$admin->get_user_id();
69
	print_r ($old_admin_groups);
70
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
71
}
72

    
73
// Workout if the developer wants to show the info banner
74
if(isset($print_info_banner) && $print_info_banner == true) {
75
	
76
// Get page details
77
// $database = new database();
78
$query = "SELECT page_id,page_title,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
79
$results = $database->query($query);
80
if($database->is_error()) {
81
	$admin->print_header();
82
	$admin->print_error($database->get_error());
83
}
84
if($results->numRows() == 0) {
85
	$admin->print_header();
86
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
87
}
88
$results_array = $results->fetchRow();
89

    
90
// Get display name of person who last modified the page
91
$user=$admin->get_user_details($results_array['modified_by']);
92

    
93
// Convert the unix ts for modified_when to human a readable form
94
if($results_array['modified_when'] != 0) {
95
	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
96
} else {
97
	$modified_ts = 'Unknown';
98
}
99

    
100
// Include page info script
101
$template = new Template(THEME_PATH.'/templates');
102
$template->set_file('page', 'pages_modify.htt');
103
$template->set_block('page', 'main_block', 'main');
104
$template->set_var(array(
105
					'PAGE_ID' => $results_array['page_id'],
106
					'PAGE_TITLE' => ($results_array['page_title']),
107
					'MODIFIED_BY' => $user['display_name'],
108
					'MODIFIED_BY_USERNAME' => $user['username'],
109
					'MODIFIED_WHEN' => $modified_ts,
110
					'ADMIN_URL' => ADMIN_URL
111
					)
112
				);
113
if($modified_ts == 'Unknown') {
114
	$template->set_var('DISPLAY_MODIFIED', 'hide');
115
} else {
116
	$template->set_var('DISPLAY_MODIFIED', '');
117
}
118

    
119
// Work-out if we should show the "manage sections" link
120
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
121
if($query_sections->numRows() > 0) {
122
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
123
} elseif(MANAGE_SECTIONS == 'enabled') {
124
	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
125
} else {
126
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
127
}
128

    
129
// Insert language TEXT
130
$template->set_var(array(
131
					'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
132
					'TEXT_CHANGE' => $TEXT['CHANGE'],
133
					'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
134
					'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
135
					'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
136
					)
137
				);
138

    
139
// Parse and print header template
140
$template->parse('main', 'main_block', false);
141
$template->pparse('output', 'page');
142

    
143
}
144

    
145
// Work-out if the developer wants us to update the timestamp for when the page was last modified
146
if(isset($update_when_modified) && $update_when_modified == true) {
147
	$database->query("UPDATE ".TABLE_PREFIX."pages SET modified_when = '".time()."', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'");
148
}
149

    
150
?>
(1-1/3)