Project

General

Profile

1
<?php
2

    
3
// $Id: get_permissions.php 10 2005-09-04 08:59:31Z ryan $
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

    
26
// Get system permissions
27
if($admin->get_post('advanced') != 'yes') {
28
	$system_permissions['pages'] = $admin->get_post('pages');
29
		$system_permissions['pages_view'] = $system_permissions['pages'];
30
		$system_permissions['pages_add'] = $system_permissions['pages'];
31
		$system_permissions['pages_add_l0'] = $system_permissions['pages'];
32
		$system_permissions['pages_settings'] = $system_permissions['pages'];
33
		$system_permissions['pages_modify'] = $system_permissions['pages'];
34
		$system_permissions['pages_intro'] = $system_permissions['pages'];
35
		$system_permissions['pages_delete'] = $system_permissions['pages'];
36
	$system_permissions['media'] = $admin->get_post('media');
37
		$system_permissions['media_view'] = $system_permissions['media'];
38
		$system_permissions['media_upload'] = $system_permissions['media'];
39
		$system_permissions['media_rename'] = $system_permissions['media'];
40
		$system_permissions['media_delete'] = $system_permissions['media'];
41
		$system_permissions['media_create'] = $system_permissions['media'];
42
	if($admin->get_post('modules') != '' AND $admin->get_post('templates') != '' AND $admin->get_post('languages') != '') {
43
		$system_permissions['addons'] = 1;
44
	} else {
45
		$system_permissions['addons'] = 0;
46
	}
47
		$system_permissions['modules'] = $admin->get_post('modules');
48
			$system_permissions['modules_view'] = $system_permissions['modules'];
49
			$system_permissions['modules_install'] = $system_permissions['modules'];
50
			$system_permissions['modules_uninstall'] = $system_permissions['modules'];
51
		$system_permissions['templates'] = $admin->get_post('templates');
52
			$system_permissions['templates_view'] = $system_permissions['templates'];
53
			$system_permissions['templates_install'] = $system_permissions['templates'];
54
			$system_permissions['templates_uninstall'] = $system_permissions['templates'];
55
		$system_permissions['languages'] = $admin->get_post('languages');
56
			$system_permissions['languages_view'] = $system_permissions['languages'];
57
			$system_permissions['languages_install'] = $system_permissions['languages'];
58
			$system_permissions['languages_uninstall'] = $system_permissions['languages'];
59
	$system_permissions['settings'] = $admin->get_post('settings');
60
		$system_permissions['settings_basic'] = $system_permissions['settings'];
61
		$system_permissions['settings_advanced'] = $system_permissions['settings'];
62
	if($admin->get_post('users') != '' AND $admin->get_post('groups') != '') {
63
		$system_permissions['access'] = 1;
64
	} else {
65
		$system_permissions['access'] = 0;
66
	}
67
		$system_permissions['users'] = $admin->get_post('users');
68
			$system_permissions['users_view'] = $system_permissions['users'];
69
			$system_permissions['users_add'] = $system_permissions['users'];
70
			$system_permissions['users_modify'] = $system_permissions['users'];
71
			$system_permissions['users_delete'] = $system_permissions['users'];
72
		$system_permissions['groups'] = $admin->get_post('groups');
73
			$system_permissions['groups_view'] = $system_permissions['groups'];
74
			$system_permissions['groups_add'] = $system_permissions['groups'];
75
			$system_permissions['groups_modify'] = $system_permissions['groups'];
76
			$system_permissions['groups_delete'] = $system_permissions['groups'];
77
} else {
78
	// Pages
79
	$system_permissions['pages_view'] = $admin->get_post('pages_view');
80
		$system_permissions['pages_add'] = $admin->get_post('pages_add');
81
	if($admin->get_post('pages_add') != 1 AND $admin->get_post('pages_add_l0') == 1) {
82
		$system_permissions['pages_add'] = $admin->get_post('pages_add_l0');
83
	}
84
	$system_permissions['pages_add_l0'] = $admin->get_post('pages_add_l0');
85
	$system_permissions['pages_settings'] = $admin->get_post('pages_settings');
86
	$system_permissions['pages_modify'] = $admin->get_post('pages_modify');
87
	$system_permissions['pages_intro'] = $admin->get_post('pages_intro');
88
	$system_permissions['pages_delete'] = $admin->get_post('pages_delete');
89
	if($system_permissions['pages_view'] == 1 OR $system_permissions['pages_add'] == 1 OR $system_permissions['pages_settings'] == 1 OR $system_permissions['pages_modify'] == 1 OR $system_permissions['pages_intro'] == 1 OR $system_permissions['pages_delete'] == 1) {
90
		$system_permissions['pages'] = 1;
91
	} else {
92
		$system_permissions['pages'] = '';
93
	}
94
	// Media
95
	$system_permissions['media_view'] = $admin->get_post('media_view');
96
	$system_permissions['media_upload'] = $admin->get_post('media_upload');
97
	$system_permissions['media_rename'] = $admin->get_post('media_rename');
98
	$system_permissions['media_delete'] = $admin->get_post('media_delete');
99
	$system_permissions['media_create'] = $admin->get_post('media_create');
100
	if($system_permissions['media_view'] == 1 OR $system_permissions['media_upload'] == 1 OR $system_permissions['media_rename'] == 1 OR $system_permissions['media_delete'] == 1 OR $system_permissions['media_create'] == 1) {
101
		$system_permissions['media'] = 1;
102
	} else {
103
		$system_permissions['media'] = '';
104
	}
105
	// Add-ons
106
		// Modules
107
		$system_permissions['modules_view'] = $admin->get_post('modules_view');
108
		$system_permissions['modules_install'] = $admin->get_post('modules_install');
109
		$system_permissions['modules_uninstall'] = $admin->get_post('modules_uninstall');
110
		if($system_permissions['modules_view'] == 1 OR $system_permissions['modules_install'] == 1 OR $system_permissions['modules_uninstall'] == 1) {
111
			$system_permissions['modules'] = 1;
112
		} else {
113
			$system_permissions['modules'] = '';
114
		}
115
		// Templates
116
		$system_permissions['templates_view'] = $admin->get_post('templates_view');
117
		$system_permissions['templates_install'] = $admin->get_post('templates_install');
118
		$system_permissions['templates_uninstall'] = $admin->get_post('templates_uninstall');
119
		if($system_permissions['templates_view'] == 1 OR $system_permissions['templates_install'] == 1 OR $system_permissions['templates_uninstall'] == 1) {
120
			$system_permissions['templates'] = 1;
121
		} else {
122
			$system_permissions['templates'] = '';
123
		}
124
		// Languages
125
		$system_permissions['languages_view'] = $admin->get_post('languages_view');
126
		$system_permissions['languages_install'] = $admin->get_post('languages_install');
127
		$system_permissions['languages_uninstall'] = $admin->get_post('languages_uninstall');
128
		if($system_permissions['languages_install'] == 1 OR $system_permissions['languages_uninstall'] == 1) {
129
			$system_permissions['languages'] = 1;
130
		} else {
131
			$system_permissions['languages'] = '';
132
		}
133
	if($system_permissions['modules'] == 1 OR $system_permissions['templates'] == 1 OR $system_permissions['languages'] == 1) {
134
		$system_permissions['addons'] = 1;
135
	} else {
136
		$system_permissions['addons'] = '';
137
	}
138
	// Settings
139
	$system_permissions['settings_basic'] = $admin->get_post('settings_basic');
140
	$system_permissions['settings_advanced'] = $admin->get_post('settings_advanced');
141
	if($system_permissions['settings_basic'] == 1 OR $system_permissions['settings_advanced'] == 1) {
142
		$system_permissions['settings'] = 1;
143
	} else {
144
		$system_permissions['settings'] = '';
145
	}
146
	// Access
147
		// Users
148
		$system_permissions['users_view'] = $admin->get_post('users_view');
149
		$system_permissions['users_add'] = $admin->get_post('users_add');
150
		$system_permissions['users_modify'] = $admin->get_post('users_modify');
151
		$system_permissions['users_delete'] = $admin->get_post('users_delete');
152
		if($system_permissions['users_view'] == 1 OR $system_permissions['users_add'] == 1 OR $system_permissions['users_modify'] == 1 OR $system_permissions['users_delete'] == 1) {
153
			$system_permissions['users'] = 1;
154
		} else {
155
			$system_permissions['users'] = '';
156
		}
157
		// Groups
158
		$system_permissions['groups_view'] = $admin->get_post('groups_view');
159
		$system_permissions['groups_add'] = $admin->get_post('groups_add');
160
		$system_permissions['groups_modify'] = $admin->get_post('groups_modify');
161
		$system_permissions['groups_delete'] = $admin->get_post('groups_delete');
162
		if($system_permissions['groups_view'] == 1 OR $system_permissions['groups_add'] == 1 OR $system_permissions['groups_modify'] == 1 OR $system_permissions['groups_delete'] == 1) {
163
			$system_permissions['groups'] = 1;
164
		} else {
165
			$system_permissions['groups'] = '';
166
		}
167
	if($system_permissions['users'] == 1 OR $system_permissions['groups'] == 1) {
168
		$system_permissions['access'] = 1;
169
	} else {
170
		$system_permissions['access'] = '';
171
	}
172
}
173

    
174
// Implode system permissions
175
$imploded_system_permissions = '';
176
foreach($system_permissions AS $name => $value) {
177
	if($value == true) {
178
		if($imploded_system_permissions == '') {
179
			$imploded_system_permissions = $name;
180
		} else {
181
			$imploded_system_permissions .= ','.$name;
182
		}
183
	}
184
}
185

    
186
$system_permissions = $imploded_system_permissions;
187

    
188
// Get module permissions
189
$module_permissions = '';
190
if($handle = opendir(WB_PATH.'/modules/')) {
191
	while (false !== ($file = readdir($handle))) {
192
		if($file != "." AND $file != ".." AND $file != "CVS" AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) {
193
			// Include the modules info file
194
			require(WB_PATH.'/modules/'.$file.'/info.php');
195
			// Check if it was selected to be used or not
196
			$count = 0;
197
			if(is_array($admin->get_post('module_permissions'))) {
198
				foreach($admin->get_post('module_permissions') AS $selected_name) {
199
					if($file == $selected_name) {
200
						$count = $count+1;
201
					}
202
				}
203
			}
204
			if($count == 0) {
205
				// Add unselected modules to list
206
				if($module_permissions == '') {
207
					$module_permissions = $file;
208
				} else {
209
					$module_permissions .= ','.$file;
210
				}
211
			}
212
		}
213
	}
214
}
215

    
216
// Get template permissions
217
$template_permissions = '';
218
if($handle = opendir(WB_PATH.'/templates/')) {
219
	while (false !== ($file = readdir($handle))) {
220
		if($file != "." AND $file != ".." AND $file != "CVS" AND is_dir(WB_PATH."/templates/$file") AND file_exists(WB_PATH."/templates/$file/info.php")) {
221
			// Include the modules info file
222
			require(WB_PATH.'/templates/'.$file.'/info.php');
223
			// Check if it was selected to be used or not
224
			$count = 0;
225
			if(is_array($admin->get_post('template_permissions'))) {
226
				foreach($admin->get_post('template_permissions') AS $selected_name) {
227
					if($file == $selected_name) {
228
						$count = $count+1;
229
					}
230
				}
231
			}
232
			if($count == 0) {
233
				// Add unselected modules to list
234
				if($template_permissions == '') {
235
					$template_permissions = $file;
236
				} else {
237
					$template_permissions .= ','.$file;
238
				}
239
			}
240
		}
241
	}
242
}
243

    
244
?>
(2-2/7)