Project

General

Profile

1
<?php
2
/**
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: sections_save.php 1457 2011-06-25 17:18:50Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/sections_save.php $
15
 * @lastmodified    $Date: 2011-06-25 19:18:50 +0200 (Sat, 25 Jun 2011) $
16
 *
17
 */
18

    
19
// Include config file
20
require('../../config.php');
21

    
22
// Make sure people are allowed to access this page
23
if(MANAGE_SECTIONS != 'enabled') {
24
	header('Location: '.ADMIN_URL.'/pages/index.php');
25
	exit(0);
26
}
27

    
28
require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
29
/**/
30
// Create new admin object
31
require_once(WB_PATH.'/framework/class.admin.php');
32
// suppress to print the header, so no new FTAN will be set
33
$admin = new admin('Pages', 'pages_modify',false);
34

    
35
if (!$admin->checkFTAN())
36
{
37
	$admin->print_header();
38
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
39
}
40
// After check print the header
41
$admin->print_header();
42

    
43
// Get page id
44
if(!isset($_GET['page_id']) || !is_numeric($_GET['page_id'])) {
45
	header("Location: index.php");
46
	exit(0);
47
} else {
48
	$page_id = $_GET['page_id'];
49
}
50
/*
51
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
52
{
53
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
54
	exit();
55
}
56
*/
57
// Get perms
58
// $database = new database();
59
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
60
$results_array = $results->fetchRow();
61
$old_admin_groups = explode(',', $results_array['admin_groups']);
62
$old_admin_users = explode(',', $results_array['admin_users']);
63
$in_old_group = FALSE;
64
foreach($admin->get_groups_id() as $cur_gid){
65
    if (in_array($cur_gid, $old_admin_groups)) {
66
        $in_old_group = TRUE;
67
    }
68
}
69
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
70
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
71
}
72

    
73
// Get page details
74
// $database = new database();
75
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
76
$results = $database->query($query);
77
if($database->is_error()) {
78
	$admin->print_header();
79
	$admin->print_error($database->get_error());
80
}
81
if($results->numRows() == 0) {
82
	$admin->print_header();
83
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
84
}
85
$results_array = $results->fetchRow();
86

    
87
// Set module permissions
88
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
89

    
90
// Loop through sections
91
$query_sections = $database->query("SELECT section_id,module,position FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
92
if($query_sections->numRows() > 0) {
93
	$num_sections = $query_sections->numRows();
94
	while($section = $query_sections->fetchRow()) {
95
		if(!is_numeric(array_search($section['module'], $module_permissions))) {
96
			// Update the section record with properties
97
			$section_id = $section['section_id'];
98
			$sql = ''; $publ_start = 0; $publ_end = 0;
99
			$dst = date("I")?" DST":""; // daylight saving time?
100
			if(isset($_POST['block'.$section_id]) && $_POST['block'.$section_id] != '') {
101
				$sql = "block = '".$admin->add_slashes($_POST['block'.$section_id])."'";
102
			}
103
			// update publ_start and publ_end, trying to make use of the strtotime()-features like "next week", "+1 month", ...
104
			if(isset($_POST['start_date'.$section_id]) && isset($_POST['end_date'.$section_id])) {
105
				if(trim($_POST['start_date'.$section_id]) == '0' || trim($_POST['start_date'.$section_id]) == '') {
106
					$publ_start = 0;
107
				} else {
108
					$publ_start = jscalendar_to_timestamp($_POST['start_date'.$section_id]);
109
				}
110
				if(trim($_POST['end_date'.$section_id]) == '0' || trim($_POST['end_date'.$section_id]) == '') {
111
					$publ_end = 0;
112
				} else {
113
					$publ_end = jscalendar_to_timestamp($_POST['end_date'.$section_id], $publ_start);
114
				}
115
				if($sql != '')
116
					$sql .= ",";
117
				$sql .= " publ_start = '".$admin->add_slashes($publ_start)."'";
118
				$sql .= ", publ_end = '".$admin->add_slashes($publ_end)."'";
119
			}
120
			$query = "UPDATE ".TABLE_PREFIX."sections SET $sql WHERE section_id = '$section_id' LIMIT 1";
121
			if($sql != '') {
122
				$database->query($query);
123
			}
124
		}
125
	}
126
}
127
// Check for error or print success message
128
if($database->is_error()) {
129
	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/sections.php?page_id='.$page_id );
130
} else {
131
	$admin->print_success($MESSAGE['PAGES']['SECTIONS_PROPERTIES_SAVED'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id );
132
}
133

    
134
// Print admin footer
135
$admin->print_footer();
(18-18/21)