Project

General

Profile

1
<?php
2

    
3
// $Id: modify.php 42 2005-09-07 21:10:36Z stefan $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
// Get page id
27
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
28
	header("Location: index.php");
29
} else {
30
	$page_id = $_GET['page_id'];
31
}
32

    
33
// Create new admin object
34
require('../../config.php');
35
require_once(WB_PATH.'/framework/class.admin.php');
36
$admin = new admin('Pages', 'pages_modify');
37

    
38
// Get perms
39
$database = new database();
40
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
41
$results_array = $results->fetchRow();
42
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
43
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
44
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
45
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
46
}
47

    
48
// Get page details
49
$database = new database();
50
$query = "SELECT page_id,page_title,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
51
$results = $database->query($query);
52
if($database->is_error()) {
53
	$admin->print_header();
54
	$admin->print_error($database->get_error());
55
}
56
if($results->numRows() == 0) {
57
	$admin->print_header();
58
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
59
}
60
$results_array = $results->fetchRow();
61

    
62
// Get display name of person who last modified the page
63
$query_user = "SELECT username,display_name FROM ".TABLE_PREFIX."users WHERE user_id = '".$results_array['modified_by']."'";
64
$get_user = $database->query($query_user);
65
if($get_user->numRows() != 0) {
66
	$user = $get_user->fetchRow();
67
} else {
68
	$user['display_name'] = 'Unknown';
69
	$user['username'] = 'unknown';
70
}
71
// Convert the unix ts for modified_when to human a readable form
72
if($results_array['modified_when'] != 0) {
73
	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
74
} else {
75
	$modified_ts = 'Unknown';
76
}
77

    
78
// Include page info script
79
$template = new Template(ADMIN_PATH.'/pages');
80
$template->set_file('page', 'modify.html');
81
$template->set_block('page', 'main_block', 'main');
82
$template->set_var(array(
83
								'PAGE_ID' => $results_array['page_id'],
84
								'PAGE_TITLE' => $admin->strip_slashes_dummy($results_array['page_title']),
85
								'MODIFIED_BY' => $user['display_name'],
86
								'MODIFIED_BY_USERNAME' => $user['username'],
87
								'MODIFIED_WHEN' => $modified_ts,
88
								'ADMIN_URL' => ADMIN_URL
89
								)
90
						);
91
if($modified_ts == 'Unknown') {
92
	$template->set_var('DISPLAY_MODIFIED', 'hide');
93
} else {
94
	$template->set_var('DISPLAY_MODIFIED', '');
95
}
96

    
97
// Work-out if we should show the "manage sections" link
98
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
99
if($query_sections->numRows() > 0) {
100
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
101
} elseif(MANAGE_SECTIONS == 'enabled') {
102
	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
103
} else {
104
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
105
}
106

    
107
// Insert language TEXT
108
$template->set_var(array(
109
								'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
110
								'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
111
								'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
112
								'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
113
								)
114
						);
115

    
116
// Parse and print header template
117
$template->parse('main', 'main_block', false);
118
$template->pparse('output', 'page');
119

    
120
// Get sections for this page
121
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
122
if($query_sections->numRows() > 0) {
123
	while($section = $query_sections->fetchRow()) {
124
		$section_id = $section['section_id'];
125
		$module = $section['module'];
126
		// Include the modules editing script if it exists
127
		if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php')) {
128
			echo '<a name="'.$section_id.'"></a>';
129
			require(WB_PATH.'/modules/'.$module.'/modify.php');
130
		}
131
	}
132
}
133

    
134
// Print admin footer
135
$admin->print_footer();
136

    
137
?>
(9-9/20)