1
|
<?php
|
2
|
|
3
|
/*
|
4
|
|
5
|
Website Baker Project <http://www.websitebaker.org/>
|
6
|
Copyright (C) 2004-2005, Ryan Djurovich
|
7
|
|
8
|
Website Baker is free software; you can redistribute it and/or modify
|
9
|
it under the terms of the GNU General Public License as published by
|
10
|
the Free Software Foundation; either version 2 of the License, or
|
11
|
(at your option) any later version.
|
12
|
|
13
|
Website Baker is distributed in the hope that it will be useful,
|
14
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
GNU General Public License for more details.
|
17
|
|
18
|
You should have received a copy of the GNU General Public License
|
19
|
along with Website Baker; if not, write to the Free Software
|
20
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
21
|
|
22
|
*/
|
23
|
|
24
|
// Include config file
|
25
|
require('../../config.php');
|
26
|
|
27
|
// Make sure people are allowed to access this page
|
28
|
if(MANAGE_SECTIONS != 'enabled') {
|
29
|
header('Location: '.ADMIN_URL.'/pages/index.php');
|
30
|
exit(0);
|
31
|
}
|
32
|
|
33
|
// Get page id
|
34
|
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
|
35
|
header("Location: index.php");
|
36
|
exit(0);
|
37
|
} else {
|
38
|
$page_id = $_GET['page_id'];
|
39
|
}
|
40
|
|
41
|
// Create new admin object
|
42
|
require_once(WB_PATH.'/framework/class.admin.php');
|
43
|
$admin = new admin('Pages', 'pages_modify');
|
44
|
|
45
|
// Check if we are supposed to add or delete a section
|
46
|
if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
|
47
|
// Get more information about this section
|
48
|
$section_id = $_GET['section_id'];
|
49
|
$query_section = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id'");
|
50
|
if($query_section->numRows() == 0) {
|
51
|
$admin->print_error('Section not found');
|
52
|
}
|
53
|
$section = $query_section->fetchRow();
|
54
|
// Include the modules delete file if it exists
|
55
|
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
|
56
|
require(WB_PATH.'/modules/'.$section['module'].'/delete.php');
|
57
|
}
|
58
|
$database->query("DELETE FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' LIMIT 1");
|
59
|
if($database->is_error()) {
|
60
|
$admin->print_error($database->get_error());
|
61
|
} else {
|
62
|
require(WB_PATH.'/framework/class.order.php');
|
63
|
$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
|
64
|
$order->clean($page_id);
|
65
|
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
|
66
|
$admin->print_footer();
|
67
|
exit();
|
68
|
}
|
69
|
} elseif(isset($_POST['module']) AND $_POST['module'] != '') {
|
70
|
// Get section info
|
71
|
$module = $_POST['module'];
|
72
|
// Include the ordering class
|
73
|
require(WB_PATH.'/framework/class.order.php');
|
74
|
// Get new order
|
75
|
$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
|
76
|
$position = $order->get_new($page_id);
|
77
|
// Insert module into DB
|
78
|
$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,module,position,block) VALUES ('$page_id','$module','$position','1')");
|
79
|
// Get the section id
|
80
|
$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
|
81
|
// Include the selected modules add file if it exists
|
82
|
if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) {
|
83
|
require(WB_PATH.'/modules/'.$module.'/add.php');
|
84
|
}
|
85
|
}
|
86
|
|
87
|
// Get perms
|
88
|
$database = new database();
|
89
|
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
|
90
|
$results_array = $results->fetchRow();
|
91
|
$old_admin_groups = explode(',', $results_array['admin_groups']);
|
92
|
$old_admin_users = explode(',', $results_array['admin_users']);
|
93
|
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
94
|
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
95
|
}
|
96
|
|
97
|
// Get page details
|
98
|
$database = new database();
|
99
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
|
100
|
$results = $database->query($query);
|
101
|
if($database->is_error()) {
|
102
|
$admin->print_header();
|
103
|
$admin->print_error($database->get_error());
|
104
|
}
|
105
|
if($results->numRows() == 0) {
|
106
|
$admin->print_header();
|
107
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
108
|
}
|
109
|
$results_array = $results->fetchRow();
|
110
|
|
111
|
// Set module permissions
|
112
|
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
113
|
|
114
|
// Unset block var
|
115
|
unset($block);
|
116
|
// Include template info file (if it exists)
|
117
|
if($results_array['template'] != '') {
|
118
|
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
|
119
|
} else {
|
120
|
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
|
121
|
}
|
122
|
if(file_exists($template_location)) {
|
123
|
require($template_location);
|
124
|
}
|
125
|
// Check if $menu is set
|
126
|
if(!isset($block[1]) OR $block[1] == '') {
|
127
|
// Make our own menu list
|
128
|
$block[1] = $TEXT['MAIN'];
|
129
|
}
|
130
|
|
131
|
?>
|
132
|
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%" height="50" style="margin-bottom: 10px;">
|
133
|
<tr style="background-color: #F0F0F0;">
|
134
|
<td valign="middle" align="left">
|
135
|
<h2><?php echo $HEADING['MANAGE_SECTIONS']; ?></h2>
|
136
|
</td>
|
137
|
<td align="right">
|
138
|
<?php echo $TEXT['CURRENT_PAGE']; ?>:
|
139
|
<b><?php echo ($results_array['page_title']); ?></b>
|
140
|
-
|
141
|
<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>"><?php echo $HEADING['MODIFY_PAGE']; ?></a>
|
142
|
-
|
143
|
<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page_id; ?>"><?php echo $TEXT['CHANGE_SETTINGS']; ?></a>
|
144
|
</td>
|
145
|
</tr>
|
146
|
</table>
|
147
|
|
148
|
<?php
|
149
|
$query_sections = $database->query("SELECT section_id,module,position,block FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
|
150
|
if($query_sections->numRows() > 0) {
|
151
|
?>
|
152
|
<form name="section_properties" action="<?php echo ADMIN_URL; ?>/pages/sections_save.php?page_id=<?php echo $page_id; ?>" method="post">
|
153
|
|
154
|
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%">
|
155
|
<tr>
|
156
|
<td><?php echo $TEXT['TYPE']; ?>:</td>
|
157
|
<?php if(SECTION_BLOCKS) { ?>
|
158
|
<td style="display: {DISPLAY_BLOCK}"><?php echo $TEXT['BLOCK']; ?>:</td>
|
159
|
<?php } ?>
|
160
|
<td colspan="3" width="60"><?php echo $TEXT['ACTIONS']; ?>:</td>
|
161
|
</tr>
|
162
|
<?php
|
163
|
$num_sections = $query_sections->numRows();
|
164
|
while($section = $query_sections->fetchRow()) {
|
165
|
// Get the modules real name
|
166
|
$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php';
|
167
|
if(file_exists($module_path)) {
|
168
|
require($module_path);
|
169
|
if(!isset($module_function)) { $module_function = 'unknown'; }
|
170
|
if(!is_numeric(array_search($section['module'], $module_permissions)) AND $module_function == 'page') {
|
171
|
?>
|
172
|
<tr>
|
173
|
<td style="width: 250px;"><a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>#<?php echo $section['section_id']; ?>"><?php echo $module_name; ?></a></td>
|
174
|
<?php if(SECTION_BLOCKS) { ?>
|
175
|
<td>
|
176
|
<select name="block<?php echo $section['section_id']; ?>" style="width: 150px;">
|
177
|
<?php
|
178
|
foreach($block AS $number => $name) {
|
179
|
?>
|
180
|
<option value="<?php echo $number; ?>"<?php if($number == $section['block']) { echo ' selected'; } ?>><?php echo $name; ?></option>
|
181
|
<?php
|
182
|
}
|
183
|
?>
|
184
|
</select>
|
185
|
</td>
|
186
|
<?php } ?>
|
187
|
<td width="20">
|
188
|
<?php if($section['position'] != 1) { ?>
|
189
|
<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>">
|
190
|
<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" alt="^" border="0" />
|
191
|
</a>
|
192
|
<?php } ?>
|
193
|
</td>
|
194
|
<td width="20">
|
195
|
<?php if($section['position'] != $num_sections) { ?>
|
196
|
<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>">
|
197
|
<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" alt="v" border="0" />
|
198
|
</a>
|
199
|
<?php } ?>
|
200
|
</td>
|
201
|
<td width="20">
|
202
|
<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>');">
|
203
|
<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="Del" border="0" />
|
204
|
</a>
|
205
|
</td>
|
206
|
</tr>
|
207
|
<?php
|
208
|
}
|
209
|
if(isset($module_function)) { unset($module_function); } // Unset module type
|
210
|
}
|
211
|
}
|
212
|
?>
|
213
|
<tr>
|
214
|
<td> </td>
|
215
|
<?php if(SECTION_BLOCKS) { ?>
|
216
|
<td><input type="submit" name="save" value="<?php echo $TEXT['SAVE']; ?>" style="width: 150px;" /></td>
|
217
|
<?php } ?>
|
218
|
<td colspan="3" width="60"> </td>
|
219
|
</tr>
|
220
|
</table>
|
221
|
|
222
|
</form>
|
223
|
|
224
|
<?php
|
225
|
}
|
226
|
|
227
|
// Work-out if we should show the "Add Section" form
|
228
|
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
|
229
|
if($query_sections->numRows() == 0) {
|
230
|
?>
|
231
|
<h2><?php echo $TEXT['ADD_SECTION']; ?></h2>
|
232
|
|
233
|
<form name="add" action="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>" method="post">
|
234
|
|
235
|
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%">
|
236
|
<tr>
|
237
|
<td>
|
238
|
<select name="module" style="width: 100%;">
|
239
|
<?php
|
240
|
// Insert module list
|
241
|
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' AND directory != 'menu_link'");
|
242
|
if($result->numRows() > 0) {
|
243
|
while($module = $result->fetchRow()) {
|
244
|
// Check if user is allowed to use this module
|
245
|
if(!is_numeric(array_search($module['directory'], $module_permissions))) {
|
246
|
?>
|
247
|
<option value="<?php echo $module['directory']; ?>"<?php if($module['directory'] == 'wysiwyg') { echo 'selected'; } ?>><?php echo $module['name']; ?></option>
|
248
|
<?php
|
249
|
}
|
250
|
}
|
251
|
}
|
252
|
?>
|
253
|
</select>
|
254
|
</td>
|
255
|
<td width="100">
|
256
|
<input type="submit" name="submit" value="<?php echo $TEXT['ADD']; ?>" style="width: 100px" />
|
257
|
</td>
|
258
|
</tr>
|
259
|
</table>
|
260
|
|
261
|
</form>
|
262
|
<?php
|
263
|
}
|
264
|
|
265
|
// Print admin footer
|
266
|
$admin->print_footer();
|
267
|
|
268
|
?>
|