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-2013, WebsiteBaker Org. e.V.
|
10
|
* @link http://www.websitebaker.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 1907 2013-06-07 02:30:42Z Luisehahne $
|
15
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/sections_save.php $
|
16
|
* @lastmodified $Date: 2013-06-07 04:30:42 +0200 (Fri, 07 Jun 2013) $
|
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
|
if(!class_exists('admin')) {
|
27
|
require_once(WB_PATH.'/framework/class.admin.php');
|
28
|
}
|
29
|
// suppress to print the header, so no new FTAN will be set
|
30
|
$admin = new admin('Pages', 'pages_modify',false);
|
31
|
|
32
|
// Make sure people are allowed to access this page
|
33
|
if(MANAGE_SECTIONS == false) {
|
34
|
$admin->send_header('Location: '.ADMIN_URL.'/pages/index.php');
|
35
|
exit(0);
|
36
|
}
|
37
|
// Get page id
|
38
|
$iPageId = (isset($_GET['page_id']) ? intval($_GET['page_id']) : 0);
|
39
|
if(!$iPageId) {
|
40
|
$admin->send_header("Location: index.php");
|
41
|
exit(0);
|
42
|
}
|
43
|
if (!$admin->checkFTAN()) {
|
44
|
$admin->print_header();
|
45
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],ADMIN_URL.'/pages/sections.php?page_id='.$iPageId);
|
46
|
}
|
47
|
|
48
|
// After check print the header
|
49
|
$admin->print_header();
|
50
|
$sBackLink = ADMIN_URL.'/pages/sections.php?page_id='.$iPageId;
|
51
|
|
52
|
// Get perms
|
53
|
// Get page details
|
54
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
|
55
|
$sql .= 'WHERE `page_id`='.$iPageId;
|
56
|
$aMsg = array();
|
57
|
if(($oPage = $database->query($sql))) {
|
58
|
if(!$oPage->numRows()) {
|
59
|
$aMsg[] = $MESSAGE['PAGES_NOT_FOUND'];
|
60
|
}else {
|
61
|
if(!($aPage = $oPage->fetchRow())) {
|
62
|
$aMsg[] = $MESSAGE['PAGES_NOT_FOUND'];
|
63
|
}
|
64
|
}
|
65
|
}else {
|
66
|
if($database->is_error()) {
|
67
|
$aMsg[] = $database->get_error();
|
68
|
}
|
69
|
}
|
70
|
if(sizeof($aMsg)>0) {
|
71
|
array_unshift($aMsg, $MESSAGE['GENERIC_NOT_UPGRADED']);
|
72
|
$admin->print_error(implode('<br />',$aMsg), $sBackLink );
|
73
|
exit;
|
74
|
}
|
75
|
|
76
|
if(!$admin->ami_group_member($aPage['admin_users']) &&
|
77
|
!$admin->is_group_match($admin->get_groups_id(), $aPage['admin_groups']))
|
78
|
{
|
79
|
$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS'], $sBackLink);
|
80
|
}
|
81
|
|
82
|
// Set module permissions
|
83
|
// $module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
84
|
$aMsg = array();
|
85
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'sections` ';
|
86
|
$sql .= 'WHERE `page_id`='.$iPageId.' ';
|
87
|
$sql .= 'ORDER BY `position` ASC';
|
88
|
if(!($oSection = $database->query($sql))) {
|
89
|
$aMsg = array();
|
90
|
$aMsg[] = $MESSAGE['GENERIC_NOT_UPGRADED'];
|
91
|
if($database->is_error()) {
|
92
|
$aMsg[] = $database->get_error();
|
93
|
}
|
94
|
$admin->print_error(implode('<br />',$aMsg), $sBackLink );
|
95
|
exit;
|
96
|
}
|
97
|
|
98
|
$aSql = array();
|
99
|
// Loop through sections and build sql statements for update
|
100
|
while($section = $oSection->fetchRow(MYSQL_ASSOC))
|
101
|
{
|
102
|
$section_id = $section['section_id'];
|
103
|
$sid = 'wb'.$section_id;
|
104
|
$dst = date('I') ? ' UTC' : ''; // daylight saving time? date('P')
|
105
|
$iBlock = intval($admin->get_post('block'.$section_id));
|
106
|
$iBlock = ($iBlock==0) ? $section['block'] : $iBlock;
|
107
|
|
108
|
$sStartDate = $admin->get_post_escaped('start_date'.$section_id);
|
109
|
$sStartDate = ($sStartDate==null)||($sStartDate=='') ? 0 : jscalendar_to_timestamp($sStartDate)-TIMEZONE;
|
110
|
$sEndDate = $admin->get_post_escaped('end_date'.$section_id);
|
111
|
$sEndDate = ($sEndDate==null)||($sEndDate=='') ? 0 : jscalendar_to_timestamp($sEndDate)-TIMEZONE;
|
112
|
$aSql[] = 'UPDATE `'.TABLE_PREFIX.'sections` '
|
113
|
. 'SET `block`=\''.(int)$iBlock.'\', '
|
114
|
. '`module`=\''.$section['module'].'\', '
|
115
|
. '`publ_start`=\''.$sStartDate.'\','
|
116
|
. '`publ_end`=\''.$sEndDate.'\' '
|
117
|
. 'WHERE `section_id`='.(int)$section_id;
|
118
|
}
|
119
|
// Update all of the sql statements
|
120
|
foreach( $aSql as $sSql ) {
|
121
|
if(!$database->query($sSql)) {
|
122
|
$aMsg = array();
|
123
|
$aMsg[] = $MESSAGE['GENERIC_NOT_UPGRADED'];
|
124
|
if($database->is_error()) {
|
125
|
$aMsg[] = $database->get_error();
|
126
|
}
|
127
|
$admin->print_error(implode('<br />',$aMsg), $sBackLink );
|
128
|
}
|
129
|
}
|
130
|
|
131
|
$admin->print_success($MESSAGE['PAGES_SECTIONS_PROPERTIES_SAVED'], $sBackLink );
|
132
|
// Print admin footer
|
133
|
$admin->print_footer();
|