@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ********************************************************************************/ |
40 | 40 | /* BEGIN - SECURITY GROUPS */ |
41 | 41 | if(file_exists("modules/ACLActions/actiondefs.override.php")){ |
42 | - require_once("modules/ACLActions/actiondefs.override.php"); |
|
42 | + require_once("modules/ACLActions/actiondefs.override.php"); |
|
43 | 43 | } else { |
44 | 44 | require_once('modules/ACLActions/actiondefs.php'); |
45 | 45 | } |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * static addActions($category, $type='module') |
|
59 | - * Adds all default actions for a category/type |
|
60 | - * |
|
61 | - * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
|
62 | - * @param STRING $type - the type (e.g. 'module', 'field') |
|
63 | - */ |
|
58 | + * static addActions($category, $type='module') |
|
59 | + * Adds all default actions for a category/type |
|
60 | + * |
|
61 | + * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
|
62 | + * @param STRING $type - the type (e.g. 'module', 'field') |
|
63 | + */ |
|
64 | 64 | static function addActions($category, $type='module'){ |
65 | 65 | global $ACLActions; |
66 | 66 | $db = DBManagerFactory::getInstance(); |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | - * static removeActions($category, $type='module') |
|
95 | - * Removes all default actions for a category/type |
|
96 | - * |
|
97 | - * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
|
98 | - * @param STRING $type - the type (e.g. 'module', 'field') |
|
99 | - */ |
|
94 | + * static removeActions($category, $type='module') |
|
95 | + * Removes all default actions for a category/type |
|
96 | + * |
|
97 | + * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
|
98 | + * @param STRING $type - the type (e.g. 'module', 'field') |
|
99 | + */ |
|
100 | 100 | public static function removeActions($category, $type='module'){ |
101 | 101 | global $ACLActions; |
102 | 102 | $db = DBManagerFactory::getInstance(); |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | - * static AccessColor($access) |
|
122 | - * |
|
123 | - * returns the color associated with an access level |
|
124 | - * these colors exist in the definitions in modules/ACLActions/actiondefs.php |
|
125 | - * @param INT $access - the access level you want the color for |
|
126 | - * @return the color either name or hex representation or false if the level does not exist |
|
127 | - */ |
|
121 | + * static AccessColor($access) |
|
122 | + * |
|
123 | + * returns the color associated with an access level |
|
124 | + * these colors exist in the definitions in modules/ACLActions/actiondefs.php |
|
125 | + * @param INT $access - the access level you want the color for |
|
126 | + * @return the color either name or hex representation or false if the level does not exist |
|
127 | + */ |
|
128 | 128 | protected static function AccessColor($access){ |
129 | 129 | global $ACLActionAccessLevels; |
130 | 130 | if(isset($ACLActionAccessLevels[$access])){ |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | - * static AccessName($access) |
|
140 | - * |
|
141 | - * returns the translated name associated with an access level |
|
142 | - * these label definitions exist in the definitions in modules/ACLActions/actiondefs.php |
|
143 | - * @param INT $access - the access level you want the color for |
|
144 | - * @return the translated access level name or false if the level does not exist |
|
145 | - */ |
|
139 | + * static AccessName($access) |
|
140 | + * |
|
141 | + * returns the translated name associated with an access level |
|
142 | + * these label definitions exist in the definitions in modules/ACLActions/actiondefs.php |
|
143 | + * @param INT $access - the access level you want the color for |
|
144 | + * @return the translated access level name or false if the level does not exist |
|
145 | + */ |
|
146 | 146 | static function AccessName($access){ |
147 | 147 | global $ACLActionAccessLevels; |
148 | 148 | if(isset($ACLActionAccessLevels[$access])){ |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
175 | - * static getAccessOptions() |
|
176 | - * this is used for building select boxes |
|
177 | - * @return array containg access levels (ints) as keys and access names as values |
|
178 | - */ |
|
175 | + * static getAccessOptions() |
|
176 | + * this is used for building select boxes |
|
177 | + * @return array containg access levels (ints) as keys and access names as values |
|
178 | + */ |
|
179 | 179 | protected static function getAccessOptions( $action, $type='module'){ |
180 | 180 | global $ACLActions; |
181 | 181 | $options = array(); |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | - * function static getDefaultActions() |
|
193 | - * This function will return a list of acl actions with their default access levels |
|
194 | - * |
|
195 | - * |
|
196 | - */ |
|
192 | + * function static getDefaultActions() |
|
193 | + * This function will return a list of acl actions with their default access levels |
|
194 | + * |
|
195 | + * |
|
196 | + */ |
|
197 | 197 | public static function getDefaultActions($type='module', $action=''){ |
198 | 198 | $query = "SELECT * FROM acl_actions WHERE deleted=0 "; |
199 | 199 | if(!empty($type)){ |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | /** |
220 | - * static getUserActions($user_id,$refresh=false, $category='', $action='') |
|
221 | - * returns a list of user actions |
|
222 | - * @param GUID $user_id |
|
223 | - * @param BOOLEAN $refresh |
|
224 | - * @param STRING $category |
|
225 | - * @param STRING $action |
|
226 | - * @return ARRAY of ACLActionsArray |
|
227 | - */ |
|
220 | + * static getUserActions($user_id,$refresh=false, $category='', $action='') |
|
221 | + * returns a list of user actions |
|
222 | + * @param GUID $user_id |
|
223 | + * @param BOOLEAN $refresh |
|
224 | + * @param STRING $category |
|
225 | + * @param STRING $action |
|
226 | + * @return ARRAY of ACLActionsArray |
|
227 | + */ |
|
228 | 228 | |
229 | 229 | static function getUserActions($user_id,$refresh=false, $category='',$type='', $action=''){ |
230 | 230 | //check in the session if we already have it loaded |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | if(!empty($type)){ |
257 | 257 | $additional_where .= " AND acl_actions.acltype = '$type' "; |
258 | 258 | } |
259 | - /* BEGIN - SECURITY GROUPS */ |
|
260 | - /** |
|
259 | + /* BEGIN - SECURITY GROUPS */ |
|
260 | + /** |
|
261 | 261 | $query = "SELECT acl_actions .*, acl_roles_actions.access_override |
262 | 262 | FROM acl_actions |
263 | 263 | LEFT JOIN acl_roles_users ON acl_roles_users.user_id = '$user_id' AND acl_roles_users.deleted = 0 |
264 | 264 | LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = acl_roles_users.role_id AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted=0 |
265 | 265 | WHERE acl_actions.deleted=0 $additional_where ORDER BY category,name"; |
266 | - */ |
|
267 | - $query = "(SELECT acl_actions .*, acl_roles_actions.access_override, 1 as user_role |
|
266 | + */ |
|
267 | + $query = "(SELECT acl_actions .*, acl_roles_actions.access_override, 1 as user_role |
|
268 | 268 | FROM acl_actions |
269 | 269 | INNER JOIN acl_roles_users ON acl_roles_users.user_id = '$user_id' AND acl_roles_users.deleted = 0 |
270 | 270 | LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = acl_roles_users.role_id AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted=0 |
@@ -286,34 +286,34 @@ discard block |
||
286 | 286 | WHERE acl_actions.deleted = 0 ) |
287 | 287 | |
288 | 288 | ORDER BY user_role desc, category,name,access_override desc"; //want non-null to show first |
289 | - /* END - SECURITY GROUPS */ |
|
289 | + /* END - SECURITY GROUPS */ |
|
290 | 290 | $result = $db->query($query); |
291 | 291 | $selected_actions = array(); |
292 | - /* BEGIN - SECURITY GROUPS */ |
|
293 | - global $sugar_config; |
|
294 | - $has_user_role = false; //used for user_role_precedence |
|
295 | - $has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults |
|
296 | - /* END - SECURITY GROUPS */ |
|
292 | + /* BEGIN - SECURITY GROUPS */ |
|
293 | + global $sugar_config; |
|
294 | + $has_user_role = false; //used for user_role_precedence |
|
295 | + $has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults |
|
296 | + /* END - SECURITY GROUPS */ |
|
297 | 297 | while($row = $db->fetchByAssoc($result, FALSE) ){ |
298 | - /* BEGIN - SECURITY GROUPS */ |
|
299 | - if($has_user_role == false && $row['user_role'] == 1) { |
|
300 | - $has_user_role = true; |
|
301 | - } |
|
302 | - if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) { |
|
303 | - $has_role = true; |
|
304 | - } |
|
305 | - //if user roles should take precedence over group roles and we have a user role |
|
306 | - //break when we get to processing the group roles |
|
307 | - if($has_user_role == true && $row['user_role'] == 0 |
|
308 | - && isset($sugar_config['securitysuite_user_role_precedence']) |
|
309 | - && $sugar_config['securitysuite_user_role_precedence'] == true ) |
|
310 | - { |
|
311 | - break; |
|
312 | - } |
|
313 | - if($row['user_role'] == -1 && $has_role == true) { |
|
314 | - break; //no need for default actions when a role is assigned to the user or user's group already |
|
315 | - } |
|
316 | - /* END - SECURITY GROUPS */ |
|
298 | + /* BEGIN - SECURITY GROUPS */ |
|
299 | + if($has_user_role == false && $row['user_role'] == 1) { |
|
300 | + $has_user_role = true; |
|
301 | + } |
|
302 | + if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) { |
|
303 | + $has_role = true; |
|
304 | + } |
|
305 | + //if user roles should take precedence over group roles and we have a user role |
|
306 | + //break when we get to processing the group roles |
|
307 | + if($has_user_role == true && $row['user_role'] == 0 |
|
308 | + && isset($sugar_config['securitysuite_user_role_precedence']) |
|
309 | + && $sugar_config['securitysuite_user_role_precedence'] == true ) |
|
310 | + { |
|
311 | + break; |
|
312 | + } |
|
313 | + if($row['user_role'] == -1 && $has_role == true) { |
|
314 | + break; //no need for default actions when a role is assigned to the user or user's group already |
|
315 | + } |
|
316 | + /* END - SECURITY GROUPS */ |
|
317 | 317 | $acl = new ACLAction(); |
318 | 318 | $isOverride = false; |
319 | 319 | $acl->populateFromRow($row); |
@@ -326,16 +326,16 @@ discard block |
||
326 | 326 | |
327 | 327 | } |
328 | 328 | if(!isset($selected_actions[$acl->category][$acl->acltype][$acl->name]) |
329 | - || ( |
|
330 | - /* BEGIN - SECURITY GROUPS - additive security*/ |
|
331 | - ( |
|
332 | - (isset($sugar_config['securitysuite_additive']) && $sugar_config['securitysuite_additive'] == true |
|
333 | - && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] < $acl->aclaccess) |
|
334 | - || |
|
335 | - ((!isset($sugar_config['securitysuite_additive']) || $sugar_config['securitysuite_additive'] == false) |
|
336 | - && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] > $acl->aclaccess) |
|
337 | - ) |
|
338 | - /* END - SECURITY GROUPS */ |
|
329 | + || ( |
|
330 | + /* BEGIN - SECURITY GROUPS - additive security*/ |
|
331 | + ( |
|
332 | + (isset($sugar_config['securitysuite_additive']) && $sugar_config['securitysuite_additive'] == true |
|
333 | + && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] < $acl->aclaccess) |
|
334 | + || |
|
335 | + ((!isset($sugar_config['securitysuite_additive']) || $sugar_config['securitysuite_additive'] == false) |
|
336 | + && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] > $acl->aclaccess) |
|
337 | + ) |
|
338 | + /* END - SECURITY GROUPS */ |
|
339 | 339 | && $isOverride |
340 | 340 | ) |
341 | 341 | || |
@@ -388,70 +388,70 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
391 | - * (static/ non-static)function hasAccess($is_owner= false , $access = 0) |
|
392 | - * checks if a user has access to this acl if the user is an owner it will check if owners have access |
|
393 | - * |
|
394 | - * This function may either be used statically or not. If used staticlly a user must pass in an access level not equal to zero |
|
395 | - * @param boolean $is_owner |
|
396 | - * @param int $access |
|
397 | - * @return true or false |
|
398 | - */ |
|
399 | - /* BEGIN - SECURITY GROUPS */ |
|
400 | - /** |
|
391 | + * (static/ non-static)function hasAccess($is_owner= false , $access = 0) |
|
392 | + * checks if a user has access to this acl if the user is an owner it will check if owners have access |
|
393 | + * |
|
394 | + * This function may either be used statically or not. If used staticlly a user must pass in an access level not equal to zero |
|
395 | + * @param boolean $is_owner |
|
396 | + * @param int $access |
|
397 | + * @return true or false |
|
398 | + */ |
|
399 | + /* BEGIN - SECURITY GROUPS */ |
|
400 | + /** |
|
401 | 401 | static function hasAccess($is_owner=false, $access = 0){ |
402 | - */ |
|
403 | - static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){ |
|
404 | - /** |
|
402 | + */ |
|
403 | + static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){ |
|
404 | + /** |
|
405 | 405 | if($access != 0 && $access == ACL_ALLOW_ALL || ($is_owner && $access == ACL_ALLOW_OWNER))return true; |
406 | 406 | //if this exists, then this function is not static, so check the aclaccess parameter |
407 | 407 | if(isset($this) && isset($this->aclaccess)){ |
408 | 408 | if($this->aclaccess == ACL_ALLOW_ALL || ($is_owner && $this->aclaccess == ACL_ALLOW_OWNER)) |
409 | 409 | return true; |
410 | 410 | } |
411 | - */ |
|
412 | - if($access != 0 && ($access == ACL_ALLOW_ALL |
|
413 | - || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) ) //if owner that's better than in group so count it...better way to clean this up? |
|
414 | - || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
|
415 | - )) { |
|
416 | - return true; |
|
417 | - } |
|
411 | + */ |
|
412 | + if($access != 0 && ($access == ACL_ALLOW_ALL |
|
413 | + || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) ) //if owner that's better than in group so count it...better way to clean this up? |
|
414 | + || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
|
415 | + )) { |
|
416 | + return true; |
|
417 | + } |
|
418 | 418 | if(!is_null($action) && isset($action->aclaccess)){ |
419 | - if($action->aclaccess == ACL_ALLOW_ALL |
|
420 | - || ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) |
|
421 | - || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
|
422 | - ) { |
|
423 | - return true; |
|
424 | - } |
|
425 | - } |
|
419 | + if($action->aclaccess == ACL_ALLOW_ALL |
|
420 | + || ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) |
|
421 | + || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
|
422 | + ) { |
|
423 | + return true; |
|
424 | + } |
|
425 | + } |
|
426 | 426 | return false; |
427 | 427 | } |
428 | - /* END - SECURITY GROUPS */ |
|
429 | - |
|
430 | - /* BEGIN - SECURITY GROUPS */ |
|
431 | - /** |
|
432 | - * STATIC function userNeedsSecurityGroup($user_id, $category, $action,$type='module') |
|
433 | - * checks if a user should have ownership to do an action |
|
434 | - * |
|
435 | - * @param GUID $user_id |
|
436 | - * @param STRING $category |
|
437 | - * @param STRING $action |
|
438 | - * @param STRING $type |
|
439 | - * @return boolean |
|
440 | - */ |
|
441 | - static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){ |
|
442 | - //check if we don't have it set in the cache if not lets reload the cache |
|
428 | + /* END - SECURITY GROUPS */ |
|
429 | + |
|
430 | + /* BEGIN - SECURITY GROUPS */ |
|
431 | + /** |
|
432 | + * STATIC function userNeedsSecurityGroup($user_id, $category, $action,$type='module') |
|
433 | + * checks if a user should have ownership to do an action |
|
434 | + * |
|
435 | + * @param GUID $user_id |
|
436 | + * @param STRING $category |
|
437 | + * @param STRING $action |
|
438 | + * @param STRING $type |
|
439 | + * @return boolean |
|
440 | + */ |
|
441 | + static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){ |
|
442 | + //check if we don't have it set in the cache if not lets reload the cache |
|
443 | 443 | |
444 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
445 | - ACLAction::getUserActions($user_id, false); |
|
444 | + if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
445 | + ACLAction::getUserActions($user_id, false); |
|
446 | 446 | |
447 | - } |
|
447 | + } |
|
448 | 448 | |
449 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
450 | - return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP; |
|
451 | - } |
|
449 | + if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
450 | + return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP; |
|
451 | + } |
|
452 | 452 | return false; |
453 | 453 | } |
454 | - /* END - SECURITY GROUPS */ |
|
454 | + /* END - SECURITY GROUPS */ |
|
455 | 455 | |
456 | 456 | |
457 | 457 | |
@@ -461,20 +461,20 @@ discard block |
||
461 | 461 | |
462 | 462 | |
463 | 463 | /** |
464 | - * static function userHasAccess($user_id, $category, $action, $is_owner = false) |
|
465 | - * |
|
466 | - * @param GUID $user_id the user id who you want to check access for |
|
467 | - * @param STRING $category the category you would like to check access for |
|
468 | - * @param STRING $action the action of that category you would like to check access for |
|
469 | - * @param BOOLEAN OPTIONAL $is_owner if the object is owned by the user you are checking access for |
|
470 | - */ |
|
471 | - /* BEGIN - SECURITY GROUPS - added $in_group */ |
|
472 | - /** |
|
464 | + * static function userHasAccess($user_id, $category, $action, $is_owner = false) |
|
465 | + * |
|
466 | + * @param GUID $user_id the user id who you want to check access for |
|
467 | + * @param STRING $category the category you would like to check access for |
|
468 | + * @param STRING $action the action of that category you would like to check access for |
|
469 | + * @param BOOLEAN OPTIONAL $is_owner if the object is owned by the user you are checking access for |
|
470 | + */ |
|
471 | + /* BEGIN - SECURITY GROUPS - added $in_group */ |
|
472 | + /** |
|
473 | 473 | public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false){ |
474 | - */ |
|
475 | - public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){ |
|
476 | - global $current_user; |
|
477 | - if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){ |
|
474 | + */ |
|
475 | + public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){ |
|
476 | + global $current_user; |
|
477 | + if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){ |
|
478 | 478 | return true; |
479 | 479 | } |
480 | 480 | //check if we don't have it set in the cache if not lets reload the cache |
@@ -488,22 +488,22 @@ discard block |
||
488 | 488 | /** |
489 | 489 | return ACLAction::hasAccess($is_owner, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
490 | 490 | */ |
491 | - return ACLAction::hasAccess($is_owner, $in_group, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
|
491 | + return ACLAction::hasAccess($is_owner, $in_group, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
|
492 | 492 | } |
493 | 493 | return false; |
494 | 494 | |
495 | 495 | } |
496 | - /* END - SECURITY GROUPS */ |
|
496 | + /* END - SECURITY GROUPS */ |
|
497 | 497 | /** |
498 | - * function getUserAccessLevel($user_id, $category, $action,$type='module') |
|
499 | - * returns the access level for a given category and action |
|
500 | - * |
|
501 | - * @param GUID $user_id |
|
502 | - * @param STRING $category |
|
503 | - * @param STRING $action |
|
504 | - * @param STRING $type |
|
505 | - * @return INT (ACCESS LEVEL) |
|
506 | - */ |
|
498 | + * function getUserAccessLevel($user_id, $category, $action,$type='module') |
|
499 | + * returns the access level for a given category and action |
|
500 | + * |
|
501 | + * @param GUID $user_id |
|
502 | + * @param STRING $category |
|
503 | + * @param STRING $action |
|
504 | + * @param STRING $type |
|
505 | + * @return INT (ACCESS LEVEL) |
|
506 | + */ |
|
507 | 507 | public static function getUserAccessLevel($user_id, $category, $action,$type='module'){ |
508 | 508 | if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
509 | 509 | ACLAction::getUserActions($user_id, false); |
@@ -520,15 +520,15 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
523 | - * STATIC function userNeedsOwnership($user_id, $category, $action,$type='module') |
|
524 | - * checks if a user should have ownership to do an action |
|
525 | - * |
|
526 | - * @param GUID $user_id |
|
527 | - * @param STRING $category |
|
528 | - * @param STRING $action |
|
529 | - * @param STRING $type |
|
530 | - * @return boolean |
|
531 | - */ |
|
523 | + * STATIC function userNeedsOwnership($user_id, $category, $action,$type='module') |
|
524 | + * checks if a user should have ownership to do an action |
|
525 | + * |
|
526 | + * @param GUID $user_id |
|
527 | + * @param STRING $category |
|
528 | + * @param STRING $action |
|
529 | + * @param STRING $type |
|
530 | + * @return boolean |
|
531 | + */ |
|
532 | 532 | public static function userNeedsOwnership($user_id, $category, $action,$type='module'){ |
533 | 533 | //check if we don't have it set in the cache if not lets reload the cache |
534 | 534 | |
@@ -545,12 +545,12 @@ discard block |
||
545 | 545 | |
546 | 546 | } |
547 | 547 | /** |
548 | - * |
|
549 | - * static pass by ref setupCategoriesMatrix(&$categories) |
|
550 | - * takes in an array of categories and modifes them adding display information |
|
551 | - * |
|
552 | - * @param unknown_type $categories |
|
553 | - */ |
|
548 | + * |
|
549 | + * static pass by ref setupCategoriesMatrix(&$categories) |
|
550 | + * takes in an array of categories and modifes them adding display information |
|
551 | + * |
|
552 | + * @param unknown_type $categories |
|
553 | + */ |
|
554 | 554 | public static function setupCategoriesMatrix(&$categories){ |
555 | 555 | global $ACLActions, $current_user; |
556 | 556 | $names = array(); |
@@ -593,11 +593,11 @@ discard block |
||
593 | 593 | |
594 | 594 | |
595 | 595 | /** |
596 | - * function toArray() |
|
597 | - * returns this acl as an array |
|
598 | - * |
|
599 | - * @return array of fields with id, name, access and category |
|
600 | - */ |
|
596 | + * function toArray() |
|
597 | + * returns this acl as an array |
|
598 | + * |
|
599 | + * @return array of fields with id, name, access and category |
|
600 | + */ |
|
601 | 601 | function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false){ |
602 | 602 | $array_fields = array('id', 'aclaccess'); |
603 | 603 | $arr = array(); |
@@ -608,11 +608,11 @@ discard block |
||
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
611 | - * function fromArray($arr) |
|
612 | - * converts an array into an acl mapping name value pairs into files |
|
613 | - * |
|
614 | - * @param Array $arr |
|
615 | - */ |
|
611 | + * function fromArray($arr) |
|
612 | + * converts an array into an acl mapping name value pairs into files |
|
613 | + * |
|
614 | + * @param Array $arr |
|
615 | + */ |
|
616 | 616 | function fromArray($arr){ |
617 | 617 | foreach($arr as $name=>$value){ |
618 | 618 | $this->$name = $value; |
@@ -620,10 +620,10 @@ discard block |
||
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
623 | - * function clearSessionCache() |
|
624 | - * clears the session variable storing the cache information for acls |
|
625 | - * |
|
626 | - */ |
|
623 | + * function clearSessionCache() |
|
624 | + * clears the session variable storing the cache information for acls |
|
625 | + * |
|
626 | + */ |
|
627 | 627 | function clearSessionCache(){ |
628 | 628 | unset($_SESSION['ACL']); |
629 | 629 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
39 | 39 | ********************************************************************************/ |
40 | 40 | /* BEGIN - SECURITY GROUPS */ |
41 | -if(file_exists("modules/ACLActions/actiondefs.override.php")){ |
|
41 | +if (file_exists("modules/ACLActions/actiondefs.override.php")) { |
|
42 | 42 | require_once("modules/ACLActions/actiondefs.override.php"); |
43 | 43 | } else { |
44 | 44 | require_once('modules/ACLActions/actiondefs.php'); |
45 | 45 | } |
46 | 46 | /* END - SECURITY GROUPS */ |
47 | -class ACLAction extends SugarBean{ |
|
47 | +class ACLAction extends SugarBean { |
|
48 | 48 | var $module_dir = 'ACLActions'; |
49 | 49 | var $object_name = 'ACLAction'; |
50 | 50 | var $table_name = 'acl_actions'; |
51 | 51 | var $new_schema = true; |
52 | 52 | var $disable_custom_fields = true; |
53 | - function ACLAction(){ |
|
53 | + function ACLAction() { |
|
54 | 54 | parent::SugarBean(); |
55 | 55 | } |
56 | 56 | |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
62 | 62 | * @param STRING $type - the type (e.g. 'module', 'field') |
63 | 63 | */ |
64 | - static function addActions($category, $type='module'){ |
|
64 | + static function addActions($category, $type = 'module') { |
|
65 | 65 | global $ACLActions; |
66 | 66 | $db = DBManagerFactory::getInstance(); |
67 | - if(isset($ACLActions[$type])){ |
|
68 | - foreach($ACLActions[$type]['actions'] as $action_name =>$action_def){ |
|
67 | + if (isset($ACLActions[$type])) { |
|
68 | + foreach ($ACLActions[$type]['actions'] as $action_name =>$action_def) { |
|
69 | 69 | |
70 | 70 | $action = new ACLAction(); |
71 | - $query = "SELECT * FROM " . $action->table_name . " WHERE name='$action_name' AND category = '$category' AND acltype='$type' AND deleted=0 "; |
|
71 | + $query = "SELECT * FROM ".$action->table_name." WHERE name='$action_name' AND category = '$category' AND acltype='$type' AND deleted=0 "; |
|
72 | 72 | $result = $db->query($query); |
73 | 73 | //only add if an action with that name and category don't exist |
74 | - $row=$db->fetchByAssoc($result); |
|
74 | + $row = $db->fetchByAssoc($result); |
|
75 | 75 | if ($row == null) { |
76 | 76 | $action->name = $action_name; |
77 | 77 | $action->category = $category; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - }else{ |
|
87 | + } else { |
|
88 | 88 | sugar_die("FAILED TO ADD: $category - TYPE $type NOT DEFINED IN modules/ACLActions/actiondefs.php"); |
89 | 89 | } |
90 | 90 | |
@@ -97,22 +97,22 @@ discard block |
||
97 | 97 | * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
98 | 98 | * @param STRING $type - the type (e.g. 'module', 'field') |
99 | 99 | */ |
100 | - public static function removeActions($category, $type='module'){ |
|
100 | + public static function removeActions($category, $type = 'module') { |
|
101 | 101 | global $ACLActions; |
102 | 102 | $db = DBManagerFactory::getInstance(); |
103 | - if(isset($ACLActions[$type])){ |
|
104 | - foreach($ACLActions[$type]['actions'] as $action_name =>$action_def){ |
|
103 | + if (isset($ACLActions[$type])) { |
|
104 | + foreach ($ACLActions[$type]['actions'] as $action_name =>$action_def) { |
|
105 | 105 | |
106 | 106 | $action = new ACLAction(); |
107 | - $query = "SELECT * FROM " . $action->table_name . " WHERE name='$action_name' AND category = '$category' AND acltype='$type' and deleted=0"; |
|
107 | + $query = "SELECT * FROM ".$action->table_name." WHERE name='$action_name' AND category = '$category' AND acltype='$type' and deleted=0"; |
|
108 | 108 | $result = $db->query($query); |
109 | 109 | //only add if an action with that name and category don't exist |
110 | - $row=$db->fetchByAssoc($result); |
|
110 | + $row = $db->fetchByAssoc($result); |
|
111 | 111 | if ($row != null) { |
112 | 112 | $action->mark_deleted($row['id']); |
113 | 113 | } |
114 | 114 | } |
115 | - }else{ |
|
115 | + } else { |
|
116 | 116 | sugar_die("FAILED TO REMOVE: $category : $name - TYPE $type NOT DEFINED IN modules/ACLActions/actiondefs.php"); |
117 | 117 | } |
118 | 118 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @param INT $access - the access level you want the color for |
126 | 126 | * @return the color either name or hex representation or false if the level does not exist |
127 | 127 | */ |
128 | - protected static function AccessColor($access){ |
|
128 | + protected static function AccessColor($access) { |
|
129 | 129 | global $ACLActionAccessLevels; |
130 | - if(isset($ACLActionAccessLevels[$access])){ |
|
130 | + if (isset($ACLActionAccessLevels[$access])) { |
|
131 | 131 | |
132 | 132 | return $ACLActionAccessLevels[$access]['color']; |
133 | 133 | } |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | * @param INT $access - the access level you want the color for |
144 | 144 | * @return the translated access level name or false if the level does not exist |
145 | 145 | */ |
146 | - static function AccessName($access){ |
|
146 | + static function AccessName($access) { |
|
147 | 147 | global $ACLActionAccessLevels; |
148 | - if(isset($ACLActionAccessLevels[$access])){ |
|
148 | + if (isset($ACLActionAccessLevels[$access])) { |
|
149 | 149 | return translate($ACLActionAccessLevels[$access]['label'], 'ACLActions'); |
150 | 150 | } |
151 | 151 | return false; |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | * @param INT $access - the access level you want the color for |
161 | 161 | * @return the access level label or false if the level does not exist |
162 | 162 | */ |
163 | - protected static function AccessLabel($access){ |
|
163 | + protected static function AccessLabel($access) { |
|
164 | 164 | global $ACLActionAccessLevels; |
165 | - if(isset($ACLActionAccessLevels[$access])){ |
|
166 | - $label=preg_replace('/(LBL_ACCESS_)(.*)/', '$2', $ACLActionAccessLevels[$access]['label']); |
|
165 | + if (isset($ACLActionAccessLevels[$access])) { |
|
166 | + $label = preg_replace('/(LBL_ACCESS_)(.*)/', '$2', $ACLActionAccessLevels[$access]['label']); |
|
167 | 167 | return strtolower($label); |
168 | 168 | |
169 | 169 | } |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | * this is used for building select boxes |
177 | 177 | * @return array containg access levels (ints) as keys and access names as values |
178 | 178 | */ |
179 | - protected static function getAccessOptions( $action, $type='module'){ |
|
179 | + protected static function getAccessOptions($action, $type = 'module') { |
|
180 | 180 | global $ACLActions; |
181 | 181 | $options = array(); |
182 | 182 | |
183 | - if(empty($ACLActions[$type]['actions'][$action]['aclaccess']))return $options; |
|
184 | - foreach($ACLActions[$type]['actions'][$action]['aclaccess'] as $action){ |
|
183 | + if (empty($ACLActions[$type]['actions'][$action]['aclaccess']))return $options; |
|
184 | + foreach ($ACLActions[$type]['actions'][$action]['aclaccess'] as $action) { |
|
185 | 185 | $options[$action] = ACLAction::AccessName($action); |
186 | 186 | } |
187 | 187 | return $options; |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | * |
195 | 195 | * |
196 | 196 | */ |
197 | - public static function getDefaultActions($type='module', $action=''){ |
|
197 | + public static function getDefaultActions($type = 'module', $action = '') { |
|
198 | 198 | $query = "SELECT * FROM acl_actions WHERE deleted=0 "; |
199 | - if(!empty($type)){ |
|
199 | + if (!empty($type)) { |
|
200 | 200 | $query .= " AND acltype='$type'"; |
201 | 201 | } |
202 | - if(!empty($action)){ |
|
202 | + if (!empty($action)) { |
|
203 | 203 | $query .= "AND name='$action'"; |
204 | 204 | } |
205 | 205 | $query .= " ORDER BY category"; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $db = DBManagerFactory::getInstance(); |
208 | 208 | $result = $db->query($query); |
209 | 209 | $default_actions = array(); |
210 | - while($row = $db->fetchByAssoc($result) ){ |
|
210 | + while ($row = $db->fetchByAssoc($result)) { |
|
211 | 211 | $acl = new ACLAction(); |
212 | 212 | $acl->populateFromRow($row); |
213 | 213 | $default_actions[] = $acl; |
@@ -226,19 +226,19 @@ discard block |
||
226 | 226 | * @return ARRAY of ACLActionsArray |
227 | 227 | */ |
228 | 228 | |
229 | - static function getUserActions($user_id,$refresh=false, $category='',$type='', $action=''){ |
|
229 | + static function getUserActions($user_id, $refresh = false, $category = '', $type = '', $action = '') { |
|
230 | 230 | //check in the session if we already have it loaded |
231 | - if(!$refresh && !empty($_SESSION['ACL'][$user_id])){ |
|
232 | - if(empty($category) && empty($action)){ |
|
231 | + if (!$refresh && !empty($_SESSION['ACL'][$user_id])) { |
|
232 | + if (empty($category) && empty($action)) { |
|
233 | 233 | return $_SESSION['ACL'][$user_id]; |
234 | - }else{ |
|
235 | - if(!empty($category) && isset($_SESSION['ACL'][$user_id][$category])){ |
|
236 | - if(empty($action)){ |
|
237 | - if(empty($type)){ |
|
234 | + } else { |
|
235 | + if (!empty($category) && isset($_SESSION['ACL'][$user_id][$category])) { |
|
236 | + if (empty($action)) { |
|
237 | + if (empty($type)) { |
|
238 | 238 | return $_SESSION['ACL'][$user_id][$category]; |
239 | 239 | } |
240 | 240 | return $_SESSION['ACL'][$user_id][$category][$type]; |
241 | - }else if(!empty($type) && isset($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
241 | + } else if (!empty($type) && isset($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
242 | 242 | return $_SESSION['ACL'][$user_id][$category][$type][$action]; |
243 | 243 | } |
244 | 244 | } |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | //if we don't have it loaded then lets check against the db |
248 | 248 | $additional_where = ''; |
249 | 249 | $db = DBManagerFactory::getInstance(); |
250 | - if(!empty($category)){ |
|
250 | + if (!empty($category)) { |
|
251 | 251 | $additional_where .= " AND acl_actions.category = '$category' "; |
252 | 252 | } |
253 | - if(!empty($action)){ |
|
253 | + if (!empty($action)) { |
|
254 | 254 | $additional_where .= " AND acl_actions.name = '$action' "; |
255 | 255 | } |
256 | - if(!empty($type)){ |
|
256 | + if (!empty($type)) { |
|
257 | 257 | $additional_where .= " AND acl_actions.acltype = '$type' "; |
258 | 258 | } |
259 | 259 | /* BEGIN - SECURITY GROUPS */ |
@@ -294,38 +294,38 @@ discard block |
||
294 | 294 | $has_user_role = false; //used for user_role_precedence |
295 | 295 | $has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults |
296 | 296 | /* END - SECURITY GROUPS */ |
297 | - while($row = $db->fetchByAssoc($result, FALSE) ){ |
|
297 | + while ($row = $db->fetchByAssoc($result, FALSE)) { |
|
298 | 298 | /* BEGIN - SECURITY GROUPS */ |
299 | - if($has_user_role == false && $row['user_role'] == 1) { |
|
299 | + if ($has_user_role == false && $row['user_role'] == 1) { |
|
300 | 300 | $has_user_role = true; |
301 | 301 | } |
302 | - if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) { |
|
302 | + if ($has_role == false && ($row['user_role'] == 1 || $row['user_role'] == 0)) { |
|
303 | 303 | $has_role = true; |
304 | 304 | } |
305 | 305 | //if user roles should take precedence over group roles and we have a user role |
306 | 306 | //break when we get to processing the group roles |
307 | - if($has_user_role == true && $row['user_role'] == 0 |
|
307 | + if ($has_user_role == true && $row['user_role'] == 0 |
|
308 | 308 | && isset($sugar_config['securitysuite_user_role_precedence']) |
309 | - && $sugar_config['securitysuite_user_role_precedence'] == true ) |
|
309 | + && $sugar_config['securitysuite_user_role_precedence'] == true) |
|
310 | 310 | { |
311 | 311 | break; |
312 | 312 | } |
313 | - if($row['user_role'] == -1 && $has_role == true) { |
|
313 | + if ($row['user_role'] == -1 && $has_role == true) { |
|
314 | 314 | break; //no need for default actions when a role is assigned to the user or user's group already |
315 | 315 | } |
316 | 316 | /* END - SECURITY GROUPS */ |
317 | 317 | $acl = new ACLAction(); |
318 | - $isOverride = false; |
|
318 | + $isOverride = false; |
|
319 | 319 | $acl->populateFromRow($row); |
320 | - if(!empty($row['access_override'])){ |
|
320 | + if (!empty($row['access_override'])) { |
|
321 | 321 | $acl->aclaccess = $row['access_override']; |
322 | 322 | $isOverride = true; |
323 | 323 | } |
324 | - if(!isset($selected_actions[$acl->category])){ |
|
324 | + if (!isset($selected_actions[$acl->category])) { |
|
325 | 325 | $selected_actions[$acl->category] = array(); |
326 | 326 | |
327 | 327 | } |
328 | - if(!isset($selected_actions[$acl->category][$acl->acltype][$acl->name]) |
|
328 | + if (!isset($selected_actions[$acl->category][$acl->acltype][$acl->name]) |
|
329 | 329 | || ( |
330 | 330 | /* BEGIN - SECURITY GROUPS - additive security*/ |
331 | 331 | ( |
@@ -353,18 +353,18 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | //only set the session variable if it was a full list; |
356 | - if(empty($category) && empty($action)){ |
|
357 | - if(!isset($_SESSION['ACL'])){ |
|
356 | + if (empty($category) && empty($action)) { |
|
357 | + if (!isset($_SESSION['ACL'])) { |
|
358 | 358 | $_SESSION['ACL'] = array(); |
359 | 359 | } |
360 | 360 | $_SESSION['ACL'][$user_id] = $selected_actions; |
361 | - }else{ |
|
362 | - if(empty($action) && !empty($category)){ |
|
363 | - if(!empty($type)){ |
|
364 | - $_SESSION['ACL'][$user_id][$category][$type] = $selected_actions[$category][$type];} |
|
361 | + } else { |
|
362 | + if (empty($action) && !empty($category)) { |
|
363 | + if (!empty($type)) { |
|
364 | + $_SESSION['ACL'][$user_id][$category][$type] = $selected_actions[$category][$type]; } |
|
365 | 365 | $_SESSION['ACL'][$user_id][$category] = $selected_actions[$category]; |
366 | - }else{ |
|
367 | - if(!empty($action) && !empty($category) && !empty($type)){ |
|
366 | + } else { |
|
367 | + if (!empty($action) && !empty($category) && !empty($type)) { |
|
368 | 368 | $_SESSION['ACL'][$user_id][$category][$type][$action] = $selected_actions[$category][$action]; |
369 | 369 | |
370 | 370 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | /** |
401 | 401 | static function hasAccess($is_owner=false, $access = 0){ |
402 | 402 | */ |
403 | - static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){ |
|
403 | + static function hasAccess($is_owner = false, $in_group = false, $access = 0, ACLAction $action = null) { |
|
404 | 404 | /** |
405 | 405 | if($access != 0 && $access == ACL_ALLOW_ALL || ($is_owner && $access == ACL_ALLOW_OWNER))return true; |
406 | 406 | //if this exists, then this function is not static, so check the aclaccess parameter |
@@ -409,14 +409,14 @@ discard block |
||
409 | 409 | return true; |
410 | 410 | } |
411 | 411 | */ |
412 | - if($access != 0 && ($access == ACL_ALLOW_ALL |
|
413 | - || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) ) //if owner that's better than in group so count it...better way to clean this up? |
|
412 | + if ($access != 0 && ($access == ACL_ALLOW_ALL |
|
413 | + || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) //if owner that's better than in group so count it...better way to clean this up? |
|
414 | 414 | || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
415 | 415 | )) { |
416 | 416 | return true; |
417 | 417 | } |
418 | - if(!is_null($action) && isset($action->aclaccess)){ |
|
419 | - if($action->aclaccess == ACL_ALLOW_ALL |
|
418 | + if (!is_null($action) && isset($action->aclaccess)) { |
|
419 | + if ($action->aclaccess == ACL_ALLOW_ALL |
|
420 | 420 | || ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) |
421 | 421 | || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
422 | 422 | ) { |
@@ -438,15 +438,15 @@ discard block |
||
438 | 438 | * @param STRING $type |
439 | 439 | * @return boolean |
440 | 440 | */ |
441 | - static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){ |
|
441 | + static function userNeedsSecurityGroup($user_id, $category, $action, $type = 'module') { |
|
442 | 442 | //check if we don't have it set in the cache if not lets reload the cache |
443 | 443 | |
444 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
444 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
445 | 445 | ACLAction::getUserActions($user_id, false); |
446 | 446 | |
447 | 447 | } |
448 | 448 | |
449 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
449 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
450 | 450 | return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP; |
451 | 451 | } |
452 | 452 | return false; |
@@ -472,19 +472,19 @@ discard block |
||
472 | 472 | /** |
473 | 473 | public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false){ |
474 | 474 | */ |
475 | - public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){ |
|
475 | + public static function userHasAccess($user_id, $category, $action, $type = 'module', $is_owner = false, $in_group = false) { |
|
476 | 476 | global $current_user; |
477 | - if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){ |
|
477 | + if ($current_user->isAdminForModule($category) && !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])) { |
|
478 | 478 | return true; |
479 | 479 | } |
480 | 480 | //check if we don't have it set in the cache if not lets reload the cache |
481 | - if(ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) return false; |
|
482 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
481 | + if (ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) return false; |
|
482 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
483 | 483 | ACLAction::getUserActions($user_id, false); |
484 | 484 | |
485 | 485 | } |
486 | 486 | |
487 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
487 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
488 | 488 | /** |
489 | 489 | return ACLAction::hasAccess($is_owner, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
490 | 490 | */ |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | * @param STRING $type |
505 | 505 | * @return INT (ACCESS LEVEL) |
506 | 506 | */ |
507 | - public static function getUserAccessLevel($user_id, $category, $action,$type='module'){ |
|
508 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
507 | + public static function getUserAccessLevel($user_id, $category, $action, $type = 'module') { |
|
508 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
509 | 509 | ACLAction::getUserActions($user_id, false); |
510 | 510 | |
511 | 511 | } |
512 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
512 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
513 | 513 | if (!empty($_SESSION['ACL'][$user_id][$category][$type]['admin']) && $_SESSION['ACL'][$user_id][$category][$type]['admin']['aclaccess'] >= ACL_ALLOW_ADMIN) |
514 | 514 | { |
515 | 515 | // If you have admin access for a module, all ACL's are allowed |
@@ -529,16 +529,16 @@ discard block |
||
529 | 529 | * @param STRING $type |
530 | 530 | * @return boolean |
531 | 531 | */ |
532 | - public static function userNeedsOwnership($user_id, $category, $action,$type='module'){ |
|
532 | + public static function userNeedsOwnership($user_id, $category, $action, $type = 'module') { |
|
533 | 533 | //check if we don't have it set in the cache if not lets reload the cache |
534 | 534 | |
535 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
535 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
536 | 536 | ACLAction::getUserActions($user_id, false); |
537 | 537 | |
538 | 538 | } |
539 | 539 | |
540 | 540 | |
541 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
541 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
542 | 542 | return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_OWNER; |
543 | 543 | } |
544 | 544 | return false; |
@@ -551,18 +551,18 @@ discard block |
||
551 | 551 | * |
552 | 552 | * @param unknown_type $categories |
553 | 553 | */ |
554 | - public static function setupCategoriesMatrix(&$categories){ |
|
554 | + public static function setupCategoriesMatrix(&$categories) { |
|
555 | 555 | global $ACLActions, $current_user; |
556 | 556 | $names = array(); |
557 | 557 | $disabled = array(); |
558 | - foreach($categories as $cat_name=>$category){ |
|
559 | - foreach($category as $type_name=>$type){ |
|
560 | - foreach($type as $act_name=>$action){ |
|
558 | + foreach ($categories as $cat_name=>$category) { |
|
559 | + foreach ($category as $type_name=>$type) { |
|
560 | + foreach ($type as $act_name=>$action) { |
|
561 | 561 | $names[$act_name] = translate($ACLActions[$type_name]['actions'][$act_name]['label'], 'ACLActions'); |
562 | 562 | $categories[$cat_name][$type_name][$act_name]['accessColor'] = ACLAction::AccessColor($action['aclaccess']); |
563 | - if($type_name== 'module'){ |
|
563 | + if ($type_name == 'module') { |
|
564 | 564 | |
565 | - if($act_name != 'aclaccess' && $categories[$cat_name]['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED){ |
|
565 | + if ($act_name != 'aclaccess' && $categories[$cat_name]['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED) { |
|
566 | 566 | $categories[$cat_name][$type_name][$act_name]['accessColor'] = 'darkgray'; |
567 | 567 | $disabled[] = $cat_name; |
568 | 568 | } |
@@ -571,19 +571,19 @@ discard block |
||
571 | 571 | $categories[$cat_name][$type_name][$act_name]['accessName'] = ACLAction::AccessName($action['aclaccess']); |
572 | 572 | $categories[$cat_name][$type_name][$act_name]['accessLabel'] = ACLAction::AccessLabel($action['aclaccess']); |
573 | 573 | |
574 | - if($cat_name=='Users'&& $act_name=='admin'){ |
|
575 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEFAULT]=ACLAction::AccessName(ACL_ALLOW_DEFAULT);; |
|
576 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEV]=ACLAction::AccessName(ACL_ALLOW_DEV);; |
|
574 | + if ($cat_name == 'Users' && $act_name == 'admin') { |
|
575 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEFAULT] = ACLAction::AccessName(ACL_ALLOW_DEFAULT); ; |
|
576 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEV] = ACLAction::AccessName(ACL_ALLOW_DEV); ; |
|
577 | 577 | } |
578 | - else{ |
|
579 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'] = ACLAction::getAccessOptions($act_name, $type_name); |
|
578 | + else { |
|
579 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'] = ACLAction::getAccessOptions($act_name, $type_name); |
|
580 | 580 | } |
581 | 581 | } |
582 | 582 | } |
583 | 583 | } |
584 | 584 | |
585 | - if(!is_admin($current_user)){ |
|
586 | - foreach($disabled as $cat_name){ |
|
585 | + if (!is_admin($current_user)) { |
|
586 | + foreach ($disabled as $cat_name) { |
|
587 | 587 | unset($categories[$cat_name]); |
588 | 588 | } |
589 | 589 | } |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | * |
599 | 599 | * @return array of fields with id, name, access and category |
600 | 600 | */ |
601 | - function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false){ |
|
601 | + function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false) { |
|
602 | 602 | $array_fields = array('id', 'aclaccess'); |
603 | 603 | $arr = array(); |
604 | - foreach($array_fields as $field){ |
|
604 | + foreach ($array_fields as $field) { |
|
605 | 605 | $arr[$field] = $this->$field; |
606 | 606 | } |
607 | 607 | return $arr; |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | * |
614 | 614 | * @param Array $arr |
615 | 615 | */ |
616 | - function fromArray($arr){ |
|
617 | - foreach($arr as $name=>$value){ |
|
616 | + function fromArray($arr) { |
|
617 | + foreach ($arr as $name=>$value) { |
|
618 | 618 | $this->$name = $value; |
619 | 619 | } |
620 | 620 | } |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * clears the session variable storing the cache information for acls |
625 | 625 | * |
626 | 626 | */ |
627 | - function clearSessionCache(){ |
|
627 | + function clearSessionCache() { |
|
628 | 628 | unset($_SESSION['ACL']); |
629 | 629 | } |
630 | 630 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @author SalesAgility <[email protected]> |
23 | 23 | */ |
24 | 24 | |
25 | -function display_lines($focus, $field, $value, $view){ |
|
25 | +function display_lines($focus, $field, $value, $view) { |
|
26 | 26 | |
27 | 27 | global $sugar_config, $locale, $app_list_strings, $mod_strings; |
28 | 28 | |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | |
32 | 32 | $html = ''; |
33 | 33 | |
34 | - if($view == 'EditView'){ |
|
34 | + if ($view == 'EditView') { |
|
35 | 35 | |
36 | 36 | $html .= '<script src="modules/AOS_Products_Quotes/line_items.js"></script>'; |
37 | - if(file_exists('custom/modules/AOS_Products_Quotes/line_items.js')){ |
|
37 | + if (file_exists('custom/modules/AOS_Products_Quotes/line_items.js')) { |
|
38 | 38 | $html .= '<script src="custom/modules/AOS_Products_Quotes/line_items.js"></script>'; |
39 | 39 | } |
40 | 40 | $html .= '<script language="javascript">var sig_digits = '.$locale->getPrecision().';'; |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | |
46 | 46 | $html .= "<table border='0' cellspacing='4' width='37.5%' id='lineItems'></table>"; |
47 | 47 | |
48 | - if($enable_groups){ |
|
48 | + if ($enable_groups) { |
|
49 | 49 | $html .= "<div style='padding-top: 10px; padding-bottom:10px;'>"; |
50 | 50 | $html .= "<input type=\"button\" tabindex=\"116\" class=\"button\" value=\"".$mod_strings['LBL_ADD_GROUP']."\" id=\"addGroup\" onclick=\"insertGroup(0)\" />"; |
51 | 51 | $html .= "</div>"; |
52 | 52 | } |
53 | 53 | $html .= '<input type="hidden" name="vathidden" id="vathidden" value="'.get_select_options_with_id($app_list_strings['vat_list'], '').'"> |
54 | 54 | <input type="hidden" name="discounthidden" id="discounthidden" value="'.get_select_options_with_id($app_list_strings['discount_list'], '').'">'; |
55 | - if($focus->id != '') { |
|
55 | + if ($focus->id != '') { |
|
56 | 56 | require_once('modules/AOS_Products_Quotes/AOS_Products_Quotes.php'); |
57 | 57 | require_once('modules/AOS_Line_Item_Groups/AOS_Line_Item_Groups.php'); |
58 | 58 | |
59 | - $sql = "SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = '" . $focus->object_name . "' AND pg.parent_id = '" . $focus->id . "' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC"; |
|
59 | + $sql = "SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = '".$focus->object_name."' AND pg.parent_id = '".$focus->id."' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC"; |
|
60 | 60 | |
61 | 61 | $result = $focus->db->query($sql); |
62 | 62 | $html .= "<script> |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | $group_item = json_encode($group_item->toArray()); |
76 | 76 | } |
77 | 77 | $html .= "<script> |
78 | - insertLineItems(" . $line_item . "," . $group_item . "); |
|
78 | + insertLineItems(" . $line_item.",".$group_item."); |
|
79 | 79 | </script>"; |
80 | 80 | |
81 | 81 | } |
82 | 82 | } |
83 | - if(!$enable_groups){ |
|
83 | + if (!$enable_groups) { |
|
84 | 84 | $html .= '<script>insertGroup();</script>'; |
85 | 85 | } |
86 | 86 | |
87 | 87 | } |
88 | - else if($view == 'DetailView'){ |
|
88 | + else if ($view == 'DetailView') { |
|
89 | 89 | $params = array('currency_id' => $focus->currency_id); |
90 | 90 | |
91 | 91 | $sql = "SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = '".$focus->object_name."' AND pg.parent_id = '".$focus->id."' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC"; |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | $line_item->retrieve($row['id']); |
110 | 110 | |
111 | 111 | |
112 | - if($enable_groups && ($group_id != $row['group_id'] || $i == 0)){ |
|
112 | + if ($enable_groups && ($group_id != $row['group_id'] || $i == 0)) { |
|
113 | 113 | $html .= $groupStart.$product.$service.$groupEnd; |
114 | - if($i != 0)$html .= "<tr><td colspan='9' nowrap='nowrap'><br></td></tr>"; |
|
114 | + if ($i != 0)$html .= "<tr><td colspan='9' nowrap='nowrap'><br></td></tr>"; |
|
115 | 115 | $groupStart = ''; |
116 | 116 | $groupEnd = ''; |
117 | 117 | $product = ''; |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | $groupEnd .= "<td class='tabDetailViewDL' style='text-align: right;padding:2px;'>".currency_format_number($group_item->total_amount, $params)."</td>"; |
153 | 153 | $groupEnd .= "</tr>"; |
154 | 154 | } |
155 | - if($line_item->product_id != '0' && $line_item->product_id != null){ |
|
156 | - if($productCount == 0) |
|
155 | + if ($line_item->product_id != '0' && $line_item->product_id != null) { |
|
156 | + if ($productCount == 0) |
|
157 | 157 | { |
158 | 158 | $product .= "<tr>"; |
159 | 159 | $product .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'> </td>"; |
@@ -169,26 +169,26 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | $product .= "<tr>"; |
172 | - $product_note = wordwrap($line_item->description,40,"<br />\n"); |
|
172 | + $product_note = wordwrap($line_item->description, 40, "<br />\n"); |
|
173 | 173 | $product .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>".++$productCount."</td>"; |
174 | - $product .= "<td class='tabDetailViewDF' style='padding:2px;'>".stripDecimalPointsAndTrailingZeroes(format_number($line_item->product_qty),$sep[1])."</td>"; |
|
174 | + $product .= "<td class='tabDetailViewDF' style='padding:2px;'>".stripDecimalPointsAndTrailingZeroes(format_number($line_item->product_qty), $sep[1])."</td>"; |
|
175 | 175 | |
176 | 176 | $product .= "<td class='tabDetailViewDF' style='padding:2px;'><a href='index.php?module=AOS_Products&action=DetailView&record=".$line_item->product_id."' class='tabDetailViewDFLink'>".$line_item->name."</a><br />".$product_note."</td>"; |
177 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_list_price,$params)."</td>"; |
|
177 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_list_price, $params)."</td>"; |
|
178 | 178 | |
179 | 179 | $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".get_discount_string($line_item->discount, $line_item->product_discount, $params, $locale, $sep)."</td>"; |
180 | 180 | |
181 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_unit_price,$params )."</td>"; |
|
182 | - if($locale->getPrecision()){ |
|
183 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".rtrim(rtrim(format_number($line_item->vat), '0'),$sep[1])."%</td>"; |
|
181 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_unit_price, $params)."</td>"; |
|
182 | + if ($locale->getPrecision()) { |
|
183 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".rtrim(rtrim(format_number($line_item->vat), '0'), $sep[1])."%</td>"; |
|
184 | 184 | } else { |
185 | 185 | $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".format_number($line_item->vat)."%</td>"; |
186 | 186 | } |
187 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt,$params )."</td>"; |
|
188 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_total_price,$params )."</td>"; |
|
187 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt, $params)."</td>"; |
|
188 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_total_price, $params)."</td>"; |
|
189 | 189 | $product .= "</tr>"; |
190 | 190 | } else { |
191 | - if($serviceCount == 0) |
|
191 | + if ($serviceCount == 0) |
|
192 | 192 | { |
193 | 193 | $service .= "<tr>"; |
194 | 194 | $service .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'> </td>"; |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | $service .= "<tr>"; |
206 | 206 | $service .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>".++$serviceCount."</td>"; |
207 | 207 | $service .= "<td class='tabDetailViewDF' style='padding:2px;' colspan='2'>".$line_item->name."</td>"; |
208 | - $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_list_price,$params)."</td>"; |
|
208 | + $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_list_price, $params)."</td>"; |
|
209 | 209 | |
210 | 210 | $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".get_discount_string($line_item->discount, $line_item->product_discount, $params, $locale, $sep)."</td>"; |
211 | 211 | |
212 | 212 | |
213 | - $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_unit_price,$params)."</td>"; |
|
213 | + $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_unit_price, $params)."</td>"; |
|
214 | 214 | $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".rtrim(rtrim(format_number($line_item->vat), '0'), $sep[1])."%</td>"; |
215 | - $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt,$params )."</td>"; |
|
216 | - $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_total_price,$params )."</td>"; |
|
215 | + $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt, $params)."</td>"; |
|
216 | + $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_total_price, $params)."</td>"; |
|
217 | 217 | $service .= "</tr>"; |
218 | 218 | |
219 | 219 | } |
@@ -230,22 +230,22 @@ discard block |
||
230 | 230 | //field was 0. |
231 | 231 | //The approach below will strip off the fractional part if it is only zeroes (and in this case the decimal separator |
232 | 232 | //will also be stripped off) The custom decimal separator is passed in to the function from the locale settings |
233 | -function stripDecimalPointsAndTrailingZeroes($inputString,$decimalSeparator) |
|
233 | +function stripDecimalPointsAndTrailingZeroes($inputString, $decimalSeparator) |
|
234 | 234 | { |
235 | - return preg_replace('/'.preg_quote($decimalSeparator).'[0]+$/','',$inputString); |
|
235 | + return preg_replace('/'.preg_quote($decimalSeparator).'[0]+$/', '', $inputString); |
|
236 | 236 | } |
237 | 237 | |
238 | -function get_discount_string($type, $amount, $params, $locale, $sep){ |
|
239 | - if($amount != '' && $amount != '0.00') |
|
238 | +function get_discount_string($type, $amount, $params, $locale, $sep) { |
|
239 | + if ($amount != '' && $amount != '0.00') |
|
240 | 240 | { |
241 | - if($type == 'Amount') |
|
241 | + if ($type == 'Amount') |
|
242 | 242 | { |
243 | - return currency_format_number($amount,$params )."</td>"; |
|
243 | + return currency_format_number($amount, $params)."</td>"; |
|
244 | 244 | } |
245 | - else if($locale->getPrecision()) |
|
245 | + else if ($locale->getPrecision()) |
|
246 | 246 | { |
247 | - return rtrim(rtrim(format_number($amount), '0'),$sep[1])."%"; |
|
248 | - } else{ |
|
247 | + return rtrim(rtrim(format_number($amount), '0'), $sep[1])."%"; |
|
248 | + } else { |
|
249 | 249 | return format_number($amount)."%"; |
250 | 250 | } |
251 | 251 | } |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | -function display_shipping_vat($focus, $field, $value, $view){ |
|
258 | +function display_shipping_vat($focus, $field, $value, $view) { |
|
259 | 259 | |
260 | - if($view == 'EditView'){ |
|
260 | + if ($view == 'EditView') { |
|
261 | 261 | global $app_list_strings; |
262 | 262 | |
263 | - if($value != '') $value = format_number($value); |
|
263 | + if ($value != '') $value = format_number($value); |
|
264 | 264 | |
265 | 265 | $html = "<input id='shipping_tax_amt' type='text' tabindex='0' title='' value='".$value."' maxlength='26,6' size='22' name='shipping_tax_amt' onblur='calculateTotal(\"lineItems\");'>"; |
266 | 266 | $html .= "<select name='shipping_tax' id='shipping_tax' onchange='calculateTotal(\"lineItems\");' >".get_select_options_with_id($app_list_strings['vat_list'], (isset($focus->shipping_tax) ? $focus->shipping_tax : ''))."</select>"; |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | function save_lines($post_data, $parent, $groups = array(), $key = '') |
52 | 52 | { |
53 | 53 | |
54 | - $line_count = isset($post_data[$key . 'name']) ? count($post_data[$key . 'name']) : 0; |
|
54 | + $line_count = isset($post_data[$key.'name']) ? count($post_data[$key.'name']) : 0; |
|
55 | 55 | $j = 0; |
56 | 56 | for ($i = 0; $i < $line_count; ++$i) { |
57 | 57 | |
58 | - if ($post_data[$key . 'deleted'][$i] == 1) { |
|
59 | - $this->mark_deleted($post_data[$key . 'id'][$i]); |
|
58 | + if ($post_data[$key.'deleted'][$i] == 1) { |
|
59 | + $this->mark_deleted($post_data[$key.'id'][$i]); |
|
60 | 60 | } else { |
61 | 61 | $product_quote = new AOS_Products_Quotes(); |
62 | 62 | foreach ($this->field_defs as $field_def) { |
63 | 63 | $field_name = $field_def['name']; |
64 | - if (isset($post_data[$key . $field_name][$i])) { |
|
65 | - $product_quote->$field_name = $post_data[$key . $field_name][$i]; |
|
64 | + if (isset($post_data[$key.$field_name][$i])) { |
|
65 | + $product_quote->$field_name = $post_data[$key.$field_name][$i]; |
|
66 | 66 | } |
67 | 67 | } |
68 | - if (isset($post_data[$key . 'group_number'][$i])) { |
|
69 | - $product_quote->group_id = $groups[$post_data[$key . 'group_number'][$i]]; |
|
68 | + if (isset($post_data[$key.'group_number'][$i])) { |
|
69 | + $product_quote->group_id = $groups[$post_data[$key.'group_number'][$i]]; |
|
70 | 70 | } |
71 | 71 | if (trim($product_quote->product_id) != '' && trim($product_quote->name) != '' && trim($product_quote->product_unit_price) != '') { |
72 | 72 | $product_quote->number = ++$j; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $product_quote->currency_id = $parent->currency_id; |
76 | 76 | $product_quote->parent_type = $parent->object_name; |
77 | 77 | $product_quote->save(); |
78 | - $_POST[$key . 'id'][$i] = $product_quote->id; |
|
78 | + $_POST[$key.'id'][$i] = $product_quote->id; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $timeRemind = $popupReminder->timer_popup; |
323 | 323 | $timeStart -= $timeRemind; |
324 | 324 | |
325 | - $url = 'index.php?action=DetailView&module=' . $popupReminder->related_event_module . '&record=' . $popupReminder->related_event_module_id; |
|
325 | + $url = 'index.php?action=DetailView&module='.$popupReminder->related_event_module.'&record='.$popupReminder->related_event_module_id; |
|
326 | 326 | $instructions = $app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG']; |
327 | 327 | |
328 | 328 | if ($popupReminder->related_event_module == 'Meetings') { |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | |
343 | 343 | $relatedToMeeting = $alert->getRelatedName($popupReminder->related_event_module, $popupReminder->related_event_module_id); |
344 | 344 | |
345 | - $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'] . $desc1 . "\n"; |
|
346 | - $description = $description . "\n" . $app_strings['MSG_JS_ALERT_MTG_REMINDER_STATUS'] . (isset($relatedEvent->status) ? $relatedEvent->status : '') . "\n" . $app_strings['MSG_JS_ALERT_MTG_REMINDER_RELATED_TO'] . $relatedToMeeting; |
|
345 | + $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'].$desc1."\n"; |
|
346 | + $description = $description."\n".$app_strings['MSG_JS_ALERT_MTG_REMINDER_STATUS'].(isset($relatedEvent->status) ? $relatedEvent->status : '')."\n".$app_strings['MSG_JS_ALERT_MTG_REMINDER_RELATED_TO'].$relatedToMeeting; |
|
347 | 347 | |
348 | 348 | |
349 | 349 | if (isset($relatedEvent->date_start)) { |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | |
362 | 362 | // standard functionality |
363 | 363 | $alert->addAlert($app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING'], $meetingName, |
364 | - $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'] . $time, |
|
365 | - $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'] . $location . |
|
366 | - $description . |
|
364 | + $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'].$time, |
|
365 | + $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'].$location. |
|
366 | + $description. |
|
367 | 367 | $instructions, |
368 | 368 | $timeStart - strtotime($alertDateTimeNow), |
369 | 369 | $url |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | |
427 | 427 | private function upgradeEventPersonQuery(SugarBean $event, $person_table) |
428 | 428 | { |
429 | - $eventIdField = strtolower($event->object_name) . '_id'; |
|
429 | + $eventIdField = strtolower($event->object_name).'_id'; |
|
430 | 430 | $query = " |
431 | 431 | SELECT * FROM {$event->table_name}_{$person_table} |
432 | 432 | WHERE |
@@ -440,9 +440,9 @@ discard block |
||
440 | 440 | { |
441 | 441 | $eventIdField = array_search($event->table_name, $event->relationship_fields); |
442 | 442 | if (!$eventIdField) { |
443 | - $eventIdField = strtolower($event->object_name . '_id'); |
|
443 | + $eventIdField = strtolower($event->object_name.'_id'); |
|
444 | 444 | } |
445 | - $personIdField = strtolower($person->object_name) . '_id'; |
|
445 | + $personIdField = strtolower($person->object_name).'_id'; |
|
446 | 446 | $query = " |
447 | 447 | SELECT * FROM {$event->table_name}_{$person->table_name} |
448 | 448 | WHERE |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | { |
106 | 106 | $savedReminderIds = array(); |
107 | 107 | foreach ($remindersData as $reminderData) { |
108 | - if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $reminderData->id = ''; |
|
108 | + if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) { |
|
109 | + $reminderData->id = ''; |
|
110 | + } |
|
109 | 111 | $reminderBean = BeanFactory::getBean('Reminders', $reminderData->id); |
110 | 112 | $reminderBean->popup = $reminderData->popup; |
111 | 113 | $reminderBean->email = $reminderData->email; |
@@ -379,7 +381,9 @@ discard block |
||
379 | 381 | { |
380 | 382 | $ret = ''; |
381 | 383 | for ($i = 0; $i < strlen($timestr); $i++) { |
382 | - if ($timestr[$i] != "'") $ret .= $timestr[$i]; |
|
384 | + if ($timestr[$i] != "'") { |
|
385 | + $ret .= $timestr[$i]; |
|
386 | + } |
|
383 | 387 | } |
384 | 388 | return $ret; |
385 | 389 | } |
@@ -23,42 +23,42 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | class AOR_Report extends Basic { |
26 | - var $new_schema = true; |
|
27 | - var $module_dir = 'AOR_Reports'; |
|
28 | - var $object_name = 'AOR_Report'; |
|
29 | - var $table_name = 'aor_reports'; |
|
30 | - var $importable = true; |
|
31 | - var $disable_row_level_security = true ; |
|
32 | - |
|
33 | - var $id; |
|
34 | - var $name; |
|
35 | - var $date_entered; |
|
36 | - var $date_modified; |
|
37 | - var $modified_user_id; |
|
38 | - var $modified_by_name; |
|
39 | - var $created_by; |
|
40 | - var $created_by_name; |
|
41 | - var $description; |
|
42 | - var $deleted; |
|
43 | - var $created_by_link; |
|
44 | - var $modified_user_link; |
|
45 | - var $assigned_user_id; |
|
46 | - var $assigned_user_name; |
|
47 | - var $assigned_user_link; |
|
48 | - var $report_module; |
|
49 | - |
|
50 | - function AOR_Report(){ |
|
51 | - parent::Basic(); |
|
26 | + var $new_schema = true; |
|
27 | + var $module_dir = 'AOR_Reports'; |
|
28 | + var $object_name = 'AOR_Report'; |
|
29 | + var $table_name = 'aor_reports'; |
|
30 | + var $importable = true; |
|
31 | + var $disable_row_level_security = true ; |
|
32 | + |
|
33 | + var $id; |
|
34 | + var $name; |
|
35 | + var $date_entered; |
|
36 | + var $date_modified; |
|
37 | + var $modified_user_id; |
|
38 | + var $modified_by_name; |
|
39 | + var $created_by; |
|
40 | + var $created_by_name; |
|
41 | + var $description; |
|
42 | + var $deleted; |
|
43 | + var $created_by_link; |
|
44 | + var $modified_user_link; |
|
45 | + var $assigned_user_id; |
|
46 | + var $assigned_user_name; |
|
47 | + var $assigned_user_link; |
|
48 | + var $report_module; |
|
49 | + |
|
50 | + function AOR_Report(){ |
|
51 | + parent::Basic(); |
|
52 | 52 | $this->load_report_beans(); |
53 | 53 | require_once('modules/AOW_WorkFlow/aow_utils.php'); |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - function bean_implements($interface){ |
|
57 | - switch($interface){ |
|
58 | - case 'ACL': return true; |
|
59 | - } |
|
60 | - return false; |
|
61 | - } |
|
56 | + function bean_implements($interface){ |
|
57 | + switch($interface){ |
|
58 | + case 'ACL': return true; |
|
59 | + } |
|
60 | + return false; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | function save($check_notify = FALSE){ |
64 | 64 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART){ |
122 | 122 | global $beanList; |
123 | 123 | $linkedCharts = $this->get_linked_beans('aor_charts','AOR_Charts'); |
124 | - if(!$linkedCharts){ |
|
124 | + if(!$linkedCharts){ |
|
125 | 125 | //No charts to display |
126 | 126 | return ''; |
127 | 127 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | while ($row = $this->db->fetchByAssoc($result)) { |
479 | 479 | if($html != '') $html .= '<br />'; |
480 | 480 | |
481 | - $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
|
481 | + $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | var $object_name = 'AOR_Report'; |
29 | 29 | var $table_name = 'aor_reports'; |
30 | 30 | var $importable = true; |
31 | - var $disable_row_level_security = true ; |
|
31 | + var $disable_row_level_security = true; |
|
32 | 32 | |
33 | 33 | var $id; |
34 | 34 | var $name; |
@@ -47,25 +47,25 @@ discard block |
||
47 | 47 | var $assigned_user_link; |
48 | 48 | var $report_module; |
49 | 49 | |
50 | - function AOR_Report(){ |
|
50 | + function AOR_Report() { |
|
51 | 51 | parent::Basic(); |
52 | 52 | $this->load_report_beans(); |
53 | 53 | require_once('modules/AOW_WorkFlow/aow_utils.php'); |
54 | 54 | } |
55 | 55 | |
56 | - function bean_implements($interface){ |
|
57 | - switch($interface){ |
|
56 | + function bean_implements($interface) { |
|
57 | + switch ($interface) { |
|
58 | 58 | case 'ACL': return true; |
59 | 59 | } |
60 | 60 | return false; |
61 | 61 | } |
62 | 62 | |
63 | - function save($check_notify = FALSE){ |
|
63 | + function save($check_notify = FALSE) { |
|
64 | 64 | |
65 | 65 | // TODO: process of saveing the fields and conditions is too long so we will have to make some optimization on save_lines functions |
66 | 66 | set_time_limit(3600); |
67 | 67 | |
68 | - if (empty($this->id)){ |
|
68 | + if (empty($this->id)) { |
|
69 | 69 | unset($_POST['aor_conditions_id']); |
70 | 70 | unset($_POST['aor_fields_id']); |
71 | 71 | } |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | $chart->save_lines($_POST, $this, 'aor_chart_'); |
86 | 86 | } |
87 | 87 | |
88 | - function load_report_beans(){ |
|
88 | + function load_report_beans() { |
|
89 | 89 | global $beanList, $app_list_strings; |
90 | 90 | |
91 | 91 | $app_list_strings['aor_moduleList'] = $app_list_strings['moduleList']; |
92 | 92 | |
93 | - foreach($app_list_strings['aor_moduleList'] as $mkey => $mvalue){ |
|
94 | - if(!isset($beanList[$mkey]) || str_begin($mkey, 'AOR_') || str_begin($mkey, 'AOW_')){ |
|
93 | + foreach ($app_list_strings['aor_moduleList'] as $mkey => $mvalue) { |
|
94 | + if (!isset($beanList[$mkey]) || str_begin($mkey, 'AOR_') || str_begin($mkey, 'AOW_')) { |
|
95 | 95 | unset($app_list_strings['aor_moduleList'][$mkey]); |
96 | 96 | } |
97 | 97 | } |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | |
105 | - function getReportFields(){ |
|
105 | + function getReportFields() { |
|
106 | 106 | $fields = array(); |
107 | - foreach($this->get_linked_beans('aor_fields','AOR_Fields') as $field){ |
|
107 | + foreach ($this->get_linked_beans('aor_fields', 'AOR_Fields') as $field) { |
|
108 | 108 | $fields[] = $field; |
109 | 109 | } |
110 | - usort($fields,function($a,$b){ |
|
110 | + usort($fields, function($a, $b) { |
|
111 | 111 | return $a->field_order - $b->field_order; |
112 | 112 | }); |
113 | 113 | return $fields; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | const CHART_TYPE_RGRAPH = 'rgraph'; |
119 | 119 | |
120 | 120 | |
121 | - function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART){ |
|
121 | + function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART) { |
|
122 | 122 | global $beanList; |
123 | - $linkedCharts = $this->get_linked_beans('aor_charts','AOR_Charts'); |
|
124 | - if(!$linkedCharts){ |
|
123 | + $linkedCharts = $this->get_linked_beans('aor_charts', 'AOR_Charts'); |
|
124 | + if (!$linkedCharts) { |
|
125 | 125 | //No charts to display |
126 | 126 | return ''; |
127 | 127 | } |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | |
146 | 146 | $field_module = $this->report_module; |
147 | 147 | $field_alias = $field_bean->table_name; |
148 | - if($path[0] != $this->report_module){ |
|
149 | - foreach($path as $rel){ |
|
150 | - if(empty($rel)){ |
|
148 | + if ($path[0] != $this->report_module) { |
|
149 | + foreach ($path as $rel) { |
|
150 | + if (empty($rel)) { |
|
151 | 151 | continue; |
152 | 152 | } |
153 | - $field_module = getRelatedModule($field_module,$rel); |
|
154 | - $field_alias = $field_alias . ':'.$rel; |
|
153 | + $field_module = getRelatedModule($field_module, $rel); |
|
154 | + $field_alias = $field_alias.':'.$rel; |
|
155 | 155 | } |
156 | 156 | } |
157 | - $label = str_replace(' ','_',$field->label).$i; |
|
157 | + $label = str_replace(' ', '_', $field->label).$i; |
|
158 | 158 | $fields[$label]['field'] = $field->field; |
159 | 159 | $fields[$label]['label'] = $field->label; |
160 | 160 | $fields[$label]['display'] = $field->display; |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | |
170 | 170 | // get the main group |
171 | 171 | |
172 | - if($field->group_display) { |
|
172 | + if ($field->group_display) { |
|
173 | 173 | |
174 | 174 | // if we have a main group already thats wrong cause only one main grouping field possible |
175 | - if(!is_null($mainGroupField)) { |
|
175 | + if (!is_null($mainGroupField)) { |
|
176 | 176 | $GLOBALS['log']->fatal('main group already found'); |
177 | 177 | } |
178 | 178 | |
@@ -187,18 +187,18 @@ discard block |
||
187 | 187 | $query = $this->build_report_query(); |
188 | 188 | $result = $this->db->query($query); |
189 | 189 | $data = array(); |
190 | - while($row = $this->db->fetchByAssoc($result, false)) |
|
190 | + while ($row = $this->db->fetchByAssoc($result, false)) |
|
191 | 191 | { |
192 | - foreach($fields as $name => $att){ |
|
192 | + foreach ($fields as $name => $att) { |
|
193 | 193 | |
194 | 194 | $currency_id = isset($row[$att['alias'].'_currency_id']) ? $row[$att['alias'].'_currency_id'] : ''; |
195 | 195 | |
196 | - switch ($att['function']){ |
|
196 | + switch ($att['function']) { |
|
197 | 197 | case 'COUNT': |
198 | 198 | break; |
199 | 199 | default: |
200 | - if(!is_numeric($row[$name])) { |
|
201 | - $row[$name] = trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id,$att['params']))); |
|
200 | + if (!is_numeric($row[$name])) { |
|
201 | + $row[$name] = trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id, $att['params']))); |
|
202 | 202 | |
203 | 203 | } |
204 | 204 | break; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | } |
209 | 209 | $fields = $this->getReportFields(); |
210 | 210 | |
211 | - switch($chartType) { |
|
211 | + switch ($chartType) { |
|
212 | 212 | case self::CHART_TYPE_PCHART: |
213 | 213 | $html = '<script src="modules/AOR_Charts/lib/pChart/imagemap.js"></script>'; |
214 | 214 | break; |
@@ -216,17 +216,17 @@ discard block |
||
216 | 216 | $html = '<script src="modules/AOR_Reports/js/Chart.js"></script>'; |
217 | 217 | break; |
218 | 218 | case self::CHART_TYPE_RGRAPH: |
219 | - if($_REQUEST['module']!= 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
219 | + if ($_REQUEST['module'] != 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
220 | 220 | require_once('include/SuiteGraphs/RGraphIncludes.php'); |
221 | 221 | |
222 | 222 | break; |
223 | 223 | } |
224 | 224 | $x = 0; |
225 | - foreach($linkedCharts as $chart){ |
|
226 | - if($chartIds !== null && !in_array($chart->id,$chartIds)){ |
|
225 | + foreach ($linkedCharts as $chart) { |
|
226 | + if ($chartIds !== null && !in_array($chart->id, $chartIds)) { |
|
227 | 227 | continue; |
228 | 228 | } |
229 | - $html .= $chart->buildChartHTML($data,$fields,$x, $chartType, $mainGroupField); |
|
229 | + $html .= $chart->buildChartHTML($data, $fields, $x, $chartType, $mainGroupField); |
|
230 | 230 | $x++; |
231 | 231 | } |
232 | 232 | return $html; |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | |
239 | 239 | $rows = $this->getGroupDisplayFieldByReportId($this->id, $level); |
240 | 240 | |
241 | - if(count($rows) > 1) { |
|
242 | - $GLOBALS['log']->fatal('ambiguous group display for report ' . $this->id); |
|
241 | + if (count($rows) > 1) { |
|
242 | + $GLOBALS['log']->fatal('ambiguous group display for report '.$this->id); |
|
243 | 243 | } |
244 | - else if(count($rows) == 1){ |
|
244 | + else if (count($rows) == 1) { |
|
245 | 245 | $rows[0]['module_path'] = unserialize(base64_decode($rows[0]['module_path'])); |
246 | - if(!$rows[0]['module_path'][0]) { |
|
246 | + if (!$rows[0]['module_path'][0]) { |
|
247 | 247 | $module = new $beanList[$this->report_module](); |
248 | 248 | $rows[0]['field_id_name'] = $module->field_defs[$rows[0]['field']]['id_name'] ? $module->field_defs[$rows[0]['field']]['id_name'] : $module->field_defs[$rows[0]['field']]['name']; |
249 | 249 | $rows[0]['module_path'][0] = $module->table_name; |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | } |
254 | 254 | $path[] = $rows[0]; |
255 | 255 | |
256 | - if($level>10) { |
|
256 | + if ($level > 10) { |
|
257 | 257 | $msg = 'Too many nested groups'; |
258 | 258 | $GLOBALS['log']->fatal($msg); |
259 | 259 | return null; |
260 | 260 | } |
261 | 261 | |
262 | - return $this->buildMultiGroupReport($offset, $links, $level+1, $path); |
|
262 | + return $this->buildMultiGroupReport($offset, $links, $level + 1, $path); |
|
263 | 263 | } |
264 | - else if(!$rows) { |
|
265 | - if($path) { |
|
264 | + else if (!$rows) { |
|
265 | + if ($path) { |
|
266 | 266 | $html = ''; |
267 | 267 | foreach ($path as $pth) { |
268 | 268 | $_fieldIdName = $this->db->quoteIdentifier($pth['field_id_name']); |
269 | - $query = "SELECT $_fieldIdName FROM " . $this->db->quoteIdentifier($pth['module_path'][0]) . " GROUP BY $_fieldIdName;"; |
|
269 | + $query = "SELECT $_fieldIdName FROM ".$this->db->quoteIdentifier($pth['module_path'][0])." GROUP BY $_fieldIdName;"; |
|
270 | 270 | $values = $this->dbSelect($query); |
271 | 271 | |
272 | - foreach($values as $value) { |
|
272 | + foreach ($values as $value) { |
|
273 | 273 | |
274 | 274 | //$where = [ $this->db->quote($pth['module_path'][0]) . '.' . $_fieldIdName . ' = \'' . $this->db->quote($value[$pth['field_id_name']]) . '\'' ]; |
275 | 275 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | // escape values for query |
306 | 306 | |
307 | 307 | $_id = $this->db->quote($reportId); |
308 | - $_level = (int) $level; |
|
308 | + $_level = (int)$level; |
|
309 | 309 | |
310 | 310 | // get results array |
311 | 311 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $results = $this->db->query($query); |
321 | 321 | |
322 | 322 | $rows = array(); |
323 | - while($row = $this->db->fetchByAssoc($results)) { |
|
323 | + while ($row = $this->db->fetchByAssoc($results)) { |
|
324 | 324 | $rows[] = $row; |
325 | 325 | } |
326 | 326 | |
@@ -329,20 +329,20 @@ discard block |
||
329 | 329 | |
330 | 330 | private function getMultiGroupFrameHTML($header, $body) { |
331 | 331 | $html = '<div class="multi-group-list" style="border: 1px solid black; padding: 10px;"> |
332 | - <h3>' . $header . '</h3> |
|
333 | - <div class="multi-group-list-inner">' . $body . '</div> |
|
332 | + <h3>' . $header.'</h3> |
|
333 | + <div class="multi-group-list-inner">' . $body.'</div> |
|
334 | 334 | </div>'; |
335 | 335 | return $html; |
336 | 336 | } |
337 | 337 | |
338 | 338 | private function addDataIdValueToInnertext($html) { |
339 | 339 | preg_match('/\sdata-id-value\s*=\s*"([^"]*)"/', $html, $match); |
340 | - $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2' . $match[1] . '$3', $html); |
|
340 | + $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2'.$match[1].'$3', $html); |
|
341 | 341 | return $html; |
342 | 342 | } |
343 | 343 | |
344 | 344 | |
345 | - function build_group_report($offset = -1, $links = true, $extra = array()){ |
|
345 | + function build_group_report($offset = -1, $links = true, $extra = array()) { |
|
346 | 346 | global $beanList; |
347 | 347 | |
348 | 348 | $html = ''; |
@@ -353,23 +353,23 @@ discard block |
||
353 | 353 | $sql = "SELECT id FROM aor_fields WHERE aor_report_id = '".$this->id."' AND group_display = 1 AND deleted = 0 ORDER BY field_order ASC"; |
354 | 354 | $field_id = $this->db->getOne($sql); |
355 | 355 | |
356 | - if(!$field_id) { |
|
357 | - $query_array['select'][] = $module->table_name . ".id AS '" . $module->table_name . "_id'"; |
|
356 | + if (!$field_id) { |
|
357 | + $query_array['select'][] = $module->table_name.".id AS '".$module->table_name."_id'"; |
|
358 | 358 | } |
359 | 359 | |
360 | - if($field_id != ''){ |
|
360 | + if ($field_id != '') { |
|
361 | 361 | $field = new AOR_Field(); |
362 | 362 | $field->retrieve($field_id); |
363 | 363 | |
364 | - $field_label = str_replace(' ','_',$field->label); |
|
364 | + $field_label = str_replace(' ', '_', $field->label); |
|
365 | 365 | |
366 | 366 | $path = unserialize(base64_decode($field->module_path)); |
367 | 367 | |
368 | 368 | $field_module = $module; |
369 | 369 | $table_alias = $field_module->table_name; |
370 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
371 | - foreach($path as $rel){ |
|
372 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$rel)]; |
|
370 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
371 | + foreach ($path as $rel) { |
|
372 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $rel)]; |
|
373 | 373 | $oldAlias = $table_alias; |
374 | 374 | $table_alias = $table_alias.":".$rel; |
375 | 375 | |
@@ -383,71 +383,71 @@ discard block |
||
383 | 383 | |
384 | 384 | $data = $field_module->field_defs[$field->field]; |
385 | 385 | |
386 | - if($data['type'] == 'relate' && isset($data['id_name'])) { |
|
386 | + if ($data['type'] == 'relate' && isset($data['id_name'])) { |
|
387 | 387 | $field->field = $data['id_name']; |
388 | 388 | } |
389 | 389 | |
390 | - if($data['type'] == 'currency' && !stripos($field->field, '_USD') && isset($field_module->field_defs['currency_id'])) { |
|
391 | - if((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
390 | + if ($data['type'] == 'currency' && !stripos($field->field, '_USD') && isset($field_module->field_defs['currency_id'])) { |
|
391 | + if ((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
392 | 392 | $query['select'][$table_alias.'_currency_id'] = $table_alias.'_cstm'.".currency_id AS '".$table_alias."_currency_id'"; |
393 | 393 | } else { |
394 | - $query_array['select'][$table_alias . '_currency_id'] = $table_alias . ".currency_id AS '" . $table_alias . "_currency_id'"; |
|
394 | + $query_array['select'][$table_alias.'_currency_id'] = $table_alias.".currency_id AS '".$table_alias."_currency_id'"; |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
398 | - if( (isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
398 | + if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
399 | 399 | $select_field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$field->field; |
400 | 400 | // ? $query_array = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm',$table_alias, $field_module, 'custom', $query); |
401 | 401 | $query_array = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $field_module, 'custom', $query); |
402 | 402 | } else { |
403 | - $select_field= $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
403 | + $select_field = $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
404 | 404 | } |
405 | 405 | |
406 | - if($field->sort_by != ''){ |
|
406 | + if ($field->sort_by != '') { |
|
407 | 407 | $query_array['sort_by'][] = $field_label.' '.$field->sort_by; |
408 | 408 | } |
409 | 409 | |
410 | - if($field->group_by == 1){ |
|
410 | + if ($field->group_by == 1) { |
|
411 | 411 | $query_array['group_by'][] = $select_field; |
412 | 412 | } |
413 | 413 | |
414 | - if($field->field_function != null){ |
|
414 | + if ($field->field_function != null) { |
|
415 | 415 | $select_field = $field->field_function.'('.$select_field.')'; |
416 | 416 | } |
417 | 417 | |
418 | - $query_array['select'][] = $select_field ." AS '".$field_label."'"; |
|
419 | - if(isset($extra['select']) && $extra['select']) { |
|
420 | - foreach($extra['select'] as $selectField => $selectAlias) { |
|
421 | - if($selectAlias) { |
|
422 | - $query_array['select'][] = $selectField . " AS " . $selectAlias; |
|
418 | + $query_array['select'][] = $select_field." AS '".$field_label."'"; |
|
419 | + if (isset($extra['select']) && $extra['select']) { |
|
420 | + foreach ($extra['select'] as $selectField => $selectAlias) { |
|
421 | + if ($selectAlias) { |
|
422 | + $query_array['select'][] = $selectField." AS ".$selectAlias; |
|
423 | 423 | } |
424 | 424 | else { |
425 | 425 | $query_array['select'][] = $selectField; |
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
429 | - $query_array['where'][] = $select_field ." IS NOT NULL AND "; |
|
430 | - if(isset($extra['where']) && $extra['where']) { |
|
431 | - $query_array['where'][] = implode(' AND ', $extra['where']) . ' AND '; |
|
429 | + $query_array['where'][] = $select_field." IS NOT NULL AND "; |
|
430 | + if (isset($extra['where']) && $extra['where']) { |
|
431 | + $query_array['where'][] = implode(' AND ', $extra['where']).' AND '; |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | $query_array = $this->build_report_query_where($query_array); |
435 | 435 | |
436 | - foreach ($query_array['select'] as $select){ |
|
437 | - $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
436 | + foreach ($query_array['select'] as $select) { |
|
437 | + $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | $query .= ' FROM '.$module->table_name.' '; |
441 | 441 | |
442 | - if(isset($query_array['join'])){ |
|
443 | - foreach ($query_array['join'] as $join){ |
|
442 | + if (isset($query_array['join'])) { |
|
443 | + foreach ($query_array['join'] as $join) { |
|
444 | 444 | $query .= $join; |
445 | 445 | } |
446 | 446 | } |
447 | - if(isset($query_array['where'])){ |
|
447 | + if (isset($query_array['where'])) { |
|
448 | 448 | $query_where = ''; |
449 | - foreach ($query_array['where'] as $where){ |
|
450 | - $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
449 | + foreach ($query_array['where'] as $where) { |
|
450 | + $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $query_where = $this->queryWhereRepair($query_where); |
@@ -455,41 +455,41 @@ discard block |
||
455 | 455 | $query .= ' '.$query_where; |
456 | 456 | } |
457 | 457 | |
458 | - if(isset($query_array['group_by'])){ |
|
458 | + if (isset($query_array['group_by'])) { |
|
459 | 459 | $query_group_by = ''; |
460 | - foreach ($query_array['group_by'] as $group_by){ |
|
461 | - $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
460 | + foreach ($query_array['group_by'] as $group_by) { |
|
461 | + $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
462 | 462 | } |
463 | 463 | $query .= ' '.$query_group_by; |
464 | 464 | } |
465 | 465 | |
466 | - if(isset($query_array['sort_by'])){ |
|
466 | + if (isset($query_array['sort_by'])) { |
|
467 | 467 | $query_sort_by = ''; |
468 | - foreach ($query_array['sort_by'] as $sort_by){ |
|
469 | - $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
468 | + foreach ($query_array['sort_by'] as $sort_by) { |
|
469 | + $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
470 | 470 | } |
471 | 471 | $query .= ' '.$query_sort_by; |
472 | 472 | } |
473 | 473 | |
474 | - $query .= ' group by ' . $field_label; |
|
474 | + $query .= ' group by '.$field_label; |
|
475 | 475 | |
476 | 476 | $result = $this->db->query($query); |
477 | 477 | |
478 | 478 | while ($row = $this->db->fetchByAssoc($result)) { |
479 | - if($html != '') $html .= '<br />'; |
|
479 | + if ($html != '') $html .= '<br />'; |
|
480 | 480 | |
481 | 481 | $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
482 | 482 | |
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | - if($html == '') $html = $this->build_report_html($offset, $links); |
|
486 | + if ($html == '') $html = $this->build_report_html($offset, $links); |
|
487 | 487 | return $html; |
488 | 488 | |
489 | 489 | } |
490 | 490 | |
491 | 491 | |
492 | - function build_report_html($offset = -1, $links = true, $group_value = '', $tableIdentifier = '', $extra = array()){ |
|
492 | + function build_report_html($offset = -1, $links = true, $group_value = '', $tableIdentifier = '', $extra = array()) { |
|
493 | 493 | |
494 | 494 | global $beanList, $sugar_config; |
495 | 495 | |
@@ -502,22 +502,22 @@ discard block |
||
502 | 502 | // We have a count query. Run it and get the results. |
503 | 503 | $result = $this->db->query($count_query); |
504 | 504 | $assoc = $this->db->fetchByAssoc($result); |
505 | - if(!empty($assoc['c'])) |
|
505 | + if (!empty($assoc['c'])) |
|
506 | 506 | { |
507 | 507 | $total_rows = $assoc['c']; |
508 | 508 | } |
509 | 509 | |
510 | 510 | $html = "<table class='list' id='report_table".$group_value."' width='100%' cellspacing='0' cellpadding='0' border='0' repeat_header='1'>"; |
511 | 511 | |
512 | - if($offset >= 0){ |
|
512 | + if ($offset >= 0) { |
|
513 | 513 | $start = 0; |
514 | 514 | $end = 0; |
515 | 515 | $previous_offset = 0; |
516 | 516 | $next_offset = 0; |
517 | 517 | $last_offset = 0; |
518 | 518 | |
519 | - if($total_rows > 0){ |
|
520 | - $start = $offset +1; |
|
519 | + if ($total_rows > 0) { |
|
520 | + $start = $offset + 1; |
|
521 | 521 | $end = (($offset + $max_rows) < $total_rows) ? $offset + $max_rows : $total_rows; |
522 | 522 | $previous_offset = ($offset - $max_rows) < 0 ? 0 : $offset - $max_rows; |
523 | 523 | $next_offset = $offset + $max_rows; |
@@ -529,36 +529,36 @@ discard block |
||
529 | 529 | |
530 | 530 | $moduleFieldByGroupValue = $this->getModuleFieldByGroupValue($beanList, $group_value); |
531 | 531 | |
532 | - $html .="<td colspan='18'> |
|
532 | + $html .= "<td colspan='18'> |
|
533 | 533 | <table class='paginationTable' border='0' cellpadding='0' cellspacing='0' width='100%'> |
534 | 534 | <td style='text-align:left' ><H3><a href=\"javascript:void(0)\" class=\"collapseLink\" onclick=\"groupedReportToggler.toggleList(this);\"><img border=\"0\" id=\"detailpanel_1_img_hide\" src=\"themes/SuiteR/images/basic_search.gif\"></a>$moduleFieldByGroupValue</H3></td> |
535 | 535 | <td class='paginationChangeButtons' align='right' nowrap='nowrap' width='1%'>"; |
536 | 536 | |
537 | - if($offset == 0){ |
|
538 | - $html .="<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' disabled='disabled'> |
|
537 | + if ($offset == 0) { |
|
538 | + $html .= "<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' disabled='disabled'> |
|
539 | 539 | <img src='".SugarThemeRegistry::current()->getImageURL('start_off.gif')."' alt='Start' align='absmiddle' border='0'> |
540 | 540 | </button> |
541 | 541 | <button type='button' id='listViewPrevButton_top' name='listViewPrevButton' class='button' title='Previous' disabled='disabled'> |
542 | 542 | <img src='".SugarThemeRegistry::current()->getImageURL('previous_off.gif')."' alt='Previous' align='absmiddle' border='0'> |
543 | 543 | </button>"; |
544 | 544 | } else { |
545 | - $html .="<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' onclick='changeReportPage(\"".$this->id."\",0,\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
545 | + $html .= "<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' onclick='changeReportPage(\"".$this->id."\",0,\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
546 | 546 | <img src='".SugarThemeRegistry::current()->getImageURL('start.gif')."' alt='Start' align='absmiddle' border='0'> |
547 | 547 | </button> |
548 | 548 | <button type='button' id='listViewPrevButton_top' name='listViewPrevButton' class='button' title='Previous' onclick='changeReportPage(\"".$this->id."\",".$previous_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
549 | 549 | <img src='".SugarThemeRegistry::current()->getImageURL('previous.gif')."' alt='Previous' align='absmiddle' border='0'> |
550 | 550 | </button>"; |
551 | 551 | } |
552 | - $html .=" <span class='pageNumbers'>(".$start ." - ".$end ." of ". $total_rows .")</span>"; |
|
553 | - if($next_offset < $total_rows){ |
|
554 | - $html .="<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' onclick='changeReportPage(\"".$this->id."\",".$next_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
552 | + $html .= " <span class='pageNumbers'>(".$start." - ".$end." of ".$total_rows.")</span>"; |
|
553 | + if ($next_offset < $total_rows) { |
|
554 | + $html .= "<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' onclick='changeReportPage(\"".$this->id."\",".$next_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
555 | 555 | <img src='".SugarThemeRegistry::current()->getImageURL('next.gif')."' alt='Next' align='absmiddle' border='0'> |
556 | 556 | </button> |
557 | 557 | <button type='button' id='listViewEndButton_top' name='listViewEndButton' title='End' class='button' onclick='changeReportPage(\"".$this->id."\",".$last_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
558 | 558 | <img src='".SugarThemeRegistry::current()->getImageURL('end.gif')."' alt='End' align='absmiddle' border='0'> |
559 | 559 | </button>"; |
560 | 560 | } else { |
561 | - $html .="<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' disabled='disabled'> |
|
561 | + $html .= "<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' disabled='disabled'> |
|
562 | 562 | <img src='".SugarThemeRegistry::current()->getImageURL('next_off.gif')."' alt='Next' align='absmiddle' border='0'> |
563 | 563 | </button> |
564 | 564 | <button type='button' id='listViewEndButton_top' name='listViewEndButton' title='End' class='button' disabled='disabled'> |
@@ -567,12 +567,12 @@ discard block |
||
567 | 567 | |
568 | 568 | } |
569 | 569 | |
570 | - $html .="</td> |
|
570 | + $html .= "</td> |
|
571 | 571 | </table> |
572 | 572 | </td>"; |
573 | 573 | |
574 | - $html .="</tr></thead>"; |
|
575 | - } else{ |
|
574 | + $html .= "</tr></thead>"; |
|
575 | + } else { |
|
576 | 576 | |
577 | 577 | $moduleFieldByGroupValue = $this->getModuleFieldByGroupValue($beanList, $group_value); |
578 | 578 | |
@@ -598,16 +598,16 @@ discard block |
||
598 | 598 | |
599 | 599 | $field_module = $this->report_module; |
600 | 600 | $field_alias = $field_bean->table_name; |
601 | - if($path[0] != $this->report_module){ |
|
602 | - foreach($path as $rel){ |
|
603 | - if(empty($rel)){ |
|
601 | + if ($path[0] != $this->report_module) { |
|
602 | + foreach ($path as $rel) { |
|
603 | + if (empty($rel)) { |
|
604 | 604 | continue; |
605 | 605 | } |
606 | - $field_module = getRelatedModule($field_module,$rel); |
|
607 | - $field_alias = $field_alias . ':'.$rel; |
|
606 | + $field_module = getRelatedModule($field_module, $rel); |
|
607 | + $field_alias = $field_alias.':'.$rel; |
|
608 | 608 | } |
609 | 609 | } |
610 | - $label = str_replace(' ','_',$field->label).$i; |
|
610 | + $label = str_replace(' ', '_', $field->label).$i; |
|
611 | 611 | $fields[$label]['field'] = $field->field; |
612 | 612 | $fields[$label]['label'] = $field->label; |
613 | 613 | $fields[$label]['display'] = $field->display; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | $fields[$label]['params'] = array("date_format" => $field->format); |
621 | 621 | |
622 | 622 | |
623 | - if($fields[$label]['display']){ |
|
623 | + if ($fields[$label]['display']) { |
|
624 | 624 | $html .= "<th scope='col'>"; |
625 | 625 | $html .= "<div style='white-space: normal;' width='100%' align='left'>"; |
626 | 626 | $html .= $field->label; |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | $html .= "</thead>"; |
634 | 634 | $html .= "<tbody>"; |
635 | 635 | |
636 | - if($offset >= 0){ |
|
636 | + if ($offset >= 0) { |
|
637 | 637 | $result = $this->db->limitQuery($report_sql, $offset, $max_rows); |
638 | 638 | } else { |
639 | 639 | $result = $this->db->query($report_sql); |
@@ -646,39 +646,39 @@ discard block |
||
646 | 646 | while ($row = $this->db->fetchByAssoc($result)) { |
647 | 647 | $html .= "<tr class='".$row_class."' height='20'>"; |
648 | 648 | |
649 | - foreach($fields as $name => $att){ |
|
650 | - if($att['display']){ |
|
649 | + foreach ($fields as $name => $att) { |
|
650 | + if ($att['display']) { |
|
651 | 651 | $html .= "<td class='' valign='top' align='left'>"; |
652 | - if($att['link'] && $links){ |
|
653 | - $html .= "<a href='" . $sugar_config['site_url'] . "/index.php?module=".$att['module']."&action=DetailView&record=".$row[$att['alias'].'_id']."'>"; |
|
652 | + if ($att['link'] && $links) { |
|
653 | + $html .= "<a href='".$sugar_config['site_url']."/index.php?module=".$att['module']."&action=DetailView&record=".$row[$att['alias'].'_id']."'>"; |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | $currency_id = isset($row[$att['alias'].'_currency_id']) ? $row[$att['alias'].'_currency_id'] : ''; |
657 | 657 | |
658 | - switch ($att['function']){ |
|
658 | + switch ($att['function']) { |
|
659 | 659 | case 'COUNT': |
660 | 660 | //case 'SUM': |
661 | 661 | $html .= $row[$name]; |
662 | 662 | break; |
663 | 663 | default: |
664 | 664 | |
665 | - $html .= getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name],'',$currency_id, $att['params']); |
|
665 | + $html .= getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id, $att['params']); |
|
666 | 666 | break; |
667 | 667 | } |
668 | - if($att['total']){ |
|
668 | + if ($att['total']) { |
|
669 | 669 | $totals[$name][] = $row[$name]; |
670 | 670 | } |
671 | - if($att['link'] && $links) $html .= "</a>"; |
|
671 | + if ($att['link'] && $links) $html .= "</a>"; |
|
672 | 672 | $html .= "</td>"; |
673 | 673 | } |
674 | 674 | } |
675 | 675 | $html .= "</tr>"; |
676 | 676 | |
677 | - $row_class = $row_class == 'oddListRowS1' ? 'evenListRowS1':'oddListRowS1'; |
|
677 | + $row_class = $row_class == 'oddListRowS1' ? 'evenListRowS1' : 'oddListRowS1'; |
|
678 | 678 | } |
679 | 679 | $html .= "</tbody>"; |
680 | 680 | |
681 | - $html .= $this->getTotalHtml($fields,$totals); |
|
681 | + $html .= $this->getTotalHtml($fields, $totals); |
|
682 | 682 | |
683 | 683 | $html .= "</table>"; |
684 | 684 | |
@@ -721,13 +721,13 @@ discard block |
||
721 | 721 | |
722 | 722 | $field_module = $this->report_module; |
723 | 723 | $field_alias = $field_bean->table_name; |
724 | - if($path[0] != $this->report_module){ |
|
725 | - foreach($path as $rel){ |
|
726 | - if(empty($rel)){ |
|
724 | + if ($path[0] != $this->report_module) { |
|
725 | + foreach ($path as $rel) { |
|
726 | + if (empty($rel)) { |
|
727 | 727 | continue; |
728 | 728 | } |
729 | - $field_module = getRelatedModule($field_module,$rel); |
|
730 | - $field_alias = $field_alias . ':'.$rel; |
|
729 | + $field_module = getRelatedModule($field_module, $rel); |
|
730 | + $field_alias = $field_alias.':'.$rel; |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
@@ -740,31 +740,31 @@ discard block |
||
740 | 740 | return $moduleFieldByGroupValue; |
741 | 741 | } |
742 | 742 | |
743 | - function getTotalHTML($fields,$totals){ |
|
743 | + function getTotalHTML($fields, $totals) { |
|
744 | 744 | global $app_list_strings; |
745 | 745 | $html = ''; |
746 | 746 | $html .= "<tbody>"; |
747 | 747 | $html .= "<tr>"; |
748 | - foreach($fields as $label => $field){ |
|
749 | - if(!$field['display']){ |
|
748 | + foreach ($fields as $label => $field) { |
|
749 | + if (!$field['display']) { |
|
750 | 750 | continue; |
751 | 751 | } |
752 | - if($field['total']){ |
|
753 | - $totalLabel = $field['label'] ." ".$app_list_strings['aor_total_options'][$field['total']]; |
|
752 | + if ($field['total']) { |
|
753 | + $totalLabel = $field['label']." ".$app_list_strings['aor_total_options'][$field['total']]; |
|
754 | 754 | $html .= "<th>{$totalLabel}</th>"; |
755 | - }else{ |
|
755 | + } else { |
|
756 | 756 | $html .= "<th></th>"; |
757 | 757 | } |
758 | 758 | } |
759 | 759 | $html .= "</tr>"; |
760 | 760 | $html .= "<tr>"; |
761 | - foreach($fields as $label => $field){ |
|
762 | - if(!$field['display']){ |
|
761 | + foreach ($fields as $label => $field) { |
|
762 | + if (!$field['display']) { |
|
763 | 763 | continue; |
764 | 764 | } |
765 | - if($field['total'] && isset($totals[$label])){ |
|
766 | - $html .= "<td>".$this->calculateTotal($field['total'],$totals[$label])."</td>"; |
|
767 | - }else{ |
|
765 | + if ($field['total'] && isset($totals[$label])) { |
|
766 | + $html .= "<td>".$this->calculateTotal($field['total'], $totals[$label])."</td>"; |
|
767 | + } else { |
|
768 | 768 | $html .= "<td></td>"; |
769 | 769 | } |
770 | 770 | } |
@@ -773,24 +773,24 @@ discard block |
||
773 | 773 | return $html; |
774 | 774 | } |
775 | 775 | |
776 | - function calculateTotal($type, $totals){ |
|
777 | - switch($type){ |
|
776 | + function calculateTotal($type, $totals) { |
|
777 | + switch ($type) { |
|
778 | 778 | case 'SUM': |
779 | 779 | return array_sum($totals); |
780 | 780 | case 'COUNT': |
781 | 781 | return count($totals); |
782 | 782 | case 'AVG': |
783 | - return array_sum($totals)/count($totals); |
|
783 | + return array_sum($totals) / count($totals); |
|
784 | 784 | default: |
785 | 785 | return ''; |
786 | 786 | } |
787 | 787 | } |
788 | 788 | |
789 | - private function encloseForCSV($field){ |
|
789 | + private function encloseForCSV($field) { |
|
790 | 790 | return '"'.$field.'"'; |
791 | 791 | } |
792 | 792 | |
793 | - function build_report_csv(){ |
|
793 | + function build_report_csv() { |
|
794 | 794 | |
795 | 795 | ini_set('zlib.output_compression', 'Off'); |
796 | 796 | |
@@ -814,20 +814,20 @@ discard block |
||
814 | 814 | $path = unserialize(base64_decode($field->module_path)); |
815 | 815 | |
816 | 816 | $field_module = $this->report_module; |
817 | - if($path[0] != $this->report_module){ |
|
818 | - foreach($path as $rel){ |
|
819 | - $field_module = getRelatedModule($field_module,$rel); |
|
817 | + if ($path[0] != $this->report_module) { |
|
818 | + foreach ($path as $rel) { |
|
819 | + $field_module = getRelatedModule($field_module, $rel); |
|
820 | 820 | } |
821 | 821 | } |
822 | - $label = str_replace(' ','_',$field->label).$i; |
|
822 | + $label = str_replace(' ', '_', $field->label).$i; |
|
823 | 823 | $fields[$label]['field'] = $field->field; |
824 | 824 | $fields[$label]['display'] = $field->display; |
825 | 825 | $fields[$label]['function'] = $field->field_function; |
826 | 826 | $fields[$label]['module'] = $field_module; |
827 | 827 | |
828 | 828 | |
829 | - if($field->display){ |
|
830 | - $csv.= $this->encloseForCSV($field->label); |
|
829 | + if ($field->display) { |
|
830 | + $csv .= $this->encloseForCSV($field->label); |
|
831 | 831 | $csv .= $delimiter; |
832 | 832 | } |
833 | 833 | ++$i; |
@@ -838,30 +838,30 @@ discard block |
||
838 | 838 | |
839 | 839 | while ($row = $this->db->fetchByAssoc($result)) { |
840 | 840 | $csv .= "\r\n"; |
841 | - foreach($fields as $name => $att){ |
|
842 | - if($att['display']){ |
|
843 | - if($att['function'] != '' ) |
|
841 | + foreach ($fields as $name => $att) { |
|
842 | + if ($att['display']) { |
|
843 | + if ($att['function'] != '') |
|
844 | 844 | $csv .= $this->encloseForCSV($row[$name]); |
845 | 845 | else |
846 | - $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name])))); |
|
846 | + $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name])))); |
|
847 | 847 | $csv .= $delimiter; |
848 | 848 | } |
849 | 849 | } |
850 | 850 | } |
851 | 851 | |
852 | - $csv= $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset()); |
|
852 | + $csv = $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset()); |
|
853 | 853 | |
854 | 854 | ob_clean(); |
855 | 855 | header("Pragma: cache"); |
856 | 856 | header("Content-type: text/comma-separated-values; charset=".$GLOBALS['locale']->getExportCharset()); |
857 | 857 | header("Content-Disposition: attachment; filename=\"{$this->name}.csv\""); |
858 | 858 | header("Content-transfer-encoding: binary"); |
859 | - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); |
|
860 | - header("Last-Modified: " . TimeDate::httpTime() ); |
|
861 | - header("Cache-Control: post-check=0, pre-check=0", false ); |
|
859 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
860 | + header("Last-Modified: ".TimeDate::httpTime()); |
|
861 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
862 | 862 | header("Content-Length: ".mb_strlen($csv, '8bit')); |
863 | 863 | if (!empty($sugar_config['export_excel_compatible'])) { |
864 | - $csv==chr(255) . chr(254) . mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8'); |
|
864 | + $csv == chr(255).chr(254).mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8'); |
|
865 | 865 | } |
866 | 866 | print $csv; |
867 | 867 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | |
871 | 871 | |
872 | 872 | |
873 | - function build_report_query($group_value ='', $extra = array()){ |
|
873 | + function build_report_query($group_value = '', $extra = array()) { |
|
874 | 874 | global $beanList; |
875 | 875 | |
876 | 876 | $module = new $beanList[$this->report_module](); |
@@ -879,26 +879,26 @@ discard block |
||
879 | 879 | $query_array = array(); |
880 | 880 | |
881 | 881 | $query_array = $this->build_report_query_select($query_array, $group_value); |
882 | - if(isset($extra['where']) && $extra['where']) { |
|
883 | - $query_array['where'][] = implode(' AND ', $extra['where']) . ' AND '; |
|
882 | + if (isset($extra['where']) && $extra['where']) { |
|
883 | + $query_array['where'][] = implode(' AND ', $extra['where']).' AND '; |
|
884 | 884 | } |
885 | 885 | $query_array = $this->build_report_query_where($query_array); |
886 | 886 | |
887 | - foreach ($query_array['select'] as $select){ |
|
888 | - $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
887 | + foreach ($query_array['select'] as $select) { |
|
888 | + $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | $query .= ' FROM '.$this->db->quoteIdentifier($module->table_name).' '; |
892 | 892 | |
893 | - if(isset($query_array['join'])){ |
|
894 | - foreach ($query_array['join'] as $join){ |
|
893 | + if (isset($query_array['join'])) { |
|
894 | + foreach ($query_array['join'] as $join) { |
|
895 | 895 | $query .= $join; |
896 | 896 | } |
897 | 897 | } |
898 | - if(isset($query_array['where'])){ |
|
898 | + if (isset($query_array['where'])) { |
|
899 | 899 | $query_where = ''; |
900 | - foreach ($query_array['where'] as $where){ |
|
901 | - $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
900 | + foreach ($query_array['where'] as $where) { |
|
901 | + $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | $query_where = $this->queryWhereRepair($query_where); |
@@ -906,18 +906,18 @@ discard block |
||
906 | 906 | $query .= ' '.$query_where; |
907 | 907 | } |
908 | 908 | |
909 | - if(isset($query_array['group_by'])){ |
|
909 | + if (isset($query_array['group_by'])) { |
|
910 | 910 | $query_group_by = ''; |
911 | - foreach ($query_array['group_by'] as $group_by){ |
|
912 | - $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
911 | + foreach ($query_array['group_by'] as $group_by) { |
|
912 | + $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
913 | 913 | } |
914 | 914 | $query .= ' '.$query_group_by; |
915 | 915 | } |
916 | 916 | |
917 | - if(isset($query_array['sort_by'])){ |
|
917 | + if (isset($query_array['sort_by'])) { |
|
918 | 918 | $query_sort_by = ''; |
919 | - foreach ($query_array['sort_by'] as $sort_by){ |
|
920 | - $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
919 | + foreach ($query_array['sort_by'] as $sort_by) { |
|
920 | + $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
921 | 921 | } |
922 | 922 | $query .= ' '.$query_sort_by; |
923 | 923 | } |
@@ -931,11 +931,11 @@ discard block |
||
931 | 931 | |
932 | 932 | $safe = 0; |
933 | 933 | $query_where_clean = ''; |
934 | - while($query_where_clean != $query_where) { |
|
934 | + while ($query_where_clean != $query_where) { |
|
935 | 935 | $query_where_clean = $query_where; |
936 | 936 | $query_where = preg_replace('/\b(AND|OR)\s*\(\s*\)|[^\w+\s*]\(\s*\)/i', '', $query_where_clean); |
937 | 937 | $safe++; |
938 | - if($safe>100){ |
|
938 | + if ($safe > 100) { |
|
939 | 939 | $GLOBALS['log']->fatal('Invalid report query conditions'); |
940 | 940 | break; |
941 | 941 | } |
@@ -944,10 +944,10 @@ discard block |
||
944 | 944 | return $query_where; |
945 | 945 | } |
946 | 946 | |
947 | - function build_report_query_select($query = array(), $group_value =''){ |
|
947 | + function build_report_query_select($query = array(), $group_value = '') { |
|
948 | 948 | global $beanList; |
949 | 949 | |
950 | - if($beanList[$this->report_module]){ |
|
950 | + if ($beanList[$this->report_module]) { |
|
951 | 951 | $module = new $beanList[$this->report_module](); |
952 | 952 | |
953 | 953 | $query['select'][] = $this->db->quoteIdentifier($module->table_name).".id AS '".$module->table_name."_id'"; |
@@ -960,16 +960,16 @@ discard block |
||
960 | 960 | $field = new AOR_Field(); |
961 | 961 | $field->retrieve($row['id']); |
962 | 962 | |
963 | - $field->label = str_replace(' ','_',$field->label).$i; |
|
963 | + $field->label = str_replace(' ', '_', $field->label).$i; |
|
964 | 964 | |
965 | 965 | $path = unserialize(base64_decode($field->module_path)); |
966 | 966 | |
967 | 967 | $field_module = $module; |
968 | 968 | $table_alias = $field_module->table_name; |
969 | 969 | $oldAlias = $table_alias; |
970 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
971 | - foreach($path as $rel){ |
|
972 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$rel)]; |
|
970 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
971 | + foreach ($path as $rel) { |
|
972 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $rel)]; |
|
973 | 973 | $oldAlias = $table_alias; |
974 | 974 | $table_alias = $table_alias.":".$rel; |
975 | 975 | $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
@@ -980,54 +980,54 @@ discard block |
||
980 | 980 | |
981 | 981 | $data = $field_module->field_defs[$field->field]; |
982 | 982 | |
983 | - if($data['type'] == 'relate' && isset($data['id_name'])) { |
|
983 | + if ($data['type'] == 'relate' && isset($data['id_name'])) { |
|
984 | 984 | $field->field = $data['id_name']; |
985 | 985 | $data_new = $field_module->field_defs[$field->field]; |
986 | - if(isset($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])){ |
|
986 | + if (isset($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])) { |
|
987 | 987 | $data_new['type'] = 'link'; |
988 | 988 | $data_new['relationship'] = $data['link']; |
989 | 989 | } |
990 | 990 | $data = $data_new; |
991 | 991 | } |
992 | 992 | |
993 | - if($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
994 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$data['relationship'])]; |
|
993 | + if ($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
994 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $data['relationship'])]; |
|
995 | 995 | $table_alias = $data['relationship']; |
996 | - $query = $this->build_report_query_join($data['relationship'],$table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
|
996 | + $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
|
997 | 997 | $field_module = $new_field_module; |
998 | 998 | $field->field = 'id'; |
999 | 999 | } |
1000 | 1000 | |
1001 | - if($data['type'] == 'currency' && isset($field_module->field_defs['currency_id'])) { |
|
1002 | - if((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
1001 | + if ($data['type'] == 'currency' && isset($field_module->field_defs['currency_id'])) { |
|
1002 | + if ((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
1003 | 1003 | $query['select'][$table_alias.'_currency_id'] = $this->db->quoteIdentifier($table_alias.'_cstm').".currency_id AS '".$table_alias."_currency_id'"; |
1004 | 1004 | } else { |
1005 | 1005 | $query['select'][$table_alias.'_currency_id'] = $this->db->quoteIdentifier($table_alias).".currency_id AS '".$table_alias."_currency_id'"; |
1006 | 1006 | } |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
1009 | + if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
1010 | 1010 | $select_field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$field->field; |
1011 | - $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm',$table_alias, $field_module, 'custom', $query); |
|
1011 | + $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $table_alias, $field_module, 'custom', $query); |
|
1012 | 1012 | } else { |
1013 | - $select_field= $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
1013 | + $select_field = $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | - if($field->sort_by != ''){ |
|
1016 | + if ($field->sort_by != '') { |
|
1017 | 1017 | $query['sort_by'][] = $select_field." ".$field->sort_by; |
1018 | 1018 | } |
1019 | 1019 | |
1020 | - if($field->group_by == 1){ |
|
1021 | - $query['group_by'][] = $field->format ? str_replace('(%1)', '(' . $select_field . ')', preg_replace(array('/\s+/', '/Y/', '/m/', '/d/'), array(', ', 'YEAR(%1)', 'MONTH(%1)', 'DAY(%1)'), trim(preg_replace('/[^Ymd]/', ' ', $field->format)))) : $select_field; |
|
1020 | + if ($field->group_by == 1) { |
|
1021 | + $query['group_by'][] = $field->format ? str_replace('(%1)', '('.$select_field.')', preg_replace(array('/\s+/', '/Y/', '/m/', '/d/'), array(', ', 'YEAR(%1)', 'MONTH(%1)', 'DAY(%1)'), trim(preg_replace('/[^Ymd]/', ' ', $field->format)))) : $select_field; |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | - if($field->field_function != null){ |
|
1024 | + if ($field->field_function != null) { |
|
1025 | 1025 | $select_field = $field->field_function.'('.$select_field.')'; |
1026 | 1026 | } |
1027 | 1027 | |
1028 | - $query['select'][] = $select_field ." AS '".$field->label."'"; |
|
1028 | + $query['select'][] = $select_field." AS '".$field->label."'"; |
|
1029 | 1029 | |
1030 | - if($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
1030 | + if ($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
1031 | 1031 | ++$i; |
1032 | 1032 | } |
1033 | 1033 | } |
@@ -1035,30 +1035,30 @@ discard block |
||
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | |
1038 | - function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(),SugarBean $rel_module = null ){ |
|
1038 | + function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(), SugarBean $rel_module = null) { |
|
1039 | 1039 | |
1040 | - if(!isset($query['join'][$alias])){ |
|
1040 | + if (!isset($query['join'][$alias])) { |
|
1041 | 1041 | |
1042 | - switch ($type){ |
|
1042 | + switch ($type) { |
|
1043 | 1043 | case 'custom': |
1044 | - $query['join'][$alias] = 'LEFT JOIN '.$this->db->quoteIdentifier($module->get_custom_table_name()).' '.$this->db->quoteIdentifier($name).' ON '.$this->db->quoteIdentifier($parentAlias).'.id = '. $this->db->quoteIdentifier($name).'.id_c '; |
|
1044 | + $query['join'][$alias] = 'LEFT JOIN '.$this->db->quoteIdentifier($module->get_custom_table_name()).' '.$this->db->quoteIdentifier($name).' ON '.$this->db->quoteIdentifier($parentAlias).'.id = '.$this->db->quoteIdentifier($name).'.id_c '; |
|
1045 | 1045 | break; |
1046 | 1046 | |
1047 | 1047 | case 'relationship': |
1048 | - if($module->load_relationship($name)){ |
|
1048 | + if ($module->load_relationship($name)) { |
|
1049 | 1049 | $params['join_type'] = 'LEFT JOIN'; |
1050 | - if($module->$name->relationship_type != 'one-to-many'){ |
|
1051 | - if($module->$name->getSide() == REL_LHS){ |
|
1050 | + if ($module->$name->relationship_type != 'one-to-many') { |
|
1051 | + if ($module->$name->getSide() == REL_LHS) { |
|
1052 | 1052 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($alias); |
1053 | 1053 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
1054 | 1054 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
1055 | - }else{ |
|
1055 | + } else { |
|
1056 | 1056 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
1057 | 1057 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
1058 | 1058 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($alias); |
1059 | 1059 | } |
1060 | 1060 | |
1061 | - }else{ |
|
1061 | + } else { |
|
1062 | 1062 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
1063 | 1063 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
1064 | 1064 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | $params['join_table_link_alias'] = $this->db->quoteIdentifier($linkAlias); |
1068 | 1068 | $join = $module->$name->getJoin($params, true); |
1069 | 1069 | $query['join'][$alias] = $join['join']; |
1070 | - if($rel_module != null) { |
|
1070 | + if ($rel_module != null) { |
|
1071 | 1071 | $query['join'][$alias] .= $this->build_report_access_query($rel_module, $name); |
1072 | 1072 | } |
1073 | 1073 | $query['select'][] = $join['select']." AS '".$alias."_id'"; |
@@ -1082,11 +1082,11 @@ discard block |
||
1082 | 1082 | return $query; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | - function build_report_access_query(SugarBean $module, $alias){ |
|
1085 | + function build_report_access_query(SugarBean $module, $alias) { |
|
1086 | 1086 | |
1087 | 1087 | $module->table_name = $alias; |
1088 | 1088 | $where = ''; |
1089 | - if($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list') ) |
|
1089 | + if ($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list')) |
|
1090 | 1090 | { |
1091 | 1091 | global $current_user; |
1092 | 1092 | $owner_where = $module->getOwnerWhere($current_user->id); |
@@ -1094,18 +1094,18 @@ discard block |
||
1094 | 1094 | |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - if(file_exists('modules/SecurityGroups/SecurityGroup.php')){ |
|
1097 | + if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { |
|
1098 | 1098 | /* BEGIN - SECURITY GROUPS */ |
1099 | - if($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list') ) |
|
1099 | + if ($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list')) |
|
1100 | 1100 | { |
1101 | 1101 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
1102 | 1102 | global $current_user; |
1103 | 1103 | $owner_where = $module->getOwnerWhere($current_user->id); |
1104 | - $group_where = SecurityGroup::getGroupWhere($alias,$module->module_dir,$current_user->id); |
|
1105 | - if(!empty($owner_where)){ |
|
1106 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
1104 | + $group_where = SecurityGroup::getGroupWhere($alias, $module->module_dir, $current_user->id); |
|
1105 | + if (!empty($owner_where)) { |
|
1106 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
1107 | 1107 | } else { |
1108 | - $where .= ' AND '. $group_where; |
|
1108 | + $where .= ' AND '.$group_where; |
|
1109 | 1109 | } |
1110 | 1110 | } |
1111 | 1111 | /* END - SECURITY GROUPS */ |
@@ -1118,16 +1118,16 @@ discard block |
||
1118 | 1118 | * @param array $query |
1119 | 1119 | * @return array |
1120 | 1120 | */ |
1121 | - function build_report_query_where($query = array()){ |
|
1121 | + function build_report_query_where($query = array()) { |
|
1122 | 1122 | global $beanList, $app_list_strings, $sugar_config; |
1123 | 1123 | |
1124 | 1124 | $closure = false; |
1125 | - if(!empty($query['where'])) { |
|
1125 | + if (!empty($query['where'])) { |
|
1126 | 1126 | $query['where'][] = '('; |
1127 | 1127 | $closure = true; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - if($beanList[$this->report_module]){ |
|
1130 | + if ($beanList[$this->report_module]) { |
|
1131 | 1131 | $module = new $beanList[$this->report_module](); |
1132 | 1132 | |
1133 | 1133 | $sql = "SELECT id FROM aor_conditions WHERE aor_report_id = '".$this->id."' AND deleted = 0 ORDER BY condition_order ASC"; |
@@ -1144,21 +1144,21 @@ discard block |
||
1144 | 1144 | $condition_module = $module; |
1145 | 1145 | $table_alias = $condition_module->table_name; |
1146 | 1146 | $oldAlias = $table_alias; |
1147 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
1148 | - foreach($path as $rel){ |
|
1149 | - if(empty($rel)){ |
|
1147 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
1148 | + foreach ($path as $rel) { |
|
1149 | + if (empty($rel)) { |
|
1150 | 1150 | continue; |
1151 | 1151 | } |
1152 | 1152 | // Bug: Prevents relationships from loading. |
1153 | 1153 | //$rel = strtolower($rel); |
1154 | - $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir,$rel)]; |
|
1154 | + $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir, $rel)]; |
|
1155 | 1155 | $oldAlias = $table_alias; |
1156 | 1156 | $table_alias = $table_alias.":".$rel; |
1157 | 1157 | $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_condition_module); |
1158 | 1158 | $condition_module = $new_condition_module; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | - if(isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) { |
|
1161 | + if (isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) { |
|
1162 | 1162 | $where_set = false; |
1163 | 1163 | |
1164 | 1164 | $data = $condition_module->field_defs[$condition->field]; |
@@ -1173,24 +1173,24 @@ discard block |
||
1173 | 1173 | $data = $data_new; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - if($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
1177 | - $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir,$data['relationship'])]; |
|
1176 | + if ($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
1177 | + $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir, $data['relationship'])]; |
|
1178 | 1178 | $table_alias = $data['relationship']; |
1179 | - $query = $this->build_report_query_join($data['relationship'],$table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module); |
|
1179 | + $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module); |
|
1180 | 1180 | $condition_module = $new_field_module; |
1181 | 1181 | |
1182 | 1182 | // Debugging: security groups conditions - It's a hack to just get the query working |
1183 | - if($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) { |
|
1183 | + if ($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) { |
|
1184 | 1184 | // $table_alias = 'opportunities:assigned_user_link:SecurityGroups' ; |
1185 | - $table_alias = $oldAlias. ':' .$rel; |
|
1185 | + $table_alias = $oldAlias.':'.$rel; |
|
1186 | 1186 | } |
1187 | 1187 | $condition->field = 'id'; |
1188 | 1188 | } |
1189 | 1189 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
1190 | - $field = $this->db->quoteIdentifier($table_alias . '_cstm') . '.' . $condition->field; |
|
1191 | - $query = $this->build_report_query_join($table_alias . '_cstm', $table_alias . '_cstm', $oldAlias, $condition_module, 'custom', $query); |
|
1190 | + $field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$condition->field; |
|
1191 | + $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $oldAlias, $condition_module, 'custom', $query); |
|
1192 | 1192 | } else { |
1193 | - $field = $this->db->quoteIdentifier($table_alias) . '.' . $condition->field; |
|
1193 | + $field = $this->db->quoteIdentifier($table_alias).'.'.$condition->field; |
|
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | if (!empty($this->user_parameters[$condition->id]) && $condition->parameter) { |
@@ -1222,10 +1222,10 @@ discard block |
||
1222 | 1222 | $condition->field = 'id'; |
1223 | 1223 | } |
1224 | 1224 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
1225 | - $value = $condition_module->table_name . '_cstm.' . $condition->value; |
|
1226 | - $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); |
|
1225 | + $value = $condition_module->table_name.'_cstm.'.$condition->value; |
|
1226 | + $query = $this->build_report_query_join($condition_module->table_name.'_cstm', $table_alias.'_cstm', $table_alias, $condition_module, 'custom', $query); |
|
1227 | 1227 | } else { |
1228 | - $value = ($table_alias ? "`$table_alias`" : $condition_module->table_name) . '.' . $condition->value; |
|
1228 | + $value = ($table_alias ? "`$table_alias`" : $condition_module->table_name).'.'.$condition->value; |
|
1229 | 1229 | } |
1230 | 1230 | break; |
1231 | 1231 | |
@@ -1237,10 +1237,10 @@ discard block |
||
1237 | 1237 | } else { |
1238 | 1238 | $value = 'NOW()'; |
1239 | 1239 | } |
1240 | - } else if($params[0] == 'today'){ |
|
1241 | - if($sugar_config['dbconfig']['db_type'] == 'mssql'){ |
|
1240 | + } else if ($params[0] == 'today') { |
|
1241 | + if ($sugar_config['dbconfig']['db_type'] == 'mssql') { |
|
1242 | 1242 | //$field = |
1243 | - $value = 'CAST(GETDATE() AS DATE)'; |
|
1243 | + $value = 'CAST(GETDATE() AS DATE)'; |
|
1244 | 1244 | } else { |
1245 | 1245 | $field = 'DATE('.$field.')'; |
1246 | 1246 | $value = 'Curdate()'; |
@@ -1248,10 +1248,10 @@ discard block |
||
1248 | 1248 | } else { |
1249 | 1249 | $data = $condition_module->field_defs[$params[0]]; |
1250 | 1250 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
1251 | - $value = $condition_module->table_name . '_cstm.' . $params[0]; |
|
1252 | - $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); |
|
1251 | + $value = $condition_module->table_name.'_cstm.'.$params[0]; |
|
1252 | + $query = $this->build_report_query_join($condition_module->table_name.'_cstm', $table_alias.'_cstm', $table_alias, $condition_module, 'custom', $query); |
|
1253 | 1253 | } else { |
1254 | - $value = $condition_module->table_name . '.' . $params[0]; |
|
1254 | + $value = $condition_module->table_name.'.'.$params[0]; |
|
1255 | 1255 | } |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1262,9 +1262,9 @@ discard block |
||
1262 | 1262 | $params[3] = 'hours'; |
1263 | 1263 | default: |
1264 | 1264 | if ($sugar_config['dbconfig']['db_type'] == 'mssql') { |
1265 | - $value = "DATEADD(" . $params[3] . ", " . $app_list_strings['aor_date_operator'][$params[1]] . " $params[2], $value)"; |
|
1265 | + $value = "DATEADD(".$params[3].", ".$app_list_strings['aor_date_operator'][$params[1]]." $params[2], $value)"; |
|
1266 | 1266 | } else { |
1267 | - $value = "DATE_ADD($value, INTERVAL " . $app_list_strings['aor_date_operator'][$params[1]] . " $params[2] " . $params[3] . ")"; |
|
1267 | + $value = "DATE_ADD($value, INTERVAL ".$app_list_strings['aor_date_operator'][$params[1]]." $params[2] ".$params[3].")"; |
|
1268 | 1268 | } |
1269 | 1269 | break; |
1270 | 1270 | } |
@@ -1279,11 +1279,11 @@ discard block |
||
1279 | 1279 | $value = '('; |
1280 | 1280 | foreach ($multi_values as $multi_value) { |
1281 | 1281 | if ($value != '(') $value .= $sep; |
1282 | - $value .= $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'"; |
|
1282 | + $value .= $field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator]." '".$multi_value."'"; |
|
1283 | 1283 | } |
1284 | 1284 | $value .= ')'; |
1285 | 1285 | } |
1286 | - $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $value; |
|
1286 | + $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).$value; |
|
1287 | 1287 | $where_set = true; |
1288 | 1288 | break; |
1289 | 1289 | case "Period": |
@@ -1292,20 +1292,20 @@ discard block |
||
1292 | 1292 | } else { |
1293 | 1293 | $params = base64_decode($condition->value); |
1294 | 1294 | } |
1295 | - $value = '"' . getPeriodDate($params)->format('Y-m-d H:i:s') . '"'; |
|
1295 | + $value = '"'.getPeriodDate($params)->format('Y-m-d H:i:s').'"'; |
|
1296 | 1296 | break; |
1297 | 1297 | case "CurrentUserID": |
1298 | 1298 | global $current_user; |
1299 | - $value = '"' . $current_user->id . '"'; |
|
1299 | + $value = '"'.$current_user->id.'"'; |
|
1300 | 1300 | break; |
1301 | 1301 | case 'Value': |
1302 | 1302 | default: |
1303 | - $value = "'" . $this->db->quote($condition->value) . "'"; |
|
1303 | + $value = "'".$this->db->quote($condition->value)."'"; |
|
1304 | 1304 | break; |
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | //handle like conditions |
1308 | - Switch($condition->operator) { |
|
1308 | + Switch ($condition->operator) { |
|
1309 | 1309 | case 'Contains': |
1310 | 1310 | $value = "CONCAT('%', ".$value." ,'%')"; |
1311 | 1311 | break; |
@@ -1317,17 +1317,17 @@ discard block |
||
1317 | 1317 | break; |
1318 | 1318 | } |
1319 | 1319 | |
1320 | - if($condition->value_type == 'Value' && !$condition->value && $condition->operator == 'Equal_To') { |
|
1320 | + if ($condition->value_type == 'Value' && !$condition->value && $condition->operator == 'Equal_To') { |
|
1321 | 1321 | $value = "{$value} OR {$field} IS NULL"; |
1322 | 1322 | } |
1323 | 1323 | |
1324 | - if (!$where_set) $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; |
|
1324 | + if (!$where_set) $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).$field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator].' '.$value; |
|
1325 | 1325 | |
1326 | 1326 | $tiltLogicOp = false; |
1327 | 1327 | } |
1328 | - else if($condition->parenthesis) { |
|
1329 | - if($condition->parenthesis == 'START') { |
|
1330 | - $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) . '('; |
|
1328 | + else if ($condition->parenthesis) { |
|
1329 | + if ($condition->parenthesis == 'START') { |
|
1330 | + $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).'('; |
|
1331 | 1331 | $tiltLogicOp = true; |
1332 | 1332 | } |
1333 | 1333 | else { |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - if(isset($query['where']) && $query['where']) { |
|
1344 | + if (isset($query['where']) && $query['where']) { |
|
1345 | 1345 | array_unshift($query['where'], '('); |
1346 | 1346 | $query['where'][] = ') AND '; |
1347 | 1347 | } |
@@ -1349,7 +1349,7 @@ discard block |
||
1349 | 1349 | |
1350 | 1350 | } |
1351 | 1351 | |
1352 | - if($closure) { |
|
1352 | + if ($closure) { |
|
1353 | 1353 | $query['where'][] = ')'; |
1354 | 1354 | } |
1355 | 1355 |
@@ -79,40 +79,40 @@ |
||
79 | 79 | |
80 | 80 | require_once('modules/AOW_WorkFlow/aow_utils.php'); |
81 | 81 | |
82 | - $line_count = count($post_data[$key . 'field']); |
|
82 | + $line_count = count($post_data[$key.'field']); |
|
83 | 83 | $j = 0; |
84 | 84 | for ($i = 0; $i < $line_count; ++$i) { |
85 | 85 | |
86 | - if ($post_data[$key . 'deleted'][$i] == 1) { |
|
87 | - $this->mark_deleted($post_data[$key . 'id'][$i]); |
|
86 | + if ($post_data[$key.'deleted'][$i] == 1) { |
|
87 | + $this->mark_deleted($post_data[$key.'id'][$i]); |
|
88 | 88 | } else { |
89 | 89 | $condition = new AOR_Condition(); |
90 | 90 | foreach ($this->field_defs as $field_def) { |
91 | 91 | $field_name = $field_def['name']; |
92 | - if (isset($post_data[$key . $field_name][$i])) { |
|
93 | - if (is_array($post_data[$key . $field_name][$i])) { |
|
92 | + if (isset($post_data[$key.$field_name][$i])) { |
|
93 | + if (is_array($post_data[$key.$field_name][$i])) { |
|
94 | 94 | |
95 | 95 | switch ($condition->value_type) { |
96 | 96 | case 'Date': |
97 | - $post_data[$key . $field_name][$i] = base64_encode(serialize($post_data[$key . $field_name][$i])); |
|
97 | + $post_data[$key.$field_name][$i] = base64_encode(serialize($post_data[$key.$field_name][$i])); |
|
98 | 98 | break; |
99 | 99 | default: |
100 | - $post_data[$key . $field_name][$i] = encodeMultienumValue($post_data[$key . $field_name][$i]); |
|
100 | + $post_data[$key.$field_name][$i] = encodeMultienumValue($post_data[$key.$field_name][$i]); |
|
101 | 101 | } |
102 | - } else if ($field_name == 'value' && $post_data[$key . 'value_type'][$i] === 'Value') { |
|
103 | - $post_data[$key . $field_name][$i] = fixUpFormatting($_REQUEST['report_module'], $condition->field, $post_data[$key . $field_name][$i]); |
|
102 | + } else if ($field_name == 'value' && $post_data[$key.'value_type'][$i] === 'Value') { |
|
103 | + $post_data[$key.$field_name][$i] = fixUpFormatting($_REQUEST['report_module'], $condition->field, $post_data[$key.$field_name][$i]); |
|
104 | 104 | } else if ($field_name == 'parameter') { |
105 | - $post_data[$key . $field_name][$i] = isset($post_data[$key . $field_name][$i]); |
|
105 | + $post_data[$key.$field_name][$i] = isset($post_data[$key.$field_name][$i]); |
|
106 | 106 | } else if ($field_name == 'module_path') { |
107 | - $post_data[$key . $field_name][$i] = base64_encode(serialize(explode(":", $post_data[$key . $field_name][$i]))); |
|
107 | + $post_data[$key.$field_name][$i] = base64_encode(serialize(explode(":", $post_data[$key.$field_name][$i]))); |
|
108 | 108 | } |
109 | - if ($field_name == 'parenthesis' && $post_data[$key . $field_name][$i] == 'END') { |
|
109 | + if ($field_name == 'parenthesis' && $post_data[$key.$field_name][$i] == 'END') { |
|
110 | 110 | if (!isset($lastParenthesisStartConditionId)) { |
111 | 111 | throw new Exception('a closure parenthesis has no starter pair'); |
112 | 112 | } |
113 | 113 | $condition->parenthesis = $lastParenthesisStartConditionId; |
114 | 114 | } else { |
115 | - $condition->$field_name = $post_data[$key . $field_name][$i]; |
|
115 | + $condition->$field_name = $post_data[$key.$field_name][$i]; |
|
116 | 116 | } |
117 | 117 | } else if ($field_name == 'parameter') { |
118 | 118 | $condition->$field_name = 0; |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | $dictionary['AOR_Condition'] = array( |
26 | - 'table'=>'aor_conditions', |
|
27 | - 'audited'=>false, |
|
28 | - 'duplicate_merge'=>true, |
|
29 | - 'fields'=>array ( |
|
30 | - 'aor_report_id' => |
|
31 | - array ( |
|
26 | + 'table'=>'aor_conditions', |
|
27 | + 'audited'=>false, |
|
28 | + 'duplicate_merge'=>true, |
|
29 | + 'fields'=>array ( |
|
30 | + 'aor_report_id' => |
|
31 | + array ( |
|
32 | 32 | 'required' => false, |
33 | 33 | 'name' => 'aor_report_id', |
34 | 34 | 'vname' => 'LBL_AOR_REPORT_ID', |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | 'merge_filter' => 'disabled', |
46 | 46 | 'len' => 36, |
47 | 47 | 'size' => '20', |
48 | - ), |
|
49 | - 'condition_order' => |
|
50 | - array ( |
|
48 | + ), |
|
49 | + 'condition_order' => |
|
50 | + array ( |
|
51 | 51 | 'required' => false, |
52 | 52 | 'name' => 'condition_order', |
53 | 53 | 'vname' => 'LBL_ORDER', |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'size' => '20', |
67 | 67 | 'enable_range_search' => false, |
68 | 68 | 'disable_num_format' => '', |
69 | - ), |
|
69 | + ), |
|
70 | 70 | 'logic_op' => array( |
71 | 71 | 'name' => 'logic_op', |
72 | 72 | 'vname' => 'LBL_LOGIC_OP', |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | 'vname' => 'LBL_PARENTHESIS', |
79 | 79 | 'type' => 'varchar', |
80 | 80 | ), |
81 | - 'module_path' => |
|
82 | - array ( |
|
81 | + 'module_path' => |
|
82 | + array ( |
|
83 | 83 | 'name' => 'module_path', |
84 | 84 | 'type' => 'longtext', |
85 | 85 | 'vname' => 'LBL_MODULE_PATH', |
86 | 86 | 'isnull' => true, |
87 | - ), |
|
88 | - 'field' => |
|
89 | - array ( |
|
87 | + ), |
|
88 | + 'field' => |
|
89 | + array ( |
|
90 | 90 | 'required' => false, |
91 | 91 | 'name' => 'field', |
92 | 92 | 'vname' => 'LBL_FIELD', |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | 'options' => 'user_type_dom', |
107 | 107 | 'studio' => 'visible', |
108 | 108 | 'dependency' => false, |
109 | - ), |
|
110 | - 'operator' => |
|
111 | - array ( |
|
109 | + ), |
|
110 | + 'operator' => |
|
111 | + array ( |
|
112 | 112 | 'required' => false, |
113 | 113 | 'name' => 'operator', |
114 | 114 | 'vname' => 'LBL_OPERATOR', |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | 'options' => 'aor_operator_list', |
130 | 130 | 'studio' => 'visible', |
131 | 131 | 'dependency' => false, |
132 | - ), |
|
132 | + ), |
|
133 | 133 | 'value_type' => |
134 | 134 | array ( |
135 | 135 | 'required' => false, |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | 'options' => 'aor_condition_type_list', |
153 | 153 | 'studio' => 'visible', |
154 | 154 | 'dependency' => false, |
155 | - ), |
|
156 | - 'value' => |
|
157 | - array ( |
|
155 | + ), |
|
156 | + 'value' => |
|
157 | + array ( |
|
158 | 158 | 'required' => false, |
159 | 159 | 'name' => 'value', |
160 | 160 | 'vname' => 'LBL_VALUE', |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | 'merge_filter' => 'disabled', |
172 | 172 | 'len' => '255', |
173 | 173 | 'size' => '20', |
174 | - ), |
|
174 | + ), |
|
175 | 175 | 'parameter' => |
176 | 176 | array ( |
177 | 177 | 'required' => false, |
@@ -190,17 +190,17 @@ discard block |
||
190 | 190 | 'merge_filter' => 'disabled', |
191 | 191 | 'studio' => 'visible', |
192 | 192 | ), |
193 | - 'aor_reports' => |
|
194 | - array ( |
|
193 | + 'aor_reports' => |
|
194 | + array ( |
|
195 | 195 | 'name' => 'aor_reports', |
196 | 196 | 'type' => 'link', |
197 | 197 | 'relationship' => 'aor_report_aor_conditions', |
198 | 198 | 'module'=>'AOR_Reports', |
199 | 199 | 'bean_name'=>'AOR_Reports', |
200 | 200 | 'source'=>'non-db', |
201 | - ), |
|
201 | + ), |
|
202 | 202 | ), |
203 | - 'relationships'=>array ( |
|
203 | + 'relationships'=>array ( |
|
204 | 204 | ), |
205 | 205 | 'indices' => array( |
206 | 206 | array( |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | 'fields' => array('aor_report_id'), |
210 | 210 | ), |
211 | 211 | ), |
212 | - 'optimistic_locking'=>true, |
|
213 | - 'unified_search'=>true, |
|
212 | + 'optimistic_locking'=>true, |
|
213 | + 'unified_search'=>true, |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | if (!class_exists('VardefManager')){ |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | if (file_exists($file)) { |
80 | 80 | require_once $file; |
81 | 81 | unset($GLOBALS['dictionary'][$bean]); |
82 | - $focus = new $bean (); |
|
82 | + $focus = new $bean(); |
|
83 | 83 | if (($focus instanceof SugarBean)) { |
84 | 84 | if (!isset($repairedTables[$focus->table_name])) { |
85 | 85 | $sql = $GLOBALS['db']->repairTable($focus, true); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $mod_strings = return_module_language($current_language, 'UpgradeWizard'); |
249 | 249 | $stop = false; |
250 | 250 | |
251 | -$httpHost = $_SERVER['HTTP_HOST']; // cn: 8472 - HTTP_HOST includes port in some cases |
|
251 | +$httpHost = $_SERVER['HTTP_HOST']; // cn: 8472 - HTTP_HOST includes port in some cases |
|
252 | 252 | if ($colon = strpos($httpHost, ':')) { |
253 | 253 | $httpHost = substr($httpHost, 0, $colon); |
254 | 254 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | { |
60 | 60 | $this->getSeedBean()->disable_row_level_security = false; |
61 | 61 | |
62 | - $campaigns = $this->getSeedBean()->get_full_list("",""); |
|
63 | - if ( $campaigns != null ) |
|
62 | + $campaigns = $this->getSeedBean()->get_full_list("", ""); |
|
63 | + if ($campaigns != null) |
|
64 | 64 | foreach ($campaigns as $c) |
65 | 65 | $this->_searchFields['campaign_id']['options'][$c->id] = $c->name; |
66 | 66 | else |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | $rawData = $this->constructQuery( |
78 | 78 | $GLOBALS['app_list_strings']['roi_type_dom'], |
79 | 79 | $GLOBALS['app_list_strings']['roi_type_dom'], |
80 | - $this->campaign_id[0],null,true,true,true,$this->id); |
|
80 | + $this->campaign_id[0], null, true, true, true, $this->id); |
|
81 | 81 | |
82 | 82 | $currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol']; |
83 | - if ($GLOBALS['current_user']->getPreference('currency')){ |
|
83 | + if ($GLOBALS['current_user']->getPreference('currency')) { |
|
84 | 84 | |
85 | 85 | $currency = new Currency(); |
86 | 86 | $currency->retrieve($GLOBALS['current_user']->getPreference('currency')); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $chartHeight = 500; |
94 | 94 | $autoRefresh = $this->processAutoRefresh(); |
95 | 95 | |
96 | - $chartReadyData = $this->prepareChartData($rawData,$currency_symbol,$thousands_symbol); |
|
96 | + $chartReadyData = $this->prepareChartData($rawData, $currency_symbol, $thousands_symbol); |
|
97 | 97 | |
98 | 98 | //$chartReadyData['data'] = [[1.1,2.2],[3.3,4.4]]; |
99 | 99 | $jsonData = json_encode($chartReadyData['data']); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | //$colours = "['red','blue','green','orange','yellow','pink']"; |
108 | 108 | $colours = "['#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a','#ffff99','#b15928']"; |
109 | 109 | |
110 | - if(!is_array($chartReadyData['data'])||count($chartReadyData['data']) < 1) |
|
110 | + if (!is_array($chartReadyData['data']) || count($chartReadyData['data']) < 1) |
|
111 | 111 | { |
112 | 112 | return "<h3 class='noGraphDataPoints'>$this->noDataMessage</h3>"; |
113 | 113 | } |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | // return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $returnStr . '</div>'. $this->processAutoRefresh(); |
217 | 217 | } |
218 | 218 | |
219 | - protected function constructQuery($datay= array(),$targets=array(),$campaign_id = null, $cache_file_name='a_file', $refresh=false,$marketing_id='',$is_dashlet=false,$dashlet_id='') { |
|
219 | + protected function constructQuery($datay = array(), $targets = array(), $campaign_id = null, $cache_file_name = 'a_file', $refresh = false, $marketing_id = '', $is_dashlet = false, $dashlet_id = '') { |
|
220 | 220 | //global $app_strings,$mod_strings, $current_module_strings, $charset, $lang, $app_list_strings, $current_language,$sugar_config; |
221 | 221 | global $mod_strings; |
222 | 222 | |
223 | - $campaign_id = (int) $campaign_id; |
|
224 | - if(!$campaign_id) { |
|
223 | + $campaign_id = (int)$campaign_id; |
|
224 | + if (!$campaign_id) { |
|
225 | 225 | $GLOBALS['log']->debug('roi chart need a campaign id'); |
226 | 226 | return false; |
227 | 227 | } |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | |
233 | 233 | $focus = new Campaign(); |
234 | 234 | $focus->retrieve($campaign_id); |
235 | - $opp_count=0; |
|
236 | - $opp_query = "select count(*) opp_count,sum(" . db_convert("amount_usdollar","IFNULL",array(0)).") total_value"; |
|
235 | + $opp_count = 0; |
|
236 | + $opp_query = "select count(*) opp_count,sum(".db_convert("amount_usdollar", "IFNULL", array(0)).") total_value"; |
|
237 | 237 | $opp_query .= " from opportunities"; |
238 | 238 | $opp_query .= " where campaign_id='$campaign_id'"; |
239 | 239 | $opp_query .= " and sales_stage='Prospecting'"; |
240 | 240 | $opp_query .= " and deleted=0"; |
241 | 241 | |
242 | - $opp_result=$focus->db->query($opp_query); |
|
243 | - $opp_data=$focus->db->fetchByAssoc($opp_result); |
|
244 | - if (empty($opp_data['total_value'])) $opp_data['total_value']=0; |
|
242 | + $opp_result = $focus->db->query($opp_query); |
|
243 | + $opp_data = $focus->db->fetchByAssoc($opp_result); |
|
244 | + if (empty($opp_data['total_value'])) $opp_data['total_value'] = 0; |
|
245 | 245 | |
246 | - $chartData['Total Value']= $opp_data['total_value']; |
|
246 | + $chartData['Total Value'] = $opp_data['total_value']; |
|
247 | 247 | |
248 | 248 | //report query |
249 | 249 | $opp_query1 = "select SUM(opp.amount) as revenue"; |
@@ -252,28 +252,28 @@ discard block |
||
252 | 252 | $opp_query1 .= " where opp.sales_stage = 'Closed Won'and camp.id='$campaign_id' and opp.deleted=0"; |
253 | 253 | $opp_query1 .= " group by camp.name"; |
254 | 254 | |
255 | - $opp_result1=$focus->db->query($opp_query1); |
|
256 | - $opp_data1=$focus->db->fetchByAssoc($opp_result1); |
|
255 | + $opp_result1 = $focus->db->query($opp_query1); |
|
256 | + $opp_data1 = $focus->db->fetchByAssoc($opp_result1); |
|
257 | 257 | |
258 | 258 | //if (empty($opp_data1[])) |
259 | - if (empty($opp_data1['revenue'])){ |
|
259 | + if (empty($opp_data1['revenue'])) { |
|
260 | 260 | $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']] = 0; |
261 | 261 | unset($opp_data1['revenue']); |
262 | - }else{ |
|
262 | + } else { |
|
263 | 263 | $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']] = $opp_data1['revenue']; |
264 | 264 | unset($opp_data1['revenue']); |
265 | 265 | $not_empty = true; |
266 | 266 | } |
267 | 267 | |
268 | - $chartData['Revenue']= $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']]; |
|
268 | + $chartData['Revenue'] = $opp_data1[$mod_strings['LBL_ROI_CHART_REVENUE']]; |
|
269 | 269 | |
270 | 270 | $camp_query1 = "select camp.name, SUM(camp.actual_cost) as investment,SUM(camp.budget) as budget,SUM(camp.expected_revenue) as expected_revenue"; |
271 | 271 | $camp_query1 .= " from campaigns camp"; |
272 | 272 | $camp_query1 .= " where camp.id='$campaign_id'"; |
273 | 273 | $camp_query1 .= " group by camp.name"; |
274 | 274 | |
275 | - $camp_result1=$focus->db->query($camp_query1); |
|
276 | - $camp_data1=$focus->db->fetchByAssoc($camp_result1); |
|
275 | + $camp_result1 = $focus->db->query($camp_query1); |
|
276 | + $camp_data1 = $focus->db->fetchByAssoc($camp_result1); |
|
277 | 277 | |
278 | 278 | |
279 | 279 | if (empty($camp_data1['investment'])) |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | else |
290 | 290 | $not_empty = true; |
291 | 291 | |
292 | - $chartData['Investment']= $camp_data1['investment']; |
|
293 | - $chartData['Budget']= $camp_data1['budget']; |
|
294 | - $chartData['Expected Revenue']= $camp_data1['expected_revenue']; |
|
292 | + $chartData['Investment'] = $camp_data1['investment']; |
|
293 | + $chartData['Budget'] = $camp_data1['budget']; |
|
294 | + $chartData['Expected Revenue'] = $camp_data1['expected_revenue']; |
|
295 | 295 | |
296 | 296 | /* |
297 | 297 | $opp_data1[$mod_strings['LBL_ROI_CHART_INVESTMENT']]=$camp_data1['investment']; |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | return $chartData; |
314 | 314 | } |
315 | 315 | |
316 | - protected function prepareChartData($data,$currency_symbol, $thousands_symbol) |
|
316 | + protected function prepareChartData($data, $currency_symbol, $thousands_symbol) |
|
317 | 317 | { |
318 | 318 | //Use the lead_source to categorise the data for the charts |
319 | 319 | $chart['labels'] = array(); |
320 | 320 | $chart['data'] = array(); |
321 | 321 | //Need to add all elements into the key, as they are stacked (even though the category is not present, the value could be) |
322 | 322 | $chart['key'] = array(); |
323 | - $chart['tooltips']= array(); |
|
323 | + $chart['tooltips'] = array(); |
|
324 | 324 | |
325 | - foreach($data as $key=>$value) |
|
325 | + foreach ($data as $key=>$value) |
|
326 | 326 | { |
327 | 327 | $formattedFloat = (float)number_format((float)$value, 2, '.', ''); |
328 | 328 | $chart['labels'][] = $key; |