Project

General

Profile

« Previous | Next » 

Revision 238

Added by stefan about 19 years ago

Fixed inconsistent line ending styles

View differences:

sections_save.php
1
<?php
2

  
3
// $Id$
-
4
/*
5

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

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

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

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

  
23
*/
24

  
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, 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

  
25 26
// Include config file
26
require('../../config.php');

27

  
27
require('../../config.php');
28

  
28 29
// Make sure people are allowed to access this page
29
if(MANAGE_SECTIONS != 'enabled') {

30
	header('Location: '.ADMIN_URL.'/pages/index.php');

31
}

32

  
30
if(MANAGE_SECTIONS != 'enabled') {
31
	header('Location: '.ADMIN_URL.'/pages/index.php');
32
}
33

  
33 34
// Get page id
34
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {

35
	header("Location: index.php");

36
} else {

37
	$page_id = $_GET['page_id'];

38
}

39

  
35
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
36
	header("Location: index.php");
37
} else {
38
	$page_id = $_GET['page_id'];
39
}
40

  
40 41
// Create new admin object
41
require_once(WB_PATH.'/framework/class.admin.php');

42
$admin = new admin('Pages', 'pages_modify');

43

  
42
require_once(WB_PATH.'/framework/class.admin.php');
43
$admin = new admin('Pages', 'pages_modify');
44

  
44 45
// Get perms
45
$database = new database();

46
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");

47
$results_array = $results->fetchRow();

48
$old_admin_groups = explode(',', $results_array['admin_groups']);

49
$old_admin_users = explode(',', $results_array['admin_users']);

50
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {

51
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);

52
}

53

  
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(',', $results_array['admin_groups']);
50
$old_admin_users = explode(',', $results_array['admin_users']);
51
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
52
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
53
}
54

  
54 55
// Get page details
55
$database = new database();

56
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";

57
$results = $database->query($query);

58
if($database->is_error()) {

59
	$admin->print_header();

60
	$admin->print_error($database->get_error());

61
}

62
if($results->numRows() == 0) {

63
	$admin->print_header();

64
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);

65
}

66
$results_array = $results->fetchRow();

67

  
56
$database = new database();
57
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
58
$results = $database->query($query);
59
if($database->is_error()) {
60
	$admin->print_header();
61
	$admin->print_error($database->get_error());
62
}
63
if($results->numRows() == 0) {
64
	$admin->print_header();
65
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
66
}
67
$results_array = $results->fetchRow();
68

  
68 69
// Set module permissions
69
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];

70

  
70
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
71

  
71 72
// Loop through sections
72
$query_sections = $database->query("SELECT section_id,module,position FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");

73
if($query_sections->numRows() > 0) {

74
	$num_sections = $query_sections->numRows();

75
	while($section = $query_sections->fetchRow()) {

73
$query_sections = $database->query("SELECT section_id,module,position FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
74
if($query_sections->numRows() > 0) {
75
	$num_sections = $query_sections->numRows();
76
	while($section = $query_sections->fetchRow()) {
76 77
		// Get the modules real name
77
		$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php';

78
		if(file_exists($module_path)) {

79
			require($module_path);

80
			if(!isset($module_function)) { $module_function = 'unknown'; }

78
		$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php';
79
		if(file_exists($module_path)) {
80
			require($module_path);
81
			if(!isset($module_function)) { $module_function = 'unknown'; }
81 82
			if(!is_numeric(array_search($section['module'], $module_permissions)) AND $module_function == 'page') {
82 83
				// Update the section record with properties
83 84
				$section_id = $section['section_id'];
......
89 89
					if($sql != '') {
90 90
						$database->query($query);
91 91
					}
92
				}

93
			}

92
				}
93
			}
94 94
			if(isset($module_function)) { unset($module_function); } // Unset module type
95
		}
96
	}
97
}
98

  
99
// Check for error or print success message
95
		}
96
	}
97
}
98
// Check for error or print success message
100 99
if($database->is_error()) {
101 100
	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
102 101
} else {
103 102
	$admin->print_success($MESSAGE['PAGES']['SECTIONS_PROPERTIES_SAVED'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
104 103
}
105

  
104

  
106 105
// Print admin footer
107
$admin->print_footer();
108

  
109
?>
106
$admin->print_footer();
107

  
108
?>

Also available in: Unified diff