1 |
16
|
stefan
|
<?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 |
19
|
stefan
|
if(!defined('WB_PATH')) { exit('Direct access to this file is not allowed'); }
|
26 |
16
|
stefan
|
|
27 |
|
|
// Get system permissions
|
28 |
|
|
if($admin->get_post('advanced') != 'yes') {
|
29 |
|
|
$system_permissions['pages'] = $admin->get_post('pages');
|
30 |
4
|
ryan
|
$system_permissions['pages_view'] = $system_permissions['pages'];
|
31 |
16
|
stefan
|
$system_permissions['pages_add'] = $system_permissions['pages'];
|
32 |
4
|
ryan
|
$system_permissions['pages_add_l0'] = $system_permissions['pages'];
|
33 |
|
|
$system_permissions['pages_settings'] = $system_permissions['pages'];
|
34 |
16
|
stefan
|
$system_permissions['pages_modify'] = $system_permissions['pages'];
|
35 |
4
|
ryan
|
$system_permissions['pages_intro'] = $system_permissions['pages'];
|
36 |
16
|
stefan
|
$system_permissions['pages_delete'] = $system_permissions['pages'];
|
37 |
|
|
$system_permissions['media'] = $admin->get_post('media');
|
38 |
4
|
ryan
|
$system_permissions['media_view'] = $system_permissions['media'];
|
39 |
|
|
$system_permissions['media_upload'] = $system_permissions['media'];
|
40 |
|
|
$system_permissions['media_rename'] = $system_permissions['media'];
|
41 |
16
|
stefan
|
$system_permissions['media_delete'] = $system_permissions['media'];
|
42 |
|
|
$system_permissions['media_create'] = $system_permissions['media'];
|
43 |
115
|
stefan
|
if($admin->get_post('modules') != '' OR $admin->get_post('templates') != '' OR $admin->get_post('languages') != '') {
|
44 |
16
|
stefan
|
$system_permissions['addons'] = 1;
|
45 |
|
|
} else {
|
46 |
|
|
$system_permissions['addons'] = 0;
|
47 |
|
|
}
|
48 |
|
|
$system_permissions['modules'] = $admin->get_post('modules');
|
49 |
4
|
ryan
|
$system_permissions['modules_view'] = $system_permissions['modules'];
|
50 |
|
|
$system_permissions['modules_install'] = $system_permissions['modules'];
|
51 |
16
|
stefan
|
$system_permissions['modules_uninstall'] = $system_permissions['modules'];
|
52 |
|
|
$system_permissions['templates'] = $admin->get_post('templates');
|
53 |
4
|
ryan
|
$system_permissions['templates_view'] = $system_permissions['templates'];
|
54 |
|
|
$system_permissions['templates_install'] = $system_permissions['templates'];
|
55 |
16
|
stefan
|
$system_permissions['templates_uninstall'] = $system_permissions['templates'];
|
56 |
|
|
$system_permissions['languages'] = $admin->get_post('languages');
|
57 |
4
|
ryan
|
$system_permissions['languages_view'] = $system_permissions['languages'];
|
58 |
|
|
$system_permissions['languages_install'] = $system_permissions['languages'];
|
59 |
16
|
stefan
|
$system_permissions['languages_uninstall'] = $system_permissions['languages'];
|
60 |
|
|
$system_permissions['settings'] = $admin->get_post('settings');
|
61 |
4
|
ryan
|
$system_permissions['settings_basic'] = $system_permissions['settings'];
|
62 |
16
|
stefan
|
$system_permissions['settings_advanced'] = $system_permissions['settings'];
|
63 |
|
|
if($admin->get_post('users') != '' AND $admin->get_post('groups') != '') {
|
64 |
|
|
$system_permissions['access'] = 1;
|
65 |
|
|
} else {
|
66 |
|
|
$system_permissions['access'] = 0;
|
67 |
|
|
}
|
68 |
|
|
$system_permissions['users'] = $admin->get_post('users');
|
69 |
4
|
ryan
|
$system_permissions['users_view'] = $system_permissions['users'];
|
70 |
|
|
$system_permissions['users_add'] = $system_permissions['users'];
|
71 |
|
|
$system_permissions['users_modify'] = $system_permissions['users'];
|
72 |
16
|
stefan
|
$system_permissions['users_delete'] = $system_permissions['users'];
|
73 |
|
|
$system_permissions['groups'] = $admin->get_post('groups');
|
74 |
4
|
ryan
|
$system_permissions['groups_view'] = $system_permissions['groups'];
|
75 |
|
|
$system_permissions['groups_add'] = $system_permissions['groups'];
|
76 |
|
|
$system_permissions['groups_modify'] = $system_permissions['groups'];
|
77 |
16
|
stefan
|
$system_permissions['groups_delete'] = $system_permissions['groups'];
|
78 |
|
|
} else {
|
79 |
|
|
// Pages
|
80 |
|
|
$system_permissions['pages_view'] = $admin->get_post('pages_view');
|
81 |
|
|
$system_permissions['pages_add'] = $admin->get_post('pages_add');
|
82 |
|
|
if($admin->get_post('pages_add') != 1 AND $admin->get_post('pages_add_l0') == 1) {
|
83 |
|
|
$system_permissions['pages_add'] = $admin->get_post('pages_add_l0');
|
84 |
4
|
ryan
|
}
|
85 |
|
|
$system_permissions['pages_add_l0'] = $admin->get_post('pages_add_l0');
|
86 |
16
|
stefan
|
$system_permissions['pages_settings'] = $admin->get_post('pages_settings');
|
87 |
|
|
$system_permissions['pages_modify'] = $admin->get_post('pages_modify');
|
88 |
4
|
ryan
|
$system_permissions['pages_intro'] = $admin->get_post('pages_intro');
|
89 |
16
|
stefan
|
$system_permissions['pages_delete'] = $admin->get_post('pages_delete');
|
90 |
|
|
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) {
|
91 |
|
|
$system_permissions['pages'] = 1;
|
92 |
|
|
} else {
|
93 |
|
|
$system_permissions['pages'] = '';
|
94 |
|
|
}
|
95 |
|
|
// Media
|
96 |
4
|
ryan
|
$system_permissions['media_view'] = $admin->get_post('media_view');
|
97 |
|
|
$system_permissions['media_upload'] = $admin->get_post('media_upload');
|
98 |
|
|
$system_permissions['media_rename'] = $admin->get_post('media_rename');
|
99 |
16
|
stefan
|
$system_permissions['media_delete'] = $admin->get_post('media_delete');
|
100 |
|
|
$system_permissions['media_create'] = $admin->get_post('media_create');
|
101 |
|
|
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) {
|
102 |
|
|
$system_permissions['media'] = 1;
|
103 |
|
|
} else {
|
104 |
|
|
$system_permissions['media'] = '';
|
105 |
|
|
}
|
106 |
|
|
// Add-ons
|
107 |
|
|
// Modules
|
108 |
4
|
ryan
|
$system_permissions['modules_view'] = $admin->get_post('modules_view');
|
109 |
|
|
$system_permissions['modules_install'] = $admin->get_post('modules_install');
|
110 |
16
|
stefan
|
$system_permissions['modules_uninstall'] = $admin->get_post('modules_uninstall');
|
111 |
|
|
if($system_permissions['modules_view'] == 1 OR $system_permissions['modules_install'] == 1 OR $system_permissions['modules_uninstall'] == 1) {
|
112 |
|
|
$system_permissions['modules'] = 1;
|
113 |
|
|
} else {
|
114 |
|
|
$system_permissions['modules'] = '';
|
115 |
|
|
}
|
116 |
|
|
// Templates
|
117 |
4
|
ryan
|
$system_permissions['templates_view'] = $admin->get_post('templates_view');
|
118 |
|
|
$system_permissions['templates_install'] = $admin->get_post('templates_install');
|
119 |
16
|
stefan
|
$system_permissions['templates_uninstall'] = $admin->get_post('templates_uninstall');
|
120 |
|
|
if($system_permissions['templates_view'] == 1 OR $system_permissions['templates_install'] == 1 OR $system_permissions['templates_uninstall'] == 1) {
|
121 |
|
|
$system_permissions['templates'] = 1;
|
122 |
|
|
} else {
|
123 |
|
|
$system_permissions['templates'] = '';
|
124 |
|
|
}
|
125 |
|
|
// Languages
|
126 |
4
|
ryan
|
$system_permissions['languages_view'] = $admin->get_post('languages_view');
|
127 |
|
|
$system_permissions['languages_install'] = $admin->get_post('languages_install');
|
128 |
16
|
stefan
|
$system_permissions['languages_uninstall'] = $admin->get_post('languages_uninstall');
|
129 |
|
|
if($system_permissions['languages_install'] == 1 OR $system_permissions['languages_uninstall'] == 1) {
|
130 |
|
|
$system_permissions['languages'] = 1;
|
131 |
|
|
} else {
|
132 |
|
|
$system_permissions['languages'] = '';
|
133 |
|
|
}
|
134 |
|
|
if($system_permissions['modules'] == 1 OR $system_permissions['templates'] == 1 OR $system_permissions['languages'] == 1) {
|
135 |
|
|
$system_permissions['addons'] = 1;
|
136 |
|
|
} else {
|
137 |
|
|
$system_permissions['addons'] = '';
|
138 |
|
|
}
|
139 |
|
|
// Settings
|
140 |
4
|
ryan
|
$system_permissions['settings_basic'] = $admin->get_post('settings_basic');
|
141 |
16
|
stefan
|
$system_permissions['settings_advanced'] = $admin->get_post('settings_advanced');
|
142 |
|
|
if($system_permissions['settings_basic'] == 1 OR $system_permissions['settings_advanced'] == 1) {
|
143 |
|
|
$system_permissions['settings'] = 1;
|
144 |
|
|
} else {
|
145 |
|
|
$system_permissions['settings'] = '';
|
146 |
|
|
}
|
147 |
|
|
// Access
|
148 |
|
|
// Users
|
149 |
4
|
ryan
|
$system_permissions['users_view'] = $admin->get_post('users_view');
|
150 |
|
|
$system_permissions['users_add'] = $admin->get_post('users_add');
|
151 |
|
|
$system_permissions['users_modify'] = $admin->get_post('users_modify');
|
152 |
16
|
stefan
|
$system_permissions['users_delete'] = $admin->get_post('users_delete');
|
153 |
|
|
if($system_permissions['users_view'] == 1 OR $system_permissions['users_add'] == 1 OR $system_permissions['users_modify'] == 1 OR $system_permissions['users_delete'] == 1) {
|
154 |
|
|
$system_permissions['users'] = 1;
|
155 |
|
|
} else {
|
156 |
|
|
$system_permissions['users'] = '';
|
157 |
|
|
}
|
158 |
|
|
// Groups
|
159 |
4
|
ryan
|
$system_permissions['groups_view'] = $admin->get_post('groups_view');
|
160 |
|
|
$system_permissions['groups_add'] = $admin->get_post('groups_add');
|
161 |
|
|
$system_permissions['groups_modify'] = $admin->get_post('groups_modify');
|
162 |
16
|
stefan
|
$system_permissions['groups_delete'] = $admin->get_post('groups_delete');
|
163 |
|
|
if($system_permissions['groups_view'] == 1 OR $system_permissions['groups_add'] == 1 OR $system_permissions['groups_modify'] == 1 OR $system_permissions['groups_delete'] == 1) {
|
164 |
|
|
$system_permissions['groups'] = 1;
|
165 |
|
|
} else {
|
166 |
|
|
$system_permissions['groups'] = '';
|
167 |
|
|
}
|
168 |
|
|
if($system_permissions['users'] == 1 OR $system_permissions['groups'] == 1) {
|
169 |
|
|
$system_permissions['access'] = 1;
|
170 |
|
|
} else {
|
171 |
|
|
$system_permissions['access'] = '';
|
172 |
|
|
}
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
// Implode system permissions
|
176 |
|
|
$imploded_system_permissions = '';
|
177 |
|
|
foreach($system_permissions AS $name => $value) {
|
178 |
|
|
if($value == true) {
|
179 |
|
|
if($imploded_system_permissions == '') {
|
180 |
|
|
$imploded_system_permissions = $name;
|
181 |
|
|
} else {
|
182 |
|
|
$imploded_system_permissions .= ','.$name;
|
183 |
|
|
}
|
184 |
|
|
}
|
185 |
|
|
}
|
186 |
|
|
|
187 |
|
|
$system_permissions = $imploded_system_permissions;
|
188 |
|
|
|
189 |
|
|
// Get module permissions
|
190 |
|
|
$module_permissions = '';
|
191 |
4
|
ryan
|
if($handle = opendir(WB_PATH.'/modules/')) {
|
192 |
|
|
while (false !== ($file = readdir($handle))) {
|
193 |
16
|
stefan
|
if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) {
|
194 |
|
|
// Include the modules info file
|
195 |
|
|
require(WB_PATH.'/modules/'.$file.'/info.php');
|
196 |
|
|
// Check if it was selected to be used or not
|
197 |
|
|
$count = 0;
|
198 |
|
|
if(is_array($admin->get_post('module_permissions'))) {
|
199 |
|
|
foreach($admin->get_post('module_permissions') AS $selected_name) {
|
200 |
|
|
if($file == $selected_name) {
|
201 |
|
|
$count = $count+1;
|
202 |
|
|
}
|
203 |
|
|
}
|
204 |
|
|
}
|
205 |
|
|
if($count == 0) {
|
206 |
|
|
// Add unselected modules to list
|
207 |
|
|
if($module_permissions == '') {
|
208 |
|
|
$module_permissions = $file;
|
209 |
|
|
} else {
|
210 |
|
|
$module_permissions .= ','.$file;
|
211 |
|
|
}
|
212 |
|
|
}
|
213 |
|
|
}
|
214 |
|
|
}
|
215 |
|
|
}
|
216 |
|
|
|
217 |
|
|
// Get template permissions
|
218 |
|
|
$template_permissions = '';
|
219 |
4
|
ryan
|
if($handle = opendir(WB_PATH.'/templates/')) {
|
220 |
|
|
while (false !== ($file = readdir($handle))) {
|
221 |
16
|
stefan
|
if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/templates/$file") AND file_exists(WB_PATH."/templates/$file/info.php")) {
|
222 |
|
|
// Include the modules info file
|
223 |
|
|
require(WB_PATH.'/templates/'.$file.'/info.php');
|
224 |
|
|
// Check if it was selected to be used or not
|
225 |
|
|
$count = 0;
|
226 |
|
|
if(is_array($admin->get_post('template_permissions'))) {
|
227 |
|
|
foreach($admin->get_post('template_permissions') AS $selected_name) {
|
228 |
|
|
if($file == $selected_name) {
|
229 |
|
|
$count = $count+1;
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
}
|
233 |
|
|
if($count == 0) {
|
234 |
|
|
// Add unselected modules to list
|
235 |
|
|
if($template_permissions == '') {
|
236 |
|
|
$template_permissions = $file;
|
237 |
|
|
} else {
|
238 |
|
|
$template_permissions .= ','.$file;
|
239 |
|
|
}
|
240 |
|
|
}
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
?>
|