1 |
238
|
stefan
|
<?php
|
2 |
1384
|
Luisehahne
|
/**
|
3 |
|
|
*
|
4 |
1753
|
Luisehahne
|
* @category backend
|
5 |
|
|
* @package admin
|
6 |
|
|
* @subpackage pages
|
7 |
|
|
* @author Ryan Djurovich, WebsiteBaker Project
|
8 |
1384
|
Luisehahne
|
* @copyright 2004-2009, Ryan Djurovich
|
9 |
1753
|
Luisehahne
|
* @copyright 2009-2012, Website Baker Org. e.V.
|
10 |
1384
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
11 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
12 |
|
|
* @platform WebsiteBaker 2.8.x
|
13 |
|
|
* @requirements PHP 5.2.2 and higher
|
14 |
|
|
* @version $Id$
|
15 |
1457
|
Luisehahne
|
* @filesource $HeadURL$
|
16 |
|
|
* @lastmodified $Date$
|
17 |
1384
|
Luisehahne
|
*
|
18 |
|
|
*/
|
19 |
238
|
stefan
|
|
20 |
4
|
ryan
|
// Include config file
|
21 |
238
|
stefan
|
require('../../config.php');
|
22 |
|
|
|
23 |
643
|
thorn
|
require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
|
24 |
1402
|
Luisehahne
|
/**/
|
25 |
|
|
// Create new admin object
|
26 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
27 |
1457
|
Luisehahne
|
// suppress to print the header, so no new FTAN will be set
|
28 |
|
|
$admin = new admin('Pages', 'pages_modify',false);
|
29 |
643
|
thorn
|
|
30 |
1753
|
Luisehahne
|
// Make sure people are allowed to access this page
|
31 |
|
|
if(MANAGE_SECTIONS == false) {
|
32 |
|
|
$admin->send_header('Location: '.ADMIN_URL.'/pages/index.php');
|
33 |
|
|
exit(0);
|
34 |
|
|
}
|
35 |
|
|
|
36 |
1473
|
Luisehahne
|
// Get page id
|
37 |
|
|
if(!isset($_GET['page_id']) || !is_numeric($_GET['page_id'])) {
|
38 |
1753
|
Luisehahne
|
$admin->send_header("Location: index.php");
|
39 |
1473
|
Luisehahne
|
exit(0);
|
40 |
|
|
} else {
|
41 |
|
|
$page_id = (int)$_GET['page_id'];
|
42 |
|
|
}
|
43 |
|
|
|
44 |
1402
|
Luisehahne
|
if (!$admin->checkFTAN())
|
45 |
|
|
{
|
46 |
1457
|
Luisehahne
|
$admin->print_header();
|
47 |
1425
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
|
48 |
1402
|
Luisehahne
|
}
|
49 |
|
|
/*
|
50 |
|
|
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
|
51 |
1357
|
FrankH
|
{
|
52 |
1402
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
53 |
1357
|
FrankH
|
exit();
|
54 |
|
|
}
|
55 |
1402
|
Luisehahne
|
*/
|
56 |
1753
|
Luisehahne
|
|
57 |
|
|
// After check print the header
|
58 |
|
|
$admin->print_header();
|
59 |
|
|
|
60 |
|
|
$sBackLink = ADMIN_URL.'/pages/sections.php?page_id='.$page_id;
|
61 |
|
|
|
62 |
4
|
ryan
|
// Get perms
|
63 |
1753
|
Luisehahne
|
// Get page details
|
64 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
|
65 |
|
|
$sql .= 'WHERE page_id = '.$page_id.'';
|
66 |
|
|
|
67 |
|
|
if($oPage = $database->query($sql)){
|
68 |
|
|
$results_array = $oPage->fetchRow();
|
69 |
|
|
} else {
|
70 |
|
|
$admin->print_error($database->get_error());
|
71 |
|
|
$aMsg = array();
|
72 |
|
|
$aMsg[] = $MESSAGE['GENERIC_NOT_UPGRADED'];
|
73 |
|
|
if($results->numRows() == 0) {
|
74 |
|
|
$aMsg[] = $MESSAGE['PAGES_NOT_FOUND'];
|
75 |
|
|
}
|
76 |
|
|
if($database->is_error()) {
|
77 |
|
|
$aMsg[] = $database->get_error();
|
78 |
|
|
}
|
79 |
|
|
$admin->print_error(implode('<br />',$aMsg), $sBackLink );
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
$old_admin_users = explode(',', $results_array['admin_users']);
|
83 |
238
|
stefan
|
$old_admin_groups = explode(',', $results_array['admin_groups']);
|
84 |
1753
|
Luisehahne
|
$in_old_group = false;
|
85 |
546
|
doc
|
foreach($admin->get_groups_id() as $cur_gid){
|
86 |
|
|
if (in_array($cur_gid, $old_admin_groups)) {
|
87 |
|
|
$in_old_group = TRUE;
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
1384
|
Luisehahne
|
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
91 |
1753
|
Luisehahne
|
$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
|
92 |
238
|
stefan
|
}
|
93 |
|
|
|
94 |
4
|
ryan
|
// Set module permissions
|
95 |
238
|
stefan
|
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
96 |
1753
|
Luisehahne
|
$aMsg = array();
|
97 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'sections` ';
|
98 |
|
|
$sql .= 'WHERE page_id = '.$page_id.' ';
|
99 |
|
|
$sql .= 'ORDER BY position ASC';
|
100 |
238
|
stefan
|
|
101 |
1753
|
Luisehahne
|
if(!($oSection = $database->query($sql))) {
|
102 |
|
|
$aMsg = array();
|
103 |
|
|
$aMsg[] = $MESSAGE['GENERIC_NOT_UPGRADED'];
|
104 |
|
|
if($database->is_error()) {
|
105 |
|
|
$aMsg[] = $database->get_error();
|
106 |
|
|
}
|
107 |
|
|
$admin->print_error(implode('<br />',$aMsg), $sBackLink );
|
108 |
238
|
stefan
|
}
|
109 |
1753
|
Luisehahne
|
|
110 |
|
|
$aSqlSection = array();
|
111 |
|
|
// Loop through sections and set sql values for update
|
112 |
|
|
while($section = $oSection->fetchRow(MYSQL_ASSOC)) {
|
113 |
|
|
|
114 |
|
|
$section_id = $section['section_id'];
|
115 |
|
|
$sid = 'wb'.$section_id;
|
116 |
|
|
|
117 |
|
|
$dst = date('I') ? ' UTC' : ''; // daylight saving time? date('P')
|
118 |
|
|
|
119 |
|
|
$iBlock = $admin->get_post_escaped('block'.$section_id);
|
120 |
|
|
$iBlock = ($iBlock==null) ? $section['block'] : $iBlock;
|
121 |
|
|
|
122 |
|
|
$sStartDate = $admin->get_post_escaped('start_date'.$section_id);;
|
123 |
|
|
$sStartDate = ($sStartDate==null)||($sStartDate=='') ? 0 : jscalendar_to_timestamp($sStartDate)-TIMEZONE;
|
124 |
|
|
|
125 |
|
|
$sEndDate = $admin->get_post_escaped('end_date'.$section_id);
|
126 |
|
|
$sEndDate = ($sEndDate==null)||($sEndDate=='') ? 0 : jscalendar_to_timestamp($sEndDate)-TIMEZONE;
|
127 |
|
|
|
128 |
|
|
$aSqlSection[$sid][] = 'UPDATE `'.TABLE_PREFIX.'sections` SET ';
|
129 |
|
|
$aSqlSection[$sid][] .= '`block`= \''.$iBlock.'\', ';
|
130 |
|
|
$aSqlSection[$sid][] .= '`module` = \''.$section['module'].'\', ';
|
131 |
|
|
$aSqlSection[$sid][] .= '`publ_start` = \''.$sStartDate.'\',';
|
132 |
|
|
$aSqlSection[$sid][] .= '`publ_end` = \''.$sEndDate.'\' ';
|
133 |
|
|
$aSqlSection[$sid][] .= 'WHERE `section_id` = \''.$section_id.'\' ';
|
134 |
4
|
ryan
|
}
|
135 |
238
|
stefan
|
|
136 |
1753
|
Luisehahne
|
foreach( $aSqlSection as $sid ) {
|
137 |
|
|
|
138 |
|
|
$sql = implode('',$sid);
|
139 |
|
|
if(!($oSection = $database->query($sql))) {
|
140 |
|
|
$aMsg = array();
|
141 |
|
|
$aMsg[] = $MESSAGE['GENERIC_NOT_UPGRADED'];
|
142 |
|
|
if($database->is_error()) {
|
143 |
|
|
$aMsg[] = $database->get_error();
|
144 |
|
|
}
|
145 |
|
|
$admin->print_error(implode('<br />',$aMsg), $sBackLink );
|
146 |
|
|
}
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
$admin->print_success($MESSAGE['PAGES_SECTIONS_PROPERTIES_SAVED'], $sBackLink );
|
150 |
|
|
|
151 |
4
|
ryan
|
// Print admin footer
|
152 |
238
|
stefan
|
$admin->print_footer();
|