Test Failed
Push — CI ( 02428e...3e0292 )
by Adam
55:43
created
include/Smarty/plugins/function.sugar_getlink.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -52,26 +52,35 @@
 block discarded – undo
52 52
 function smarty_function_sugar_getlink($params, &$smarty) {
53 53
 
54 54
 	// error checking for required parameters
55
-	if(!isset($params['url'])) 
56
-		$smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'url');
57
-	if(!isset($params['title']))
58
-		$smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'title');
55
+	if(!isset($params['url'])) {
56
+			$smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'url');
57
+	}
58
+	if(!isset($params['title'])) {
59
+			$smarty->trigger_error($GLOBALS['app_strings']['ERR_MISSING_REQUIRED_FIELDS'] . 'title');
60
+	}
59 61
 
60 62
 	// set defaults
61
-	if(!isset($params['attr']))
62
-		$params['attr'] = '';
63
-	if(!isset($params['img_name'])) 
64
-		$params['img_name'] = '';
65
-	if(!isset($params['img_attr']))
66
-		$params['img_attr'] = '';
67
-	if(!isset($params['img_width']))
68
-		$params['img_width'] = null;
69
-	if(!isset($params['img_height']))
70
-		$params['height'] = null;
71
-	if(!isset($params['img_placement']))
72
-		$params['img_placement'] = 'imageonly';
73
-	if(!isset($params['img_alt']))
74
-		$params['img_alt'] = '';
63
+	if(!isset($params['attr'])) {
64
+			$params['attr'] = '';
65
+	}
66
+	if(!isset($params['img_name'])) {
67
+			$params['img_name'] = '';
68
+	}
69
+	if(!isset($params['img_attr'])) {
70
+			$params['img_attr'] = '';
71
+	}
72
+	if(!isset($params['img_width'])) {
73
+			$params['img_width'] = null;
74
+	}
75
+	if(!isset($params['img_height'])) {
76
+			$params['height'] = null;
77
+	}
78
+	if(!isset($params['img_placement'])) {
79
+			$params['img_placement'] = 'imageonly';
80
+	}
81
+	if(!isset($params['img_alt'])) {
82
+			$params['img_alt'] = '';
83
+	}
75 84
 
76 85
 	return SugarThemeRegistry::current()->getLink($params['url'], $params['title'], $params['attr'], $params['img_name'], 
77 86
 		$params['img_attr'], $params['img_width'], $params['img_height'], $params['img_alt'], $params['img_placement']);	
Please login to merge, or discard this patch.
include/Smarty/plugins/function.multienum_to_array.php 1 patch
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -67,17 +67,19 @@
 block discarded – undo
67 67
 {
68 68
 	$ret = "";
69 69
 	if(empty($params['string'])) {
70
-        if (empty($params['default']))
71
-            $ret = array();
72
-        else if(is_array($params['default']))
73
-            $ret = $params['default'];
74
-        else
75
-           $ret = unencodeMultienum($params['default']);
70
+        if (empty($params['default'])) {
71
+                    $ret = array();
72
+        } else if(is_array($params['default'])) {
73
+                    $ret = $params['default'];
74
+        } else {
75
+                   $ret = unencodeMultienum($params['default']);
76
+        }
76 77
     } else {
77
-    	if (is_array($params['string']))
78
-    	  $ret = $params['string'];
79
-    	else
80
-    	  $ret = unencodeMultienum($params['string']);
78
+    	if (is_array($params['string'])) {
79
+    	    	  $ret = $params['string'];
80
+    	} else {
81
+    	    	  $ret = unencodeMultienum($params['string']);
82
+    	}
81 83
     }
82 84
 	
83 85
     
Please login to merge, or discard this patch.
include/Smarty/plugins/function.sugar_button.php 1 patch
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -338,7 +338,9 @@  discard block
 block discarded – undo
338 338
 			break;
339 339
 
340 340
 			case "SUBPANELSAVE":
341
-                if($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate')) $view =  "form_SubpanelQuickCreate_{$module}";
341
+                if($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate')) {
342
+                    $view =  "form_SubpanelQuickCreate_{$module}";
343
+                }
342 344
 
343 345
                 /* BEGIN - SECURITY GROUPS - redirect a subpanel save to the detail view if select popup and user in more than 1 group*/ 
344 346
                 /**
@@ -475,8 +477,9 @@  discard block
 block discarded – undo
475 477
     $set_submit = false;
476 478
     $is_hidden_field = false;
477 479
     //if the code is wrapped with the form element, it will escape the operation for JS replacement
478
-    if(isset($dom_tree['tag']) && $dom_tree['tag'] == 'form')
479
-        return false;
480
+    if(isset($dom_tree['tag']) && $dom_tree['tag'] == 'form') {
481
+            return false;
482
+    }
480 483
 
481 484
     if(isset($dom_tree['type']) && $dom_tree['type'] == 'hidden') {
482 485
         $is_hidden_field = true;
@@ -486,8 +489,9 @@  discard block
 block discarded – undo
486 489
     if(isset($dom_tree['onclick'])) {
487 490
         if(strpos($dom_tree['onclick'], "this.form") !== false) {
488 491
             $dom_tree['onclick'] = str_replace("this.form", "_form", $dom_tree['onclick']);
489
-            if(substr($dom_tree['onclick'], -1) != ';')
490
-                $dom_tree['onclick'] .= ";";
492
+            if(substr($dom_tree['onclick'], -1) != ';') {
493
+                            $dom_tree['onclick'] .= ";";
494
+            }
491 495
             //Onclick handler contains returning a variable, for example it prompts a confirm message.
492 496
             if(strpos($dom_tree['onclick'], "return ") !== false ) {
493 497
                 $dom_tree['onclick'] = $js_form.' var _onclick=(function(){ldelim}'.$dom_tree['onclick']."{rdelim}()); if(_onclick!==false) _form.submit();";
Please login to merge, or discard this patch.
include/Smarty/Smarty_Compiler.class.php 1 patch
Braces   +148 added lines, -108 removed lines patch added patch discarded remove patch
@@ -243,7 +243,9 @@  discard block
 block discarded – undo
243 243
         // run template source through prefilter functions
244 244
         if (count($this->_plugins['prefilter']) > 0) {
245 245
             foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
246
-                if ($prefilter === false) continue;
246
+                if ($prefilter === false) {
247
+                    continue;
248
+                }
247 249
                 if ($prefilter[3] || is_callable($prefilter[0])) {
248 250
                     $source_content = call_user_func_array($prefilter[0],
249 251
                                                             array($source_content, &$this));
@@ -385,7 +387,9 @@  discard block
 block discarded – undo
385 387
         // run compiled template through postfilter functions
386 388
         if (count($this->_plugins['postfilter']) > 0) {
387 389
             foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
388
-                if ($postfilter === false) continue;
390
+                if ($postfilter === false) {
391
+                    continue;
392
+                }
389 393
                 if ($postfilter[3] || is_callable($postfilter[0])) {
390 394
                     $compiled_content = call_user_func_array($postfilter[0],
391 395
                                                               array($compiled_content, &$this));
@@ -435,8 +439,9 @@  discard block
 block discarded – undo
435 439
     function _compile_tag($template_tag)
436 440
     {
437 441
         /* Matched comment. */
438
-        if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*')
439
-            return '';
442
+        if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*') {
443
+                    return '';
444
+        }
440 445
         
441 446
         /* Split tag into two three parts: command, command modifiers and the arguments. */
442 447
         if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp
@@ -474,18 +479,21 @@  discard block
 block discarded – undo
474 479
 
475 480
             case 'else':
476 481
                 list($_open_tag) = end($this->_tag_stack);
477
-                if ($_open_tag != 'if' && $_open_tag != 'elseif')
478
-                    $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
479
-                else
480
-                    $this->_push_tag('else');
482
+                if ($_open_tag != 'if' && $_open_tag != 'elseif') {
483
+                                    $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
484
+                } else {
485
+                                    $this->_push_tag('else');
486
+                }
481 487
                 return '<?php else: ?>';
482 488
 
483 489
             case 'elseif':
484 490
                 list($_open_tag) = end($this->_tag_stack);
485
-                if ($_open_tag != 'if' && $_open_tag != 'elseif')
486
-                    $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
487
-                if ($_open_tag == 'if')
488
-                    $this->_push_tag('elseif');
491
+                if ($_open_tag != 'if' && $_open_tag != 'elseif') {
492
+                                    $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
493
+                }
494
+                if ($_open_tag == 'if') {
495
+                                    $this->_push_tag('elseif');
496
+                }
489 497
                 return $this->_compile_if_tag($tag_args, true);
490 498
 
491 499
             case '/if':
@@ -515,10 +523,11 @@  discard block
 block discarded – undo
515 523
 
516 524
             case '/section':
517 525
                 $_open_tag = $this->_pop_tag('section');
518
-                if ($_open_tag == 'sectionelse')
519
-                    return "<?php endif; ?>";
520
-                else
521
-                    return "<?php endfor; endif; ?>";
526
+                if ($_open_tag == 'sectionelse') {
527
+                                    return "<?php endif; ?>";
528
+                } else {
529
+                                    return "<?php endfor; endif; ?>";
530
+                }
522 531
 
523 532
             case 'foreach':
524 533
                 $this->_push_tag('foreach');
@@ -531,10 +540,11 @@  discard block
 block discarded – undo
531 540
 
532 541
             case '/foreach':
533 542
                 $_open_tag = $this->_pop_tag('foreach');
534
-                if ($_open_tag == 'foreachelse')
535
-                    return "<?php endif; unset(\$_from); ?>";
536
-                else
537
-                    return "<?php endforeach; endif; unset(\$_from); ?>";
543
+                if ($_open_tag == 'foreachelse') {
544
+                                    return "<?php endif; unset(\$_from); ?>";
545
+                } else {
546
+                                    return "<?php endforeach; endif; unset(\$_from); ?>";
547
+                }
538 548
                 break;
539 549
 
540 550
             case 'strip':
@@ -677,8 +687,9 @@  discard block
 block discarded – undo
677 687
         if (substr($tag_command, 0, 1) == '/') {
678 688
             $start_tag = false;
679 689
             $tag_command = substr($tag_command, 1);
680
-        } else
681
-            $start_tag = true;
690
+        } else {
691
+                    $start_tag = true;
692
+        }
682 693
 
683 694
         $found = false;
684 695
         $have_function = true;
@@ -728,10 +739,11 @@  discard block
 block discarded – undo
728 739
          */
729 740
         $this->_add_plugin('block', $tag_command);
730 741
 
731
-        if ($start_tag)
732
-            $this->_push_tag($tag_command);
733
-        else
734
-            $this->_pop_tag($tag_command);
742
+        if ($start_tag) {
743
+                    $this->_push_tag($tag_command);
744
+        } else {
745
+                    $this->_pop_tag($tag_command);
746
+        }
735 747
 
736 748
         if ($start_tag) {
737 749
             $output = '<?php ' . $this->_push_cacheable_state('block', $tag_command);
@@ -856,8 +868,9 @@  discard block
 block discarded – undo
856 868
                     unset($attrs['assign']);
857 869
                     continue;
858 870
                 }
859
-                if (is_bool($arg_value))
860
-                    $arg_value = $arg_value ? 'true' : 'false';
871
+                if (is_bool($arg_value)) {
872
+                                    $arg_value = $arg_value ? 'true' : 'false';
873
+                }
861 874
                 $arg_list[] = "'$arg_name' => $arg_value";
862 875
             }
863 876
         }
@@ -948,8 +961,9 @@  discard block
 block discarded – undo
948 961
         }
949 962
 
950 963
         foreach ($attrs as $arg_name => $arg_value) {
951
-            if (is_bool($arg_value))
952
-                $arg_value = $arg_value ? 'true' : 'false';
964
+            if (is_bool($arg_value)) {
965
+                            $arg_value = $arg_value ? 'true' : 'false';
966
+            }
953 967
             $arg_list[] = "'$arg_name' => $arg_value";
954 968
         }
955 969
 
@@ -987,13 +1001,15 @@  discard block
 block discarded – undo
987 1001
                 $theme_template = $arg_value;
988 1002
                 continue;
989 1003
             }
990
-            if (is_bool($arg_value))
991
-                $arg_value = $arg_value ? 'true' : 'false';
1004
+            if (is_bool($arg_value)) {
1005
+                            $arg_value = $arg_value ? 'true' : 'false';
1006
+            }
992 1007
             $arg_list[] = "'$arg_name' => $arg_value";
993 1008
         }
994 1009
 
995
-        if ( $theme_template == 'true' )
996
-            $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"',"'"),'',$include_file)).'"';
1010
+        if ( $theme_template == 'true' ) {
1011
+                    $include_file = '"'.SugarThemeRegistry::current()->getTemplate(str_replace(array('"',"'"),'',$include_file)).'"';
1012
+        }
997 1013
 
998 1014
         $output = '<?php ';
999 1015
 
@@ -1040,8 +1056,9 @@  discard block
 block discarded – undo
1040 1056
         $arg_list = array();
1041 1057
         foreach($attrs as $arg_name => $arg_value) {
1042 1058
             if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
1043
-                if(is_bool($arg_value))
1044
-                    $arg_value = $arg_value ? 'true' : 'false';
1059
+                if(is_bool($arg_value)) {
1060
+                                    $arg_value = $arg_value ? 'true' : 'false';
1061
+                }
1045 1062
                 $arg_list[] = "'$arg_name' => $arg_value";
1046 1063
             }
1047 1064
         }
@@ -1079,10 +1096,11 @@  discard block
 block discarded – undo
1079 1096
                     break;
1080 1097
 
1081 1098
                 case 'show':
1082
-                    if (is_bool($attr_value))
1083
-                        $show_attr_value = $attr_value ? 'true' : 'false';
1084
-                    else
1085
-                        $show_attr_value = "(bool)$attr_value";
1099
+                    if (is_bool($attr_value)) {
1100
+                                            $show_attr_value = $attr_value ? 'true' : 'false';
1101
+                    } else {
1102
+                                            $show_attr_value = "(bool)$attr_value";
1103
+                    }
1086 1104
                     $output .= "{$section_props}['show'] = $show_attr_value;\n";
1087 1105
                     break;
1088 1106
 
@@ -1105,24 +1123,28 @@  discard block
 block discarded – undo
1105 1123
             }
1106 1124
         }
1107 1125
 
1108
-        if (!isset($attrs['show']))
1109
-            $output .= "{$section_props}['show'] = true;\n";
1126
+        if (!isset($attrs['show'])) {
1127
+                    $output .= "{$section_props}['show'] = true;\n";
1128
+        }
1110 1129
 
1111
-        if (!isset($attrs['loop']))
1112
-            $output .= "{$section_props}['loop'] = 1;\n";
1130
+        if (!isset($attrs['loop'])) {
1131
+                    $output .= "{$section_props}['loop'] = 1;\n";
1132
+        }
1113 1133
 
1114
-        if (!isset($attrs['max']))
1115
-            $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
1116
-        else
1117
-            $output .= "if ({$section_props}['max'] < 0)\n" .
1134
+        if (!isset($attrs['max'])) {
1135
+                    $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
1136
+        } else {
1137
+                    $output .= "if ({$section_props}['max'] < 0)\n" .
1118 1138
                        "    {$section_props}['max'] = {$section_props}['loop'];\n";
1139
+        }
1119 1140
 
1120
-        if (!isset($attrs['step']))
1121
-            $output .= "{$section_props}['step'] = 1;\n";
1141
+        if (!isset($attrs['step'])) {
1142
+                    $output .= "{$section_props}['step'] = 1;\n";
1143
+        }
1122 1144
 
1123
-        if (!isset($attrs['start']))
1124
-            $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
1125
-        else {
1145
+        if (!isset($attrs['start'])) {
1146
+                    $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
1147
+        } else {
1126 1148
             $output .= "if ({$section_props}['start'] < 0)\n" .
1127 1149
                        "    {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" .
1128 1150
                        "else\n" .
@@ -1377,8 +1399,9 @@  discard block
 block discarded – undo
1377 1399
                                 $is_arg_start--;
1378 1400
                             } 
1379 1401
                         } 
1380
-                    } else
1381
-                        $is_arg_start = $i-1;
1402
+                    } else {
1403
+                                            $is_arg_start = $i-1;
1404
+                    }
1382 1405
                     /* Construct the argument for 'is' expression, so it knows
1383 1406
                        what to operate on. */
1384 1407
                     $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
@@ -1420,10 +1443,11 @@  discard block
 block discarded – undo
1420 1443
             }
1421 1444
         }
1422 1445
 
1423
-        if ($elseif)
1424
-            return '<?php elseif ('.implode(' ', $tokens).'): ?>';
1425
-        else
1426
-            return '<?php if ('.implode(' ', $tokens).'): ?>';
1446
+        if ($elseif) {
1447
+                    return '<?php elseif ('.implode(' ', $tokens).'): ?>';
1448
+        } else {
1449
+                    return '<?php if ('.implode(' ', $tokens).'): ?>';
1450
+        }
1427 1451
     }
1428 1452
 
1429 1453
 
@@ -1447,10 +1471,12 @@  discard block
 block discarded – undo
1447 1471
         }
1448 1472
 
1449 1473
         foreach ($attrs as $arg_name => $arg_value) {
1450
-            if (is_bool($arg_value))
1451
-                $arg_value = $arg_value ? 'true' : 'false';
1452
-            if (is_null($arg_value))
1453
-                $arg_value = 'null';
1474
+            if (is_bool($arg_value)) {
1475
+                            $arg_value = $arg_value ? 'true' : 'false';
1476
+            }
1477
+            if (is_null($arg_value)) {
1478
+                            $arg_value = 'null';
1479
+            }
1454 1480
             if ($_cache_attrs && in_array($arg_name, $_cache_attrs)) {
1455 1481
                 $arg_list[] = "'$arg_name' => (\$this->_cache_including) ? \$_cache_attrs['$arg_name'] : (\$_cache_attrs['$arg_name']=$arg_value)";
1456 1482
             } else {
@@ -1475,8 +1501,9 @@  discard block
 block discarded – undo
1475 1501
         if (($first_token = array_shift($tokens)) == 'not') {
1476 1502
             $negate_expr = true;
1477 1503
             $expr_type = array_shift($tokens);
1478
-        } else
1479
-            $expr_type = $first_token;
1504
+        } else {
1505
+                    $expr_type = $first_token;
1506
+        }
1480 1507
 
1481 1508
         switch ($expr_type) {
1482 1509
             case 'even':
@@ -1484,8 +1511,9 @@  discard block
 block discarded – undo
1484 1511
                     $expr_end++;
1485 1512
                     $expr_arg = $tokens[$expr_end++];
1486 1513
                     $expr = "!(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))";
1487
-                } else
1488
-                    $expr = "!(1 & $is_arg)";
1514
+                } else {
1515
+                                    $expr = "!(1 & $is_arg)";
1516
+                }
1489 1517
                 break;
1490 1518
 
1491 1519
             case 'odd':
@@ -1493,8 +1521,9 @@  discard block
 block discarded – undo
1493 1521
                     $expr_end++;
1494 1522
                     $expr_arg = $tokens[$expr_end++];
1495 1523
                     $expr = "(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))";
1496
-                } else
1497
-                    $expr = "(1 & $is_arg)";
1524
+                } else {
1525
+                                    $expr = "(1 & $is_arg)";
1526
+                }
1498 1527
                 break;
1499 1528
 
1500 1529
             case 'div':
@@ -1553,16 +1582,18 @@  discard block
 block discarded – undo
1553 1582
                     if (preg_match('~^\w+$~', $token)) {
1554 1583
                         $attr_name = $token;
1555 1584
                         $state = 1;
1556
-                    } else
1557
-                        $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__);
1585
+                    } else {
1586
+                                            $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__);
1587
+                    }
1558 1588
                     break;
1559 1589
 
1560 1590
                 case 1:
1561 1591
                     /* If the token is '=', then we go to state 2. */
1562 1592
                     if ($token == '=') {
1563 1593
                         $state = 2;
1564
-                    } else
1565
-                        $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
1594
+                    } else {
1595
+                                            $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
1596
+                    }
1566 1597
                     break;
1567 1598
 
1568 1599
                 case 2:
@@ -1586,8 +1617,9 @@  discard block
 block discarded – undo
1586 1617
 
1587 1618
                         $attrs[$attr_name] = $token;
1588 1619
                         $state = 0;
1589
-                    } else
1590
-                        $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__);
1620
+                    } else {
1621
+                                            $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__);
1622
+                    }
1591 1623
                     break;
1592 1624
             }
1593 1625
             $last_token = $token;
@@ -1649,32 +1681,27 @@  discard block
 block discarded – undo
1649 1681
                     $this->_parse_modifiers($return, $match[2]);
1650 1682
                 }
1651 1683
                 return $return;
1652
-            }
1653
-        elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1684
+            } elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1654 1685
                 // numerical constant
1655 1686
                 preg_match('~^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
1656 1687
                 if($match[2] != '') {
1657 1688
                     $this->_parse_modifiers($match[1], $match[2]);
1658 1689
                     return $match[1];
1659 1690
                 }
1660
-            }
1661
-        elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1691
+            } elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1662 1692
                 // single quoted text
1663 1693
                 preg_match('~^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
1664 1694
                 if($match[2] != '') {
1665 1695
                     $this->_parse_modifiers($match[1], $match[2]);
1666 1696
                     return $match[1];
1667 1697
                 }
1668
-            }
1669
-        elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1698
+            } elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1670 1699
                 // config var
1671 1700
                 return $this->_parse_conf_var($val);
1672
-            }
1673
-        elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1701
+            } elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
1674 1702
                 // section var
1675 1703
                 return $this->_parse_section_prop($val);
1676
-            }
1677
-        elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
1704
+            } elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
1678 1705
             // literal string
1679 1706
             return $this->_expand_quoted_text('"' . strtr($val, array('\\' => '\\\\', '"' => '\\"')) .'"');
1680 1707
         }
@@ -1737,8 +1764,9 @@  discard block
 block discarded – undo
1737 1764
                         // just output the math operator to php
1738 1765
                         $_output .= $_math_var;
1739 1766
 
1740
-                        if(empty($_first_var))
1741
-                            $_first_var = $_complete_var;
1767
+                        if(empty($_first_var)) {
1768
+                                                    $_first_var = $_complete_var;
1769
+                        }
1742 1770
 
1743 1771
                         $_complete_var = "";
1744 1772
                     } else {
@@ -1747,8 +1775,9 @@  discard block
 block discarded – undo
1747 1775
                 }
1748 1776
             }
1749 1777
             if($_has_math) {
1750
-                if(!empty($_complete_var) || is_numeric($_complete_var))
1751
-                    $_output .= $this->_parse_var($_complete_var);
1778
+                if(!empty($_complete_var) || is_numeric($_complete_var)) {
1779
+                                    $_output .= $this->_parse_var($_complete_var);
1780
+                }
1752 1781
 
1753 1782
                 // get the modifiers working (only the last var from math + modifier is left)
1754 1783
                 $var_expr = $_complete_var;
@@ -1756,10 +1785,11 @@  discard block
 block discarded – undo
1756 1785
         }
1757 1786
 
1758 1787
         // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit)
1759
-        if(is_numeric(substr($var_expr, 0, 1)))
1760
-            $_var_ref = $var_expr;
1761
-        else
1762
-            $_var_ref = substr($var_expr, 1);
1788
+        if(is_numeric(substr($var_expr, 0, 1))) {
1789
+                    $_var_ref = $var_expr;
1790
+        } else {
1791
+                    $_var_ref = substr($var_expr, 1);
1792
+        }
1763 1793
         
1764 1794
         if(!$_has_math) {
1765 1795
             
@@ -1812,10 +1842,11 @@  discard block
 block discarded – undo
1812 1842
                         $_output .= "[\$this->_sections['$_var_section']['$_var_section_prop']]";
1813 1843
                     }
1814 1844
                 } else if (substr($_index, 0, 1) == '.') {
1815
-                    if (substr($_index, 1, 1) == '$')
1816
-                        $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]";
1817
-                    else
1818
-                        $_output .= "['" . substr($_index, 1) . "']";
1845
+                    if (substr($_index, 1, 1) == '$') {
1846
+                                            $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]";
1847
+                    } else {
1848
+                                            $_output .= "['" . substr($_index, 1) . "']";
1849
+                    }
1819 1850
                 } else if (substr($_index,0,2) == '->') {
1820 1851
                     if(substr($_index,2,2) == '__') {
1821 1852
                         $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__);
@@ -1956,10 +1987,11 @@  discard block
 block discarded – undo
1956 1987
                     $_modifier_args[0] = '@' . $_modifier_args[0];
1957 1988
                 }
1958 1989
             }
1959
-            if (count($_modifier_args) > 0)
1960
-                $_modifier_args = ', '.implode(', ', $_modifier_args);
1961
-            else
1962
-                $_modifier_args = '';
1990
+            if (count($_modifier_args) > 0) {
1991
+                            $_modifier_args = ', '.implode(', ', $_modifier_args);
1992
+            } else {
1993
+                            $_modifier_args = '';
1994
+            }
1963 1995
 
1964 1996
             if ($_map_array) {
1965 1997
                 $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->_compile_plugin_call('modifier', $_modifier_name) . "(\$_tmp$_modifier_args))";
@@ -2273,8 +2305,12 @@  discard block
 block discarded – undo
2273 2305
     function _push_cacheable_state($type, $name) {
2274 2306
         $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
2275 2307
         if ($_cacheable
2276
-            || 0<$this->_cacheable_state++) return '';
2277
-        if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty'));
2308
+            || 0<$this->_cacheable_state++) {
2309
+            return '';
2310
+        }
2311
+        if (!isset($this->_cache_serial)) {
2312
+            $this->_cache_serial = md5(uniqid('Smarty'));
2313
+        }
2278 2314
         $_ret = 'if ($this->caching && !$this->_cache_including): echo \'{nocache:'
2279 2315
             . $this->_cache_serial . '#' . $this->_nocache_count
2280 2316
             . '}\'; endif;';
@@ -2291,7 +2327,9 @@  discard block
 block discarded – undo
2291 2327
     function _pop_cacheable_state($type, $name) {
2292 2328
         $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
2293 2329
         if ($_cacheable
2294
-            || --$this->_cacheable_state>0) return '';
2330
+            || --$this->_cacheable_state>0) {
2331
+            return '';
2332
+        }
2295 2333
         return 'if ($this->caching && !$this->_cache_including): echo \'{/nocache:'
2296 2334
             . $this->_cache_serial . '#' . ($this->_nocache_count++)
2297 2335
             . '}\'; endif;';
@@ -2357,11 +2395,13 @@  discard block
 block discarded – undo
2357 2395
  */
2358 2396
 function _smarty_sort_length($a, $b)
2359 2397
 {
2360
-    if($a == $b)
2361
-        return 0;
2398
+    if($a == $b) {
2399
+            return 0;
2400
+    }
2362 2401
 
2363
-    if(strlen($a) == strlen($b))
2364
-        return ($a > $b) ? -1 : 1;
2402
+    if(strlen($a) == strlen($b)) {
2403
+            return ($a > $b) ? -1 : 1;
2404
+    }
2365 2405
 
2366 2406
     return (strlen($a) > strlen($b)) ? -1 : 1;
2367 2407
 }
Please login to merge, or discard this patch.
data/SugarBean.php 1 patch
Braces   +338 added lines, -325 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -315,8 +317,9 @@  discard block
 block discarded – undo
315 317
         global  $dictionary, $current_user;
316 318
         static $loaded_defs = array();
317 319
         $this->db = DBManagerFactory::getInstance();
318
-        if (empty($this->module_name))
319
-            $this->module_name = $this->module_dir;
320
+        if (empty($this->module_name)) {
321
+                    $this->module_name = $this->module_dir;
322
+        }
320 323
         if((false == $this->disable_vardefs && empty($loaded_defs[$this->object_name])) || !empty($GLOBALS['reload_vardefs']))
321 324
         {
322 325
             VardefManager::loadVardef($this->module_dir, $this->object_name);
@@ -339,12 +342,15 @@  discard block
 block discarded – undo
339 342
                 $this->setupCustomFields($this->module_dir);
340 343
             }
341 344
             //load up field_arrays from CacheHandler;
342
-            if(empty($this->list_fields))
343
-                $this->list_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'list_fields');
344
-            if(empty($this->column_fields))
345
-                $this->column_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'column_fields');
346
-            if(empty($this->required_fields))
347
-                $this->required_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'required_fields');
345
+            if(empty($this->list_fields)) {
346
+                            $this->list_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'list_fields');
347
+            }
348
+            if(empty($this->column_fields)) {
349
+                            $this->column_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'column_fields');
350
+            }
351
+            if(empty($this->required_fields)) {
352
+                            $this->required_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'required_fields');
353
+            }
348 354
 
349 355
             if(isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs)
350 356
             {
@@ -361,8 +367,7 @@  discard block
 block discarded – undo
361 367
             $loaded_defs[$this->object_name]['required_fields'] =& $this->required_fields;
362 368
             $loaded_defs[$this->object_name]['field_name_map'] =& $this->field_name_map;
363 369
             $loaded_defs[$this->object_name]['field_defs'] =& $this->field_defs;
364
-        }
365
-        else
370
+        } else
366 371
         {
367 372
             $this->column_fields =& $loaded_defs[$this->object_name]['column_fields'] ;
368 373
             $this->list_fields =& $loaded_defs[$this->object_name]['list_fields'];
@@ -400,8 +405,9 @@  discard block
 block discarded – undo
400 405
      */
401 406
     function getObjectName()
402 407
     {
403
-        if ($this->object_name)
404
-            return $this->object_name;
408
+        if ($this->object_name) {
409
+                    return $this->object_name;
410
+        }
405 411
 
406 412
         // This is a quick way out. The generated metadata files have the table name
407 413
         // as the key. The correct way to do this is to override this function
@@ -459,8 +465,7 @@  discard block
 block discarded – undo
459 465
         if (isset($dictionary[$this->getObjectName()]['audited']))
460 466
         {
461 467
             return $dictionary[$this->getObjectName()]['audited'];
462
-        }
463
-        else
468
+        } else
464 469
         {
465 470
             return false;
466 471
         }
@@ -598,8 +603,9 @@  discard block
 block discarded – undo
598 603
      */
599 604
     function getFieldDefinition($name)
600 605
     {
601
-        if ( !isset($this->field_defs[$name]) )
602
-            return false;
606
+        if ( !isset($this->field_defs[$name]) ) {
607
+                    return false;
608
+        }
603 609
 
604 610
         return $this->field_defs[$name];
605 611
     }
@@ -657,8 +663,9 @@  discard block
 block discarded – undo
657 663
      */
658 664
     public function unPopulateDefaultValues()
659 665
     {
660
-        if ( !is_array($this->field_defs) )
661
-            return;
666
+        if ( !is_array($this->field_defs) ) {
667
+                    return;
668
+        }
662 669
 
663 670
         foreach ($this->field_defs as $field => $value) {
664 671
 		    if( !empty($this->$field)
@@ -698,8 +705,9 @@  discard block
 block discarded – undo
698 705
     }
699 706
 
700 707
     function populateDefaultValues($force=false){
701
-        if ( !is_array($this->field_defs) )
702
-            return;
708
+        if ( !is_array($this->field_defs) ) {
709
+                    return;
710
+        }
703 711
         foreach($this->field_defs as $field=>$value){
704 712
             if((isset($value['default']) || !empty($value['display_default'])) && ($force || empty($this->$field))){
705 713
                 $type = $value['type'];
@@ -717,10 +725,11 @@  discard block
 block discarded – undo
717 725
                         }
718 726
                         break;
719 727
                     case 'multienum':
720
-                        if(empty($value['default']) && !empty($value['display_default']))
721
-                            $this->$field = $value['display_default'];
722
-                        else
723
-                            $this->$field = $value['default'];
728
+                        if(empty($value['default']) && !empty($value['display_default'])) {
729
+                                                    $this->$field = $value['display_default'];
730
+                        } else {
731
+                                                    $this->$field = $value['default'];
732
+                        }
724 733
                         break;
725 734
                     case 'bool':
726 735
                     	if(isset($this->$field)){
@@ -770,8 +779,7 @@  discard block
 block discarded – undo
770 779
         {
771 780
             $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table ".$tablename. " does not exist");
772 781
             display_notice("meta data absent for table ".$tablename." keyed to $key ");
773
-        }
774
-        else
782
+        } else
775 783
         {
776 784
             if (isset($dictionary[$key]['relationships']))
777 785
             {
@@ -821,8 +829,7 @@  discard block
 block discarded – undo
821 829
             if($iscustom)
822 830
             {
823 831
                 $filename='custom/modules/' . $module_dir . '/Ext/Vardefs/vardefs.ext.php';
824
-            }
825
-            else
832
+            } else
826 833
             {
827 834
                 if ($key == 'User')
828 835
                 {
@@ -830,8 +837,7 @@  discard block
 block discarded – undo
830 837
                     // this must be done because the Employees/vardefs.php does an include_once on
831 838
                     // Users/vardefs.php
832 839
                     $filename='modules/Users/vardefs.php';
833
-                }
834
-                else
840
+                } else
835 841
                 {
836 842
                     $filename='modules/'. $module_dir . '/vardefs.php';
837 843
                 }
@@ -845,8 +851,7 @@  discard block
 block discarded – undo
845 851
                 {
846 852
                     $dictionary = $GLOBALS['dictionary'];
847 853
                 }
848
-            }
849
-            else
854
+            } else
850 855
             {
851 856
                 $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found" . $filename);
852 857
                 return;
@@ -857,8 +862,7 @@  discard block
 block discarded – undo
857 862
         {
858 863
             $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table ".$tablename. " does not exist");
859 864
             display_notice("meta data absent for table ".$tablename." keyed to $key ");
860
-        }
861
-        else
865
+        } else
862 866
         {
863 867
             if (isset($dictionary[$key]['relationships']))
864 868
             {
@@ -884,8 +888,7 @@  discard block
 block discarded – undo
884 888
                     if (Relationship::exists($rel_name,$db))
885 889
                     {
886 890
                         $GLOBALS['log']->debug('Skipping, reltionship already exists '.$rel_name);
887
-                    }
888
-                    else
891
+                    } else
889 892
                     {
890 893
                         $seed = BeanFactory::getBean("Relationships");
891 894
                         $keys = array_keys($seed->field_defs);
@@ -895,12 +898,10 @@  discard block
 block discarded – undo
895 898
                             if ($key == "id")
896 899
                             {
897 900
                                 $toInsert[$key] = create_guid();
898
-                            }
899
-                            else if ($key == "relationship_name")
901
+                            } else if ($key == "relationship_name")
900 902
                             {
901 903
                                 $toInsert[$key] = $rel_name;
902
-                            }
903
-                            else if (isset($rel_def[$key]))
904
+                            } else if (isset($rel_def[$key]))
904 905
                             {
905 906
                                 $toInsert[$key] = $rel_def[$key];
906 907
                             }
@@ -916,8 +917,7 @@  discard block
 block discarded – undo
916 917
                         $db->query($insert_string, true);
917 918
                     }
918 919
                 }
919
-            }
920
-            else
920
+            } else
921 921
             {
922 922
                 //todo
923 923
                 //log informational message stating no relationships meta was set for this bean.
@@ -986,10 +986,11 @@  discard block
 block discarded – undo
986 986
             //if rel_name is provided, search the fieldef array keys by name.
987 987
             if (isset($fieldDefs[$rel_name]['type']) && $fieldDefs[$rel_name]['type'] == 'link')
988 988
             {
989
-                if ($class == "Link2")
990
-                    $this->$rel_name = new $class($rel_name, $this);
991
-                else
992
-                    $this->$rel_name = new $class($fieldDefs[$rel_name]['relationship'], $this, $fieldDefs[$rel_name]);
989
+                if ($class == "Link2") {
990
+                                    $this->$rel_name = new $class($rel_name, $this);
991
+                } else {
992
+                                    $this->$rel_name = new $class($fieldDefs[$rel_name]['relationship'], $this, $fieldDefs[$rel_name]);
993
+                }
993 994
 
994 995
                 if (empty($this->$rel_name) ||
995 996
                         (method_exists($this->$rel_name, "loadedSuccesfully") && !$this->$rel_name->loadedSuccesfully()))
@@ -1048,8 +1049,9 @@  discard block
 block discarded – undo
1048 1049
     function get_linked_beans($field_name,$bean_name = '', $order_by = '', $begin_index = 0, $end_index = -1, $deleted=0, $optional_where="")
1049 1050
     {
1050 1051
         //if bean_name is Case then use aCase
1051
-        if($bean_name=="Case")
1052
-            $bean_name = "aCase";
1052
+        if($bean_name=="Case") {
1053
+                    $bean_name = "aCase";
1054
+        }
1053 1055
 
1054 1056
         if($this->load_relationship($field_name)) {
1055 1057
             if ($this->$field_name instanceof Link) {
@@ -1057,19 +1059,20 @@  discard block
 block discarded – undo
1057 1059
                 return array_values($this->$field_name->getBeans(new $bean_name(), $order_by, $begin_index, $end_index, $deleted, $optional_where));
1058 1060
             } else {
1059 1061
                 // Link2 style
1060
-                if ($end_index != -1 || !empty($deleted) || !empty($optional_where) || !empty($order_by))
1061
-                    return array_values($this->$field_name->getBeans(array(
1062
+                if ($end_index != -1 || !empty($deleted) || !empty($optional_where) || !empty($order_by)) {
1063
+                                    return array_values($this->$field_name->getBeans(array(
1062 1064
                         'where' => $optional_where,
1063 1065
                         'deleted' => $deleted,
1064 1066
                         'limit' => ($end_index - $begin_index),
1065 1067
                         'order_by' => $order_by
1066 1068
                     )));
1067
-                else
1068
-                    return array_values($this->$field_name->getBeans());
1069
+                } else {
1070
+                                    return array_values($this->$field_name->getBeans());
1071
+                }
1069 1072
             }
1073
+        } else {
1074
+                    return array();
1070 1075
         }
1071
-        else
1072
-            return array();
1073 1076
     }
1074 1077
 
1075 1078
     /**
@@ -1131,8 +1134,7 @@  discard block
 block discarded – undo
1131 1134
                            || is_bool($value_array['importable']) && $value_array['importable'] == true)) {
1132 1135
                         $importableFields[$key]=$value_array;
1133 1136
                     }
1134
-                }
1135
-                else {
1137
+                } else {
1136 1138
 
1137 1139
                     //Expose the cooresponding id field of a relate field if it is only defined as a link so that users can relate records by id during import
1138 1140
                     if( isset($value_array['type']) && ($value_array['type'] == 'relate') && isset($value_array['id_name']) )
@@ -1217,8 +1219,7 @@  discard block
 block discarded – undo
1217 1219
             if ($this->load_relationship($name))
1218 1220
             {
1219 1221
                 $this->$name->delete($id);
1220
-            }
1221
-            else
1222
+            } else
1222 1223
             {
1223 1224
                 $GLOBALS['log']->fatal("error loading relationship $name");
1224 1225
             }
@@ -1239,8 +1240,7 @@  discard block
 block discarded – undo
1239 1240
         {
1240 1241
             $GLOBALS['log']->fatal("create_tables: Metadata for table ".$this->table_name. " does not exist");
1241 1242
             display_notice("meta data absent for table ".$this->table_name." keyed to $key ");
1242
-        }
1243
-        else
1243
+        } else
1244 1244
         {
1245 1245
             if(!$this->db->tableExists($this->table_name))
1246 1246
             {
@@ -1248,12 +1248,11 @@  discard block
 block discarded – undo
1248 1248
                     if($this->bean_implements('ACL')){
1249 1249
                         if(!empty($this->acltype)){
1250 1250
                             ACLAction::addActions($this->getACLCategory(), $this->acltype);
1251
-                        }else{
1251
+                        } else{
1252 1252
                             ACLAction::addActions($this->getACLCategory());
1253 1253
                         }
1254 1254
                     }
1255
-            }
1256
-            else
1255
+            } else
1257 1256
             {
1258 1257
                 echo "Table already exists : $this->table_name<br>";
1259 1258
             }
@@ -1281,10 +1280,13 @@  discard block
 block discarded – undo
1281 1280
             $GLOBALS['log']->fatal("drop_tables: Metadata for table ".$this->table_name. " does not exist");
1282 1281
             echo "meta data absent for table ".$this->table_name."<br>\n";
1283 1282
         } else {
1284
-            if(empty($this->table_name))return;
1285
-            if ($this->db->tableExists($this->table_name))
1286
-
1283
+            if(empty($this->table_name)) {
1284
+                return;
1285
+            }
1286
+            if ($this->db->tableExists($this->table_name)) {
1287
+            
1287 1288
                 $this->db->dropTable($this);
1289
+            }
1288 1290
             if ($this->db->tableExists($this->table_name. '_cstm'))
1289 1291
             {
1290 1292
                 $this->db->dropTableName($this->table_name. '_cstm');
@@ -1322,8 +1324,9 @@  discard block
 block discarded – undo
1322 1324
             if (isset($def['type'])) {
1323 1325
                 $type=$def['type'];
1324 1326
             }
1325
-            if(isset($def['dbType']))
1326
-                $type .= $def['dbType'];
1327
+            if(isset($def['dbType'])) {
1328
+                            $type .= $def['dbType'];
1329
+            }
1327 1330
 
1328 1331
             if($def['type'] == 'html' || $def['type'] == 'longhtml') {
1329 1332
                 $this->$key = SugarCleaner::cleanHtml($this->$key, true);
@@ -1373,7 +1376,9 @@  discard block
 block discarded – undo
1373 1376
 
1374 1377
         $this->_checkOptimisticLocking($action, $isUpdate);
1375 1378
 
1376
-        if(!empty($this->modified_by_name)) $this->old_modified_by_name = $this->modified_by_name;
1379
+        if(!empty($this->modified_by_name)) {
1380
+            $this->old_modified_by_name = $this->modified_by_name;
1381
+        }
1377 1382
         if($this->update_modified_by)
1378 1383
         {
1379 1384
             $this->modified_user_id = 1;
@@ -1384,8 +1389,9 @@  discard block
 block discarded – undo
1384 1389
                 $this->modified_by_name = $current_user->user_name;
1385 1390
             }
1386 1391
         }
1387
-        if ($this->deleted != 1)
1388
-            $this->deleted = 0;
1392
+        if ($this->deleted != 1) {
1393
+                    $this->deleted = 0;
1394
+        }
1389 1395
         if(!$isUpdate)
1390 1396
         {
1391 1397
             if (empty($this->date_entered))
@@ -1607,7 +1613,7 @@  discard block
 block discarded – undo
1607 1613
 
1608 1614
                 if(!$notify_mail->Send()) {
1609 1615
                     $GLOBALS['log']->fatal("Notifications: error sending e-mail (method: {$notify_mail->Mailer}), (error: {$notify_mail->ErrorInfo})");
1610
-                }else{
1616
+                } else{
1611 1617
                     $GLOBALS['log']->info("Notifications: e-mail successfully sent");
1612 1618
                 }
1613 1619
             }
@@ -1646,8 +1652,7 @@  discard block
 block discarded – undo
1646 1652
         $xtpl = new XTemplate(get_notify_template_file($current_language));
1647 1653
         if($this->module_dir == "Cases") {
1648 1654
             $template_name = "Case"; //we should use Case, you can refer to the en_us.notify_template.html.
1649
-        }
1650
-        else {
1655
+        } else {
1651 1656
             $template_name = $beanList[$this->module_dir]; //bug 20637, in workflow this->object_name = strange chars.
1652 1657
         }
1653 1658
 
@@ -1745,8 +1750,7 @@  discard block
 block discarded – undo
1745 1750
             // if we should use relation data from properties (for REQUEST-independent calls)
1746 1751
             $rel_id = isset($this->new_rel_id) ? $this->new_rel_id : '';
1747 1752
             $rel_link = isset($this->new_rel_relname) ? $this->new_rel_relname : '';
1748
-        }
1749
-        else
1753
+        } else
1750 1754
         {
1751 1755
             // if we should use relation data from REQUEST
1752 1756
             $rel_id = isset($_REQUEST['relate_id']) ? $_REQUEST['relate_id'] : '';
@@ -1765,8 +1769,7 @@  discard block
 block discarded – undo
1765 1769
             if ($isRelationshipLoaded && !empty($this->$rel_link) && $this->$rel_link->getRelationshipObject() && $this->$rel_link->getRelationshipObject()->getLHSModule() == $this->$rel_link->getRelationshipObject()->getRHSModule() )
1766 1770
             {
1767 1771
                 $new_rel_link = $this->$rel_link->getRelationshipObject()->getLHSLink();
1768
-            }
1769
-            else
1772
+            } else
1770 1773
             {
1771 1774
                 //Try to find the link in this bean based on the relationship
1772 1775
                 foreach ($this->field_defs as $key => $def)
@@ -1800,7 +1803,9 @@  discard block
 block discarded – undo
1800 1803
             foreach ($this->relationship_fields as $id => $rel_name)
1801 1804
             {
1802 1805
 
1803
-                if (in_array($id, $exclude)) continue;
1806
+                if (in_array($id, $exclude)) {
1807
+                    continue;
1808
+                }
1804 1809
 
1805 1810
                 if(!empty($this->$id))
1806 1811
                 {
@@ -1853,8 +1858,10 @@  discard block
 block discarded – undo
1853 1858
         foreach ($this->field_defs as $def)
1854 1859
         {
1855 1860
             if ($def ['type'] == 'relate' && isset ($def ['id_name']) && isset ($def ['link']) && isset ($def['save'])) {
1856
-                if (in_array($def['id_name'], $exclude) || in_array($def['id_name'], $this->relationship_fields))
1857
-                    continue; // continue to honor the exclude array and exclude any relationships that will be handled by the relationship_fields mechanism
1861
+                if (in_array($def['id_name'], $exclude) || in_array($def['id_name'], $this->relationship_fields)) {
1862
+                                    continue;
1863
+                }
1864
+                // continue to honor the exclude array and exclude any relationships that will be handled by the relationship_fields mechanism
1858 1865
 
1859 1866
                 $linkField = $def ['link'];
1860 1867
                 if (isset($this->field_defs[$linkField])) {
@@ -1911,12 +1918,14 @@  discard block
 block discarded – undo
1911 1918
         {
1912 1919
             if (!empty($def['type']) && $def['type'] == "parent")
1913 1920
             {
1914
-                if (empty($def['type_name']) || empty($def['id_name']))
1915
-                    continue;
1921
+                if (empty($def['type_name']) || empty($def['id_name'])) {
1922
+                                    continue;
1923
+                }
1916 1924
                 $typeField = $def['type_name'];
1917 1925
                 $idField = $def['id_name'];
1918
-                if (in_array($idField, $exclude))
1919
-                    continue;
1926
+                if (in_array($idField, $exclude)) {
1927
+                                    continue;
1928
+                }
1920 1929
                 //Determine if the parent field has changed.
1921 1930
                 if (
1922 1931
                     //First check if the fetched row parent existed and now we no longer have one
@@ -2039,8 +2048,9 @@  discard block
 block discarded – undo
2039 2048
 	{
2040 2049
 		global $disable_date_format;
2041 2050
 		global $timedate;
2042
-		if (empty($timedate))
2043
-			$timedate=TimeDate::getInstance();
2051
+		if (empty($timedate)) {
2052
+					$timedate=TimeDate::getInstance();
2053
+		}
2044 2054
 
2045 2055
 		if(empty($this->field_defs))
2046 2056
 		{
@@ -2052,15 +2062,16 @@  discard block
 block discarded – undo
2052 2062
 			if(!isset($this->processed_dates_times[$field]))
2053 2063
 			{
2054 2064
 				$this->processed_dates_times[$field] = '1';
2055
-				if(empty($this->$field)) continue;
2065
+				if(empty($this->$field)) {
2066
+				    continue;
2067
+				}
2056 2068
 				if($field == 'date_modified' || $field == 'date_entered')
2057 2069
 				{
2058 2070
 					$this->$field = $this->db->fromConvert($this->$field, 'datetime');
2059 2071
 					if(empty($disable_date_format)) {
2060 2072
 						$this->$field = $timedate->to_display_date_time($this->$field);
2061 2073
 					}
2062
-				}
2063
-				elseif(isset($this->field_name_map[$field]['type']))
2074
+				} elseif(isset($this->field_name_map[$field]['type']))
2064 2075
 				{
2065 2076
 					$type = $this->field_name_map[$field]['type'];
2066 2077
 
@@ -2086,8 +2097,7 @@  discard block
 block discarded – undo
2086 2097
 									$this->$rel_field = $timedate->to_display_time($mergetime);
2087 2098
 								}
2088 2099
 							}
2089
-						}
2090
-						else
2100
+						} else
2091 2101
 						{
2092 2102
 							if(empty($disable_date_format)) {
2093 2103
 								$this->$field = $timedate->to_display_date($this->$field, false);
@@ -2098,8 +2108,7 @@  discard block
 block discarded – undo
2098 2108
 						if($this->$field == '0000-00-00 00:00:00')
2099 2109
 						{
2100 2110
 							$this->$field = '';
2101
-						}
2102
-						else
2111
+						} else
2103 2112
 						{
2104 2113
 							if(empty($disable_date_format)) {
2105 2114
 								$this->$field = $timedate->to_display_date_time($this->$field, true, true);
@@ -2188,7 +2197,9 @@  discard block
 block discarded – undo
2188 2197
             switch($def['type']) {
2189 2198
                 case 'datetime':
2190 2199
                 case 'datetimecombo':
2191
-                    if(empty($this->$field)) break;
2200
+                    if(empty($this->$field)) {
2201
+                        break;
2202
+                    }
2192 2203
                     if ($this->$field == 'NULL') {
2193 2204
                     	$this->$field = '';
2194 2205
                     	break;
@@ -2200,7 +2211,9 @@  discard block
 block discarded – undo
2200 2211
                     }
2201 2212
                     break;
2202 2213
                 case 'date':
2203
-                    if(empty($this->$field)) break;
2214
+                    if(empty($this->$field)) {
2215
+                        break;
2216
+                    }
2204 2217
                     if ($this->$field == 'NULL') {
2205 2218
                     	$this->$field = '';
2206 2219
                     	break;
@@ -2212,7 +2225,9 @@  discard block
 block discarded – undo
2212 2225
                     }
2213 2226
                     break;
2214 2227
                 case 'time':
2215
-                    if(empty($this->$field)) break;
2228
+                    if(empty($this->$field)) {
2229
+                        break;
2230
+                    }
2216 2231
                     if ($this->$field == 'NULL') {
2217 2232
                     	$this->$field = '';
2218 2233
                     	break;
@@ -2301,7 +2316,9 @@  discard block
 block discarded – undo
2301 2316
 
2302 2317
         $query .= $custom_join['join'];
2303 2318
         $query .= " WHERE $this->table_name.id = ".$this->db->quoted($id);
2304
-        if ($deleted) $query .= " AND $this->table_name.deleted=0";
2319
+        if ($deleted) {
2320
+            $query .= " AND $this->table_name.deleted=0";
2321
+        }
2305 2322
         $GLOBALS['log']->debug("Retrieve $this->object_name : ".$query);
2306 2323
         $result = $this->db->limitQuery($query,0,1,true, "Retrieving record by id $this->table_name:$id found ");
2307 2324
         if(empty($result))
@@ -2358,21 +2375,23 @@  discard block
 block discarded – undo
2358 2375
             if ($def [ 'type' ] == 'relate' && isset ( $def [ 'id_name'] ) && isset ( $def [ 'link'] ) && isset ( $def[ 'save' ])) {
2359 2376
                 if (isset($this->$key)) {
2360 2377
                     $this->rel_fields_before_value[$key]=$this->$key;
2361
-                    if (isset($this->$def [ 'id_name']))
2362
-                        $this->rel_fields_before_value[$def [ 'id_name']]=$this->$def [ 'id_name'];
2378
+                    if (isset($this->$def [ 'id_name'])) {
2379
+                                            $this->rel_fields_before_value[$def [ 'id_name']]=$this->$def [ 'id_name'];
2380
+                    }
2381
+                } else {
2382
+                                    $this->rel_fields_before_value[$key]=null;
2363 2383
                 }
2364
-                else
2365
-                    $this->rel_fields_before_value[$key]=null;
2366 2384
            }
2367 2385
         }
2368 2386
         if (isset($this->relationship_fields) && is_array($this->relationship_fields))
2369 2387
         {
2370 2388
             foreach ($this->relationship_fields as $rel_id=>$rel_name)
2371 2389
             {
2372
-                if (isset($this->$rel_id))
2373
-                    $this->rel_fields_before_value[$rel_id]=$this->$rel_id;
2374
-                else
2375
-                    $this->rel_fields_before_value[$rel_id]=null;
2390
+                if (isset($this->$rel_id)) {
2391
+                                    $this->rel_fields_before_value[$rel_id]=$this->$rel_id;
2392
+                } else {
2393
+                                    $this->rel_fields_before_value[$rel_id]=null;
2394
+                }
2376 2395
             }
2377 2396
         }
2378 2397
 
@@ -2398,8 +2417,9 @@  discard block
 block discarded – undo
2398 2417
         $nullvalue='';
2399 2418
         foreach($this->field_defs as $field=>$field_value)
2400 2419
         {
2401
-            if($field == 'user_preferences' && $this->module_dir == 'Users')
2402
-                continue;
2420
+            if($field == 'user_preferences' && $this->module_dir == 'Users') {
2421
+                            continue;
2422
+            }
2403 2423
             if(isset($row[$field]))
2404 2424
             {
2405 2425
                 $this->$field = $row[$field];
@@ -2407,8 +2427,7 @@  discard block
 block discarded – undo
2407 2427
                 if(!empty($row[$owner])){
2408 2428
                     $this->$owner = $row[$owner];
2409 2429
                 }
2410
-            }
2411
-            else
2430
+            } else
2412 2431
             {
2413 2432
                 $this->$field = $nullvalue;
2414 2433
             }
@@ -2452,10 +2471,11 @@  discard block
 block discarded – undo
2452 2471
         //handle distinct clause
2453 2472
         $star = '*';
2454 2473
         if(substr_count(strtolower($query), 'distinct')){
2455
-            if (!empty($this->seed) && !empty($this->seed->table_name ))
2456
-                $star = 'DISTINCT ' . $this->seed->table_name . '.id';
2457
-            else
2458
-                $star = 'DISTINCT ' . $this->table_name . '.id';
2474
+            if (!empty($this->seed) && !empty($this->seed->table_name )) {
2475
+                            $star = 'DISTINCT ' . $this->seed->table_name . '.id';
2476
+            } else {
2477
+                            $star = 'DISTINCT ' . $this->table_name . '.id';
2478
+            }
2459 2479
 
2460 2480
         }
2461 2481
 
@@ -2476,10 +2496,11 @@  discard block
 block discarded – undo
2476 2496
                 preg_match($pattern, $union_query, $matches);
2477 2497
                 if (!empty($matches)) {
2478 2498
                     if (stristr($matches[0], "distinct")) {
2479
-                        if (!empty($this->seed) && !empty($this->seed->table_name ))
2480
-                            $star = 'DISTINCT ' . $this->seed->table_name . '.id';
2481
-                        else
2482
-                            $star = 'DISTINCT ' . $this->table_name . '.id';
2499
+                        if (!empty($this->seed) && !empty($this->seed->table_name )) {
2500
+                                                    $star = 'DISTINCT ' . $this->seed->table_name . '.id';
2501
+                        } else {
2502
+                                                    $star = 'DISTINCT ' . $this->table_name . '.id';
2503
+                        }
2483 2504
                     }
2484 2505
                 } // if
2485 2506
                 $replacement = 'SELECT count(' . $star . ') c FROM ';
@@ -2529,7 +2550,7 @@  discard block
 block discarded – undo
2529 2550
             if(!empty($owner_where)){
2530 2551
                 if(empty($where)){
2531 2552
                     $where = $owner_where;
2532
-                }else{
2553
+                } else{
2533 2554
                     $where .= ' AND '.  $owner_where;
2534 2555
                 }
2535 2556
             }
@@ -2550,14 +2571,14 @@  discard block
 block discarded – undo
2550 2571
     */
2551 2572
     public function process_order_by($order_by, $submodule = null, $suppress_table_name = false)
2552 2573
     {
2553
-        if (empty($order_by))
2554
-            return $order_by;
2574
+        if (empty($order_by)) {
2575
+                    return $order_by;
2576
+        }
2555 2577
         //submodule is empty,this is for list object in focus
2556 2578
         if (empty($submodule))
2557 2579
         {
2558 2580
             $bean_queried = $this;
2559
-        }
2560
-        else
2581
+        } else
2561 2582
         {
2562 2583
             //submodule is set, so this is for subpanel, use submodule
2563 2584
             $bean_queried = $submodule;
@@ -2652,8 +2673,7 @@  discard block
 block discarded – undo
2652 2673
             if(empty($where))
2653 2674
             {
2654 2675
                 $where = $owner_where;
2655
-            }
2656
-            else
2676
+            } else
2657 2677
             {
2658 2678
                 $where .= ' AND '.  $owner_where;
2659 2679
             }
@@ -2739,8 +2759,7 @@  discard block
 block discarded – undo
2739 2759
             if(empty($entire_where))
2740 2760
             {
2741 2761
                 $entire_where = ' WHERE ' . $where;
2742
-            }
2743
-            else
2762
+            } else
2744 2763
             {
2745 2764
                 $entire_where .= ' AND ' . $where;
2746 2765
             }
@@ -2780,16 +2799,15 @@  discard block
 block discarded – undo
2780 2799
                             }
2781 2800
                             //call function from required file
2782 2801
                             $query_array = $shortcut_function_name($parameters);
2783
-                        }else{
2802
+                        } else{
2784 2803
                             //call function from parent bean
2785 2804
                             $query_array = $parentbean->$shortcut_function_name($parameters);
2786 2805
                         }
2787
-                    }
2788
-                    else
2806
+                    } else
2789 2807
                     {
2790 2808
                         $query_array = $parentbean->$shortcut_function_name();
2791 2809
                     }
2792
-                }  else {
2810
+                } else {
2793 2811
                     $related_field_name = $this_subpanel->get_data_source_name();
2794 2812
                     if (!$parentbean->load_relationship($related_field_name)){
2795 2813
                         unset ($parentbean->$related_field_name);
@@ -2805,8 +2823,7 @@  discard block
 block discarded – undo
2805 2823
                     if(empty($where_definition))
2806 2824
                     {
2807 2825
                         $where_definition = $table_where;
2808
-                    }
2809
-                    else
2826
+                    } else
2810 2827
                     {
2811 2828
                         $where_definition .= ' AND ' . $table_where;
2812 2829
                     }
@@ -2897,8 +2914,7 @@  discard block
 block discarded – undo
2897 2914
         {
2898 2915
             $subpanel_def->load_sub_subpanels();
2899 2916
             $subpanel_list=$subpanel_def->sub_subpanels;
2900
-        }
2901
-        else
2917
+        } else
2902 2918
         {
2903 2919
             $subpanel_list[]=$subpanel_def;
2904 2920
         }
@@ -2925,7 +2941,7 @@  discard block
 block discarded – undo
2925 2941
                         }
2926 2942
                         //call function from required file
2927 2943
                         $tmp_final_query =  $shortcut_function_name($parameters);
2928
-                    }else{
2944
+                    } else{
2929 2945
                         //call function from parent bean
2930 2946
                         $tmp_final_query =  $parentbean->$shortcut_function_name($parameters);
2931 2947
                     }
@@ -2953,8 +2969,9 @@  discard block
 block discarded – undo
2953 2969
                 $query_fields = $GLOBALS['db']->getSelectFieldsFromQuery($subquery['select']);
2954 2970
                 foreach($query_fields as $field => $select)
2955 2971
                 {
2956
-                    if (!in_array($field, $all_fields))
2957
-                        $all_fields[] = $field;
2972
+                    if (!in_array($field, $all_fields)) {
2973
+                                            $all_fields[] = $field;
2974
+                    }
2958 2975
                 }
2959 2976
                 $subqueries[$i]['query_fields'] = $query_fields;
2960 2977
             }
@@ -2968,8 +2985,7 @@  discard block
 block discarded – undo
2968 2985
                     if (!isset($subquery['query_fields'][$field]))
2969 2986
                     {
2970 2987
                         $subquery['select'] .= " NULL $field,";
2971
-                    }
2972
-                    else
2988
+                    } else
2973 2989
                     {
2974 2990
                         $subquery['select'] .= " {$subquery['query_fields'][$field]},";
2975 2991
                     }
@@ -2991,12 +3007,10 @@  discard block
 block discarded – undo
2991 3007
                 if (!empty($subquery['params']['distinct']) && !empty($subpanel_def->table_name))
2992 3008
                 {
2993 3009
                     $query_rows = "( SELECT count(DISTINCT ". $subpanel_def->table_name . ".id)".  $subquery['from_min'].$query_array['join']. $subquery['where'].' )';
2994
-                }
2995
-                elseif ($select_position !== false && $distinct_position!= false)
3010
+                } elseif ($select_position !== false && $distinct_position!= false)
2996 3011
                 {
2997 3012
                     $query_rows = "( ".substr_replace($query_array['select'],"SELECT count(",$select_position,6). ")" .  $subquery['from_min'].$query_array['join']. $subquery['where'].' )';
2998
-                }
2999
-                else
3013
+                } else
3000 3014
                 {
3001 3015
                     //resort to default behavior.
3002 3016
                     $query_rows = "( SELECT count(*)".  $subquery['from_min'].$query_array['join']. $subquery['where'].' )';
@@ -3010,8 +3024,7 @@  discard block
 block discarded – undo
3010 3024
                         if (empty($subquery['where']))
3011 3025
                         {
3012 3026
                             $subquerystring.=" WHERE " .$subquery['secondary_where'];
3013
-                        }
3014
-                        else
3027
+                        } else
3015 3028
                         {
3016 3029
                             $subquerystring.=" AND " .$subquery['secondary_where'];
3017 3030
                         }
@@ -3054,8 +3067,7 @@  discard block
 block discarded – undo
3054 3067
             {
3055 3068
                 $submodule->assign_display_fields($submodule->module_dir);
3056 3069
                 $response['list'] = array($submodule);
3057
-            }
3058
-            else
3070
+            } else
3059 3071
         {
3060 3072
                 $response['list'] = array();
3061 3073
             }
@@ -3120,8 +3132,7 @@  discard block
 block discarded – undo
3120 3132
             if(empty($where))
3121 3133
             {
3122 3134
                 $where = $owner_where;
3123
-            }
3124
-            else
3135
+            } else
3125 3136
             {
3126 3137
                 $where .= ' AND '.  $owner_where;
3127 3138
             }
@@ -3168,8 +3179,7 @@  discard block
 block discarded – undo
3168 3179
         if(empty($filter))
3169 3180
         {
3170 3181
             $ret_array['select'] = " SELECT $distinct $this->table_name.* ";
3171
-        }
3172
-        else
3182
+        } else
3173 3183
         {
3174 3184
             $ret_array['select'] = " SELECT $distinct $this->table_name.id ";
3175 3185
         }
@@ -3183,8 +3193,7 @@  discard block
 block discarded – undo
3183 3193
         {
3184 3194
             $ret_array['secondary_select']=& $ret_array['select'];
3185 3195
             $ret_array['secondary_from'] = & $ret_array['from'];
3186
-        }
3187
-        else
3196
+        } else
3188 3197
         {
3189 3198
             $ret_array['secondary_select'] = '';
3190 3199
         }
@@ -3229,17 +3238,15 @@  discard block
 block discarded – undo
3229 3238
                     if(isset($this->field_defs[$field]))
3230 3239
                     {
3231 3240
                         $fields[$field]= $this->field_defs[$field];
3232
-                    }
3233
-                    else
3241
+                    } else
3234 3242
                     {
3235 3243
                         $fields[$field] = array('force_exists'=>true);
3236 3244
                     }
3237 3245
                 }
3238
-            }else{
3246
+            } else{
3239 3247
                 $fields = 	$filter;
3240 3248
             }
3241
-        }
3242
-        else
3249
+        } else
3243 3250
         {
3244 3251
             $fields = 	$this->field_defs;
3245 3252
         }
@@ -3255,8 +3262,9 @@  discard block
 block discarded – undo
3255 3262
 			$this->field_defs[$field]['source'] == 'non-db')
3256 3263
 		{
3257 3264
 			$addrelatefield = $this->get_relationship_field($field);
3258
-			if ($addrelatefield)
3259
-				$addrelate[$addrelatefield] = true;
3265
+			if ($addrelatefield) {
3266
+							$addrelate[$addrelatefield] = true;
3267
+			}
3260 3268
 		}
3261 3269
 		if(!empty($this->field_defs[$field]['id_name'])){
3262 3270
 			$addrelate[$this->field_defs[$field]['id_name']] = true;
@@ -3278,15 +3286,15 @@  discard block
 block discarded – undo
3278 3286
             {
3279 3287
                 if(!empty($filter) && isset($filter[$field]['force_exists']) && $filter[$field]['force_exists'])
3280 3288
                 {
3281
-                    if ( isset($filter[$field]['force_default']) )
3282
-                        $ret_array['select'] .= ", {$filter[$field]['force_default']} $field ";
3283
-                    else
3284
-                    //spaces are a fix for length issue problem with unions.  The union only returns the maximum number of characters from the first select statement.
3289
+                    if ( isset($filter[$field]['force_default']) ) {
3290
+                                            $ret_array['select'] .= ", {$filter[$field]['force_default']} $field ";
3291
+                    } else {
3292
+                                        //spaces are a fix for length issue problem with unions.  The union only returns the maximum number of characters from the first select statement.
3285 3293
                         $ret_array['select'] .= ", '                                                                                                                                                                                                                                                              ' $field ";
3294
+                    }
3286 3295
                 }
3287 3296
                 continue;
3288
-            }
3289
-            else
3297
+            } else
3290 3298
             {
3291 3299
                 $data = $this->field_defs[$field];
3292 3300
             }
@@ -3306,8 +3314,9 @@  discard block
 block discarded – undo
3306 3314
                     }
3307 3315
                 }
3308 3316
 		
3309
-            	if (!$process_field)
3310
-                	continue;
3317
+            	if (!$process_field) {
3318
+            	                	continue;
3319
+            	}
3311 3320
             }
3312 3321
 
3313 3322
             if(  (!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter) ))
@@ -3385,16 +3394,14 @@  discard block
 block discarded – undo
3385 3394
                     if(empty($join_type))
3386 3395
                     {
3387 3396
                         $params['join_type'] = ' LEFT JOIN ';
3388
-                    }
3389
-                    else
3397
+                    } else
3390 3398
                     {
3391 3399
                         $params['join_type'] = $join_type;
3392 3400
                     }
3393 3401
                     if(isset($data['join_name']))
3394 3402
                     {
3395 3403
                         $params['join_table_alias'] = $data['join_name'];
3396
-                    }
3397
-                    else
3404
+                    } else
3398 3405
                     {
3399 3406
                         $params['join_table_alias']	= 'jt' . $jtcount;
3400 3407
 
@@ -3402,8 +3409,7 @@  discard block
 block discarded – undo
3402 3409
                     if(isset($data['join_link_name']))
3403 3410
                     {
3404 3411
                         $params['join_table_link_alias'] = $data['join_link_name'];
3405
-                    }
3406
-                    else
3412
+                    } else
3407 3413
                     {
3408 3414
                         $params['join_table_link_alias'] = 'jtl' . $jtcount;
3409 3415
                     }
@@ -3443,8 +3449,7 @@  discard block
 block discarded – undo
3443 3449
                                 if(isset($rel_mod->field_defs['assigned_user_id']))
3444 3450
                                 {
3445 3451
                                     $ret_array['secondary_select'].= " , ".	$params['join_table_alias'] . ".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod";
3446
-                                }
3447
-                                else
3452
+                                } else
3448 3453
                                 {
3449 3454
                                     if(isset($rel_mod->field_defs['created_by']))
3450 3455
                                     {
@@ -3457,8 +3462,7 @@  discard block
 block discarded – undo
3457 3462
                         if(isset($data['db_concat_fields']))
3458 3463
                         {
3459 3464
                             $ret_array['secondary_select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field;
3460
-                        }
3461
-                        else
3465
+                        } else
3462 3466
                         {
3463 3467
                             if(!isset($data['relationship_fields']))
3464 3468
                             {
@@ -3471,7 +3475,9 @@  discard block
 block discarded – undo
3471 3475
                         }
3472 3476
                         $count_used =0;
3473 3477
                         foreach($used_join_key as $used_key) {
3474
-                            if($used_key == $join['rel_key']) $count_used++;
3478
+                            if($used_key == $join['rel_key']) {
3479
+                                $count_used++;
3480
+                            }
3475 3481
                         }
3476 3482
                         if($count_used <= 1) {//27416, the $ret_array['secondary_select'] should always generate, regardless the dbtype
3477 3483
                             // add rel_key only if it was not aready added
@@ -3485,7 +3491,9 @@  discard block
 block discarded – undo
3485 3491
                         {
3486 3492
                             foreach($data['relationship_fields'] as $r_name=>$alias_name)
3487 3493
                             {
3488
-                                if(!empty( $secondarySelectedFields[$alias_name]))continue;
3494
+                                if(!empty( $secondarySelectedFields[$alias_name])) {
3495
+                                    continue;
3496
+                                }
3489 3497
                                 $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'].'.'. $r_name .' ' . $alias_name;
3490 3498
                                 $secondarySelectedFields[$alias_name] = true;
3491 3499
                             }
@@ -3498,14 +3506,12 @@  discard block
 block discarded – undo
3498 3506
                                 $ret_array['secondary_where'] = $params['join_table_link_alias'] . '.' . $join['rel_key']. "='" .$parentbean->id . "'";
3499 3507
                             }
3500 3508
                         }
3501
-                    }
3502
-                    else
3509
+                    } else
3503 3510
                     {
3504 3511
                         if(isset($data['db_concat_fields']))
3505 3512
                         {
3506 3513
                             $ret_array['select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field;
3507
-                        }
3508
-                        else
3514
+                        } else
3509 3515
                         {
3510 3516
                             $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field;
3511 3517
                         }
@@ -3532,8 +3538,7 @@  discard block
 block discarded – undo
3532 3538
                                 if(isset($rel_mod->field_defs['assigned_user_id']))
3533 3539
                                 {
3534 3540
                                     $ret_array['select'] .= ' , ' .$params['join_table_alias'] . '.assigned_user_id ' .  $field . '_owner';
3535
-                                }
3536
-                                else
3541
+                                } else
3537 3542
                                 {
3538 3543
                                     $ret_array['select'] .= ' , ' .$params['join_table_alias'] . '.created_by ' .  $field . '_owner';
3539 3544
                                 }
@@ -3568,20 +3573,22 @@  discard block
 block discarded – undo
3568 3573
 	                       $where = preg_replace('/'.$data['name'].'/', $db_field, $where);
3569 3574
 
3570 3575
 				// For relationship fields replace their alias by the corresponsding link table and r_name
3571
-				if(isset($data['relationship_fields']))
3572
-					foreach($data['relationship_fields'] as $r_name=>$alias_name)
3576
+				if(isset($data['relationship_fields'])) {
3577
+									foreach($data['relationship_fields'] as $r_name=>$alias_name)
3573 3578
 					{
3574 3579
 						$db_field = $this->db->concat($params['join_table_link_alias'], $r_name);
3580
+				}
3575 3581
 						$where = preg_replace('/' . $alias_name . '/', $db_field, $where);
3576 3582
 					}
3577 3583
                     	}
3578
-                    }else{
3584
+                    } else{
3579 3585
                         $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.'.$data['rname'], $where);
3580 3586
 
3581 3587
 			// For relationship fields replace their alias by the corresponsding link table and r_name
3582
-			if(isset($data['relationship_fields']))
3583
-				foreach($data['relationship_fields'] as $r_name=>$alias_name)
3588
+			if(isset($data['relationship_fields'])) {
3589
+							foreach($data['relationship_fields'] as $r_name=>$alias_name)
3584 3590
 					$where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where);
3591
+			}
3585 3592
                     }
3586 3593
                     if(!$table_joined)
3587 3594
                     {
@@ -3598,8 +3605,7 @@  discard block
 block discarded – undo
3598 3605
             if(isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name.'.assigned_user_id']))
3599 3606
             {
3600 3607
                 $ret_array['select'] .= ", $this->table_name.assigned_user_id ";
3601
-            }
3602
-            else if(isset($this->field_defs['created_by']) &&  empty($selectedFields[$this->table_name.'.created_by']))
3608
+            } else if(isset($this->field_defs['created_by']) &&  empty($selectedFields[$this->table_name.'.created_by']))
3603 3609
             {
3604 3610
                 $ret_array['select'] .= ", $this->table_name.created_by ";
3605 3611
             }
@@ -3621,14 +3627,15 @@  discard block
 block discarded – undo
3621 3627
         if($show_deleted == 0)
3622 3628
         {
3623 3629
             $where_auto = "$this->table_name.deleted=0";
3624
-        }else if($show_deleted == 1)
3630
+        } else if($show_deleted == 1)
3625 3631
         {
3626 3632
             $where_auto = "$this->table_name.deleted=1";
3627 3633
         }
3628
-        if($where != "")
3629
-            $ret_array['where'] = " where ($where) AND $where_auto";
3630
-        else
3631
-            $ret_array['where'] = " where $where_auto";
3634
+        if($where != "") {
3635
+                    $ret_array['where'] = " where ($where) AND $where_auto";
3636
+        } else {
3637
+                    $ret_array['where'] = " where $where_auto";
3638
+        }
3632 3639
 
3633 3640
         //make call to process the order by clause
3634 3641
         $order_by = $this->process_order_by($order_by);
@@ -3656,8 +3663,9 @@  discard block
 block discarded – undo
3656 3663
 		foreach ($this->field_defs as $field_def => $value)
3657 3664
 		{
3658 3665
 			if (isset($value['relationship_fields']) && 
3659
-				in_array($field, $value['relationship_fields']) )
3660
-				return $field_def;
3666
+				in_array($field, $value['relationship_fields']) ) {
3667
+							return $field_def;
3668
+			}
3661 3669
 		}
3662 3670
 
3663 3671
 		return false;
@@ -3705,24 +3713,23 @@  discard block
 block discarded – undo
3705 3713
                         if(isset($field_def['db_concat_fields']))
3706 3714
                         {
3707 3715
                             $queries[$child_info['parent_type']] .= ' , ' . $this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']) . ' parent_name';
3708
-                        }
3709
-                        else
3716
+                        } else
3710 3717
                         {
3711 3718
                             $queries[$child_info['parent_type']] .= ' , name parent_name';
3712 3719
                         }
3713 3720
                         if(isset($templates[$child_info['parent_type']]->field_defs['assigned_user_id']))
3714 3721
                         {
3715 3722
                             $queries[$child_info['parent_type']] .= ", assigned_user_id parent_name_owner , '{$child_info['parent_type']}' parent_name_mod";;
3716
-                        }else if(isset($templates[$child_info['parent_type']]->field_defs['created_by']))
3723
+                        } else if(isset($templates[$child_info['parent_type']]->field_defs['created_by']))
3717 3724
                         {
3718 3725
                             $queries[$child_info['parent_type']] .= ", created_by parent_name_owner, '{$child_info['parent_type']}' parent_name_mod";
3719 3726
                         }
3720 3727
                         $queries[$child_info['parent_type']] .= " FROM " . $templates[$child_info['parent_type']]->table_name ." WHERE id IN ('{$child_info['parent_id']}'";
3721
-                    }
3722
-                    else
3728
+                    } else
3723 3729
                     {
3724
-                        if(empty($parent_child_map[$child_info['parent_id']]))
3725
-                        $queries[$child_info['parent_type']] .= " ,'{$child_info['parent_id']}'";
3730
+                        if(empty($parent_child_map[$child_info['parent_id']])) {
3731
+                                                $queries[$child_info['parent_type']] .= " ,'{$child_info['parent_id']}'";
3732
+                        }
3726 3733
                     }
3727 3734
                     $parent_child_map[$child_info['parent_id']][] = $child_info['child_id'];
3728 3735
                 }
@@ -3795,8 +3802,7 @@  discard block
 block discarded – undo
3795 3802
                     $row_offset = (floor(($rows_found -1) / $limit)) * $limit;
3796 3803
                 }
3797 3804
             }
3798
-        }
3799
-        else
3805
+        } else
3800 3806
         {
3801 3807
             if((empty($limit) || $limit == -1))
3802 3808
             {
@@ -3813,8 +3819,7 @@  discard block
 block discarded – undo
3813 3819
         if(!empty($limit) && $limit != -1 && $limit != -99)
3814 3820
         {
3815 3821
             $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $this->object_name list: ");
3816
-        }
3817
-        else
3822
+        } else
3818 3823
         {
3819 3824
             $result = $db->query($query,true,"Error retrieving $this->object_name list: ");
3820 3825
         }
@@ -3831,7 +3836,9 @@  discard block
 block discarded – undo
3831 3836
             while ($max_per_page == -99 || ($index < $row_offset + $max_per_page))
3832 3837
             {
3833 3838
                 $row = $db->fetchByAssoc($result);
3834
-                if (empty($row)) break;
3839
+                if (empty($row)) {
3840
+                    break;
3841
+                }
3835 3842
 
3836 3843
                 //instantiate a new class each time. This is because php5 passes
3837 3844
                 //by reference by default so if we continually update $this, we will
@@ -3851,11 +3858,10 @@  discard block
 block discarded – undo
3851 3858
                         }
3852 3859
 
3853 3860
                         $GLOBALS['log']->debug("$temp->object_name({$row['id']}): ".$field." = ".$temp->$field);
3854
-                    }else if (isset($row[$this->table_name .'.'.$field]))
3861
+                    } else if (isset($row[$this->table_name .'.'.$field]))
3855 3862
                     {
3856 3863
                         $temp->$field = $row[$this->table_name .'.'.$field];
3857
-                    }
3858
-                    else
3864
+                    } else
3859 3865
                     {
3860 3866
                         $temp->$field = "";
3861 3867
                     }
@@ -3863,7 +3869,9 @@  discard block
 block discarded – undo
3863 3869
 
3864 3870
                 $temp->check_date_relationships_load();
3865 3871
                 $temp->fill_in_additional_list_fields();
3866
-                if($temp->hasCustomFields()) $temp->custom_fields->fill_relationships();
3872
+                if($temp->hasCustomFields()) {
3873
+                    $temp->custom_fields->fill_relationships();
3874
+                }
3867 3875
                 $temp->call_custom_logic("process_record");
3868 3876
 
3869 3877
                 // fix defect #44206. implement the same logic as sugar_currency_format
@@ -3910,8 +3918,9 @@  discard block
 block discarded – undo
3910 3918
         if (!$is_count_query)
3911 3919
         {
3912 3920
             $count_query = SugarBean::create_list_count_query($query);
3913
-        } else
3914
-            $count_query=$query;
3921
+        } else {
3922
+                    $count_query=$query;
3923
+        }
3915 3924
 
3916 3925
         $result = $this->db->query($count_query, true, "Error running count query for $this->object_name List: ");
3917 3926
         $row_num = 0;
@@ -3984,8 +3993,7 @@  discard block
 block discarded – undo
3984 3993
                 $row_offset = (floor(($rows_found -1) / $limit)) * $limit;
3985 3994
 
3986 3995
             }
3987
-        }
3988
-        else
3996
+        } else
3989 3997
         {
3990 3998
             if((empty($limit) || $limit == -1))
3991 3999
             {
@@ -4007,8 +4015,7 @@  discard block
 block discarded – undo
4007 4015
             if(!empty($limit) && $limit != -1 && $limit != -99)
4008 4016
             {
4009 4017
                 $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $parent_bean->object_name list: ");
4010
-            }
4011
-            else
4018
+            } else
4012 4019
             {
4013 4020
                 $result = $db->query($query,true,"Error retrieving $this->object_name list: ");
4014 4021
             }
@@ -4054,13 +4061,11 @@  discard block
 block discarded – undo
4054 4061
                             {
4055 4062
                                 $current_bean->$field = $this->convertField($row[$field], $value);
4056 4063
                                 unset($row[$field]);
4057
-                            }
4058
-                            else if (isset($row[$this->table_name .'.'.$field]))
4064
+                            } else if (isset($row[$this->table_name .'.'.$field]))
4059 4065
                             {
4060 4066
                                 $current_bean->$field = $this->convertField($row[$this->table_name .'.'.$field], $value);
4061 4067
                                 unset($row[$this->table_name .'.'.$field]);
4062
-                            }
4063
-                            else
4068
+                            } else
4064 4069
                             {
4065 4070
                                 $current_bean->$field = "";
4066 4071
                                 unset($row[$field]);
@@ -4084,8 +4089,7 @@  discard block
 block discarded – undo
4084 4089
                             {
4085 4090
                                 $execute_function[] = 	$value['function_class'];
4086 4091
                                 $execute_function[] = 	$value['function_name'];
4087
-                            }
4088
-                            else
4092
+                            } else
4089 4093
                             {
4090 4094
                                 $execute_function	= $value['function_name'];
4091 4095
                             }
@@ -4098,8 +4102,7 @@  discard block
 block discarded – undo
4098 4102
                                         $can_execute = false;
4099 4103
                                     } else if($param == '$this') {
4100 4104
                                         $execute_params[] = $this;
4101
-                                    }
4102
-                                    else
4105
+                                    } else
4103 4106
                                     {
4104 4107
                                         $execute_params[] = $this->$param;
4105 4108
                                     }
@@ -4110,13 +4113,11 @@  discard block
 block discarded – undo
4110 4113
                                         $can_execute = false;
4111 4114
                                     } else if($param == '$this') {
4112 4115
                                         $execute_params[] = $current_bean;
4113
-                                    }
4114
-                                    else
4116
+                                    } else
4115 4117
                                     {
4116 4118
                                         $execute_params[] = $current_bean->$param;
4117 4119
                                     }
4118
-                                }
4119
-                                else
4120
+                                } else
4120 4121
                                 {
4121 4122
                                     $can_execute = false;
4122 4123
                                 }
@@ -4177,8 +4178,7 @@  discard block
 block discarded – undo
4177 4178
             if(isset($post_retrieve))
4178 4179
             {
4179 4180
                 $parent_fields = $this->retrieve_parent_fields($post_retrieve);
4180
-            }
4181
-            else
4181
+            } else
4182 4182
             {
4183 4183
                 $parent_fields = array();
4184 4184
             }
@@ -4197,8 +4197,7 @@  discard block
 block discarded – undo
4197 4197
                     $previous_offset++;
4198 4198
                 }
4199 4199
             }
4200
-        }
4201
-        else
4200
+        } else
4202 4201
         {
4203 4202
             $row_found 	= 0;
4204 4203
             $parent_fields = array();
@@ -4267,8 +4266,9 @@  discard block
 block discarded – undo
4267 4266
 
4268 4267
         $response = Array();
4269 4268
         $response['bean'] = $this;
4270
-        if (empty($total_rows))
4271
-            $total_rows=0;
4269
+        if (empty($total_rows)) {
4270
+                    $total_rows=0;
4271
+        }
4272 4272
         $response['row_count'] = $total_rows;
4273 4273
         $response['next_offset'] = $next_offset;
4274 4274
         $response['previous_offset'] = $previous_offset;
@@ -4311,8 +4311,7 @@  discard block
 block discarded – undo
4311 4311
                 {
4312 4312
                     $bean->$field = $row[$field];
4313 4313
                     $GLOBALS['log']->debug("process_full_list: $bean->object_name({$row['id']}): ".$field." = ".$bean->$field);
4314
-                }
4315
-                else
4314
+                } else
4316 4315
                 {
4317 4316
                     $bean->$field = '';
4318 4317
                 }
@@ -4329,8 +4328,11 @@  discard block
 block discarded – undo
4329 4328
             $list[] = $bean;
4330 4329
         }
4331 4330
         //}
4332
-        if (isset($list)) return $list;
4333
-        else return null;
4331
+        if (isset($list)) {
4332
+            return $list;
4333
+        } else {
4334
+            return null;
4335
+        }
4334 4336
     }
4335 4337
 
4336 4338
     /**
@@ -4394,10 +4396,12 @@  discard block
 block discarded – undo
4394 4396
             $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
4395 4397
 
4396 4398
         }
4397
-		if(!empty($this->field_defs['created_by']) && !empty($this->created_by))
4398
-		$this->created_by_name = get_assigned_user_name($this->created_by);
4399
-		if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id))
4400
-		$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
4399
+		if(!empty($this->field_defs['created_by']) && !empty($this->created_by)) {
4400
+				$this->created_by_name = get_assigned_user_name($this->created_by);
4401
+		}
4402
+		if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) {
4403
+				$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
4404
+		}
4401 4405
 
4402 4406
 		if(!empty($this->field_defs['parent_name'])){
4403 4407
 			$this->fill_in_additional_parent_fields();
@@ -4412,7 +4416,7 @@  discard block
 block discarded – undo
4412 4416
 
4413 4417
         if(!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id){
4414 4418
             return false;
4415
-        }else{
4419
+        } else{
4416 4420
             $this->parent_name = '';
4417 4421
         }
4418 4422
         if(!empty($this->parent_type)) {
@@ -4442,8 +4446,9 @@  discard block
 block discarded – undo
4442 4446
         {
4443 4447
             $list=$this->$linkFieldName->get();
4444 4448
             $this->$idField = '' ; // match up with null value in $this->populateFromRow()
4445
-            if (!empty($list))
4446
-                $this->$idField = $list[0];
4449
+            if (!empty($list)) {
4450
+                            $this->$idField = $list[0];
4451
+            }
4447 4452
         }
4448 4453
     }
4449 4454
 
@@ -4452,11 +4457,13 @@  discard block
 block discarded – undo
4452 4457
     */
4453 4458
     function fill_in_relationship_fields(){
4454 4459
         global $fill_in_rel_depth;
4455
-        if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0)
4456
-            $fill_in_rel_depth = 0;
4460
+        if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) {
4461
+                    $fill_in_rel_depth = 0;
4462
+        }
4457 4463
 
4458
-        if($fill_in_rel_depth > 1)
4459
-            return;
4464
+        if($fill_in_rel_depth > 1) {
4465
+                    return;
4466
+        }
4460 4467
 
4461 4468
         $fill_in_rel_depth++;
4462 4469
 
@@ -4498,13 +4505,13 @@  discard block
 block discarded – undo
4498 4505
                     }
4499 4506
                     if(!empty($this->$id_name) && isset($this->$name))
4500 4507
                     {
4501
-                        if(!isset($field['additionalFields']))
4502
-                           $field['additionalFields'] = array();
4508
+                        if(!isset($field['additionalFields'])) {
4509
+                                                   $field['additionalFields'] = array();
4510
+                        }
4503 4511
                         if(!empty($field['rname']))
4504 4512
                         {
4505 4513
                             $field['additionalFields'][$field['rname']]= $name;
4506
-                        }
4507
-                        else
4514
+                        } else
4508 4515
                         {
4509 4516
                             $field['additionalFields']['name']= $name;
4510 4517
                         }
@@ -4539,8 +4546,7 @@  discard block
 block discarded – undo
4539 4546
 		if(isset($_SESSION['show_deleted']))
4540 4547
 		{
4541 4548
 			$this->mark_undeleted($id);
4542
-		}
4543
-		else
4549
+		} else
4544 4550
 		{
4545 4551
 			// call the custom business logic
4546 4552
 			$custom_logic_arguments['id'] = $id;
@@ -4802,8 +4808,7 @@  discard block
 block discarded – undo
4802 4808
         if(!empty($row_offset) && $row_offset != 0 && !empty($limit) && $limit != -1)
4803 4809
         {
4804 4810
             $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $template->object_name list: ");
4805
-        }
4806
-        else
4811
+        } else
4807 4812
         {
4808 4813
             $result = $db->query($query, true);
4809 4814
         }
@@ -4872,8 +4877,7 @@  discard block
 block discarded – undo
4872 4877
     if (!empty($limit))
4873 4878
     {
4874 4879
         $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $this->object_name list: ");
4875
-    }
4876
-    else
4880
+    } else
4877 4881
     {
4878 4882
         $result = $db->query($query, true);
4879 4883
     }
@@ -4919,8 +4923,7 @@  discard block
 block discarded – undo
4919 4923
             if(empty($ids))
4920 4924
             {
4921 4925
                 $ids = "('" . $row['id'] . "'";
4922
-            }
4923
-            else
4926
+            } else
4924 4927
             {
4925 4928
                 $ids .= ",'" . $row['id'] . "'";
4926 4929
             }
@@ -4928,7 +4931,7 @@  discard block
 block discarded – undo
4928 4931
         if(empty($ids))
4929 4932
         {
4930 4933
             $ids = "('')";
4931
-        }else{
4934
+        } else{
4932 4935
             $ids .= ')';
4933 4936
         }
4934 4937
 
@@ -5000,10 +5003,12 @@  discard block
 block discarded – undo
5000 5003
             if(isset($this->$field)){
5001 5004
 
5002 5005
                 // cn: bug 12270 - sensitive fields being passed arbitrarily in listViews
5003
-                if(isset($sensitiveFields[$field]))
5004
-                    continue;
5005
-                if(!isset($cache[$field]))
5006
-                    $cache[$field] = strtoupper($field);
5006
+                if(isset($sensitiveFields[$field])) {
5007
+                                    continue;
5008
+                }
5009
+                if(!isset($cache[$field])) {
5010
+                                    $cache[$field] = strtoupper($field);
5011
+                }
5007 5012
 
5008 5013
                 //Fields hidden by Dependent Fields
5009 5014
                 if (isset($value['hidden']) && $value['hidden'] === true) {
@@ -5020,18 +5025,17 @@  discard block
 block discarded – undo
5020 5025
                     elseif(!empty($value['options']) && !empty($mod_strings[$value['options']][$this->$field]))
5021 5026
                     {
5022 5027
                         $return_array[$cache[$field]] = $mod_strings[$value['options']][$this->$field];
5023
-                    }
5024
-                    else{
5028
+                    } else{
5025 5029
                         $return_array[$cache[$field]] = $this->$field;
5026 5030
                     }
5027 5031
                     //end bug 21672
5028 5032
 // tjy: no need to do this str_replace as the changes in 29994 for ListViewGeneric.tpl for translation handle this now
5029 5033
 //				}elseif(!empty($value['type']) && $value['type'] == 'multienum'&& empty($value['function'])){
5030 5034
 //					$return_array[strtoupper($field)] = str_replace('^,^', ', ', $this->$field );
5031
-                }elseif(!empty($value['custom_module']) && $value['type'] != 'currency'){
5035
+                } elseif(!empty($value['custom_module']) && $value['type'] != 'currency'){
5032 5036
 //					$this->format_field($value);
5033 5037
                     $return_array[$cache[$field]] = $this->$field;
5034
-                }else{
5038
+                } else{
5035 5039
                     $return_array[$cache[$field]] = $this->$field;
5036 5040
                 }
5037 5041
                 // handle "Assigned User Name"
@@ -5150,23 +5154,29 @@  discard block
 block discarded – undo
5150 5154
     }
5151 5155
 
5152 5156
     function getRelatedFields($module, $id, $fields, $return_array = false){
5153
-        if(empty($GLOBALS['beanList'][$module]))return '';
5157
+        if(empty($GLOBALS['beanList'][$module])) {
5158
+            return '';
5159
+        }
5154 5160
         $object = BeanFactory::getObjectName($module);
5155 5161
 
5156 5162
         VardefManager::loadVardef($module, $object);
5157
-        if(empty($GLOBALS['dictionary'][$object]['table']))return '';
5163
+        if(empty($GLOBALS['dictionary'][$object]['table'])) {
5164
+            return '';
5165
+        }
5158 5166
         $table = $GLOBALS['dictionary'][$object]['table'];
5159 5167
         $query  = 'SELECT id';
5160 5168
         foreach($fields as $field=>$alias){
5161 5169
             if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])){
5162 5170
                 $query .= ' ,' .$this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) .  ' as ' . $alias ;
5163
-            }else if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]) &&
5171
+            } else if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]) &&
5164 5172
                 (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) ||
5165 5173
                 $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db"))
5166 5174
             {
5167 5175
                 $query .= ' ,' .$table . '.' . $field . ' as ' . $alias;
5168 5176
             }
5169
-            if(!$return_array)$this->$alias = '';
5177
+            if(!$return_array) {
5178
+                $this->$alias = '';
5179
+            }
5170 5180
         }
5171 5181
         if($query == 'SELECT id' || empty($id)){
5172 5182
             return '';
@@ -5177,8 +5187,7 @@  discard block
 block discarded – undo
5177 5187
         {
5178 5188
             $query .= " , ".	$table  . ".assigned_user_id owner";
5179 5189
 
5180
-        }
5181
-        else if(isset($GLOBALS['dictionary'][$object]['fields']['created_by']))
5190
+        } else if(isset($GLOBALS['dictionary'][$object]['fields']['created_by']))
5182 5191
         {
5183 5192
             $query .= " , ".	$table . ".created_by owner";
5184 5193
 
@@ -5214,8 +5223,9 @@  discard block
 block discarded – undo
5214 5223
         {
5215 5224
             if(isset($this->field_name_map[$field]) && empty($this->$field))
5216 5225
             {
5217
-                if($this->field_name_map[$field]['type'] != 'date' && $this->field_name_map[$field]['type'] != 'enum')
5218
-                $this->$field = $field;
5226
+                if($this->field_name_map[$field]['type'] != 'date' && $this->field_name_map[$field]['type'] != 'enum') {
5227
+                                $this->$field = $field;
5228
+                }
5219 5229
                 if($this->field_name_map[$field]['type'] == 'date')
5220 5230
                 {
5221 5231
                     $this->$field = $timedate->to_display_date('1980-07-09');
@@ -5290,8 +5300,7 @@  discard block
 block discarded – undo
5290 5300
             $query = "INSERT INTO $table (id, ". implode(',', array_keys($relate_values)) . ", date_modified) VALUES ('" . create_guid() . "', " . "'" . implode("', '", $relate_values) . "', ".$date_modified.")" ;
5291 5301
 
5292 5302
             $this->db->query($query, false, "Creating Relationship:" . $query);
5293
-        }
5294
-        else if ($do_update)
5303
+        } else if ($do_update)
5295 5304
         {
5296 5305
             $conds = array();
5297 5306
             foreach($data_values as $key=>$value)
@@ -5370,10 +5379,12 @@  discard block
 block discarded – undo
5370 5379
         if(!isset($this->processed) || $this->processed == false){
5371 5380
             //add some logic to ensure we do not get into an infinite loop
5372 5381
             if(!empty($this->logicHookDepth[$event])) {
5373
-                if($this->logicHookDepth[$event] > $this->max_logic_depth)
5374
-                    return;
5375
-            }else
5376
-                $this->logicHookDepth[$event] = 0;
5382
+                if($this->logicHookDepth[$event] > $this->max_logic_depth) {
5383
+                                    return;
5384
+                }
5385
+            } else {
5386
+                            $this->logicHookDepth[$event] = 0;
5387
+            }
5377 5388
 
5378 5389
             //we have to put the increment operator here
5379 5390
             //otherwise we may never increase the depth for that event in the case
@@ -5403,16 +5414,13 @@  discard block
 block discarded – undo
5403 5414
         if ($this->custom_fields->avail_fields[$name]['ext1'])
5404 5415
         {
5405 5416
             $realKey = 'ext1';
5406
-        }
5407
-        elseif ($this->custom_fields->avail_fields[$name]['ext2'])
5417
+        } elseif ($this->custom_fields->avail_fields[$name]['ext2'])
5408 5418
         {
5409 5419
             $realKey = 'ext2';
5410
-        }
5411
-        elseif ($this->custom_fields->avail_fields[$name]['ext3'])
5420
+        } elseif ($this->custom_fields->avail_fields[$name]['ext3'])
5412 5421
         {
5413 5422
             $realKey = 'ext3';
5414
-        }
5415
-        else
5423
+        } else
5416 5424
         {
5417 5425
             $GLOBALS['log']->fatal("SUGARBEAN: cannot find Real Key for custom field of type dropdown - cannot return Value.");
5418 5426
             return false;
@@ -5446,9 +5454,11 @@  discard block
 block discarded – undo
5446 5454
 		/**
5447 5455
         if($is_owner == 'not_set')
5448 5456
 		*/
5449
-    	if($is_owner === 'not_set') //eggsurplus: should be ===
5457
+    	if($is_owner === 'not_set') {
5458
+    	    //eggsurplus: should be ===
5450 5459
         {
5451 5460
             $not_set = true;
5461
+    	}
5452 5462
             $is_owner = $this->isOwner($current_user->id);
5453 5463
         }
5454 5464
 		// DJM - OBS Customizations - May 2009
@@ -5499,8 +5509,9 @@  discard block
 block discarded – undo
5499 5509
 			// DJM - OBS Customizations - END CHANGE
5500 5510
     	}
5501 5511
         //if we don't implent acls return true
5502
-        if(!$this->bean_implements('ACL'))
5503
-        return true;
5512
+        if(!$this->bean_implements('ACL')) {
5513
+                return true;
5514
+        }
5504 5515
         $view = strtolower($view);
5505 5516
         switch ($view)
5506 5517
         {
@@ -5518,7 +5529,7 @@  discard block
 block discarded – undo
5518 5529
                     $temp = new $class();
5519 5530
                     if(!empty($this->fetched_row) && !empty($this->fetched_row['id']) && !empty($this->fetched_row['assigned_user_id']) && !empty($this->fetched_row['created_by'])){
5520 5531
                         $temp->populateFromRow($this->fetched_row);
5521
-                    }else{
5532
+                    } else{
5522 5533
                         $temp->retrieve($this->id);
5523 5534
                     }
5524 5535
                     $is_owner = $temp->isOwner($current_user->id);
@@ -5597,10 +5608,11 @@  discard block
 block discarded – undo
5597 5608
             }
5598 5609
             return false;
5599 5610
         } elseif (isset($this->assigned_user_id)) {
5600
-            if($this->assigned_user_id == $user_id) return true;
5611
+            if($this->assigned_user_id == $user_id) {
5612
+                return true;
5613
+            }
5601 5614
             return false;
5602
-        }
5603
-        else
5615
+        } else
5604 5616
         {
5605 5617
             //other wise if there is a created_by that is the owner
5606 5618
             if(isset($this->created_by) && $this->created_by == $user_id)
@@ -5642,8 +5654,7 @@  discard block
 block discarded – undo
5642 5654
         if($this->ACLAccess('DetailView'))
5643 5655
         {
5644 5656
             $array_assign['MAIN'] = 'a';
5645
-        }
5646
-        else
5657
+        } else
5647 5658
         {
5648 5659
             $array_assign['MAIN'] = 'span';
5649 5660
         }
@@ -5662,20 +5673,20 @@  discard block
 block discarded – undo
5662 5673
 
5663 5674
         foreach($this->field_defs as $field=>$data)
5664 5675
         {
5665
-            if( !$dbOnly || !isset($data['source']) || $data['source'] == 'db')
5666
-            if(!$stringOnly || is_string($this->$field))
5676
+            if( !$dbOnly || !isset($data['source']) || $data['source'] == 'db') {
5677
+                        if(!$stringOnly || is_string($this->$field))
5667 5678
             if($upperKeys)
5668 5679
             {
5669 5680
                                 if(!isset($cache[$field])){
5670 5681
                                     $cache[$field] = strtoupper($field);
5682
+            }
5671 5683
                                 }
5672 5684
                 $arr[$cache[$field]] = $this->$field;
5673
-            }
5674
-            else
5685
+            } else
5675 5686
             {
5676 5687
                 if(isset($this->$field)){
5677 5688
                     $arr[$field] = $this->$field;
5678
-                }else{
5689
+                } else{
5679 5690
                     $arr[$field] = '';
5680 5691
                 }
5681 5692
             }
@@ -5750,7 +5761,9 @@  discard block
 block discarded – undo
5750 5761
 
5751 5762
         $this->fill_in_additional_list_fields();
5752 5763
 
5753
-        if($this->hasCustomFields())$this->custom_fields->fill_relationships();
5764
+        if($this->hasCustomFields()) {
5765
+            $this->custom_fields->fill_relationships();
5766
+        }
5754 5767
         $this->call_custom_logic("process_record");
5755 5768
     }
5756 5769
 
@@ -5843,7 +5856,10 @@  discard block
 block discarded – undo
5843 5856
  */
5844 5857
     function decrypt_after_retrieve($value)
5845 5858
     {
5846
-        if(empty($value)) return $value; // no need to decrypt empty
5859
+        if(empty($value)) {
5860
+            return $value;
5861
+        }
5862
+        // no need to decrypt empty
5847 5863
         require_once("include/utils/encryption_utils.php");
5848 5864
         return blowfishDecode($this->getEncryptKey(), $value);
5849 5865
     }
@@ -5870,16 +5886,14 @@  discard block
 block discarded – undo
5870 5886
                     $_SESSION['o_lock_save'] = $saveform;
5871 5887
                     header('Location: index.php?module=OptimisticLock&action=LockResolve');
5872 5888
                     die();
5873
-                }
5874
-                else
5889
+                } else
5875 5890
                 {
5876 5891
                     unset ($_SESSION['o_lock_object']);
5877 5892
                     unset ($_SESSION['o_lock_id']);
5878 5893
                     unset ($_SESSION['o_lock_dm']);
5879 5894
                 }
5880 5895
             }
5881
-        }
5882
-        else
5896
+        } else
5883 5897
         {
5884 5898
             if(isset($_SESSION['o_lock_object']))	{ unset ($_SESSION['o_lock_object']); }
5885 5899
             if(isset($_SESSION['o_lock_id']))		{ unset ($_SESSION['o_lock_id']); }
@@ -5894,9 +5908,11 @@  discard block
 block discarded – undo
5894 5908
     */
5895 5909
     private function _sendNotifications($check_notify){
5896 5910
         if($check_notify || (isset($this->notify_inworkflow) && $this->notify_inworkflow == true) // cn: bug 5795 - no invites sent to Contacts, and also bug 25995, in workflow, it will set the notify_on_save=true.
5897
-           && !$this->isOwner($this->created_by) )  // cn: bug 42727 no need to send email to owner (within workflow)
5911
+           && !$this->isOwner($this->created_by) ) {
5912
+            // cn: bug 42727 no need to send email to owner (within workflow)
5898 5913
         {
5899 5914
             $admin = new Administration();
5915
+        }
5900 5916
             $admin->retrieveSettings();
5901 5917
             $sendNotifications = false;
5902 5918
 
@@ -5904,13 +5920,11 @@  discard block
 block discarded – undo
5904 5920
             {
5905 5921
                 $GLOBALS['log']->info("Notifications: user assignment has changed, checking if user receives notifications");
5906 5922
                 $sendNotifications = true;
5907
-            }
5908
-            elseif(isset($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == 1)
5923
+            } elseif(isset($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == 1)
5909 5924
             {
5910 5925
                 // cn: bug 5795 Send Invites failing for Contacts
5911 5926
                 $sendNotifications = true;
5912
-            }
5913
-            else
5927
+            } else
5914 5928
             {
5915 5929
                 $GLOBALS['log']->info("Notifications: not sending e-mail, notify_on is set to OFF");
5916 5930
             }
@@ -6116,8 +6130,7 @@  discard block
 block discarded – undo
6116 6130
             !empty($this->field_defs['email_addresses_non_primary']) && $this->field_defs['email_addresses_non_primary']['type'] == 'email')
6117 6131
         {
6118 6132
             return true;
6119
-        }
6120
-        else
6133
+        } else
6121 6134
         {
6122 6135
             return false;
6123 6136
         }
Please login to merge, or discard this patch.
data/Relationships/SugarRelationship.php 1 patch
Braces   +34 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -135,8 +137,7 @@  discard block
 block discarded – undo
135 137
             if ($link->getSide() == REL_LHS)
136 138
             {
137 139
                 $sub_result = $this->remove($focus, $relBean);
138
-            }
139
-            else
140
+            } else
140 141
             {
141 142
                 $sub_result = $this->remove($relBean, $focus);
142 143
             }
@@ -202,8 +203,10 @@  discard block
 block discarded – undo
202 203
     protected function addRow($row)
203 204
     {
204 205
         $existing = $this->checkExisting($row);
205
-        if (!empty($existing)) //Update the existing row, overriding the values with those passed in
206
+        if (!empty($existing)) {
207
+            //Update the existing row, overriding the values with those passed in
206 208
             return $this->updateRow($existing['id'], array_merge($existing, $row));
209
+        }
207 210
 
208 211
         $values = array();
209 212
         foreach($this->getFields() as  $def)
@@ -232,7 +235,9 @@  discard block
 block discarded – undo
232 235
     {
233 236
         $newVals = array();
234 237
         //Unset the ID since we are using it to update the row
235
-        if (isset($values['id'])) unset($values['id']);
238
+        if (isset($values['id'])) {
239
+            unset($values['id']);
240
+        }
236 241
         foreach($values as $field => $val)
237 242
         {
238 243
             $newVals[] = "$field='$val'";
@@ -252,8 +257,9 @@  discard block
 block discarded – undo
252 257
      */
253 258
     protected function removeRow($where)
254 259
     {
255
-        if (empty($where))
256
-            return false;
260
+        if (empty($where)) {
261
+                    return false;
262
+        }
257 263
 
258 264
         $date_modified = TimeDate::getInstance()->getNow()->asDb();
259 265
         $stringSets = array();
@@ -278,8 +284,9 @@  discard block
 block discarded – undo
278 284
     {
279 285
         $leftIDName = $this->def['join_key_lhs'];
280 286
         $rightIDName = $this->def['join_key_rhs'];
281
-        if (empty($row[$leftIDName]) ||  empty($row[$rightIDName]))
282
-            return false;
287
+        if (empty($row[$leftIDName]) ||  empty($row[$rightIDName])) {
288
+                    return false;
289
+        }
283 290
 
284 291
         $leftID = $row[$leftIDName];
285 292
         $rightID = $row[$rightIDName];
@@ -308,14 +315,16 @@  discard block
 block discarded – undo
308 315
     {
309 316
         $ignore_role_filter = $ignore_role_filter || $this->ignore_role_filter;
310 317
         $roleCheck = "";
311
-        if (empty ($table))
312
-            $table = $this->getRelationshipTable();
318
+        if (empty ($table)) {
319
+                    $table = $this->getRelationshipTable();
320
+        }
313 321
         if (!empty($this->def['relationship_role_column']) && !empty($this->def["relationship_role_column_value"]) && !$ignore_role_filter )
314 322
         {
315
-            if (empty($table))
316
-                $roleCheck = " AND $this->relationship_role_column";
317
-            else
318
-                $roleCheck = " AND $table.{$this->relationship_role_column}";
323
+            if (empty($table)) {
324
+                            $roleCheck = " AND $this->relationship_role_column";
325
+            } else {
326
+                            $roleCheck = " AND $table.{$this->relationship_role_column}";
327
+            }
319 328
             //role column value.
320 329
             if (empty($this->def['relationship_role_column_value']))
321 330
             {
@@ -406,8 +415,9 @@  discard block
 block discarded – undo
406 415
     protected function getOptionalWhereClause($optional_array) {
407 416
         //lhs_field, operator, and rhs_value must be set in optional_array
408 417
         foreach(array("lhs_field", "operator", "rhs_value") as $required){
409
-            if (empty($optional_array[$required]))
410
-                return "";
418
+            if (empty($optional_array[$required])) {
419
+                            return "";
420
+            }
411 421
         }
412 422
 
413 423
         return $optional_array['lhs_field']."".$optional_array['operator']."'".$optional_array['rhs_value']."'";
@@ -445,8 +455,7 @@  discard block
 block discarded – undo
445 455
                 if (empty($bean->deleted) && empty($bean->in_save))
446 456
                 {
447 457
                     $bean->save();
448
-                }
449
-                else
458
+                } else
450 459
                 {
451 460
                     // Bug 55942 save the in-save id which will be used to send workflow alert later
452 461
                     if (isset($bean->id) && !empty($_SESSION['WORKFLOW_ALERTS']))
@@ -479,8 +488,9 @@  discard block
 block discarded – undo
479 488
 
480 489
     public function __get($name)
481 490
     {
482
-        if (isset($this->def[$name]))
483
-            return $this->def[$name];
491
+        if (isset($this->def[$name])) {
492
+                    return $this->def[$name];
493
+        }
484 494
 
485 495
         switch($name)
486 496
         {
@@ -500,8 +510,9 @@  discard block
 block discarded – undo
500 510
                 return array('lhs_table', 'lhs_key', 'rhs_module', 'rhs_table', 'rhs_key', 'relationship_type');
501 511
         }
502 512
 
503
-        if (isset($this->$name))
504
-            return $this->$name;
513
+        if (isset($this->$name)) {
514
+                    return $this->$name;
515
+        }
505 516
 
506 517
         return null;
507 518
     }
Please login to merge, or discard this patch.
data/Relationships/One2OneBeanRelationship.php 1 patch
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -72,11 +74,13 @@  discard block
 block discarded – undo
72 74
     protected function updateLinks($lhs, $lhsLinkName, $rhs, $rhsLinkName)
73 75
     {
74 76
         //RHS and LHS only ever have one bean
75
-        if (isset($lhs->$lhsLinkName))
76
-            $lhs->$lhsLinkName->beans = array($rhs->id => $rhs);
77
+        if (isset($lhs->$lhsLinkName)) {
78
+                    $lhs->$lhsLinkName->beans = array($rhs->id => $rhs);
79
+        }
77 80
 
78
-        if (isset($rhs->$rhsLinkName))
79
-            $rhs->$rhsLinkName->beans = array($lhs->id => $lhs);
81
+        if (isset($rhs->$rhsLinkName)) {
82
+                    $rhs->$rhsLinkName->beans = array($lhs->id => $lhs);
83
+        }
80 84
     }
81 85
 
82 86
     public function getJoin($link, $params = array(), $return_array = false)
Please login to merge, or discard this patch.
data/Relationships/One2MBeanRelationship.php 1 patch
Braces   +39 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -66,7 +68,9 @@  discard block
 block discarded – undo
66 68
         // test to see if the relationship exist if the relationship between the two beans
67 69
         // exist then we just fail out with false as we don't want to re-trigger this
68 70
         // the save and such as it causes problems with the related() in sugarlogic
69
-        if($this->relationship_exists($lhs, $rhs) && !empty($GLOBALS['resavingRelatedBeans'])) return false;
71
+        if($this->relationship_exists($lhs, $rhs) && !empty($GLOBALS['resavingRelatedBeans'])) {
72
+            return false;
73
+        }
70 74
 
71 75
         $lhsLinkName = $this->lhsLink;
72 76
         $rhsLinkName = $this->rhsLink;
@@ -79,8 +83,9 @@  discard block
 block discarded – undo
79 83
             $prevRelated = $oldLink->getBeans(null);
80 84
             foreach($prevRelated as $oldLHS)
81 85
             {
82
-                if ($oldLHS->id != $lhs->id)
83
-                    $this->remove($oldLHS, $rhs, false);
86
+                if ($oldLHS->id != $lhs->id) {
87
+                                    $this->remove($oldLHS, $rhs, false);
88
+                }
84 89
             }
85 90
         }
86 91
 
@@ -111,19 +116,22 @@  discard block
 block discarded – undo
111 116
 
112 117
         //One2MBean relationships require that the RHS bean be saved or else the relationship will not be saved.
113 118
         //If we aren't already in a relationship save, intitiate a save now.
114
-        if (empty($GLOBALS['resavingRelatedBeans']))
115
-            SugarRelationship::resaveRelatedBeans();
119
+        if (empty($GLOBALS['resavingRelatedBeans'])) {
120
+                    SugarRelationship::resaveRelatedBeans();
121
+        }
116 122
         
117 123
         return true;
118 124
     }
119 125
 
120 126
     protected function updateLinks($lhs, $lhsLinkName, $rhs, $rhsLinkName)
121 127
     {
122
-        if (isset($lhs->$lhsLinkName))
123
-            $lhs->$lhsLinkName->addBean($rhs);
128
+        if (isset($lhs->$lhsLinkName)) {
129
+                    $lhs->$lhsLinkName->addBean($rhs);
130
+        }
124 131
         //RHS only has one bean ever, so we don't need to preload the relationship
125
-        if (isset($rhs->$rhsLinkName))
126
-            $rhs->$rhsLinkName->beans = array($lhs->id => $lhs);
132
+        if (isset($rhs->$rhsLinkName)) {
133
+                    $rhs->$rhsLinkName->beans = array($lhs->id => $lhs);
134
+        }
127 135
     }
128 136
 
129 137
     protected function updateFields($lhs, $rhs, $additionalFields)
@@ -148,8 +156,9 @@  discard block
 block discarded – undo
148 156
         $rhsID = $this->def['rhs_key'];
149 157
 
150 158
         //If this relationship has already been removed, we can just return
151
-        if ($rhs->$rhsID != $lhs->id)
152
-            return false;
159
+        if ($rhs->$rhsID != $lhs->id) {
160
+                    return false;
161
+        }
153 162
 
154 163
         $rhs->$rhsID = '';
155 164
 
@@ -192,8 +201,7 @@  discard block
 block discarded – undo
192 201
             {
193 202
                 $rows[$id] = array('id' => $id);
194 203
             }
195
-        }
196
-        else //If the link is LHS, we need to query to get the full list and load all the beans.
204
+        } else //If the link is LHS, we need to query to get the full list and load all the beans.
197 205
         {
198 206
             $db = DBManagerFactory::getInstance();
199 207
             $query = $this->getQuery($link, $params);
@@ -241,8 +249,9 @@  discard block
 block discarded – undo
241 249
             //Add any optional where clause
242 250
             if (!empty($params['where'])) {
243 251
                 $add_where = is_string($params['where']) ? $params['where'] : "$rhsTable." . $this->getOptionalWhereClause($params['where']);
244
-                if (!empty($add_where))
245
-                    $where .= " AND $add_where";
252
+                if (!empty($add_where)) {
253
+                                    $where .= " AND $add_where";
254
+                }
246 255
             }
247 256
 
248 257
             //Add any optional order clauses
@@ -255,7 +264,9 @@  discard block
 block discarded – undo
255 264
             if (empty($params['return_as_array'])) {
256 265
                 //Limit is not compatible with return_as_array
257 266
                 $query = "SELECT id FROM $from $where";
258
-                if (!empty($order_by)) $query .= ' ORDER BY '.$order_by;
267
+                if (!empty($order_by)) {
268
+                    $query .= ' ORDER BY '.$order_by;
269
+                }
259 270
                 if (!empty($params['limit']) && $params['limit'] > 0) {
260 271
                     $offset = isset($params['offset']) ? $params['offset'] : 0;
261 272
                     $query = DBManagerFactory::getInstance()->limitQuery($query, $offset, $params['limit'], false, "", false);
@@ -276,8 +287,9 @@  discard block
 block discarded – undo
276 287
     {
277 288
         $linkIsLHS = $link->getSide() == REL_LHS;
278 289
         $startingTable = (empty($params['left_join_table_alias']) ? $this->def['lhs_table'] : $params['left_join_table_alias']);
279
-        if (!$linkIsLHS)
280
-            $startingTable = (empty($params['right_join_table_alias']) ? $this->def['rhs_table'] : $params['right_join_table_alias']);
290
+        if (!$linkIsLHS) {
291
+                    $startingTable = (empty($params['right_join_table_alias']) ? $this->def['rhs_table'] : $params['right_join_table_alias']);
292
+        }
281 293
         $startingKey = $linkIsLHS ? $this->def['lhs_key'] : $this->def['rhs_key'];
282 294
         $targetTable = $linkIsLHS ? $this->def['rhs_table'] : $this->def['lhs_table'];
283 295
         $targetTableWithAlias = $targetTable;
@@ -315,8 +327,9 @@  discard block
 block discarded – undo
315 327
 
316 328
         $linkIsLHS = $link->getSide() == REL_RHS;
317 329
         $startingTable = (empty($params['left_join_table_alias']) ? $this->def['lhs_table'] : $params['left_join_table_alias']);
318
-        if (!$linkIsLHS)
319
-            $startingTable = (empty($params['right_join_table_alias']) ? $this->def['rhs_table'] : $params['right_join_table_alias']);
330
+        if (!$linkIsLHS) {
331
+                    $startingTable = (empty($params['right_join_table_alias']) ? $this->def['rhs_table'] : $params['right_join_table_alias']);
332
+        }
320 333
         $startingKey = $linkIsLHS ? $this->def['lhs_key'] : $this->def['rhs_key'];
321 334
         $targetTable = $linkIsLHS ? $this->def['rhs_table'] : $this->def['lhs_table'];
322 335
         $targetKey = $linkIsLHS ? $this->def['rhs_key'] : $this->def['lhs_key'];
@@ -393,9 +406,10 @@  discard block
 block discarded – undo
393 406
 
394 407
     public function getRelationshipTable()
395 408
     {
396
-        if (isset($this->def['table']))
397
-            return $this->def['table'];
398
-        else
399
-            return $this->def['rhs_table'];
409
+        if (isset($this->def['table'])) {
410
+                    return $this->def['table'];
411
+        } else {
412
+                    return $this->def['rhs_table'];
413
+        }
400 414
     }
401 415
 }
Please login to merge, or discard this patch.
data/Relationships/M2MRelationship.php 1 patch
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -84,8 +86,7 @@  discard block
 block discarded – undo
84 86
         {
85 87
             $GLOBALS['log']->error("Warning: Multiple links found for relationship {$this->name} within module {$module}");
86 88
             return $this->getMostAppropriateLinkedDefinition($results);
87
-        }
88
-        else
89
+        } else
89 90
         {
90 91
             return FALSE;
91 92
         }
@@ -178,8 +179,9 @@  discard block
 block discarded – undo
178 179
 
179 180
         $this->addRow($dataToInsert);
180 181
 
181
-        if ($this->self_referencing)
182
-            $this->addSelfReferencing($lhs, $rhs, $additionalFields);
182
+        if ($this->self_referencing) {
183
+                    $this->addSelfReferencing($lhs, $rhs, $additionalFields);
184
+        }
183 185
 
184 186
             $lhs->$lhsLinkName->addBean($rhs);
185 187
             $rhs->$rhsLinkName->addBean($lhs);
@@ -339,8 +341,9 @@  discard block
 block discarded – undo
339 341
 
340 342
         $this->removeRow($dataToRemove);
341 343
 
342
-        if ($this->self_referencing)
343
-            $this->removeSelfReferencing($lhs, $rhs);
344
+        if ($this->self_referencing) {
345
+                    $this->removeSelfReferencing($lhs, $rhs);
346
+        }
344 347
 
345 348
         if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes")
346 349
         {
@@ -395,8 +398,9 @@  discard block
 block discarded – undo
395 398
         $idField = $link->getSide() == REL_LHS ? $this->def['join_key_rhs'] : $this->def['join_key_lhs'];
396 399
         while ($row = $db->fetchByAssoc($result, FALSE))
397 400
         {
398
-            if (empty($row['id']) && empty($row[$idField]))
399
-                continue;
401
+            if (empty($row['id']) && empty($row[$idField])) {
402
+                            continue;
403
+            }
400 404
             $id = empty($row['id']) ? $row[$idField] : $row['id'];
401 405
             $rows[$id] = $row;
402 406
         }
@@ -414,15 +418,17 @@  discard block
 block discarded – undo
414 418
             $targetKey = $this->def['join_key_rhs'];
415 419
             $relatedSeed = BeanFactory::getBean($this->getRHSModule());
416 420
             $relatedSeedKey = $this->def['rhs_key'];
417
-            if (!empty($params['where']) || !empty($params['order_by']))
418
-                $whereTable = (empty($params['right_join_table_alias']) ? $relatedSeed->table_name : $params['right_join_table_alias']);
421
+            if (!empty($params['where']) || !empty($params['order_by'])) {
422
+                            $whereTable = (empty($params['right_join_table_alias']) ? $relatedSeed->table_name : $params['right_join_table_alias']);
423
+            }
419 424
         } else {
420 425
             $knownKey = $this->def['join_key_rhs'];
421 426
             $targetKey = $this->def['join_key_lhs'];
422 427
             $relatedSeed = BeanFactory::getBean($this->getLHSModule());
423 428
             $relatedSeedKey = $this->def['lhs_key'];
424
-            if (!empty($params['where']) || !empty($params['order_by']))
425
-                $whereTable = (empty($params['left_join_table_alias']) ? $relatedSeed->table_name : $params['left_join_table_alias']);
429
+            if (!empty($params['where']) || !empty($params['order_by'])) {
430
+                            $whereTable = (empty($params['left_join_table_alias']) ? $relatedSeed->table_name : $params['left_join_table_alias']);
431
+            }
426 432
         }
427 433
         $rel_table = $this->getRelationshipTable();
428 434
 
@@ -432,8 +438,9 @@  discard block
 block discarded – undo
432 438
         //Add any optional where clause
433 439
         if (!empty($params['where'])) {
434 440
             $add_where = is_string($params['where']) ? $params['where'] : "$whereTable." . $this->getOptionalWhereClause($params['where']);
435
-            if (!empty($add_where))
436
-                $where .= " AND $add_where";
441
+            if (!empty($add_where)) {
442
+                            $where .= " AND $add_where";
443
+            }
437 444
         }
438 445
 
439 446
         //Add any optional order clauses
@@ -454,7 +461,9 @@  discard block
 block discarded – undo
454 461
 
455 462
         if (empty($params['return_as_array'])) {
456 463
             $query = "SELECT $targetKey id FROM $from WHERE $where AND $rel_table.deleted=$deleted";
457
-            if(!empty($order_by)) $query .= ' ORDER BY '.$order_by;
464
+            if(!empty($order_by)) {
465
+                $query .= ' ORDER BY '.$order_by;
466
+            }
458 467
             //Limit is not compatible with return_as_array
459 468
             if (!empty($params['limit']) && $params['limit'] > 0) {
460 469
                 $offset = isset($params['offset']) ? $params['offset'] : 0;
@@ -636,18 +645,20 @@  discard block
 block discarded – undo
636 645
 
637 646
     public function getRelationshipTable()
638 647
     {
639
-        if (!empty($this->def['table']))
640
-            return $this->def['table'];
641
-        else if(!empty($this->def['join_table']))
642
-            return $this->def['join_table'];
648
+        if (!empty($this->def['table'])) {
649
+                    return $this->def['table'];
650
+        } else if(!empty($this->def['join_table'])) {
651
+                    return $this->def['join_table'];
652
+        }
643 653
 
644 654
         return false;
645 655
     }
646 656
 
647 657
     public function getFields()
648 658
     {
649
-        if (!empty($this->def['fields']))
650
-            return $this->def['fields'];
659
+        if (!empty($this->def['fields'])) {
660
+                    return $this->def['fields'];
661
+        }
651 662
         $fields = array(
652 663
             "id" => array('name' => 'id'),
653 664
             'date_modified' => array('name' => 'date_modified'),
Please login to merge, or discard this patch.