|
1
|
|
|
<?php |
|
2
|
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3
|
|
|
/********************************************************************************* |
|
4
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
|
5
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
|
6
|
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
|
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
|
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
|
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
|
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
|
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
|
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
|
20
|
|
|
* details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
|
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
|
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
25
|
|
|
* 02110-1301 USA. |
|
26
|
|
|
* |
|
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
|
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
|
29
|
|
|
* |
|
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
|
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
|
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
|
33
|
|
|
* |
|
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
|
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
|
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
|
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
|
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
|
39
|
|
|
********************************************************************************/ |
|
40
|
|
|
/* BEGIN - SECURITY GROUPS */ |
|
41
|
|
|
if(file_exists("modules/ACLActions/actiondefs.override.php")){ |
|
42
|
|
|
require_once("modules/ACLActions/actiondefs.override.php"); |
|
43
|
|
|
} else { |
|
44
|
|
|
require_once('modules/ACLActions/actiondefs.php'); |
|
45
|
|
|
} |
|
46
|
|
|
/* END - SECURITY GROUPS */ |
|
47
|
|
|
require_once('modules/ACL/ACLJSController.php'); |
|
48
|
|
|
class ACLController { |
|
49
|
|
|
|
|
50
|
|
|
/* BEGIN - SECURITY GROUPS - added $in_group */ |
|
51
|
|
|
/** |
|
52
|
|
|
function checkAccess($category, $action, $is_owner=false, $type='module'){ |
|
53
|
|
|
*/ |
|
54
|
46 |
|
static function checkAccess($category, $action, $is_owner=false, $type='module',$in_group=false){ |
|
55
|
|
|
|
|
56
|
46 |
|
global $current_user; |
|
57
|
46 |
|
if(is_admin($current_user))return true; |
|
58
|
|
|
//calendar is a special case since it has 3 modules in it (calls, meetings, tasks) |
|
59
|
|
|
|
|
60
|
46 |
|
if($category == 'Calendar'){ |
|
61
|
|
|
/** |
|
62
|
|
|
return ACLAction::userHasAccess($current_user->id, 'Calls', $action,$type, $is_owner) || ACLAction::userHasAccess($current_user->id, 'Meetings', $action,'module', $is_owner) || ACLAction::userHasAccess($current_user->id, 'Tasks', $action,'module', $is_owner); |
|
63
|
|
|
*/ |
|
64
|
|
|
return ACLAction::userHasAccess($current_user->id, 'Calls', $action,$type, $is_owner, $in_group) || ACLAction::userHasAccess($current_user->id, 'Meetings', $action,'module', $is_owner, $in_group) || ACLAction::userHasAccess($current_user->id, 'Tasks', $action,'module', $is_owner, $in_group); |
|
65
|
|
|
} |
|
66
|
46 |
|
if($category == 'Activities'){ |
|
67
|
|
|
/** |
|
68
|
|
|
return ACLAction::userHasAccess($current_user->id, 'Calls', $action,$type, $is_owner) || ACLAction::userHasAccess($current_user->id, 'Meetings', $action,'module', $is_owner) || ACLAction::userHasAccess($current_user->id, 'Tasks', $action,'module', $is_owner)|| ACLAction::userHasAccess($current_user->id, 'Emails', $action,'module', $is_owner)|| ACLAction::userHasAccess($current_user->id, 'Notes', $action,'module', $is_owner); |
|
69
|
|
|
*/ |
|
70
|
|
|
return ACLAction::userHasAccess($current_user->id, 'Calls', $action,$type, $is_owner, $in_group) || ACLAction::userHasAccess($current_user->id, 'Meetings', $action,'module', $is_owner, $in_group) || ACLAction::userHasAccess($current_user->id, 'Tasks', $action,'module', $is_owner, $in_group)|| ACLAction::userHasAccess($current_user->id, 'Emails', $action,'module', $is_owner, $in_group)|| ACLAction::userHasAccess($current_user->id, 'Notes', $action,'module', $is_owner, $in_group); |
|
71
|
|
|
} |
|
72
|
|
|
/** |
|
73
|
|
|
return ACLAction::userHasAccess($current_user->id, $category, $action,$type, $is_owner); |
|
74
|
|
|
*/ |
|
75
|
46 |
|
return ACLAction::userHasAccess($current_user->id, $category, $action,$type, $is_owner, $in_group); |
|
76
|
|
|
} |
|
77
|
|
|
/* END - SECURITY GROUPS */ |
|
78
|
|
|
|
|
79
|
39 |
|
static function requireOwner($category, $value, $type='module'){ |
|
80
|
39 |
|
global $current_user; |
|
81
|
39 |
|
if(is_admin($current_user))return false; |
|
82
|
38 |
|
return ACLAction::userNeedsOwnership($current_user->id, $category, $value,$type); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/* BEGIN - SECURITY GROUPS */ |
|
86
|
39 |
|
static function requireSecurityGroup($category, $value, $type='module'){ |
|
87
|
39 |
|
global $current_user; |
|
88
|
39 |
|
if(is_admin($current_user))return false; |
|
89
|
38 |
|
return ACLAction::userNeedsSecurityGroup($current_user->id, $category, $value,$type); |
|
90
|
|
|
} |
|
91
|
|
|
/* END - SECURITY GROUPS */ |
|
92
|
|
|
|
|
93
|
2 |
|
static function filterModuleList(&$moduleList, $by_value=true){ |
|
94
|
|
|
|
|
95
|
2 |
|
global $aclModuleList, $current_user; |
|
96
|
2 |
|
if(is_admin($current_user)) return; |
|
97
|
2 |
|
$actions = ACLAction::getUserActions($current_user->id, false); |
|
98
|
|
|
|
|
99
|
2 |
|
$compList = array(); |
|
100
|
2 |
|
if($by_value){ |
|
101
|
2 |
|
foreach($moduleList as $key=>$value){ |
|
102
|
2 |
|
$compList[$value]= $key; |
|
103
|
|
|
} |
|
104
|
|
|
}else{ |
|
105
|
|
|
$compList =& $moduleList; |
|
106
|
|
|
} |
|
107
|
2 |
|
foreach($actions as $action_name=>$action){ |
|
108
|
|
|
|
|
109
|
2 |
|
if(!empty($action['module'])){ |
|
110
|
2 |
|
$aclModuleList[$action_name] = $action_name; |
|
111
|
2 |
|
if(isset($compList[$action_name])){ |
|
112
|
2 |
|
if($action['module']['access']['aclaccess'] < ACL_ALLOW_ENABLED){ |
|
113
|
|
|
if($by_value){ |
|
114
|
|
|
unset($moduleList[$compList[$action_name]]); |
|
115
|
|
|
}else{ |
|
116
|
2 |
|
unset($moduleList[$action_name]); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
2 |
|
if(isset($compList['Calendar']) && |
|
123
|
2 |
|
!( ACLController::checkModuleAllowed('Calls', $actions) || ACLController::checkModuleAllowed('Meetings', $actions) || ACLController::checkModuleAllowed('Tasks', $actions))) |
|
124
|
|
|
{ |
|
125
|
|
|
if($by_value){ |
|
126
|
|
|
unset($moduleList[$compList['Calendar']]); |
|
127
|
|
|
}else{ |
|
128
|
|
|
unset($moduleList['Calendar']); |
|
129
|
|
|
} |
|
130
|
|
|
if(isset($compList['Activities']) && !ACLController::checkModuleAllowed('Notes', $actions)){ |
|
131
|
|
|
if($by_value){ |
|
132
|
|
|
unset($moduleList[$compList['Activities']]); |
|
133
|
|
|
}else{ |
|
134
|
|
|
unset($moduleList['Activities']); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
2 |
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* Check to see if the module is available for this user. |
|
143
|
|
|
* |
|
144
|
|
|
* @param String $module_name |
|
145
|
|
|
* @return true if they are allowed. false otherwise. |
|
146
|
|
|
*/ |
|
147
|
2 |
|
static function checkModuleAllowed($module_name, $actions) |
|
148
|
|
|
{ |
|
149
|
2 |
|
if(!empty($actions[$module_name]['module']['access']['aclaccess']) && |
|
150
|
2 |
|
ACL_ALLOW_ENABLED == $actions[$module_name]['module']['access']['aclaccess']) |
|
151
|
|
|
{ |
|
152
|
2 |
|
return true; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
return false; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
8 |
|
static function disabledModuleList($moduleList, $by_value=true,$view='list'){ |
|
159
|
8 |
|
global $aclModuleList, $current_user; |
|
160
|
8 |
|
if(is_admin($GLOBALS['current_user'])) return array(); |
|
161
|
8 |
|
$actions = ACLAction::getUserActions($current_user->id, false); |
|
162
|
8 |
|
$disabled = array(); |
|
163
|
8 |
|
$compList = array(); |
|
164
|
|
|
|
|
165
|
8 |
|
if($by_value){ |
|
166
|
|
|
foreach($moduleList as $key=>$value){ |
|
167
|
|
|
$compList[$value]= $key; |
|
168
|
|
|
} |
|
169
|
|
|
}else{ |
|
170
|
8 |
|
$compList =& $moduleList; |
|
171
|
|
|
} |
|
172
|
8 |
|
if(isset($moduleList['ProductTemplates'])){ |
|
173
|
|
|
$moduleList['Products'] ='Products'; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
8 |
|
foreach($actions as $action_name=>$action){ |
|
177
|
|
|
|
|
178
|
8 |
|
if(!empty($action['module'])){ |
|
179
|
8 |
|
$aclModuleList[$action_name] = $action_name; |
|
180
|
8 |
|
if(isset($compList[$action_name])){ |
|
181
|
8 |
|
if($action['module']['access']['aclaccess'] < ACL_ALLOW_ENABLED || $action['module'][$view]['aclaccess'] < 0){ |
|
182
|
|
|
if($by_value){ |
|
183
|
|
|
$disabled[$compList[$action_name]] =$compList[$action_name] ; |
|
184
|
|
|
}else{ |
|
185
|
8 |
|
$disabled[$action_name] = $action_name; |
|
186
|
|
|
} |
|
187
|
|
|
} |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
8 |
|
if(isset($compList['Calendar']) && !( ACL_ALLOW_ENABLED == $actions['Calls']['module']['access']['aclaccess'] || ACL_ALLOW_ENABLED == $actions['Meetings']['module']['access']['aclaccess'] || ACL_ALLOW_ENABLED == $actions['Tasks']['module']['access']['aclaccess'])){ |
|
192
|
|
|
if($by_value){ |
|
193
|
|
|
$disabled[$compList['Calendar']] = $compList['Calendar']; |
|
194
|
|
|
}else{ |
|
195
|
|
|
$disabled['Calendar'] = 'Calendar'; |
|
196
|
|
|
} |
|
197
|
|
|
if(isset($compList['Activities']) &&!( ACL_ALLOW_ENABLED == $actions['Notes']['module']['access']['aclaccess'] || ACL_ALLOW_ENABLED == $actions['Notes']['module']['access']['aclaccess'] )){ |
|
198
|
|
|
if($by_value){ |
|
199
|
|
|
$disabled[$compList['Activities']] = $compList['Activities']; |
|
200
|
|
|
}else{ |
|
201
|
|
|
$disabled['Activities'] = 'Activities'; |
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
} |
|
205
|
8 |
|
if(isset($disabled['Products'])){ |
|
206
|
|
|
$disabled['ProductTemplates'] = 'ProductTemplates'; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
|
|
210
|
8 |
|
return $disabled; |
|
211
|
|
|
|
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
|
|
215
|
|
|
|
|
216
|
|
|
function addJavascript($category,$form_name='', $is_owner=false){ |
|
217
|
|
|
$jscontroller = new ACLJSController($category, $form_name, $is_owner); |
|
218
|
|
|
echo $jscontroller->getJavascript(); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
10 |
|
static function moduleSupportsACL($module){ |
|
222
|
10 |
|
static $checkModules = array(); |
|
223
|
10 |
|
global $beanFiles, $beanList; |
|
224
|
10 |
|
if(isset($checkModules[$module])){ |
|
225
|
9 |
|
return $checkModules[$module]; |
|
226
|
|
|
} |
|
227
|
2 |
|
if(!isset($beanList[$module])){ |
|
228
|
2 |
|
$checkModules[$module] = false; |
|
229
|
|
|
|
|
230
|
|
|
}else{ |
|
231
|
1 |
|
$class = $beanList[$module]; |
|
232
|
1 |
|
require_once($beanFiles[$class]); |
|
233
|
1 |
|
$mod = new $class(); |
|
234
|
1 |
|
if(!is_subclass_of($mod, 'SugarBean')){ |
|
235
|
|
|
$checkModules[$module] = false; |
|
236
|
|
|
}else{ |
|
237
|
1 |
|
$checkModules[$module] = $mod->bean_implements('ACL'); |
|
238
|
|
|
} |
|
239
|
|
|
} |
|
240
|
2 |
|
return $checkModules[$module] ; |
|
241
|
|
|
|
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
1 |
|
static function displayNoAccess($redirect_home = false){ |
|
245
|
1 |
|
echo '<script>function set_focus(){}</script><p class="error">' . translate('LBL_NO_ACCESS', 'ACL') . '</p>'; |
|
246
|
1 |
|
if($redirect_home)echo translate('LBL_REDIRECT_TO_HOME', 'ACL') . ' <span id="seconds_left">3</span> ' . translate('LBL_SECONDS', 'ACL') . '<script> function redirect_countdown(left){document.getElementById("seconds_left").innerHTML = left; if(left == 0){document.location.href = "index.php";}else{left--; setTimeout("redirect_countdown("+ left+")", 1000)}};setTimeout("redirect_countdown(3)", 1000)</script>'; |
|
247
|
1 |
|
} |
|
248
|
|
|
|
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
|
|
252
|
|
|
|
|
253
|
|
|
|
|
254
|
|
|
|
|
255
|
|
|
|
|
256
|
|
|
|
|
257
|
|
|
|
|
258
|
|
|
|
|
259
|
|
|
?> |
|
260
|
|
|
|