This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | 1 | 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 | |||
41 | |||
42 | class ACLRole extends SugarBean{ |
||
43 | var $module_dir = 'ACLRoles'; |
||
44 | var $object_name = 'ACLRole'; |
||
45 | var $table_name = 'acl_roles'; |
||
46 | var $new_schema = true; |
||
47 | var $disable_row_level_security = true; |
||
48 | var $disable_custom_fields = true; |
||
49 | var $relationship_fields = array( |
||
50 | 'user_id'=>'users' |
||
51 | ); |
||
52 | |||
53 | var $created_by; |
||
54 | |||
55 | 20 | public function __construct(){ |
|
56 | 20 | parent::__construct(); |
|
57 | 20 | } |
|
58 | |||
59 | /** |
||
60 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
||
61 | */ |
||
62 | public function ACLRole(){ |
||
63 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
||
64 | if(isset($GLOBALS['log'])) { |
||
65 | $GLOBALS['log']->deprecated($deprecatedMessage); |
||
66 | } |
||
67 | else { |
||
68 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
||
69 | } |
||
70 | self::__construct(); |
||
71 | } |
||
72 | |||
73 | |||
74 | // bug 16790 - missing get_summary_text method led Tracker to display SugarBean's "base implementation" |
||
75 | 1 | function get_summary_text() |
|
76 | { |
||
77 | 1 | return "$this->name"; |
|
78 | } |
||
79 | |||
80 | |||
81 | /** |
||
82 | * function setAction($role_id, $action_id, $access) |
||
83 | * |
||
84 | * Sets the relationship between a role and an action and sets the access level of that relationship |
||
85 | * |
||
86 | * @param GUID $role_id - the role id |
||
87 | * @param GUID $action_id - the ACL Action id |
||
88 | * @param int $access - the access level ACL_ALLOW_ALL ACL_ALLOW_NONE ACL_ALLOW_OWNER... |
||
89 | */ |
||
90 | 1 | function setAction($role_id, $action_id, $access){ |
|
91 | 1 | $relationship_data = array('role_id'=>$role_id, 'action_id'=>$action_id,); |
|
92 | 1 | $additional_data = array('access_override'=>$access); |
|
93 | 1 | $this->set_relationship('acl_roles_actions',$relationship_data,true, true,$additional_data); |
|
94 | 1 | } |
|
95 | |||
96 | |||
97 | /** |
||
98 | * static getUserRoles($user_id) |
||
99 | * returns a list of ACLRoles for a given user id |
||
100 | * |
||
101 | * @param GUID $user_id |
||
102 | * @return a list of ACLRole objects |
||
103 | */ |
||
104 | 1 | function getUserRoles($user_id, $getAsNameArray = true){ |
|
105 | |||
106 | //if we don't have it loaded then lets check against the db |
||
107 | 1 | $additional_where = ''; |
|
108 | $query = "SELECT acl_roles.* ". |
||
109 | "FROM acl_roles ". |
||
110 | 1 | "INNER JOIN acl_roles_users ON acl_roles_users.user_id = '$user_id' ". |
|
111 | 1 | "AND acl_roles_users.role_id = acl_roles.id AND acl_roles_users.deleted = 0 ". |
|
112 | 1 | "WHERE acl_roles.deleted=0 "; |
|
113 | |||
114 | 1 | $result = $GLOBALS['db']->query($query); |
|
115 | 1 | $user_roles = array(); |
|
116 | |||
117 | 1 | while($row = $GLOBALS['db']->fetchByAssoc($result) ){ |
|
118 | $role = new ACLRole(); |
||
119 | $role->populateFromRow($row); |
||
120 | if($getAsNameArray) |
||
121 | $user_roles[] = $role->name; |
||
122 | else |
||
123 | $user_roles[] = $role; |
||
124 | } |
||
125 | |||
126 | 1 | return $user_roles; |
|
127 | } |
||
128 | |||
129 | /** |
||
130 | * static getUserRoleNames($user_id) |
||
131 | * returns a list of Role names for a given user id |
||
132 | * |
||
133 | * @param GUID $user_id |
||
134 | * @return a list of ACLRole Names |
||
135 | */ |
||
136 | 2 | function getUserRoleNames($user_id){ |
|
137 | |||
138 | 2 | $user_roles = sugar_cache_retrieve("RoleMembershipNames_".$user_id); |
|
139 | |||
140 | 2 | if(!$user_roles){ |
|
141 | //if we don't have it loaded then lets check against the db |
||
142 | 2 | $additional_where = ''; |
|
143 | $query = "SELECT acl_roles.* ". |
||
144 | "FROM acl_roles ". |
||
145 | 2 | "INNER JOIN acl_roles_users ON acl_roles_users.user_id = '$user_id' ". |
|
146 | 2 | "AND acl_roles_users.role_id = acl_roles.id AND acl_roles_users.deleted = 0 ". |
|
147 | 2 | "WHERE acl_roles.deleted=0 "; |
|
148 | |||
149 | 2 | $result = $GLOBALS['db']->query($query); |
|
150 | 2 | $user_roles = array(); |
|
151 | |||
152 | 2 | while($row = $GLOBALS['db']->fetchByAssoc($result) ){ |
|
153 | $user_roles[] = $row['name']; |
||
154 | } |
||
155 | |||
156 | 2 | sugar_cache_put("RoleMembershipNames_".$user_id, $user_roles); |
|
157 | } |
||
158 | |||
159 | 2 | return $user_roles; |
|
160 | } |
||
161 | |||
162 | |||
163 | /** |
||
164 | * static getAllRoles($returnAsArray = false) |
||
165 | * |
||
166 | * @param boolean $returnAsArray - should it return the results as an array of arrays or as an array of ACLRoles |
||
167 | * @return either an array of array representations of acl roles or an array of ACLRoles |
||
168 | */ |
||
169 | 1 | function getAllRoles($returnAsArray = false){ |
|
170 | 1 | $db = DBManagerFactory::getInstance(); |
|
171 | $query = "SELECT acl_roles.* FROM acl_roles |
||
172 | 1 | WHERE acl_roles.deleted=0 ORDER BY name"; |
|
173 | |||
174 | 1 | $result = $db->query($query); |
|
175 | 1 | $roles = array(); |
|
176 | |||
177 | 1 | while($row = $db->fetchByAssoc($result) ){ |
|
178 | $role = new ACLRole(); |
||
179 | $role->populateFromRow($row); |
||
180 | if($returnAsArray){ |
||
181 | $roles[] = $role->toArray(); |
||
182 | }else{ |
||
183 | $roles[] = $role; |
||
184 | } |
||
185 | |||
186 | } |
||
187 | 1 | return $roles; |
|
188 | |||
189 | |||
190 | } |
||
191 | |||
192 | /** |
||
193 | * static getRoleActions($role_id) |
||
194 | * |
||
195 | * gets the actions of a given role |
||
196 | * |
||
197 | * @param GUID $role_id |
||
198 | * @return array of actions |
||
199 | */ |
||
200 | 1 | function getRoleActions($role_id, $type='module'){ |
|
201 | 1 | global $beanList; |
|
202 | //if we don't have it loaded then lets check against the db |
||
203 | 1 | $additional_where = ''; |
|
204 | 1 | $db = DBManagerFactory::getInstance(); |
|
205 | 1 | $query = "SELECT acl_actions.*"; |
|
206 | //only if we have a role id do we need to join the table otherwise lets use the ones defined in acl_actions as the defaults |
||
207 | 1 | if(!empty($role_id)){ |
|
208 | 1 | $query .=" ,acl_roles_actions.access_override "; |
|
209 | } |
||
210 | 1 | $query .=" FROM acl_actions "; |
|
211 | |||
212 | 1 | if(!empty($role_id)){ |
|
213 | 1 | $query .= " LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = '$role_id' AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted = 0"; |
|
214 | } |
||
215 | 1 | $query .= " WHERE acl_actions.deleted=0 ORDER BY acl_actions.category, acl_actions.name"; |
|
216 | 1 | $result = $db->query($query); |
|
217 | 1 | $role_actions = array(); |
|
218 | |||
219 | 1 | while($row = $db->fetchByAssoc($result) ){ |
|
220 | 1 | $action = new ACLAction(); |
|
221 | 1 | $action->populateFromRow($row); |
|
222 | 1 | if(!empty($row['access_override'])){ |
|
223 | $action->aclaccess = $row['access_override']; |
||
224 | }else{ |
||
225 | 1 | $action->aclaccess = ACL_ALLOW_DEFAULT; |
|
226 | |||
227 | } |
||
228 | //#27877 . If there is no this module in beanlist , we will not show them in UI, no matter this module was deleted or not in ACL_ACTIONS table. |
||
229 | 1 | if(empty($beanList[$action->category])){ |
|
230 | continue; |
||
231 | } |
||
232 | //end |
||
233 | |||
234 | 1 | if(!isset($role_actions[$action->category])){ |
|
235 | 1 | $role_actions[$action->category] = array(); |
|
236 | } |
||
237 | |||
238 | 1 | $role_actions[$action->category][$action->acltype][$action->name] = $action->toArray(); |
|
239 | |||
240 | |||
241 | } |
||
242 | |||
243 | // Sort by translated categories |
||
244 | 1 | uksort($role_actions, "ACLRole::langCompare"); |
|
245 | 1 | return $role_actions; |
|
246 | |||
247 | } |
||
248 | |||
249 | 1 | private static function langCompare($a, $b) |
|
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
250 | { |
||
251 | 1 | global $app_list_strings; |
|
252 | // Fallback to array key if translation is empty |
||
253 | 1 | $a = empty($app_list_strings['moduleList'][$a]) ? $a : $app_list_strings['moduleList'][$a]; |
|
254 | 1 | $b = empty($app_list_strings['moduleList'][$b]) ? $b : $app_list_strings['moduleList'][$b]; |
|
255 | 1 | if ($a == $b) |
|
256 | return 0; |
||
257 | 1 | return ($a < $b) ? -1 : 1; |
|
258 | } |
||
259 | /** |
||
260 | * function mark_relationships_deleted($id) |
||
261 | * |
||
262 | * special case to delete acl_roles_actions relationship |
||
263 | * |
||
264 | * @param ACLRole GUID $id |
||
265 | */ |
||
266 | 1 | function mark_relationships_deleted($id){ |
|
267 | //we need to delete the actions relationship by hand (special case) |
||
268 | 1 | $date_modified = db_convert("'".TimeDate::getInstance()->nowDb()."'", 'datetime'); |
|
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. ![]() |
|||
269 | 1 | $query = "UPDATE acl_roles_actions SET deleted=1 , date_modified=$date_modified WHERE role_id = '$id' AND deleted=0"; |
|
270 | 1 | $this->db->query($query); |
|
271 | 1 | parent::mark_relationships_deleted($id); |
|
272 | 1 | } |
|
273 | |||
274 | /** |
||
275 | * toArray() |
||
276 | * returns this role as an array |
||
277 | * |
||
278 | * @return array of fields with id, name, description |
||
279 | */ |
||
280 | 1 | function toArray($dbOnly = false, $stringOnly = false, $upperKeys=false){ |
|
281 | 1 | $array_fields = array('id', 'name', 'description'); |
|
282 | 1 | $arr = array(); |
|
283 | 1 | foreach($array_fields as $field){ |
|
284 | 1 | if(isset($this->$field)){ |
|
285 | 1 | $arr[$field] = $this->$field; |
|
286 | }else{ |
||
287 | 1 | $arr[$field] = ''; |
|
288 | } |
||
289 | } |
||
290 | 1 | return $arr; |
|
291 | } |
||
292 | |||
293 | /** |
||
294 | * fromArray($arr) |
||
295 | * converts an array into an role mapping name value pairs into files |
||
296 | * |
||
297 | * @param Array $arr |
||
298 | */ |
||
299 | 1 | function fromArray($arr){ |
|
300 | 1 | foreach($arr as $name=>$value){ |
|
301 | 1 | $this->$name = $value; |
|
302 | } |
||
303 | 1 | } |
|
304 | } |
||
305 | |||
306 | ?> |