Project

General

Profile

1
<?php
2

    
3
// $Id: save.php 915 2009-01-21 19:27:01Z Ruebenwurzel $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
// Get page & section id
27
if(!isset($_POST['page_id']) OR !is_numeric($_POST['page_id'])) {
28
	header("Location: index.php");
29
	exit(0);
30
} else {
31
	$page_id = $_POST['page_id'];
32
}
33
if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) {
34
	header("Location: index.php");
35
	exit(0);
36
} else {
37
	$section_id = $_POST['section_id'];
38
}
39

    
40
// Create new admin object
41
require('../../config.php');
42
require_once(WB_PATH.'/framework/class.admin.php');
43
$admin = new admin('Pages', 'pages_modify');
44

    
45
// Get perms
46
$database = new database();
47
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
48
$results_array = $results->fetchRow();
49
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
50
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
51
$in_old_group = FALSE;
52
foreach($admin->get_groups_id() as $cur_gid){
53
    if (in_array($cur_gid, $old_admin_groups)) {
54
        $in_old_group = TRUE;
55
    }
56
}
57
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
58
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
59
}
60

    
61
// Get page module
62
$database = new database();
63
$query = "SELECT module FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
64
$results = $database->query($query);
65
if($database->is_error()) {
66
	$admin->print_error($database->get_error());
67
}
68
if($results->numRows() == 0) {
69
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
70
}
71
$results_array = $results->fetchRow();
72
$module = $results_array['module'];
73

    
74
// Update the pages table
75
$now = mktime();
76
$query = "UPDATE ".TABLE_PREFIX."pages SET modified_when = '$now', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'";
77
$database->query($query);
78

    
79
// Include the modules saving script if it exists
80
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php')) {
81
	require(WB_PATH.'/modules/'.$module.'/save.php');
82
}
83

    
84
// Check if there is a db error, otherwise say successful
85
if($database->is_error()) {
86
	$admin->print_error($database->get_error(), $js_back);
87
} else {
88
	$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
89
}
90

    
91
// Print admin footer
92
$admin->print_footer();
93

    
94
?>
(11-11/16)