Revision 1009
Added by Matthias over 16 years ago
| sections.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
|
|
| 3 |
// $Id$ |
|
| 4 |
|
|
| 5 |
/* |
|
| 6 |
|
|
| 7 |
Website Baker Project <http://www.websitebaker.org/> |
|
| 8 |
Copyright (C) 2004-2009, 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 |
// Include config file |
|
| 27 |
require('../../config.php');
|
|
| 28 |
|
|
| 29 |
// Make sure people are allowed to access this page |
|
| 30 |
if(MANAGE_SECTIONS != 'enabled') {
|
|
| 31 |
header('Location: '.ADMIN_URL.'/pages/index.php');
|
|
| 32 |
exit(0); |
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
// Get page id |
|
| 36 |
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
|
|
| 37 |
header("Location: index.php");
|
|
| 38 |
exit(0); |
|
| 39 |
} else {
|
|
| 40 |
$page_id = $_GET['page_id']; |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
// Create new admin object |
|
| 44 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
| 45 |
$admin = new admin('Pages', 'pages_modify');
|
|
| 46 |
|
|
| 47 |
// Check if we are supposed to add or delete a section |
|
| 48 |
if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
|
|
| 49 |
// Get more information about this section |
|
| 50 |
$section_id = $_GET['section_id']; |
|
| 51 |
$query_section = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id'");
|
|
| 52 |
if($query_section->numRows() == 0) {
|
|
| 53 |
$admin->print_error('Section not found');
|
|
| 54 |
} |
|
| 55 |
$section = $query_section->fetchRow(); |
|
| 56 |
// Include the modules delete file if it exists |
|
| 57 |
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
|
|
| 58 |
require(WB_PATH.'/modules/'.$section['module'].'/delete.php'); |
|
| 59 |
} |
|
| 60 |
$database->query("DELETE FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' LIMIT 1");
|
|
| 61 |
if($database->is_error()) {
|
|
| 62 |
$admin->print_error($database->get_error()); |
|
| 63 |
} else {
|
|
| 64 |
require(WB_PATH.'/framework/class.order.php'); |
|
| 65 |
$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id'); |
|
| 66 |
$order->clean($page_id); |
|
| 67 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id); |
|
| 68 |
$admin->print_footer(); |
|
| 69 |
exit(); |
|
| 70 |
} |
|
| 71 |
} elseif(isset($_POST['module']) AND $_POST['module'] != '') {
|
|
| 72 |
// Get section info |
|
| 73 |
$module = $admin->add_slashes($_POST['module']); |
|
| 74 |
// Include the ordering class |
|
| 75 |
require(WB_PATH.'/framework/class.order.php'); |
|
| 76 |
// Get new order |
|
| 77 |
$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id'); |
|
| 78 |
$position = $order->get_new($page_id); |
|
| 79 |
// Insert module into DB |
|
| 80 |
$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,module,position,block) VALUES ('$page_id','$module','$position','1')");
|
|
| 81 |
// Get the section id |
|
| 82 |
$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
|
|
| 83 |
// Include the selected modules add file if it exists |
|
| 84 |
if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) {
|
|
| 85 |
require(WB_PATH.'/modules/'.$module.'/add.php'); |
|
| 86 |
} |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
// Get perms |
|
| 90 |
$database = new database(); |
|
| 91 |
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
|
|
| 92 |
$results_array = $results->fetchRow(); |
|
| 93 |
$old_admin_groups = explode(',', $results_array['admin_groups']);
|
|
| 94 |
$old_admin_users = explode(',', $results_array['admin_users']);
|
|
| 95 |
$in_old_group = FALSE; |
|
| 96 |
foreach($admin->get_groups_id() as $cur_gid){
|
|
| 97 |
if (in_array($cur_gid, $old_admin_groups)) {
|
|
| 98 |
$in_old_group = TRUE; |
|
| 99 |
} |
|
| 100 |
} |
|
| 101 |
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
|
| 102 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
// Get page details |
|
| 106 |
$database = new database(); |
|
| 107 |
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
| 108 |
$results = $database->query($query); |
|
| 109 |
if($database->is_error()) {
|
|
| 110 |
$admin->print_header(); |
|
| 111 |
$admin->print_error($database->get_error()); |
|
| 112 |
} |
|
| 113 |
if($results->numRows() == 0) {
|
|
| 114 |
$admin->print_header(); |
|
| 115 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
| 116 |
} |
|
| 117 |
$results_array = $results->fetchRow(); |
|
| 118 |
|
|
| 119 |
// Set module permissions |
|
| 120 |
$module_permissions = $_SESSION['MODULE_PERMISSIONS']; |
|
| 121 |
|
|
| 122 |
// Unset block var |
|
| 123 |
unset($block); |
|
| 124 |
// Include template info file (if it exists) |
|
| 125 |
if($results_array['template'] != '') {
|
|
| 126 |
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php'; |
|
| 127 |
} else {
|
|
| 128 |
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php'; |
|
| 129 |
} |
|
| 130 |
if(file_exists($template_location)) {
|
|
| 131 |
require($template_location); |
|
| 132 |
} |
|
| 133 |
// Check if $menu is set |
|
| 134 |
if(!isset($block[1]) OR $block[1] == '') {
|
|
| 135 |
// Make our own menu list |
|
| 136 |
$block[1] = $TEXT['MAIN']; |
|
| 137 |
} |
|
| 138 |
?> |
|
| 139 |
|
|
| 140 |
<?php // include jscalendar-setup |
|
| 141 |
$jscal_use_time = true; // whether to use a clock, too |
|
| 142 |
require_once(WB_PATH."/include/jscalendar/wb-setup.php"); |
|
| 143 |
?> |
|
| 144 |
<table cellpadding="0" cellspacing="0" class="sections_header"> |
|
| 145 |
<tr> |
|
| 146 |
<td valign="middle" align="left"> |
|
| 147 |
<h2><?php echo $HEADING['MANAGE_SECTIONS']; ?></h2> |
|
| 148 |
</td> |
|
| 149 |
<td align="right"> |
|
| 150 |
<?php echo $TEXT['CURRENT_PAGE']; ?>: |
|
| 151 |
<b><?php echo ($results_array['page_title']); ?></b> |
|
| 152 |
- |
|
| 153 |
<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>"><?php echo $HEADING['MODIFY_PAGE']; ?></a> |
|
| 154 |
- |
|
| 155 |
<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page_id; ?>"><?php echo $TEXT['CHANGE_SETTINGS']; ?></a> |
|
| 156 |
</td> |
|
| 157 |
</tr> |
|
| 158 |
</table> |
|
| 159 |
|
|
| 160 |
<?php |
|
| 161 |
$query_sections = $database->query("SELECT section_id,module,position,block,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
|
|
| 162 |
if($query_sections->numRows() > 0) {
|
|
| 163 |
?> |
|
| 164 |
<form name="section_properties" action="<?php echo ADMIN_URL; ?>/pages/sections_save.php?page_id=<?php echo $page_id; ?>" method="post"> |
|
| 165 |
|
|
| 166 |
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%"> |
|
| 167 |
<tr> |
|
| 168 |
<td><?php echo $TEXT['TYPE']; ?>:</td> |
|
| 169 |
<?php if(SECTION_BLOCKS) { ?>
|
|
| 170 |
<td style="display: {DISPLAY_BLOCK}"><?php echo $TEXT['BLOCK']; ?>:</td>
|
|
| 171 |
<?php } ?> |
|
| 172 |
<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td> |
|
| 173 |
<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td> |
|
| 174 |
<td colspan="3" width="60"><?php echo $TEXT['ACTIONS']; ?>:</td> |
|
| 175 |
</tr> |
|
| 176 |
<?php |
|
| 177 |
$num_sections = $query_sections->numRows(); |
|
| 178 |
while($section = $query_sections->fetchRow()) {
|
|
| 179 |
// Get the modules real name |
|
| 180 |
$module_name=$database->get_one("SELECT name FROM ".TABLE_PREFIX."addons WHERE directory='".$section['module']."'");
|
|
| 181 |
if(!is_numeric(array_search($section['module'], $module_permissions))) {
|
|
| 182 |
?> |
|
| 183 |
<tr onmouseover="this.style.backgroundColor = '#F1F8DD'" onmouseout="this.style.backgroundColor = '#FFF'"> |
|
| 184 |
<td class="<?php if(SECTION_BLOCKS) print 'input_normal'; else print 'input_wide'; ?>"><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> |
|
| 185 |
<?php if(SECTION_BLOCKS) { ?>
|
|
| 186 |
<td> |
|
| 187 |
<select name="block<?php echo $section['section_id']; ?>" class="input_normal"> |
|
| 188 |
<?php |
|
| 189 |
foreach($block AS $number => $name) {
|
|
| 190 |
?> |
|
| 191 |
<option value="<?php echo $number; ?>"<?php |
|
| 192 |
if($number == $section['block']) { echo ' selected'; } ?>><?php
|
|
| 193 |
$block_name = htmlentities(strip_tags($name)); |
|
| 194 |
$block_name = ($block_name == '') ? $TEXT['BLOCK'] . '#' . (int) $number : $block_name; |
|
| 195 |
echo $block_name; ?></option> |
|
| 196 |
<?php |
|
| 197 |
} |
|
| 198 |
?> |
|
| 199 |
</select> |
|
| 200 |
</td> |
|
| 201 |
<?php } // jscalendar-stuff following ?> |
|
| 202 |
<td><input type="text" id="start_date<?php echo $section['section_id']; ?>" name="start_date<?php echo $section['section_id']; ?>" value="<?php if($section['publ_start']==0) print ""; else print date($jscal_format, $section['publ_start'])?>" class="input_normal" /> |
|
| 203 |
<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="trigger_start<?php echo $section['section_id']; ?>" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" /> |
|
| 204 |
<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" onclick="document.section_properties.start_date<?php echo $section['section_id']; ?>.value=''" /> |
|
| 205 |
</td> |
|
| 206 |
<td><input type="text" id="end_date<?php echo $section['section_id']; ?>" name="end_date<?php echo $section['section_id']; ?>" value="<?php if($section['publ_end']==0) print ""; else print date($jscal_format, $section['publ_end'])?>" class="input_normal" /> |
|
| 207 |
<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="trigger_stop<?php echo $section['section_id']; ?>" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" /> |
|
| 208 |
<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" title="<?php echo $TEXT['DELETE_DATE']; ?>" onclick="document.section_properties.end_date<?php echo $section['section_id']; ?>.value=''"/> |
|
| 209 |
</td> |
|
| 210 |
<td width="20"> |
|
| 211 |
<?php if($section['position'] != 1) { ?>
|
|
| 212 |
<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>"> |
|
| 213 |
<img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="^" border="0" /> |
|
| 214 |
</a> |
|
| 215 |
<?php } ?> |
|
| 216 |
</td> |
|
| 217 |
<td width="20"> |
|
| 218 |
<?php if($section['position'] != $num_sections) { ?>
|
|
| 219 |
<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section['section_id']; ?>"> |
|
| 220 |
<img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="v" border="0" /> |
|
| 221 |
</a> |
|
| 222 |
<?php } ?> |
|
| 223 |
</td> |
|
| 224 |
<td width="20"> |
|
| 225 |
<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']; ?>');">
|
|
| 226 |
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="Del" border="0" /> |
|
| 227 |
</a> |
|
| 228 |
</td> |
|
| 229 |
</tr> |
|
| 230 |
<?php |
|
| 231 |
} |
|
| 232 |
} |
|
| 233 |
?> |
|
| 234 |
<tr> |
|
| 235 |
<td align="center" colspan="<?php if(SECTION_BLOCKS) print '7'; else print '6'; ?>"><input type="submit" name="save" value="<?php echo $TEXT['SAVE']; ?>" class="input_medium" /></td> |
|
| 236 |
</tr> |
|
| 237 |
</table> |
|
| 238 |
|
|
| 239 |
</form> |
|
| 240 |
<?php |
|
| 241 |
// now add the calendars -- remember to to set the range to [1970, 2037] if the date is used as timestamp! |
|
| 242 |
// the loop is simply a copy from above. |
|
| 243 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
|
|
| 244 |
if($query_sections->numRows() > 0) {
|
|
| 245 |
$num_sections = $query_sections->numRows(); |
|
| 246 |
while($section = $query_sections->fetchRow()) {
|
|
| 247 |
// Get the modules real name |
|
| 248 |
$module_name=$database->get_one("SELECT name FROM ".TABLE_PREFIX."addons WHERE directory='".$section['module']."'");
|
|
| 249 |
if(!is_numeric(array_search($section['module'], $module_permissions))) {
|
|
| 250 |
?> |
|
| 251 |
<script type="text/javascript"> |
|
| 252 |
Calendar.setup( |
|
| 253 |
{
|
|
| 254 |
inputField : "start_date<?php echo $section['section_id']; ?>", |
|
| 255 |
ifFormat : "<?php echo $jscal_ifformat ?>", |
|
| 256 |
button : "trigger_start<?php echo $section['section_id']; ?>", |
|
| 257 |
firstDay : <?php echo $jscal_firstday ?>, |
|
| 258 |
<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?>
|
|
| 259 |
showsTime : "true", |
|
| 260 |
timeFormat : "24", |
|
| 261 |
<?php } ?> |
|
| 262 |
date : "<?php echo $jscal_today ?>", |
|
| 263 |
range : [1970, 2037], |
|
| 264 |
step : 1 |
|
| 265 |
} |
|
| 266 |
); |
|
| 267 |
</script> |
|
| 268 |
<script type="text/javascript"> |
|
| 269 |
Calendar.setup( |
|
| 270 |
{
|
|
| 271 |
inputField : "end_date<?php echo $section['section_id']; ?>", |
|
| 272 |
ifFormat : "<?php echo $jscal_ifformat ?>", |
|
| 273 |
button : "trigger_stop<?php echo $section['section_id']; ?>", |
|
| 274 |
firstDay : <?php echo $jscal_firstday ?>, |
|
| 275 |
<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE) { ?>
|
|
| 276 |
showsTime : "true", |
|
| 277 |
timeFormat : "24", |
|
| 278 |
<?php } ?> |
|
| 279 |
date : "<?php echo $jscal_today ?>", |
|
| 280 |
range : [1970, 2037], |
|
| 281 |
step : 1 |
|
| 282 |
} |
|
| 283 |
); |
|
| 284 |
</script> |
|
| 285 |
<?php |
|
| 286 |
} |
|
| 287 |
} |
|
| 288 |
} |
|
| 289 |
?> |
|
| 290 |
<?php |
|
| 291 |
} |
|
| 292 |
|
|
| 293 |
// Work-out if we should show the "Add Section" form |
|
| 294 |
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
|
|
| 295 |
if($query_sections->numRows() == 0) {
|
|
| 296 |
?> |
|
| 297 |
<h2><?php echo $TEXT['ADD_SECTION']; ?></h2> |
|
| 298 |
|
|
| 299 |
<form name="add" action="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>" method="post"> |
|
| 300 |
|
|
| 301 |
<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%"> |
|
| 302 |
<tr> |
|
| 303 |
<td> |
|
| 304 |
<select name="module" class="input_full"> |
|
| 305 |
<?php |
|
| 306 |
// Insert module list |
|
| 307 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' AND directory != 'menu_link' order by name");
|
|
| 308 |
if($result->numRows() > 0) {
|
|
| 309 |
while($module = $result->fetchRow()) {
|
|
| 310 |
// Check if user is allowed to use this module |
|
| 311 |
if(!is_numeric(array_search($module['directory'], $module_permissions))) {
|
|
| 312 |
?> |
|
| 313 |
<option value="<?php echo $module['directory']; ?>"<?php if($module['directory'] == 'wysiwyg') { echo 'selected'; } ?>><?php echo $module['name']; ?></option>
|
|
| 314 |
<?php |
|
| 315 |
} |
|
| 316 |
} |
|
| 317 |
} |
|
| 318 |
?> |
|
| 319 |
</select> |
|
| 320 |
</td> |
|
| 321 |
</tr> |
|
| 322 |
<tr> |
|
| 323 |
<td> |
|
| 324 |
<input type="submit" name="submit" value="<?php echo $TEXT['ADD']; ?>" class="input_narrow" /> |
|
| 325 |
</td> |
|
| 326 |
</tr> |
|
| 327 |
</table> |
|
| 328 |
|
|
| 329 |
</form> |
|
| 330 |
<?php |
|
| 331 |
} |
|
| 332 |
|
|
| 333 |
// Print admin footer |
|
| 334 |
$admin->print_footer(); |
|
| 335 |
|
|
| 336 |
?> |
|
| 1 |
<?php |
|
| 2 |
|
|
| 3 |
// $Id$ |
|
| 4 |
|
|
| 5 |
/* |
|
| 6 |
|
|
| 7 |
Website Baker Project <http://www.websitebaker.org/> |
|
| 8 |
Copyright (C) 2004-2009, 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 |
// Include config file |
|
| 27 |
require('../../config.php');
|
|
| 28 |
|
|
| 29 |
// Make sure people are allowed to access this page |
|
| 30 |
if(MANAGE_SECTIONS != 'enabled') {
|
|
| 31 |
header('Location: '.ADMIN_URL.'/pages/index.php');
|
|
| 32 |
exit(0); |
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
// Get page id |
|
| 36 |
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
|
|
| 37 |
header("Location: index.php");
|
|
| 38 |
exit(0); |
|
| 39 |
} else {
|
|
| 40 |
$page_id = $_GET['page_id']; |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
$debug = false; // to show position and section_id |
|
| 44 |
|
|
| 45 |
// Create new admin object |
|
| 46 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
| 47 |
$admin = new admin('Pages', 'pages_modify');
|
|
| 48 |
|
|
| 49 |
// Check if we are supposed to add or delete a section |
|
| 50 |
if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
|
|
| 51 |
// Get more information about this section |
|
| 52 |
$section_id = $_GET['section_id']; |
|
| 53 |
$query_section = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id'");
|
|
| 54 |
if($query_section->numRows() == 0) {
|
|
| 55 |
$admin->print_error('Section not found');
|
|
| 56 |
} |
|
| 57 |
$section = $query_section->fetchRow(); |
|
| 58 |
// Include the modules delete file if it exists |
|
| 59 |
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
|
|
| 60 |
require(WB_PATH.'/modules/'.$section['module'].'/delete.php'); |
|
| 61 |
} |
|
| 62 |
$database->query("DELETE FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' LIMIT 1");
|
|
| 63 |
if($database->is_error()) {
|
|
| 64 |
$admin->print_error($database->get_error()); |
|
| 65 |
} else {
|
|
| 66 |
require(WB_PATH.'/framework/class.order.php'); |
|
| 67 |
$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id'); |
|
| 68 |
$order->clean($page_id); |
|
| 69 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id); |
|
| 70 |
$admin->print_footer(); |
|
| 71 |
exit(); |
|
| 72 |
} |
|
| 73 |
} elseif(isset($_POST['module']) AND $_POST['module'] != '') {
|
|
| 74 |
// Get section info |
|
| 75 |
$module = $admin->add_slashes($_POST['module']); |
|
| 76 |
// Include the ordering class |
|
| 77 |
require(WB_PATH.'/framework/class.order.php'); |
|
| 78 |
// Get new order |
|
| 79 |
$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id'); |
|
| 80 |
$position = $order->get_new($page_id); |
|
| 81 |
// Insert module into DB |
|
| 82 |
$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,module,position,block) VALUES ('$page_id','$module','$position','1')");
|
|
| 83 |
// Get the section id |
|
| 84 |
$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
|
|
| 85 |
// Include the selected modules add file if it exists |
|
| 86 |
if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) {
|
|
| 87 |
require(WB_PATH.'/modules/'.$module.'/add.php'); |
|
| 88 |
} |
|
| 89 |
} |
|
| 90 |
|
|
| 91 |
// Get perms |
|
| 92 |
$database = new database(); |
|
| 93 |
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
|
|
| 94 |
$results_array = $results->fetchRow(); |
|
| 95 |
$old_admin_groups = explode(',', $results_array['admin_groups']);
|
|
| 96 |
$old_admin_users = explode(',', $results_array['admin_users']);
|
|
| 97 |
$in_old_group = FALSE; |
|
| 98 |
foreach($admin->get_groups_id() as $cur_gid){
|
|
| 99 |
if (in_array($cur_gid, $old_admin_groups)) {
|
|
| 100 |
$in_old_group = TRUE; |
|
| 101 |
} |
|
| 102 |
} |
|
| 103 |
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
|
| 104 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
| 105 |
} |
|
| 106 |
|
|
| 107 |
// Get page details |
|
| 108 |
$database = new database(); |
|
| 109 |
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
| 110 |
$results = $database->query($query); |
|
| 111 |
if($database->is_error()) {
|
|
| 112 |
$admin->print_header(); |
|
| 113 |
$admin->print_error($database->get_error()); |
|
| 114 |
} |
|
| 115 |
if($results->numRows() == 0) {
|
|
| 116 |
$admin->print_header(); |
|
| 117 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
| 118 |
} |
|
| 119 |
$results_array = $results->fetchRow(); |
|
| 120 |
|
|
| 121 |
// Set module permissions |
|
| 122 |
$module_permissions = $_SESSION['MODULE_PERMISSIONS']; |
|
| 123 |
|
|
| 124 |
// Unset block var |
|
| 125 |
unset($block); |
|
| 126 |
// Include template info file (if it exists) |
|
| 127 |
if($results_array['template'] != '') {
|
|
| 128 |
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php'; |
|
| 129 |
} else {
|
|
| 130 |
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php'; |
|
| 131 |
} |
|
| 132 |
if(file_exists($template_location)) {
|
|
| 133 |
require($template_location); |
|
| 134 |
} |
|
| 135 |
// Check if $menu is set |
|
| 136 |
if(!isset($block[1]) OR $block[1] == '') {
|
|
| 137 |
// Make our own menu list |
|
| 138 |
$block[1] = $TEXT['MAIN']; |
|
| 139 |
} |
|
| 140 |
|
|
| 141 |
/*-- load css files with jquery --*/ |
|
| 142 |
// include jscalendar-setup |
|
| 143 |
$jscal_use_time = true; // whether to use a clock, too |
|
| 144 |
require_once(WB_PATH."/include/jscalendar/wb-setup.php"); |
|
| 145 |
|
|
| 146 |
// Setup template object |
|
| 147 |
$template = new Template(THEME_PATH.'/templates'); |
|
| 148 |
$template->set_file('page', 'pages_sections.htt');
|
|
| 149 |
$template->set_block('page', 'main_block', 'main');
|
|
| 150 |
$template->set_block('main_block', 'module_block', 'module_list');
|
|
| 151 |
$template->set_block('main_block', 'section_block', 'section_list');
|
|
| 152 |
$template->set_block('section_block', 'block_block', 'block_list');
|
|
| 153 |
$template->set_block('main_block', 'calendar_block', 'calendar_list');
|
|
| 154 |
|
|
| 155 |
// set first defaults and messages |
|
| 156 |
$template->set_var(array( |
|
| 157 |
'PAGE_ID' => $results_array['page_id'], |
|
| 158 |
'PAGE_TITLE' => ($results_array['page_title']), |
|
| 159 |
'MENU_TITLE' => ($results_array['menu_title']), |
|
| 160 |
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'], |
|
| 161 |
'HEADING_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'], |
|
| 162 |
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'], |
|
| 163 |
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'], |
|
| 164 |
'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'], |
|
| 165 |
'TEXT_ID' => 'ID', |
|
| 166 |
'TEXT_TYPE' => $TEXT['TYPE'], |
|
| 167 |
'TEXT_BLOCK' => $TEXT['BLOCK'], |
|
| 168 |
'TEXT_PUBL_START_DATE' => $TEXT{'PUBL_START_DATE'},
|
|
| 169 |
'TEXT_PUBL_END_DATE' => $TEXT['PUBL_END_DATE'], |
|
| 170 |
'TEXT_ACTIONS' => $TEXT['ACTIONS'], |
|
| 171 |
'ADMIN_URL' => ADMIN_URL, |
|
| 172 |
'WB_URL' => WB_URL, |
|
| 173 |
'WB_PATH' => WB_PATH, |
|
| 174 |
'THEME_URL' => THEME_URL, |
|
| 175 |
) ); |
|
| 176 |
|
|
| 177 |
// Insert variables |
|
| 178 |
$template->set_var(array( |
|
| 179 |
'VAR_PAGE_ID' => $results_array['page_id'], |
|
| 180 |
'VAR_PAGE_TITLE' => $results_array['page_title'], |
|
| 181 |
'SETTINGS_LINK' => ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'], |
|
| 182 |
'MODIFY_LINK' => ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'], |
|
| 183 |
) ); |
|
| 184 |
|
|
| 185 |
$query_sections = $database->query("SELECT section_id,module,position,block,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
|
|
| 186 |
if($query_sections->numRows() > 0) {
|
|
| 187 |
$num_sections = $query_sections->numRows(); |
|
| 188 |
while($section = $query_sections->fetchRow()) {
|
|
| 189 |
if(!is_numeric(array_search($section['module'], $module_permissions))) {
|
|
| 190 |
// Get the modules real name |
|
| 191 |
$module_name=$database->get_one("SELECT name FROM ".TABLE_PREFIX."addons WHERE directory='".$section['module']."'");
|
|
| 192 |
$template->set_var(array( |
|
| 193 |
) ); |
|
| 194 |
if(SECTION_BLOCKS) {
|
|
| 195 |
$edit_page ='<a name="'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'#'.$section['section_id'].'">'.$module_name.'</a>'; |
|
| 196 |
$input_attribute = 'input_normal'; |
|
| 197 |
$template->set_var(array( |
|
| 198 |
'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility: visible;"', |
|
| 199 |
'NAME_SIZE' => 180, |
|
| 200 |
'INPUT_ATTRIBUTE' => $input_attribute, |
|
| 201 |
'VAR_SECTION_ID' => $section['section_id'], |
|
| 202 |
'VAR_POSITION' => $section['position'], |
|
| 203 |
'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page, |
|
| 204 |
) ); |
|
| 205 |
// Add block options to the section_list |
|
| 206 |
$template->clear_var('block_list');
|
|
| 207 |
foreach($block AS $number => $name) {
|
|
| 208 |
$template->set_var('NAME', htmlentities(strip_tags($name)));
|
|
| 209 |
$template->set_var('VALUE', $number);
|
|
| 210 |
$template->set_var('SIZE', 1);
|
|
| 211 |
if($section['block'] == $number) {
|
|
| 212 |
$template->set_var('SELECTED', ' selected="selected"');
|
|
| 213 |
} else {
|
|
| 214 |
$template->set_var('SELECTED', '');
|
|
| 215 |
} |
|
| 216 |
$template->parse('block_list', 'block_block', true);
|
|
| 217 |
} |
|
| 218 |
} else {
|
|
| 219 |
$edit_page = $module_name; |
|
| 220 |
$input_attribute = 'input_small'; |
|
| 221 |
$template->set_var(array( |
|
| 222 |
'STYLE_DISPLAY_SECTION_BLOCK' => ' style="display:none;"', |
|
| 223 |
'NAME_SIZE' => 270, |
|
| 224 |
'INPUT_ATTRIBUTE' => $input_attribute, |
|
| 225 |
'VAR_SECTION_ID' => $section['section_id'], |
|
| 226 |
'VAR_POSITION' => $section['position'], |
|
| 227 |
'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page, |
|
| 228 |
) ); |
|
| 229 |
} |
|
| 230 |
// Insert icon and images |
|
| 231 |
$template->set_var(array( |
|
| 232 |
'CLOCK_16_PNG' => 'clock_16.png', |
|
| 233 |
'CLOCK_DEL_16_PNG' => 'clock_del_16.png', |
|
| 234 |
'DELETE_16_PNG' => 'delete_16.png', |
|
| 235 |
) ); |
|
| 236 |
// set calendar start values |
|
| 237 |
if($section['publ_start']==0) {
|
|
| 238 |
$template->set_var('VALUE_PUBL_START', '');
|
|
| 239 |
} else {
|
|
| 240 |
$template->set_var('VALUE_PUBL_START', date($jscal_format, $section['publ_start']));
|
|
| 241 |
} |
|
| 242 |
// set calendar start values |
|
| 243 |
if($section['publ_end']==0) {
|
|
| 244 |
$template->set_var('VALUE_PUBL_END', '');
|
|
| 245 |
} else {
|
|
| 246 |
$template->set_var('VALUE_PUBL_END', date($jscal_format, $section['publ_end']));
|
|
| 247 |
} |
|
| 248 |
// Insert icons up and down |
|
| 249 |
if($section['position'] != 1 ) {
|
|
| 250 |
$template->set_var( |
|
| 251 |
'VAR_MOVE_UP_URL', |
|
| 252 |
'<a href="'.ADMIN_URL.'/pages/move_up.php?page_id='.$page_id.'&section_id='.$section['section_id'].'"> |
|
| 253 |
<img src="'.THEME_URL.'/images/up_16.png" alt="^" /> |
|
| 254 |
</a>' ); |
|
| 255 |
} else {
|
|
| 256 |
$template->set_var(array( |
|
| 257 |
'VAR_MOVE_UP_URL' => '', |
|
| 258 |
) ); |
|
| 259 |
} |
|
| 260 |
if($section['position'] != $num_sections ) {
|
|
| 261 |
$template->set_var( |
|
| 262 |
'VAR_MOVE_DOWN_URL', |
|
| 263 |
'<a href="'.ADMIN_URL.'/pages/move_down.php?page_id='.$page_id.'&section_id='.$section['section_id'].'"> |
|
| 264 |
<img src="'.THEME_URL.'/images/down_16.png" alt="v" /> |
|
| 265 |
</a>' ); |
|
| 266 |
} else {
|
|
| 267 |
$template->set_var(array( |
|
| 268 |
'VAR_MOVE_DOWN_URL' => '', |
|
| 269 |
) ); |
|
| 270 |
} |
|
| 271 |
} |
|
| 272 |
if($debug) {
|
|
| 273 |
$template->set_var(array( |
|
| 274 |
'DISPLAY_DEBUG' => ' style="visibility="visible;"', |
|
| 275 |
'TEXT_PID' => 'PID', |
|
| 276 |
'TEXT_SID' => 'SID', |
|
| 277 |
'POSITION' => $section['position'], |
|
| 278 |
'DEBUG_COLSPAN_SIZE' => 9, |
|
| 279 |
) ); |
|
| 280 |
} else {
|
|
| 281 |
$template->set_var(array( |
|
| 282 |
'DISPLAY_DEBUG' => ' style="display: none;"', |
|
| 283 |
'TEXT_PID' => '', |
|
| 284 |
'TEXT_SID' => '', |
|
| 285 |
'POSITION' => '', |
|
| 286 |
'DEBUG_COLSPAN_SIZE' => 7, |
|
| 287 |
) ); |
|
| 288 |
} |
|
| 289 |
$template->parse('section_list', 'section_block', true);
|
|
| 290 |
} |
|
| 291 |
} |
|
| 292 |
|
|
| 293 |
// now add the calendars -- remember to to set the range to [1970, 2037] if the date is used as timestamp! |
|
| 294 |
// the loop is simply a copy from above. |
|
| 295 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
|
|
| 296 |
if($query_sections->numRows() > 0) {
|
|
| 297 |
$num_sections = $query_sections->numRows(); |
|
| 298 |
while($section = $query_sections->fetchRow()) {
|
|
| 299 |
// Get the modules real name |
|
| 300 |
$module_name=$database->get_one("SELECT name FROM ".TABLE_PREFIX."addons WHERE directory='".$section['module']."'");
|
|
| 301 |
if(!is_numeric(array_search($section['module'], $module_permissions))) {
|
|
| 302 |
$template->set_var(array( |
|
| 303 |
'jscal_ifformat' => $jscal_ifformat, |
|
| 304 |
'jscal_firstday' => $jscal_firstday, |
|
| 305 |
'jscal_today' => $jscal_today, |
|
| 306 |
'start_date' => 'start_date'.$section['section_id'], |
|
| 307 |
'end_date' => 'end_date'.$section['section_id'], |
|
| 308 |
'trigger_start' => 'trigger_start'.$section['section_id'], |
|
| 309 |
'trigger_end' => 'trigger_stop'.$section['section_id'], |
|
| 310 |
) ); |
|
| 311 |
if(isset($jscal_use_time) && $jscal_use_time==TRUE) {
|
|
| 312 |
$template->set_var(array( |
|
| 313 |
'showsTime' => "true", |
|
| 314 |
'timeFormat' => "24", |
|
| 315 |
) ); |
|
| 316 |
} else {
|
|
| 317 |
$template->set_var(array( |
|
| 318 |
'showsTime' => "false", |
|
| 319 |
'timeFormat' => "24", |
|
| 320 |
) ); |
|
| 321 |
} |
|
| 322 |
} |
|
| 323 |
$template->parse('calendar_list', 'calendar_block', true);
|
|
| 324 |
} |
|
| 325 |
} |
|
| 326 |
|
|
| 327 |
// Work-out if we should show the "Add Section" form |
|
| 328 |
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
|
|
| 329 |
if($query_sections->numRows() == 0) {
|
|
| 330 |
// Modules list |
|
| 331 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' AND directory != 'menu_link' order by name");
|
|
| 332 |
if($result->numRows() > 0) {
|
|
| 333 |
while ($module = $result->fetchRow()) {
|
|
| 334 |
// Check if user is allowed to use this module echo $module['directory'],'<br />'; |
|
| 335 |
if(!is_numeric(array_search($module['directory'], $module_permissions))) {
|
|
| 336 |
$template->set_var('VALUE', $module['directory']);
|
|
| 337 |
$template->set_var('NAME', $module['name']);
|
|
| 338 |
if($module['directory'] == 'wysiwyg') {
|
|
| 339 |
$template->set_var('SELECTED', ' selected="selected"');
|
|
| 340 |
} else {
|
|
| 341 |
$template->set_var('SELECTED', '');
|
|
| 342 |
} |
|
| 343 |
$template->parse('module_list', 'module_block', true);
|
|
| 344 |
} |
|
| 345 |
} |
|
| 346 |
} |
|
| 347 |
} |
|
| 348 |
// Insert language text and messages |
|
| 349 |
$template->set_var(array( |
|
| 350 |
'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'], |
|
| 351 |
'TEXT_ARE_YOU_SURE' => $TEXT['ARE_YOU_SURE'], |
|
| 352 |
'TEXT_TYPE' => $TEXT['TYPE'], |
|
| 353 |
'TEXT_ADD' => $TEXT['ADD'], |
|
| 354 |
'TEXT_SAVE' => $TEXT['SAVE'], |
|
| 355 |
'TEXTLINK_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'], |
|
| 356 |
'TEXT_CALENDAR' => $TEXT['CALENDAR'], |
|
| 357 |
'TEXT_DELETE_DATE' => $TEXT['DELETE_DATE'], |
|
| 358 |
'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'], |
|
| 359 |
) ); |
|
| 360 |
$template->parse('main', 'main_block', false);
|
|
| 361 |
$template->pparse('output', 'page');
|
|
| 362 |
|
|
| 363 |
// Print admin footer |
|
| 364 |
$admin->print_footer(); |
|
| 365 |
|
|
| 366 |
?> |
|
Also available in: Unified diff
-Moved styles from admin/pages/sections.php to sections.htt in backend themes (Thanks to Luisehahne)
- Moved javascript files from admin/pages/index.php to external js files (Thanks to Luisehahne)
- Major improovements and changes to all backend files to get more valide Code output (Thanks to Luisehahne)