1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category backend
|
5
|
* @package admin
|
6
|
* @subpackage pages
|
7
|
* @author Ryan Djurovich, WebsiteBaker Project
|
8
|
* @copyright 2004-2009, Ryan Djurovich
|
9
|
* @copyright 2009-2012, Website Baker Org. e.V.
|
10
|
* @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: sections_save.php 1753 2012-09-15 02:01:46Z Luisehahne $
|
15
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/sections_save.php $
|
16
|
* @lastmodified $Date: 2012-09-15 04:01:46 +0200 (Sat, 15 Sep 2012) $
|
17
|
*
|
18
|
*/
|
19
|
|
20
|
// Include config file
|
21
|
require('../../config.php');
|
22
|
|
23
|
require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
|
24
|
/**/
|
25
|
// Create new admin object
|
26
|
require_once(WB_PATH.'/framework/class.admin.php');
|
27
|
// suppress to print the header, so no new FTAN will be set
|
28
|
$admin = new admin('Pages', 'pages_modify',false);
|
29
|
|
30
|
// 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
|
// Get page id
|
37
|
if(!isset($_GET['page_id']) || !is_numeric($_GET['page_id'])) {
|
38
|
$admin->send_header("Location: index.php");
|
39
|
exit(0);
|
40
|
} else {
|
41
|
$page_id = (int)$_GET['page_id'];
|
42
|
}
|
43
|
|
44
|
if (!$admin->checkFTAN())
|
45
|
{
|
46
|
$admin->print_header();
|
47
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
|
48
|
}
|
49
|
/*
|
50
|
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
|
51
|
{
|
52
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
53
|
exit();
|
54
|
}
|
55
|
*/
|
56
|
|
57
|
// After check print the header
|
58
|
$admin->print_header();
|
59
|
|
60
|
$sBackLink = ADMIN_URL.'/pages/sections.php?page_id='.$page_id;
|
61
|
|
62
|
// Get perms
|
63
|
// 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
|
$old_admin_groups = explode(',', $results_array['admin_groups']);
|
84
|
$in_old_group = false;
|
85
|
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
|
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
91
|
$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
|
92
|
}
|
93
|
|
94
|
// Set module permissions
|
95
|
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
96
|
$aMsg = array();
|
97
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'sections` ';
|
98
|
$sql .= 'WHERE page_id = '.$page_id.' ';
|
99
|
$sql .= 'ORDER BY position ASC';
|
100
|
|
101
|
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
|
}
|
109
|
|
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
|
}
|
135
|
|
136
|
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
|
// Print admin footer
|
152
|
$admin->print_footer();
|