1 |
238
|
stefan
|
<?php
|
2 |
1384
|
Luisehahne
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package pages
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
|
|
* @copyright 2009-2011, 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$
|
14 |
|
|
* @filesource $HeadURL: http://svn.websitebaker2.org/branches/2.8.x/wb/admin/pages/sections.php $
|
15 |
|
|
* @lastmodified $Date: 2011-01-10 13:14:10 +0100 (Mo, 10. Jan 2011) $
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
238
|
stefan
|
|
19 |
4
|
ryan
|
// Include config file
|
20 |
238
|
stefan
|
require('../../config.php');
|
21 |
|
|
|
22 |
4
|
ryan
|
// Make sure people are allowed to access this page
|
23 |
238
|
stefan
|
if(MANAGE_SECTIONS != 'enabled') {
|
24 |
|
|
header('Location: '.ADMIN_URL.'/pages/index.php');
|
25 |
286
|
stefan
|
exit(0);
|
26 |
238
|
stefan
|
}
|
27 |
|
|
|
28 |
643
|
thorn
|
require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
|
29 |
1402
|
Luisehahne
|
/**/
|
30 |
|
|
// Create new admin object
|
31 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
32 |
|
|
$admin = new admin('Pages', 'pages_modify');
|
33 |
643
|
thorn
|
|
34 |
1402
|
Luisehahne
|
if (!$admin->checkFTAN())
|
35 |
|
|
{
|
36 |
1425
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
|
37 |
1402
|
Luisehahne
|
exit();
|
38 |
|
|
}
|
39 |
|
|
|
40 |
4
|
ryan
|
// Get page id
|
41 |
1384
|
Luisehahne
|
if(!isset($_GET['page_id']) || !is_numeric($_GET['page_id'])) {
|
42 |
238
|
stefan
|
header("Location: index.php");
|
43 |
286
|
stefan
|
exit(0);
|
44 |
238
|
stefan
|
} else {
|
45 |
|
|
$page_id = $_GET['page_id'];
|
46 |
|
|
}
|
47 |
1402
|
Luisehahne
|
/*
|
48 |
|
|
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
|
49 |
1357
|
FrankH
|
{
|
50 |
1402
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
51 |
1357
|
FrankH
|
exit();
|
52 |
|
|
}
|
53 |
1402
|
Luisehahne
|
*/
|
54 |
4
|
ryan
|
// Get perms
|
55 |
1358
|
Luisehahne
|
// $database = new database();
|
56 |
238
|
stefan
|
$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(',', $results_array['admin_groups']);
|
59 |
|
|
$old_admin_users = explode(',', $results_array['admin_users']);
|
60 |
546
|
doc
|
$in_old_group = FALSE;
|
61 |
|
|
foreach($admin->get_groups_id() as $cur_gid){
|
62 |
|
|
if (in_array($cur_gid, $old_admin_groups)) {
|
63 |
|
|
$in_old_group = TRUE;
|
64 |
|
|
}
|
65 |
|
|
}
|
66 |
1384
|
Luisehahne
|
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
67 |
238
|
stefan
|
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
68 |
|
|
}
|
69 |
|
|
|
70 |
4
|
ryan
|
// Get page details
|
71 |
1384
|
Luisehahne
|
// $database = new database();
|
72 |
238
|
stefan
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
|
73 |
|
|
$results = $database->query($query);
|
74 |
|
|
if($database->is_error()) {
|
75 |
|
|
$admin->print_header();
|
76 |
|
|
$admin->print_error($database->get_error());
|
77 |
|
|
}
|
78 |
|
|
if($results->numRows() == 0) {
|
79 |
|
|
$admin->print_header();
|
80 |
|
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
81 |
|
|
}
|
82 |
|
|
$results_array = $results->fetchRow();
|
83 |
|
|
|
84 |
4
|
ryan
|
// Set module permissions
|
85 |
238
|
stefan
|
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
86 |
|
|
|
87 |
4
|
ryan
|
// Loop through sections
|
88 |
238
|
stefan
|
$query_sections = $database->query("SELECT section_id,module,position FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
|
89 |
|
|
if($query_sections->numRows() > 0) {
|
90 |
|
|
$num_sections = $query_sections->numRows();
|
91 |
|
|
while($section = $query_sections->fetchRow()) {
|
92 |
347
|
stefan
|
if(!is_numeric(array_search($section['module'], $module_permissions))) {
|
93 |
|
|
// Update the section record with properties
|
94 |
|
|
$section_id = $section['section_id'];
|
95 |
552
|
thorn
|
$sql = ''; $publ_start = 0; $publ_end = 0;
|
96 |
|
|
$dst = date("I")?" DST":""; // daylight saving time?
|
97 |
1384
|
Luisehahne
|
if(isset($_POST['block'.$section_id]) && $_POST['block'.$section_id] != '') {
|
98 |
347
|
stefan
|
$sql = "block = '".$admin->add_slashes($_POST['block'.$section_id])."'";
|
99 |
552
|
thorn
|
}
|
100 |
|
|
// update publ_start and publ_end, trying to make use of the strtotime()-features like "next week", "+1 month", ...
|
101 |
1384
|
Luisehahne
|
if(isset($_POST['start_date'.$section_id]) && isset($_POST['end_date'.$section_id])) {
|
102 |
|
|
if(trim($_POST['start_date'.$section_id]) == '0' || trim($_POST['start_date'.$section_id]) == '') {
|
103 |
552
|
thorn
|
$publ_start = 0;
|
104 |
|
|
} else {
|
105 |
643
|
thorn
|
$publ_start = jscalendar_to_timestamp($_POST['start_date'.$section_id]);
|
106 |
238
|
stefan
|
}
|
107 |
1384
|
Luisehahne
|
if(trim($_POST['end_date'.$section_id]) == '0' || trim($_POST['end_date'.$section_id]) == '') {
|
108 |
552
|
thorn
|
$publ_end = 0;
|
109 |
|
|
} else {
|
110 |
643
|
thorn
|
$publ_end = jscalendar_to_timestamp($_POST['end_date'.$section_id], $publ_start);
|
111 |
552
|
thorn
|
}
|
112 |
|
|
if($sql != '')
|
113 |
|
|
$sql .= ",";
|
114 |
656
|
thorn
|
$sql .= " publ_start = '".$admin->add_slashes($publ_start)."'";
|
115 |
|
|
$sql .= ", publ_end = '".$admin->add_slashes($publ_end)."'";
|
116 |
238
|
stefan
|
}
|
117 |
552
|
thorn
|
$query = "UPDATE ".TABLE_PREFIX."sections SET $sql WHERE section_id = '$section_id' LIMIT 1";
|
118 |
|
|
if($sql != '') {
|
119 |
|
|
$database->query($query);
|
120 |
|
|
}
|
121 |
238
|
stefan
|
}
|
122 |
|
|
}
|
123 |
|
|
}
|
124 |
|
|
// Check for error or print success message
|
125 |
4
|
ryan
|
if($database->is_error()) {
|
126 |
1402
|
Luisehahne
|
$admin->print_error($database->get_error(), ADMIN_URL.'/pages/sections.php?page_id='.$page_id );
|
127 |
4
|
ryan
|
} else {
|
128 |
1402
|
Luisehahne
|
$admin->print_success($MESSAGE['PAGES']['SECTIONS_PROPERTIES_SAVED'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id );
|
129 |
4
|
ryan
|
}
|
130 |
238
|
stefan
|
|
131 |
4
|
ryan
|
// Print admin footer
|
132 |
238
|
stefan
|
$admin->print_footer();
|