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 |
1907
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
10 |
|
|
* @link http://www.websitebaker.org/
|
11 |
1384
|
Luisehahne
|
* @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 |
1889
|
Luisehahne
|
* @filesource $HeadURL$
|
16 |
1457
|
Luisehahne
|
* @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 |
1889
|
Luisehahne
|
if(!class_exists('admin')) {
|
27 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
28 |
|
|
}
|
29 |
1457
|
Luisehahne
|
// suppress to print the header, so no new FTAN will be set
|
30 |
|
|
$admin = new admin('Pages', 'pages_modify',false);
|
31 |
643
|
thorn
|
|
32 |
1753
|
Luisehahne
|
// 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 |
1473
|
Luisehahne
|
// Get page id
|
38 |
1889
|
Luisehahne
|
$iPageId = (isset($_GET['page_id']) ? intval($_GET['page_id']) : 0);
|
39 |
|
|
if(!$iPageId) {
|
40 |
1753
|
Luisehahne
|
$admin->send_header("Location: index.php");
|
41 |
1473
|
Luisehahne
|
exit(0);
|
42 |
|
|
}
|
43 |
1889
|
Luisehahne
|
if (!$admin->checkFTAN()) {
|
44 |
1457
|
Luisehahne
|
$admin->print_header();
|
45 |
1889
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],ADMIN_URL.'/pages/sections.php?page_id='.$iPageId);
|
46 |
1402
|
Luisehahne
|
}
|
47 |
1753
|
Luisehahne
|
|
48 |
|
|
// After check print the header
|
49 |
|
|
$admin->print_header();
|
50 |
1889
|
Luisehahne
|
$sBackLink = ADMIN_URL.'/pages/sections.php?page_id='.$iPageId;
|
51 |
1753
|
Luisehahne
|
|
52 |
4
|
ryan
|
// Get perms
|
53 |
1753
|
Luisehahne
|
// Get page details
|
54 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
|
55 |
1889
|
Luisehahne
|
$sql .= 'WHERE `page_id`='.$iPageId;
|
56 |
|
|
$aMsg = array();
|
57 |
|
|
if(($oPage = $database->query($sql))) {
|
58 |
|
|
if(!$oPage->numRows()) {
|
59 |
1753
|
Luisehahne
|
$aMsg[] = $MESSAGE['PAGES_NOT_FOUND'];
|
60 |
1889
|
Luisehahne
|
}else {
|
61 |
|
|
if(!($aPage = $oPage->fetchRow())) {
|
62 |
|
|
$aMsg[] = $MESSAGE['PAGES_NOT_FOUND'];
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
}else {
|
66 |
1753
|
Luisehahne
|
if($database->is_error()) {
|
67 |
|
|
$aMsg[] = $database->get_error();
|
68 |
|
|
}
|
69 |
1889
|
Luisehahne
|
}
|
70 |
|
|
if(sizeof($aMsg)>0) {
|
71 |
|
|
array_unshift($aMsg, $MESSAGE['GENERIC_NOT_UPGRADED']);
|
72 |
1753
|
Luisehahne
|
$admin->print_error(implode('<br />',$aMsg), $sBackLink );
|
73 |
1889
|
Luisehahne
|
exit;
|
74 |
1753
|
Luisehahne
|
}
|
75 |
|
|
|
76 |
1889
|
Luisehahne
|
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 |
546
|
doc
|
}
|
81 |
238
|
stefan
|
|
82 |
4
|
ryan
|
// Set module permissions
|
83 |
1889
|
Luisehahne
|
// $module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
84 |
1753
|
Luisehahne
|
$aMsg = array();
|
85 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'sections` ';
|
86 |
1889
|
Luisehahne
|
$sql .= 'WHERE `page_id`='.$iPageId.' ';
|
87 |
|
|
$sql .= 'ORDER BY `position` ASC';
|
88 |
1753
|
Luisehahne
|
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 |
1889
|
Luisehahne
|
exit;
|
96 |
238
|
stefan
|
}
|
97 |
1753
|
Luisehahne
|
|
98 |
1889
|
Luisehahne
|
$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 |
1893
|
Luisehahne
|
$iBlock = intval($admin->get_post('block'.$section_id));
|
106 |
|
|
$iBlock = ($iBlock==0) ? $section['block'] : $iBlock;
|
107 |
|
|
|
108 |
1889
|
Luisehahne
|
$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 |
4
|
ryan
|
}
|
119 |
1889
|
Luisehahne
|
// 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 |
1753
|
Luisehahne
|
}
|
130 |
|
|
|
131 |
|
|
$admin->print_success($MESSAGE['PAGES_SECTIONS_PROPERTIES_SAVED'], $sBackLink );
|
132 |
4
|
ryan
|
// Print admin footer
|
133 |
238
|
stefan
|
$admin->print_footer();
|