Completed
Push — master ( 97ae17...26fbd7 )
by Adam
18:33
created
include/SugarFields/Fields/Text/SugarFieldText.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 require_once 'include/clean.php';
42 42
 class SugarFieldText extends SugarFieldBase {
43 43
 
44
-	function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
44
+    function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
45 45
         if(!isset($displayParams['nl2br'])){
46 46
             $displayParams['nl2br'] = true;
47 47
         }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         if(!isset($displayParams['url2html'])) {
52 52
             $displayParams['url2html'] = true;
53 53
         }
54
-		return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
54
+        return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
55 55
     }
56 56
     function getClassicEditView($field_id='description', $value='', $prefix='', $rich_text=false, $maxlength='', $tabindex=1, $cols=80, $rows=4) {
57 57
 
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
 
69 69
 
70 70
         $this->ss->assign('displayParams', $displayParams);
71
-		if(isset($GLOBALS['current_user'])) {
72
-			$height = $GLOBALS['current_user']->getPreference('text_editor_height');
73
-			$width = $GLOBALS['current_user']->getPreference('text_editor_width');
74
-			$height = isset($height) ? $height : '300px';
75
-	        $width = isset($width) ? $width : '95%';
76
-			$this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
77
-			$this->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
78
-		} else {
79
-			$this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
80
-			$this->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
81
-		}
71
+        if(isset($GLOBALS['current_user'])) {
72
+            $height = $GLOBALS['current_user']->getPreference('text_editor_height');
73
+            $width = $GLOBALS['current_user']->getPreference('text_editor_width');
74
+            $height = isset($height) ? $height : '300px';
75
+            $width = isset($width) ? $width : '95%';
76
+            $this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
77
+            $this->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
78
+        } else {
79
+            $this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
80
+            $this->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
81
+        }
82 82
 
83
-		return $this->ss->fetch($this->findTemplate('ClassicEditView'));
83
+        return $this->ss->fetch($this->findTemplate('ClassicEditView'));
84 84
     }
85 85
 }
86 86
 ?>
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 class SugarFieldText extends SugarFieldBase {
43 43
 
44 44
 	function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
45
-        if(!isset($displayParams['nl2br'])){
45
+        if (!isset($displayParams['nl2br'])) {
46 46
             $displayParams['nl2br'] = true;
47 47
         }
48
-        if(!isset($displayParams['htmlescape'])) {
48
+        if (!isset($displayParams['htmlescape'])) {
49 49
             $displayParams['htmlescape'] = true;
50 50
         }
51
-        if(!isset($displayParams['url2html'])) {
51
+        if (!isset($displayParams['url2html'])) {
52 52
             $displayParams['url2html'] = true;
53 53
         }
54 54
 		return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex);
55 55
     }
56
-    function getClassicEditView($field_id='description', $value='', $prefix='', $rich_text=false, $maxlength='', $tabindex=1, $cols=80, $rows=4) {
56
+    function getClassicEditView($field_id = 'description', $value = '', $prefix = '', $rich_text = false, $maxlength = '', $tabindex = 1, $cols = 80, $rows = 4) {
57 57
 
58 58
         $this->ss->assign('prefix', $prefix);
59 59
         $this->ss->assign('field_id', $field_id);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
 
70 70
         $this->ss->assign('displayParams', $displayParams);
71
-		if(isset($GLOBALS['current_user'])) {
71
+		if (isset($GLOBALS['current_user'])) {
72 72
 			$height = $GLOBALS['current_user']->getPreference('text_editor_height');
73 73
 			$width = $GLOBALS['current_user']->getPreference('text_editor_width');
74 74
 			$height = isset($height) ? $height : '300px';
Please login to merge, or discard this patch.
include/SugarFields/Fields/CronSchedule/SugarFieldCronSchedule.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,48 +3,48 @@
 block discarded – undo
3 3
 
4 4
 class SugarFieldCronSchedule extends SugarFieldBase {
5 5
 
6
-    private function getDays(){
6
+    private function getDays() {
7 7
         $days = array();
8 8
         $date = new DateTime("1986-05-01");
9 9
         $period = new DateInterval('P1D');
10
-        for($x = 1; $x <= 31; $x++){
11
-            $days[$x] = $date->format('jS');;
10
+        for ($x = 1; $x <= 31; $x++) {
11
+            $days[$x] = $date->format('jS'); ;
12 12
             $date->add($period);
13 13
         }
14 14
         return $days;
15 15
     }
16
-    private function getWeekDays(){
16
+    private function getWeekDays() {
17 17
         $days = array();
18 18
         $date = new DateTime("1986-05-04");
19 19
         $period = new DateInterval('P1D');
20
-        for($x = 0; $x < 7; $x++){
20
+        for ($x = 0; $x < 7; $x++) {
21 21
             $days[$x] = $date->format('D');
22 22
             $date->add($period);
23 23
         }
24 24
         return $days;
25 25
     }
26 26
 
27
-    function getHumanReadable($schedule){
27
+    function getHumanReadable($schedule) {
28 28
 
29 29
     }
30 30
 
31 31
     function setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass = true) {
32
-        global $app_list_strings,$app_strings;
32
+        global $app_list_strings, $app_strings;
33 33
         parent::setup($parentFieldArray, $vardef, $displayParams, $tabindex, $twopass);
34
-        $this->ss->assign('APP',$app_strings);
35
-        $this->ss->assign('types',get_select_options_with_id($app_list_strings['aor_scheduled_report_schedule_types'],''));
34
+        $this->ss->assign('APP', $app_strings);
35
+        $this->ss->assign('types', get_select_options_with_id($app_list_strings['aor_scheduled_report_schedule_types'], ''));
36 36
         $weekdays = $this->getWeekDays();
37
-        $this->ss->assign('weekday_vals',json_encode($weekdays));
38
-        $this->ss->assign('weekdays',get_select_options($weekdays,''));
37
+        $this->ss->assign('weekday_vals', json_encode($weekdays));
38
+        $this->ss->assign('weekdays', get_select_options($weekdays, ''));
39 39
         $days = $this->getDays();
40
-        $this->ss->assign('days',get_select_options($days,''));
41
-        function padNumbers($x){
42
-            return str_pad($x,2,'0',STR_PAD_LEFT);
40
+        $this->ss->assign('days', get_select_options($days, ''));
41
+        function padNumbers($x) {
42
+            return str_pad($x, 2, '0', STR_PAD_LEFT);
43 43
         }
44
-        $minutes = array_map('padNumbers',range(0,59));
45
-        $hours = array_map('padNumbers',range(0,23));
46
-        $this->ss->assign('minutes',get_select_options($minutes,''));
47
-        $this->ss->assign('hours',get_select_options($hours,''));
44
+        $minutes = array_map('padNumbers', range(0, 59));
45
+        $hours = array_map('padNumbers', range(0, 23));
46
+        $this->ss->assign('minutes', get_select_options($minutes, ''));
47
+        $this->ss->assign('hours', get_select_options($hours, ''));
48 48
     }
49 49
 
50 50
 
Please login to merge, or discard this patch.
include/SugarEmailAddress/SugarEmailAddress.php 3 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     var $object_name = 'EmailAddress';
57 57
 
58 58
     //bug 40068, According to rules in page 6 of http://www.apps.ietf.org/rfc/rfc3696.html#sec-3,
59
-	//allowed special characters ! # $ % & ' * + - / = ?  ^ _ ` . { | } ~ in local part
59
+    //allowed special characters ! # $ % & ' * + - / = ?  ^ _ ` . { | } ~ in local part
60 60
     var $regex = "/^(?:['\.\-\+&#!\$\*=\?\^_`\{\}~\/\w]+)@(?:(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|\w+(?:[\.-]*\w+)*(?:\.[\w-]{2,})+)\$/";
61 61
     var $disable_custom_fields = true;
62 62
     var $db;
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
             // determine which array to process
392 392
             foreach($_REQUEST as $k => $v) {
393 393
                 if(strpos($k, 'emailAddress') !== false) {
394
-                   $fromRequest = true;
395
-                   break;
394
+                    $fromRequest = true;
395
+                    break;
396 396
                 }
397 397
             $widget_id = $_REQUEST[$module .'_email_widget_id'];
398 398
     }
@@ -409,30 +409,30 @@  discard block
 block discarded – undo
409 409
 
410 410
                 $eId = $module . $widget_id;
411 411
                 if(isset($_REQUEST[$eId . 'emailAddressPrimaryFlag'])) {
412
-                   $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag'];
412
+                    $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag'];
413 413
                 } else if(isset($_REQUEST[$module . 'emailAddressPrimaryFlag'])) {
414
-                   $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag'];
414
+                    $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag'];
415 415
                 }
416 416
 
417 417
                 $optOutValues = array();
418 418
                 if(isset($_REQUEST[$eId .'emailAddressOptOutFlag'])) {
419
-                   $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag'];
419
+                    $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag'];
420 420
                 } else if(isset($_REQUEST[$module . 'emailAddressOptOutFlag'])) {
421
-                   $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag'];
421
+                    $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag'];
422 422
                 }
423 423
 
424 424
                 $invalidValues = array();
425 425
                 if(isset($_REQUEST[$eId .'emailAddressInvalidFlag'])) {
426
-                   $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag'];
426
+                    $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag'];
427 427
                 } else if(isset($_REQUEST[$module . 'emailAddressInvalidFlag'])) {
428
-                   $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag'];
428
+                    $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag'];
429 429
                 }
430 430
 
431 431
                 $deleteValues = array();
432 432
                 if(isset($_REQUEST[$eId .'emailAddressDeleteFlag'])) {
433
-                   $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag'];
433
+                    $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag'];
434 434
                 } else if(isset($_REQUEST[$module . 'emailAddressDeleteFlag'])) {
435
-                   $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag'];
435
+                    $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag'];
436 436
                 }
437 437
 
438 438
                 // prep from form save
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
 
447 447
                 if($fromRequest && empty($replyTo)) {
448 448
                     if(isset($_REQUEST[$eId .'emailAddressReplyToFlag'])) {
449
-                       $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag'];
449
+                        $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag'];
450 450
                     } else if(isset($_REQUEST[$module . 'emailAddressReplyToFlag'])) {
451
-                       $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag'];
451
+                        $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag'];
452 452
                     }
453 453
                 }
454 454
                 if($fromRequest && empty($new_addrs)) {
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
                         if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
473 473
                             $validateFlag = str_replace("Value", "Flag", $k);
474 474
                             if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true")
475
-                              $new_addrs[$k] = $v;
475
+                                $new_addrs[$k] = $v;
476 476
                         }
477 477
                     }
478 478
                 }
@@ -484,18 +484,18 @@  discard block
 block discarded – undo
484 484
                     $optOutValues = array();
485 485
                     $invalidValues = array();
486 486
                     foreach($new_addrs as $k=>$email) {
487
-                       preg_match('/emailAddress([0-9])+$/', $k, $matches);
488
-                       $count = $matches[1];
489
-                       $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . $this->db->quote(strtoupper($email)) . "'");
490
-                       if(!empty($result)) {
491
-                          $row=$this->db->fetchByAssoc($result);
492
-                          if(!empty($row['opt_out'])) {
493
-                             $optOutValues[$k] = "emailAddress$count";
494
-                          }
495
-                          if(!empty($row['invalid_email'])) {
496
-                             $invalidValues[$k] = "emailAddress$count";
497
-                          }
498
-                       }
487
+                        preg_match('/emailAddress([0-9])+$/', $k, $matches);
488
+                        $count = $matches[1];
489
+                        $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . $this->db->quote(strtoupper($email)) . "'");
490
+                        if(!empty($result)) {
491
+                            $row=$this->db->fetchByAssoc($result);
492
+                            if(!empty($row['opt_out'])) {
493
+                                $optOutValues[$k] = "emailAddress$count";
494
+                            }
495
+                            if(!empty($row['invalid_email'])) {
496
+                                $invalidValues[$k] = "emailAddress$count";
497
+                            }
498
+                        }
499 499
                     }
500 500
                 }
501 501
                 // Re-populate the addresses class variable if we have new address(es).
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 
523 523
         //If no widgets, set addresses array to empty
524 524
         if($post_from_email_address_widget && !$hasEmailValue) {
525
-           $this->addresses = array();
525
+            $this->addresses = array();
526 526
         }
527 527
     }
528 528
 
@@ -861,14 +861,14 @@  discard block
 block discarded – undo
861 861
             $count = 0;
862 862
             $key = $module . $widget_id . 'emailAddress'.$count;
863 863
             while(isset($_REQUEST[$key])) {
864
-                   $email = $_REQUEST[$key];
865
-                   $prefillDataArr[] =  array('email_address'=>$email,
866
-                                             'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key,
867
-                                             'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']),
868
-                                             'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']),
869
-                                             'reply_to_address'=>false
864
+                    $email = $_REQUEST[$key];
865
+                    $prefillDataArr[] =  array('email_address'=>$email,
866
+                                                'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key,
867
+                                                'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']),
868
+                                                'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']),
869
+                                                'reply_to_address'=>false
870 870
                                         );
871
-                   $key = $module . $widget_id . 'emailAddress' . ++$count;
871
+                    $key = $module . $widget_id . 'emailAddress' . ++$count;
872 872
             } //while
873 873
         }
874 874
 
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
         $this->smarty->assign('emailAddressWidget',$_POST['emailAddressWidget']);
986 986
 
987 987
         if(isset($_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'])) {
988
-           $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'];
988
+            $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'];
989 989
         }
990 990
 
991 991
         while(isset($_POST[$mod . $widget_id . "emailAddress" . $count])) {
@@ -994,31 +994,31 @@  discard block
 block discarded – undo
994 994
         }
995 995
 
996 996
         if($count == 0) {
997
-           return "";
997
+            return "";
998 998
         }
999 999
 
1000 1000
         if(isset($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'])) {
1001
-           foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) {
1002
-              $optOut[] = $v;
1003
-           }
1001
+            foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) {
1002
+                $optOut[] = $v;
1003
+            }
1004 1004
         }
1005 1005
 
1006 1006
         if(isset($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'])) {
1007
-           foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) {
1008
-              $invalid[] = $v;
1009
-           }
1007
+            foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) {
1008
+                $invalid[] = $v;
1009
+            }
1010 1010
         }
1011 1011
 
1012 1012
         if(isset($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'])) {
1013
-           foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) {
1014
-              $replyTo[] = $v;
1015
-           }
1013
+            foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) {
1014
+                $replyTo[] = $v;
1015
+            }
1016 1016
         }
1017 1017
 
1018 1018
         if(isset($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'])) {
1019
-           foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) {
1020
-              $delete[] = $v;
1021
-           }
1019
+            foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) {
1020
+                $delete[] = $v;
1021
+            }
1022 1022
         }
1023 1023
 
1024 1024
         while(isset($_POST[$mod . $widget_id . "emailAddressVerifiedValue" . $count])) {
@@ -1052,13 +1052,13 @@  discard block
 block discarded – undo
1052 1052
         $get .= '&emailAddressWidget='.$_POST['emailAddressWidget'];
1053 1053
 
1054 1054
         while(isset($_REQUEST[$mod . $widget_id . 'emailAddress' . $count])) {
1055
-              $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]);
1056
-              $count++;
1055
+                $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]);
1056
+                $count++;
1057 1057
         } //while
1058 1058
 
1059 1059
         while(isset($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count])) {
1060
-              $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]);
1061
-              $count++;
1060
+                $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]);
1061
+                $count++;
1062 1062
         } //while
1063 1063
 
1064 1064
         $options = array('emailAddressPrimaryFlag', 'emailAddressOptOutFlag', 'emailAddressInvalidFlag', 'emailAddressDeleteFlag', 'emailAddressReplyToFlag');
@@ -1067,14 +1067,14 @@  discard block
 block discarded – undo
1067 1067
             $count = 0;
1068 1068
             $optionIdentifier = $mod.$widget_id.$option;
1069 1069
             if(isset($_REQUEST[$optionIdentifier])) {
1070
-               if(is_array($_REQUEST[$optionIdentifier])) {
1071
-                   foreach($_REQUEST[$optionIdentifier] as $optOut) {
1072
-                      $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut;
1073
-                      $count++;
1074
-                   } //foreach
1075
-               } else {
1076
-                   $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier];
1077
-               }
1070
+                if(is_array($_REQUEST[$optionIdentifier])) {
1071
+                    foreach($_REQUEST[$optionIdentifier] as $optOut) {
1072
+                        $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut;
1073
+                        $count++;
1074
+                    } //foreach
1075
+                } else {
1076
+                    $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier];
1077
+                }
1078 1078
             } //if
1079 1079
         } //foreach
1080 1080
         return $get;
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
     }
1083 1083
 
1084 1084
     function setView($view) {
1085
-       $this->view = $view;
1085
+        $this->view = $view;
1086 1086
     }
1087 1087
 
1088 1088
 /**
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
      * @param string $module
85 85
      */
86 86
     function handleLegacySave($bean, $prefix = "") {
87
-        if(!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) {
87
+        if (!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) {
88 88
             if (empty($this->addresses) || !isset($_REQUEST['massupdate'])) {
89 89
                 $this->addresses = array();
90 90
                 $optOut = (isset($bean->email_opt_out) && $bean->email_opt_out == "1") ? true : false;
91 91
                 $invalid = (isset($bean->invalid_email) && $bean->invalid_email == "1") ? true : false;
92 92
 
93 93
                 $isPrimary = true;
94
-                for($i = 1; $i <= 10; $i++){
94
+                for ($i = 1; $i <= 10; $i++) {
95 95
                     $email = 'email'.$i;
96
-                    if(isset($bean->$email) && !empty($bean->$email)){
96
+                    if (isset($bean->$email) && !empty($bean->$email)) {
97 97
                         $opt_out_field = $email.'_opt_out';
98 98
                         $invalid_field = $email.'_invalid';
99 99
                         $field_optOut = (isset($bean->$opt_out_field)) ? $bean->$opt_out_field : $optOut;
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
                 }
105 105
             }
106 106
         }
107
-        $this->populateAddresses($bean->id, $bean->module_dir, array(),'');
108
-        if(isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) {
107
+        $this->populateAddresses($bean->id, $bean->module_dir, array(), '');
108
+        if (isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) {
109 109
             $this->populateLegacyFields($bean);
110 110
         }
111 111
     }
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
         return;
128 128
     }
129 129
 
130
-    function populateLegacyFields(&$bean){
130
+    function populateLegacyFields(&$bean) {
131 131
         $primary_found = false;
132 132
         $alternate_found = false;
133 133
         $alternate2_found = false;
134
-        foreach($this->addresses as $k=>$address) {
134
+        foreach ($this->addresses as $k=>$address) {
135 135
             if ($primary_found && $alternate_found)
136 136
                 break;
137 137
             if ($address['primary_address'] == 1 && !$primary_found) {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             } elseif (!$alternate_found) {
141 141
                 $alternate_index = $k;
142 142
                 $alternate_found = true;
143
-            } elseif (!$alternate2_found){
143
+            } elseif (!$alternate2_found) {
144 144
                 $alternate2_index = $k;
145 145
                 $alternate2_found = true;
146 146
             }
@@ -177,27 +177,27 @@  discard block
 block discarded – undo
177 177
         $args = func_get_args();
178 178
         return call_user_func_array(array($this, '_save'), $args);
179 179
     }
180
-    private function _save($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='', $in_workflow=false) {
181
-        if(empty($this->addresses) || $in_workflow){
182
-            $this->populateAddresses($id, $module, $new_addrs,$primary);
180
+    private function _save($id, $module, $new_addrs = array(), $primary = '', $replyTo = '', $invalid = '', $optOut = '', $in_workflow = false) {
181
+        if (empty($this->addresses) || $in_workflow) {
182
+            $this->populateAddresses($id, $module, $new_addrs, $primary);
183 183
         }
184 184
 
185 185
         //find all email addresses..
186
-        $current_links=array();
186
+        $current_links = array();
187 187
         // Need to correct this to handle the Employee/User split
188 188
         $module = $this->getCorrectedModule($module);
189
-        $q2="select *  from email_addr_bean_rel eabr WHERE eabr.bean_id = '".$this->db->quote($id)."' AND eabr.bean_module = '".$this->db->quote($module)."' and eabr.deleted=0";
189
+        $q2 = "select *  from email_addr_bean_rel eabr WHERE eabr.bean_id = '".$this->db->quote($id)."' AND eabr.bean_module = '".$this->db->quote($module)."' and eabr.deleted=0";
190 190
         $r2 = $this->db->query($q2);
191
-        while(($row2=$this->db->fetchByAssoc($r2)) != null ) {
192
-            $current_links[$row2['email_address_id']]=$row2;
191
+        while (($row2 = $this->db->fetchByAssoc($r2)) != null) {
192
+            $current_links[$row2['email_address_id']] = $row2;
193 193
         }
194 194
 
195 195
         $isConversion = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? true : false;
196 196
 
197 197
         if (!empty($this->addresses)) {
198 198
             // insert new relationships and create email address record, if they don't exist
199
-            foreach($this->addresses as $address) {
200
-                if(!empty($address['email_address'])) {
199
+            foreach ($this->addresses as $address) {
200
+                if (!empty($address['email_address'])) {
201 201
                     $guid = create_guid();
202 202
                     $emailId = isset($address['email_address_id'])
203 203
                         && isset($current_links[$address['email_address_id']])
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
                     $emailId = $this->AddUpdateEmailAddress($address['email_address'],
206 206
                                                             $address['invalid_email'],
207 207
                                                             $address['opt_out'],
208
-                                                            $emailId);// this will save the email address if not found
208
+                                                            $emailId); // this will save the email address if not found
209 209
 
210 210
                     //verify linkage and flags.
211
-                    $upd_eabr="";
211
+                    $upd_eabr = "";
212 212
                     if (isset($current_links[$emailId])) {
213 213
                         if (!$isConversion) { // do not update anything if this is for lead conversion
214
-                        if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address'] ) {
215
-                            $upd_eabr="UPDATE email_addr_bean_rel SET primary_address='".$this->db->quote($address['primary_address'])."', reply_to_address='".$this->db->quote($address['reply_to_address'])."' WHERE id='".$this->db->quote($current_links[$emailId]['id'])."'";
214
+                        if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address']) {
215
+                            $upd_eabr = "UPDATE email_addr_bean_rel SET primary_address='".$this->db->quote($address['primary_address'])."', reply_to_address='".$this->db->quote($address['reply_to_address'])."' WHERE id='".$this->db->quote($current_links[$emailId]['id'])."'";
216 216
                         }
217 217
 
218 218
                         unset($current_links[$emailId]);
@@ -243,13 +243,13 @@  discard block
 block discarded – undo
243 243
         // for lead conversion, do not delete email addresses
244 244
         if (!empty($current_links) && !$isConversion) {
245 245
 
246
-            $delete="";
246
+            $delete = "";
247 247
             foreach ($current_links as $eabr) {
248 248
 
249
-                $delete.=empty($delete) ? "'".$this->db->quote($eabr['id']) . "' " : ",'" . $this->db->quote($eabr['id']) . "'";
249
+                $delete .= empty($delete) ? "'".$this->db->quote($eabr['id'])."' " : ",'".$this->db->quote($eabr['id'])."'";
250 250
             }
251 251
 
252
-            $eabr_unlink="update email_addr_bean_rel set deleted=1 where id in ({$delete})";
252
+            $eabr_unlink = "update email_addr_bean_rel set deleted=1 where id in ({$delete})";
253 253
             $this->db->query($eabr_unlink);
254 254
         }
255 255
         $this->stateBeforeWorkflow = null;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         )
272 272
     {
273 273
         $emailCaps = strtoupper(trim($email));
274
-        if(empty($emailCaps))
274
+        if (empty($emailCaps))
275 275
             return 0;
276 276
 
277 277
         $q = "SELECT *
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
         $r = $this->db->query($q, true);
310 310
 
311 311
         $retArr = array();
312
-        while($a = $this->db->fetchByAssoc($r)) {
312
+        while ($a = $this->db->fetchByAssoc($r)) {
313 313
             $retArr[] = $a['bean_id'];
314 314
         }
315
-        if(count($retArr) > 0) {
315
+        if (count($retArr) > 0) {
316 316
             return $retArr;
317 317
         } else {
318 318
             return false;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
         $email = trim($email);
334 334
 
335
-        if(empty($email)) {
335
+        if (empty($email)) {
336 336
             return array();
337 337
         }
338 338
 
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
                 WHERE ea.email_address_caps = $emailCaps and eabl.deleted=0 ";
342 342
         $r = $this->db->query($q);
343 343
 
344
-        while($a = $this->db->fetchByAssoc($r)) {
345
-            if(isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) {
344
+        while ($a = $this->db->fetchByAssoc($r)) {
345
+            if (isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) {
346 346
                 $className = $beanList[$a['bean_module']];
347 347
 
348
-                if(isset($beanFiles[$className]) && !empty($beanFiles[$className])) {
349
-                    if(!class_exists($className)) {
348
+                if (isset($beanFiles[$className]) && !empty($beanFiles[$className])) {
349
+                    if (!class_exists($className)) {
350 350
                         require_once($beanFiles[$className]);
351 351
                     }
352 352
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
      * @param string $replyTo GUID of reply-to address
375 375
      * @param string $invalid GUID of invalid address
376 376
      */
377
-    function populateAddresses($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='') {
377
+    function populateAddresses($id, $module, $new_addrs = array(), $primary = '', $replyTo = '', $invalid = '', $optOut = '') {
378 378
         $module = $this->getCorrectedModule($module);
379 379
         //One last check for the ConvertLead action in which case we need to change $module to 'Leads'
380 380
         $module = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? 'Leads' : $module;
@@ -385,54 +385,54 @@  discard block
 block discarded – undo
385 385
         $hasEmailValue = false;
386 386
         $email_ids = array();
387 387
 
388
-        if (isset($_REQUEST) && isset($_REQUEST[$module .'_email_widget_id'])) {
388
+        if (isset($_REQUEST) && isset($_REQUEST[$module.'_email_widget_id'])) {
389 389
 
390 390
             $fromRequest = false;
391 391
             // determine which array to process
392
-            foreach($_REQUEST as $k => $v) {
393
-                if(strpos($k, 'emailAddress') !== false) {
392
+            foreach ($_REQUEST as $k => $v) {
393
+                if (strpos($k, 'emailAddress') !== false) {
394 394
                    $fromRequest = true;
395 395
                    break;
396 396
                 }
397
-            $widget_id = $_REQUEST[$module .'_email_widget_id'];
397
+            $widget_id = $_REQUEST[$module.'_email_widget_id'];
398 398
     }
399 399
 
400 400
             //Iterate over the widgets for this module, in case there are multiple email widgets for this module
401
-            while(isset($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount]))
401
+            while (isset($_REQUEST[$module.$widget_id."emailAddress".$widgetCount]))
402 402
             {
403
-                if (empty($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount])) {
403
+                if (empty($_REQUEST[$module.$widget_id."emailAddress".$widgetCount])) {
404 404
                     $widgetCount++;
405 405
                     continue;
406 406
                 }
407 407
 
408 408
                 $hasEmailValue = true;
409 409
 
410
-                $eId = $module . $widget_id;
411
-                if(isset($_REQUEST[$eId . 'emailAddressPrimaryFlag'])) {
412
-                   $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag'];
413
-                } else if(isset($_REQUEST[$module . 'emailAddressPrimaryFlag'])) {
414
-                   $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag'];
410
+                $eId = $module.$widget_id;
411
+                if (isset($_REQUEST[$eId.'emailAddressPrimaryFlag'])) {
412
+                   $primaryValue = $_REQUEST[$eId.'emailAddressPrimaryFlag'];
413
+                } else if (isset($_REQUEST[$module.'emailAddressPrimaryFlag'])) {
414
+                   $primaryValue = $_REQUEST[$module.'emailAddressPrimaryFlag'];
415 415
                 }
416 416
 
417 417
                 $optOutValues = array();
418
-                if(isset($_REQUEST[$eId .'emailAddressOptOutFlag'])) {
419
-                   $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag'];
420
-                } else if(isset($_REQUEST[$module . 'emailAddressOptOutFlag'])) {
421
-                   $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag'];
418
+                if (isset($_REQUEST[$eId.'emailAddressOptOutFlag'])) {
419
+                   $optOutValues = $_REQUEST[$eId.'emailAddressOptOutFlag'];
420
+                } else if (isset($_REQUEST[$module.'emailAddressOptOutFlag'])) {
421
+                   $optOutValues = $_REQUEST[$module.'emailAddressOptOutFlag'];
422 422
                 }
423 423
 
424 424
                 $invalidValues = array();
425
-                if(isset($_REQUEST[$eId .'emailAddressInvalidFlag'])) {
426
-                   $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag'];
427
-                } else if(isset($_REQUEST[$module . 'emailAddressInvalidFlag'])) {
428
-                   $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag'];
425
+                if (isset($_REQUEST[$eId.'emailAddressInvalidFlag'])) {
426
+                   $invalidValues = $_REQUEST[$eId.'emailAddressInvalidFlag'];
427
+                } else if (isset($_REQUEST[$module.'emailAddressInvalidFlag'])) {
428
+                   $invalidValues = $_REQUEST[$module.'emailAddressInvalidFlag'];
429 429
                 }
430 430
 
431 431
                 $deleteValues = array();
432
-                if(isset($_REQUEST[$eId .'emailAddressDeleteFlag'])) {
433
-                   $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag'];
434
-                } else if(isset($_REQUEST[$module . 'emailAddressDeleteFlag'])) {
435
-                   $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag'];
432
+                if (isset($_REQUEST[$eId.'emailAddressDeleteFlag'])) {
433
+                   $deleteValues = $_REQUEST[$eId.'emailAddressDeleteFlag'];
434
+                } else if (isset($_REQUEST[$module.'emailAddressDeleteFlag'])) {
435
+                   $deleteValues = $_REQUEST[$module.'emailAddressDeleteFlag'];
436 436
                 }
437 437
 
438 438
                 // prep from form save
@@ -440,36 +440,36 @@  discard block
 block discarded – undo
440 440
                 $replyToField = '';
441 441
                 $invalidField = '';
442 442
                 $optOutField = '';
443
-                if($fromRequest && empty($primary) && isset($primaryValue)) {
443
+                if ($fromRequest && empty($primary) && isset($primaryValue)) {
444 444
                     $primaryField = $primaryValue;
445 445
                 }
446 446
 
447
-                if($fromRequest && empty($replyTo)) {
448
-                    if(isset($_REQUEST[$eId .'emailAddressReplyToFlag'])) {
449
-                       $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag'];
450
-                    } else if(isset($_REQUEST[$module . 'emailAddressReplyToFlag'])) {
451
-                       $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag'];
447
+                if ($fromRequest && empty($replyTo)) {
448
+                    if (isset($_REQUEST[$eId.'emailAddressReplyToFlag'])) {
449
+                       $replyToField = $_REQUEST[$eId.'emailAddressReplyToFlag'];
450
+                    } else if (isset($_REQUEST[$module.'emailAddressReplyToFlag'])) {
451
+                       $replyToField = $_REQUEST[$module.'emailAddressReplyToFlag'];
452 452
                     }
453 453
                 }
454
-                if($fromRequest && empty($new_addrs)) {
455
-                    foreach($_REQUEST as $k => $v) {
456
-                        if(preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) {
454
+                if ($fromRequest && empty($new_addrs)) {
455
+                    foreach ($_REQUEST as $k => $v) {
456
+                        if (preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) {
457 457
                             $new_addrs[$k] = $v;
458 458
                         }
459 459
                     }
460 460
                 }
461
-                if($fromRequest && empty($email_ids)) {
462
-                    foreach($_REQUEST as $k => $v) {
463
-                        if(preg_match('/'.$eId.'emailAddressId[0-9]+$/i', $k) && !empty($v)) {
461
+                if ($fromRequest && empty($email_ids)) {
462
+                    foreach ($_REQUEST as $k => $v) {
463
+                        if (preg_match('/'.$eId.'emailAddressId[0-9]+$/i', $k) && !empty($v)) {
464 464
                             $key = str_replace('emailAddressId', 'emailAddress', $k);
465 465
                             $email_ids[$key] = $v;
466 466
                         }
467 467
                     }
468 468
                 }
469 469
 
470
-                if($fromRequest && empty($new_addrs)) {
471
-                    foreach($_REQUEST as $k => $v) {
472
-                        if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
470
+                if ($fromRequest && empty($new_addrs)) {
471
+                    foreach ($_REQUEST as $k => $v) {
472
+                        if (preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
473 473
                             $validateFlag = str_replace("Value", "Flag", $k);
474 474
                             if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true")
475 475
                               $new_addrs[$k] = $v;
@@ -478,21 +478,21 @@  discard block
 block discarded – undo
478 478
                 }
479 479
 
480 480
                 //empty the addresses array if the post happened from email address widget.
481
-                if($post_from_email_address_widget) {
482
-                    $this->addresses=array();  //this gets populated during retrieve of the contact bean.
481
+                if ($post_from_email_address_widget) {
482
+                    $this->addresses = array(); //this gets populated during retrieve of the contact bean.
483 483
                 } else {
484 484
                     $optOutValues = array();
485 485
                     $invalidValues = array();
486
-                    foreach($new_addrs as $k=>$email) {
486
+                    foreach ($new_addrs as $k=>$email) {
487 487
                        preg_match('/emailAddress([0-9])+$/', $k, $matches);
488 488
                        $count = $matches[1];
489
-                       $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . $this->db->quote(strtoupper($email)) . "'");
490
-                       if(!empty($result)) {
491
-                          $row=$this->db->fetchByAssoc($result);
492
-                          if(!empty($row['opt_out'])) {
489
+                       $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '".$this->db->quote(strtoupper($email))."'");
490
+                       if (!empty($result)) {
491
+                          $row = $this->db->fetchByAssoc($result);
492
+                          if (!empty($row['opt_out'])) {
493 493
                              $optOutValues[$k] = "emailAddress$count";
494 494
                           }
495
-                          if(!empty($row['invalid_email'])) {
495
+                          if (!empty($row['invalid_email'])) {
496 496
                              $invalidValues[$k] = "emailAddress$count";
497 497
                           }
498 498
                        }
@@ -500,11 +500,11 @@  discard block
 block discarded – undo
500 500
                 }
501 501
                 // Re-populate the addresses class variable if we have new address(es).
502 502
                 if (!empty($new_addrs)) {
503
-                    foreach($new_addrs as $k => $reqVar) {
503
+                    foreach ($new_addrs as $k => $reqVar) {
504 504
                         //$key = preg_match("/^$eId/s", $k) ? substr($k, strlen($eId)) : $k;
505 505
                         $reqVar = trim($reqVar);
506
-                        if(strpos($k, 'emailAddress') !== false) {
507
-                            if(!empty($reqVar) && !in_array($k, $deleteValues)) {
506
+                        if (strpos($k, 'emailAddress') !== false) {
507
+                            if (!empty($reqVar) && !in_array($k, $deleteValues)) {
508 508
                                 $email_id   = (array_key_exists($k, $email_ids)) ? $email_ids[$k] : null;
509 509
                                 $primary    = ($k == $primaryValue) ? true : false;
510 510
                                 $replyTo    = ($k == $replyToField) ? true : false;
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
         }
522 522
 
523 523
         //If no widgets, set addresses array to empty
524
-        if($post_from_email_address_widget && !$hasEmailValue) {
524
+        if ($post_from_email_address_widget && !$hasEmailValue) {
525 525
            $this->addresses = array();
526 526
         }
527 527
     }
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
      * @param bool $primary Default false
533 533
      * @param bool $replyTo Default false
534 534
      */
535
-    function addAddress($addr, $primary=false, $replyTo=false, $invalid=false, $optOut=false, $email_id = null) {
535
+    function addAddress($addr, $primary = false, $replyTo = false, $invalid = false, $optOut = false, $email_id = null) {
536 536
         $addr = html_entity_decode($addr, ENT_QUOTES);
537
-        if(preg_match($this->regex, $addr)) {
537
+        if (preg_match($this->regex, $addr)) {
538 538
             $primaryFlag = ($primary) ? '1' : '0';
539 539
             $replyToFlag = ($replyTo) ? '1' : '0';
540 540
             $invalidFlag = ($invalid) ? '1' : '0';
@@ -570,17 +570,17 @@  discard block
 block discarded – undo
570 570
      * Updates invalid_email and opt_out flags for each address
571 571
      */
572 572
     function updateFlags() {
573
-        if(!empty($this->addresses)) {
574
-            foreach($this->addresses as $addressMeta) {
575
-                if(isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) {
573
+        if (!empty($this->addresses)) {
574
+            foreach ($this->addresses as $addressMeta) {
575
+                if (isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) {
576 576
                     $address = $this->db->quote($this->_cleanAddress($addressMeta['email_address']));
577 577
 
578 578
                     $q = "SELECT * FROM email_addresses WHERE email_address = '{$address}'";
579 579
                     $r = $this->db->query($q);
580 580
                     $a = $this->db->fetchByAssoc($r);
581 581
 
582
-                    if(!empty($a)) {
583
-                        if(isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) {
582
+                    if (!empty($a)) {
583
+                        if (isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) {
584 584
                             $qUpdate = "UPDATE email_addresses SET invalid_email = ".intval($addressMeta['invalid_email']).", opt_out = ".intval($addressMeta['opt_out']).", date_modified = '".TimeDate::getInstance()->nowDb()."' WHERE id = '".$this->db->quote($a['id'])."'";
585 585
                             $rUpdate = $this->db->query($qUpdate);
586 586
                         }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
     public function splitEmailAddress($addr)
594 594
     {
595 595
         $email = $this->_cleanAddress($addr);
596
-        if(!preg_match($this->regex, $email)) {
596
+        if (!preg_match($this->regex, $email)) {
597 597
             $email = ''; // remove bad email addr
598 598
         }
599 599
         $name = trim(str_replace(array($email, '<', '>', '"', "'"), '', $addr));
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
     function _cleanAddress($addr) {
610 610
         $addr = trim(from_html($addr));
611 611
 
612
-        if(strpos($addr, "<") !== false && strpos($addr, ">") !== false) {
613
-            $address = trim(substr($addr, strrpos($addr, "<") +1, strrpos($addr, ">") - strrpos($addr, "<") -1));
612
+        if (strpos($addr, "<") !== false && strpos($addr, ">") !== false) {
613
+            $address = trim(substr($addr, strrpos($addr, "<") + 1, strrpos($addr, ">") - strrpos($addr, "<") - 1));
614 614
         } else {
615 615
             $address = trim($addr);
616 616
         }
@@ -631,11 +631,11 @@  discard block
 block discarded – undo
631 631
         $r = $this->db->query($q);
632 632
         $a = $this->db->fetchByAssoc($r);
633 633
 
634
-        if(!empty($a) && !empty($a['id'])) {
634
+        if (!empty($a) && !empty($a['id'])) {
635 635
             return $a['id'];
636 636
         } else {
637 637
             $guid = '';
638
-            if(!empty($address)){
638
+            if (!empty($address)) {
639 639
                 $guid = create_guid();
640 640
                 $now = TimeDate::getInstance()->nowDb();
641 641
                 $qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted)
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
      *        to propagate to the new SugarEmailAddress - see bug 39188
658 658
      * @return String GUID of Email Address or '' if cleaned address was empty.
659 659
      */
660
-    public function AddUpdateEmailAddress($addr,$invalid=0,$opt_out=0,$id=null)
660
+    public function AddUpdateEmailAddress($addr, $invalid = 0, $opt_out = 0, $id = null)
661 661
     {
662 662
         // sanity checks to avoid SQL injection.
663 663
         $invalid = intval($invalid);
@@ -707,12 +707,12 @@  discard block
 block discarded – undo
707 707
             if ($duplicate_email['invalid_email'] != $new_invalid ||
708 708
                 $duplicate_email['opt_out'] != $new_opt_out ||
709 709
                 (trim($duplicate_email['email_address']) != $address)) {
710
-                $upd_q = 'UPDATE ' . $this->table_name . ' ' .
711
-                    'SET email_address=\'' . $address . '\', ' .
712
-                    'invalid_email=' . $new_invalid . ', ' .
713
-                    'opt_out=' . $new_opt_out . ', ' .
714
-                    'date_modified=' . $this->db->now() . ' ' .
715
-                    'WHERE id=\'' . $this->db->quote($duplicate_email['id']) . '\'';
710
+                $upd_q = 'UPDATE '.$this->table_name.' '.
711
+                    'SET email_address=\''.$address.'\', '.
712
+                    'invalid_email='.$new_invalid.', '.
713
+                    'opt_out='.$new_opt_out.', '.
714
+                    'date_modified='.$this->db->now().' '.
715
+                    'WHERE id=\''.$this->db->quote($duplicate_email['id']).'\'';
716 716
                 $upd_r = $this->db->query($upd_q);
717 717
             }
718 718
             return $duplicate_email['id'];
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
         else {
721 721
             // no case-insensitive address match - it's new, or undeleted.
722 722
             $guid = '';
723
-            if(!empty($address)){
723
+            if (!empty($address)) {
724 724
                 $guid = create_guid();
725 725
                 $now = TimeDate::getInstance()->nowDb();
726 726
                 $qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted, invalid_email, opt_out)
@@ -736,12 +736,12 @@  discard block
 block discarded – undo
736 736
      * @param object $focus Object in focus
737 737
      * @return string email
738 738
      */
739
-    function getPrimaryAddress($focus,$parent_id=null,$parent_type=null) {
739
+    function getPrimaryAddress($focus, $parent_id = null, $parent_type = null) {
740 740
 
741
-        $parent_type=empty($parent_type) ? $focus->module_dir : $parent_type;
741
+        $parent_type = empty($parent_type) ? $focus->module_dir : $parent_type;
742 742
         // Bug63174: Email address is not shown in the list view for employees
743 743
         $parent_type = $this->getCorrectedModule($parent_type);
744
-        $parent_id=empty($parent_id) ? $focus->id : $parent_id;
744
+        $parent_id = empty($parent_id) ? $focus->id : $parent_id;
745 745
 
746 746
         $q = "SELECT ea.email_address FROM email_addresses ea
747 747
                 LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
         $r = $this->db->limitQuery($q, 0, 1);
754 754
         $a = $this->db->fetchByAssoc($r);
755 755
 
756
-        if(isset($a['email_address'])) {
756
+        if (isset($a['email_address'])) {
757 757
             return $a['email_address'];
758 758
         }
759 759
         return '';
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
         $r = $this->db->query($q);
795 795
         $a = $this->db->fetchByAssoc($r);
796 796
 
797
-        if(isset($a['email_address'])) {
797
+        if (isset($a['email_address'])) {
798 798
             return $a['email_address'];
799 799
         }
800 800
         return '';
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
                 ORDER BY ear.reply_to_address, ear.primary_address DESC";
820 820
         $r = $this->db->query($q);
821 821
 
822
-        while($a = $this->db->fetchByAssoc($r, FALSE)) {
822
+        while ($a = $this->db->fetchByAssoc($r, FALSE)) {
823 823
             $return[] = $a;
824 824
         }
825 825
 
@@ -833,9 +833,9 @@  discard block
 block discarded – undo
833 833
      * @param bool asMetadata Default false
834 834
      * @return string HTML/JS for widget
835 835
      */
836
-    function getEmailAddressWidgetEditView($id, $module, $asMetadata=false, $tpl='',$tabindex='0')
836
+    function getEmailAddressWidgetEditView($id, $module, $asMetadata = false, $tpl = '', $tabindex = '0')
837 837
     {
838
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
838
+        if (!($this->smarty instanceOf Sugar_Smarty))
839 839
             $this->smarty = new Sugar_Smarty();
840 840
 
841 841
         global $app_strings, $dictionary, $beanList;
@@ -846,33 +846,33 @@  discard block
 block discarded – undo
846 846
         $passedModule = $module;
847 847
         $module = $this->getCorrectedModule($module);
848 848
         $saveModule = $module;
849
-        if(isset($_POST['is_converted']) && $_POST['is_converted']==true){
850
-            $id=$_POST['return_id'];
851
-            $module=$_POST['return_module'];
849
+        if (isset($_POST['is_converted']) && $_POST['is_converted'] == true) {
850
+            $id = $_POST['return_id'];
851
+            $module = $_POST['return_module'];
852 852
         }
853 853
         $prefillDataArr = array();
854
-        if(!empty($id)) {
854
+        if (!empty($id)) {
855 855
             $prefillDataArr = $this->getAddressesByGUID($id, $module);
856 856
             //When coming from convert leads, sometimes module is Contacts while the id is for a lead.
857 857
             if (empty($prefillDataArr) && $module == "Contacts")
858 858
                 $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
859
-        } else if(isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])){
860
-            $widget_id = isset($_REQUEST[$module . '_email_widget_id']) ? $_REQUEST[$module . '_email_widget_id'] : '0';
859
+        } else if (isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])) {
860
+            $widget_id = isset($_REQUEST[$module.'_email_widget_id']) ? $_REQUEST[$module.'_email_widget_id'] : '0';
861 861
             $count = 0;
862
-            $key = $module . $widget_id . 'emailAddress'.$count;
863
-            while(isset($_REQUEST[$key])) {
862
+            $key = $module.$widget_id.'emailAddress'.$count;
863
+            while (isset($_REQUEST[$key])) {
864 864
                    $email = $_REQUEST[$key];
865
-                   $prefillDataArr[] =  array('email_address'=>$email,
865
+                   $prefillDataArr[] = array('email_address'=>$email,
866 866
                                              'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key,
867 867
                                              'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']),
868 868
                                              'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']),
869 869
                                              'reply_to_address'=>false
870 870
                                         );
871
-                   $key = $module . $widget_id . 'emailAddress' . ++$count;
871
+                   $key = $module.$widget_id.'emailAddress'.++$count;
872 872
             } //while
873 873
         }
874 874
 
875
-        if(!empty($prefillDataArr)) {
875
+        if (!empty($prefillDataArr)) {
876 876
             $json = new JSON(JSON_LOOSE_TYPE);
877 877
             $prefillData = $json->encode($prefillDataArr);
878 878
             $prefill = !empty($prefillDataArr) ? 'true' : 'false';
@@ -895,16 +895,16 @@  discard block
 block discarded – undo
895 895
         $form = $this->view;
896 896
 
897 897
         //determine if this should be a quickcreate form, or a quick create form under subpanels
898
-        if ($this->view == "QuickCreate"){
899
-            $form = 'form_DC'.$this->view .'_'.$module;
900
-            if(isset($_REQUEST['action']) && $_REQUEST['action']=='SubpanelCreates' ||  $_REQUEST['action']=='SubpanelEdits'){
901
-                $form = 'form_Subpanel'.$this->view .'_'.$module;
898
+        if ($this->view == "QuickCreate") {
899
+            $form = 'form_DC'.$this->view.'_'.$module;
900
+            if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'SubpanelCreates' || $_REQUEST['action'] == 'SubpanelEdits') {
901
+                $form = 'form_Subpanel'.$this->view.'_'.$module;
902 902
             }
903 903
         }
904 904
 
905 905
         $this->smarty->assign('emailView', $form);
906 906
 
907
-        if($module == 'Users') {
907
+        if ($module == 'Users') {
908 908
             $this->smarty->assign('useReplyTo', true);
909 909
         } else {
910 910
             $this->smarty->assign('useOptOut', true);
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
         $newEmail = $this->smarty->fetch($template);
916 916
 
917 917
 
918
-        if($asMetadata) {
918
+        if ($asMetadata) {
919 919
             // used by Email 2.0
920 920
             $ret = array();
921 921
             $ret['prefillData'] = $prefillDataArr;
@@ -933,18 +933,18 @@  discard block
 block discarded – undo
933 933
      * @param object $focus Bean in focus
934 934
      * @return string HTML/JS for widget
935 935
      */
936
-    function getEmailAddressWidgetDetailView($focus, $tpl='')
936
+    function getEmailAddressWidgetDetailView($focus, $tpl = '')
937 937
     {
938
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
938
+        if (!($this->smarty instanceOf Sugar_Smarty))
939 939
             $this->smarty = new Sugar_Smarty();
940 940
 
941 941
         global $app_strings;
942 942
         global $current_user;
943 943
         $assign = array();
944
-        if(empty($focus->id))return '';
944
+        if (empty($focus->id))return '';
945 945
         $prefillData = $this->getAddressesByGUID($focus->id, $focus->module_dir);
946 946
 
947
-        foreach($prefillData as $addressItem) {
947
+        foreach ($prefillData as $addressItem) {
948 948
             $key = ($addressItem['primary_address'] == 1) ? 'primary' : "";
949 949
             $key = ($addressItem['reply_to_address'] == 1) ? 'reply_to' : $key;
950 950
             $key = ($addressItem['opt_out'] == 1) ? 'opt_out' : $key;
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
      */
971 971
     function getEmailAddressWidgetDuplicatesView($focus)
972 972
     {
973
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
973
+        if (!($this->smarty instanceOf Sugar_Smarty))
974 974
             $this->smarty = new Sugar_Smarty();
975 975
 
976 976
         $count = 0;
@@ -980,49 +980,49 @@  discard block
 block discarded – undo
980 980
         $invalid = array();
981 981
         $mod = isset($focus) ? $focus->module_dir : "";
982 982
 
983
-        $widget_id = $_POST[$mod .'_email_widget_id'];
984
-        $this->smarty->assign('email_widget_id',$widget_id);
985
-        $this->smarty->assign('emailAddressWidget',$_POST['emailAddressWidget']);
983
+        $widget_id = $_POST[$mod.'_email_widget_id'];
984
+        $this->smarty->assign('email_widget_id', $widget_id);
985
+        $this->smarty->assign('emailAddressWidget', $_POST['emailAddressWidget']);
986 986
 
987
-        if(isset($_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'])) {
988
-           $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'];
987
+        if (isset($_POST[$mod.$widget_id.'emailAddressPrimaryFlag'])) {
988
+           $primary = $_POST[$mod.$widget_id.'emailAddressPrimaryFlag'];
989 989
         }
990 990
 
991
-        while(isset($_POST[$mod . $widget_id . "emailAddress" . $count])) {
992
-            $emails[] = $_POST[$mod . $widget_id . 'emailAddress' . $count];
991
+        while (isset($_POST[$mod.$widget_id."emailAddress".$count])) {
992
+            $emails[] = $_POST[$mod.$widget_id.'emailAddress'.$count];
993 993
             $count++;
994 994
         }
995 995
 
996
-        if($count == 0) {
996
+        if ($count == 0) {
997 997
            return "";
998 998
         }
999 999
 
1000
-        if(isset($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'])) {
1001
-           foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) {
1000
+        if (isset($_POST[$mod.$widget_id.'emailAddressOptOutFlag'])) {
1001
+           foreach ($_POST[$mod.$widget_id.'emailAddressOptOutFlag'] as $v) {
1002 1002
               $optOut[] = $v;
1003 1003
            }
1004 1004
         }
1005 1005
 
1006
-        if(isset($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'])) {
1007
-           foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) {
1006
+        if (isset($_POST[$mod.$widget_id.'emailAddressInvalidFlag'])) {
1007
+           foreach ($_POST[$mod.$widget_id.'emailAddressInvalidFlag'] as $v) {
1008 1008
               $invalid[] = $v;
1009 1009
            }
1010 1010
         }
1011 1011
 
1012
-        if(isset($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'])) {
1013
-           foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) {
1012
+        if (isset($_POST[$mod.$widget_id.'emailAddressReplyToFlag'])) {
1013
+           foreach ($_POST[$mod.$widget_id.'emailAddressReplyToFlag'] as $v) {
1014 1014
               $replyTo[] = $v;
1015 1015
            }
1016 1016
         }
1017 1017
 
1018
-        if(isset($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'])) {
1019
-           foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) {
1018
+        if (isset($_POST[$mod.$widget_id.'emailAddressDeleteFlag'])) {
1019
+           foreach ($_POST[$mod.$widget_id.'emailAddressDeleteFlag'] as $v) {
1020 1020
               $delete[] = $v;
1021 1021
            }
1022 1022
         }
1023 1023
 
1024
-        while(isset($_POST[$mod . $widget_id . "emailAddressVerifiedValue" . $count])) {
1025
-            $verified[] = $_POST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count];
1024
+        while (isset($_POST[$mod.$widget_id."emailAddressVerifiedValue".$count])) {
1025
+            $verified[] = $_POST[$mod.$widget_id.'emailAddressVerifiedValue'.$count];
1026 1026
             $count++;
1027 1027
         }
1028 1028
 
@@ -1047,33 +1047,33 @@  discard block
 block discarded – undo
1047 1047
         $count = 0;
1048 1048
         $mod = isset($focus) ? $focus->module_dir : "";
1049 1049
 
1050
-        $widget_id = $_POST[$mod .'_email_widget_id'];
1051
-        $get .= '&' . $mod . '_email_widget_id='. $widget_id;
1050
+        $widget_id = $_POST[$mod.'_email_widget_id'];
1051
+        $get .= '&'.$mod.'_email_widget_id='.$widget_id;
1052 1052
         $get .= '&emailAddressWidget='.$_POST['emailAddressWidget'];
1053 1053
 
1054
-        while(isset($_REQUEST[$mod . $widget_id . 'emailAddress' . $count])) {
1055
-              $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]);
1054
+        while (isset($_REQUEST[$mod.$widget_id.'emailAddress'.$count])) {
1055
+              $get .= "&".$mod.$widget_id."emailAddress".$count."=".urlencode($_REQUEST[$mod.$widget_id.'emailAddress'.$count]);
1056 1056
               $count++;
1057 1057
         } //while
1058 1058
 
1059
-        while(isset($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count])) {
1060
-              $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]);
1059
+        while (isset($_REQUEST[$mod.$widget_id.'emailAddressVerifiedValue'.$count])) {
1060
+              $get .= "&".$mod.$widget_id."emailAddressVerifiedValue".$count."=".urlencode($_REQUEST[$mod.$widget_id.'emailAddressVerifiedValue'.$count]);
1061 1061
               $count++;
1062 1062
         } //while
1063 1063
 
1064 1064
         $options = array('emailAddressPrimaryFlag', 'emailAddressOptOutFlag', 'emailAddressInvalidFlag', 'emailAddressDeleteFlag', 'emailAddressReplyToFlag');
1065 1065
 
1066
-        foreach($options as $option) {
1066
+        foreach ($options as $option) {
1067 1067
             $count = 0;
1068 1068
             $optionIdentifier = $mod.$widget_id.$option;
1069
-            if(isset($_REQUEST[$optionIdentifier])) {
1070
-               if(is_array($_REQUEST[$optionIdentifier])) {
1071
-                   foreach($_REQUEST[$optionIdentifier] as $optOut) {
1072
-                      $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut;
1069
+            if (isset($_REQUEST[$optionIdentifier])) {
1070
+               if (is_array($_REQUEST[$optionIdentifier])) {
1071
+                   foreach ($_REQUEST[$optionIdentifier] as $optOut) {
1072
+                      $get .= "&".$optionIdentifier."[".$count."]=".$optOut;
1073 1073
                       $count++;
1074 1074
                    } //foreach
1075 1075
                } else {
1076
-                   $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier];
1076
+                   $get .= "&".$optionIdentifier."=".$_REQUEST[$optionIdentifier];
1077 1077
                }
1078 1078
             } //if
1079 1079
         } //foreach
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
  * @return string The value for the bean_module column in the email_addr_bean_rel table
1092 1092
  */
1093 1093
     function getCorrectedModule(&$module) {
1094
-        return ($module == "Employees")? "Users" : $module;
1094
+        return ($module == "Employees") ? "Users" : $module;
1095 1095
     }
1096 1096
 
1097 1097
     public function stash($parentBeanId, $moduleName)
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
         $ids = array();
1102 1102
         while ($row = $this->db->fetchByAssoc($result, false))
1103 1103
         {
1104
-            $ids[] =$this->db->quote($row['email_address_id']); // avoid 2nd order SQL Injection
1104
+            $ids[] = $this->db->quote($row['email_address_id']); // avoid 2nd order SQL Injection
1105 1105
         }
1106 1106
         if (!empty($ids))
1107 1107
         {
@@ -1125,15 +1125,15 @@  discard block
 block discarded – undo
1125 1125
  * @param string $view DetailView or EditView
1126 1126
  * @return string
1127 1127
  */
1128
-function getEmailAddressWidget($focus, $field, $value, $view, $tabindex='0') {
1128
+function getEmailAddressWidget($focus, $field, $value, $view, $tabindex = '0') {
1129 1129
     $sea = new SugarEmailAddress();
1130 1130
     $sea->setView($view);
1131 1131
 
1132
-        if($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
1132
+        if ($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
1133 1133
             $module = $focus->module_dir;
1134 1134
             if ($view == 'ConvertLead' && $module == "Contacts")  $module = "Leads";
1135 1135
 
1136
-            return $sea->getEmailAddressWidgetEditView($focus->id, $module, false,'',$tabindex);
1136
+            return $sea->getEmailAddressWidgetEditView($focus->id, $module, false, '', $tabindex);
1137 1137
         }
1138 1138
 
1139 1139
     return $sea->getEmailAddressWidgetDetailView($focus);
Please login to merge, or discard this patch.
Braces   +39 added lines, -26 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.
@@ -132,8 +134,9 @@  discard block
 block discarded – undo
132 134
         $alternate_found = false;
133 135
         $alternate2_found = false;
134 136
         foreach($this->addresses as $k=>$address) {
135
-            if ($primary_found && $alternate_found)
136
-                break;
137
+            if ($primary_found && $alternate_found) {
138
+                            break;
139
+            }
137 140
             if ($address['primary_address'] == 1 && !$primary_found) {
138 141
                 $primary_index = $k;
139 142
                 $primary_found = true;
@@ -271,8 +274,9 @@  discard block
 block discarded – undo
271 274
         )
272 275
     {
273 276
         $emailCaps = strtoupper(trim($email));
274
-        if(empty($emailCaps))
275
-            return 0;
277
+        if(empty($emailCaps)) {
278
+                    return 0;
279
+        }
276 280
 
277 281
         $q = "SELECT *
278 282
                 FROM email_addr_bean_rel eabl JOIN email_addresses ea
@@ -288,7 +292,9 @@  discard block
 block discarded – undo
288 292
 
289 293
         // do it this way to make the count accurate in oracle
290 294
         $i = 0;
291
-        while ($this->db->fetchByAssoc($r)) ++$i;
295
+        while ($this->db->fetchByAssoc($r)) {
296
+            ++$i;
297
+        }
292 298
 
293 299
         return $i;
294 300
     }
@@ -471,8 +477,9 @@  discard block
 block discarded – undo
471 477
                     foreach($_REQUEST as $k => $v) {
472 478
                         if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) {
473 479
                             $validateFlag = str_replace("Value", "Flag", $k);
474
-                            if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true")
475
-                              $new_addrs[$k] = $v;
480
+                            if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true") {
481
+                                                          $new_addrs[$k] = $v;
482
+                            }
476 483
                         }
477 484
                     }
478 485
                 }
@@ -675,8 +682,7 @@  discard block
 block discarded – undo
675 682
         if ($id) {
676 683
             $r = $this->db->query("SELECT * FROM email_addresses WHERE id='".$this->db->quote($id)."'");
677 684
             $current_email = $this->db->fetchByAssoc($r);
678
-        }
679
-        else {
685
+        } else {
680 686
             $current_email = null;
681 687
         }
682 688
 
@@ -716,8 +722,7 @@  discard block
 block discarded – undo
716 722
                 $upd_r = $this->db->query($upd_q);
717 723
             }
718 724
             return $duplicate_email['id'];
719
-        }
720
-        else {
725
+        } else {
721 726
             // no case-insensitive address match - it's new, or undeleted.
722 727
             $guid = '';
723 728
             if(!empty($address)){
@@ -783,8 +788,7 @@  discard block
 block discarded – undo
783 788
             // otherwise
784 789
             $q .= "
785 790
                 ORDER BY ear.reply_to_address DESC";
786
-        }
787
-        else
791
+        } else
788 792
         {
789 793
             // retrieve reply-to address only
790 794
             $q .= "
@@ -835,8 +839,9 @@  discard block
 block discarded – undo
835 839
      */
836 840
     function getEmailAddressWidgetEditView($id, $module, $asMetadata=false, $tpl='',$tabindex='0')
837 841
     {
838
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
839
-            $this->smarty = new Sugar_Smarty();
842
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
843
+                    $this->smarty = new Sugar_Smarty();
844
+        }
840 845
 
841 846
         global $app_strings, $dictionary, $beanList;
842 847
 
@@ -854,8 +859,9 @@  discard block
 block discarded – undo
854 859
         if(!empty($id)) {
855 860
             $prefillDataArr = $this->getAddressesByGUID($id, $module);
856 861
             //When coming from convert leads, sometimes module is Contacts while the id is for a lead.
857
-            if (empty($prefillDataArr) && $module == "Contacts")
858
-                $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
862
+            if (empty($prefillDataArr) && $module == "Contacts") {
863
+                            $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
864
+            }
859 865
         } else if(isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])){
860 866
             $widget_id = isset($_REQUEST[$module . '_email_widget_id']) ? $_REQUEST[$module . '_email_widget_id'] : '0';
861 867
             $count = 0;
@@ -880,8 +886,9 @@  discard block
 block discarded – undo
880 886
 
881 887
         $required = false;
882 888
         $vardefs = $dictionary[$beanList[$passedModule]]['fields'];
883
-        if (!empty($vardefs['email1']) && isset($vardefs['email1']['required']) && $vardefs['email1']['required'])
884
-            $required = true;
889
+        if (!empty($vardefs['email1']) && isset($vardefs['email1']['required']) && $vardefs['email1']['required']) {
890
+                    $required = true;
891
+        }
885 892
         $this->smarty->assign('required', $required);
886 893
 
887 894
         $this->smarty->assign('module', $saveModule);
@@ -935,13 +942,16 @@  discard block
 block discarded – undo
935 942
      */
936 943
     function getEmailAddressWidgetDetailView($focus, $tpl='')
937 944
     {
938
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
939
-            $this->smarty = new Sugar_Smarty();
945
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
946
+                    $this->smarty = new Sugar_Smarty();
947
+        }
940 948
 
941 949
         global $app_strings;
942 950
         global $current_user;
943 951
         $assign = array();
944
-        if(empty($focus->id))return '';
952
+        if(empty($focus->id)) {
953
+            return '';
954
+        }
945 955
         $prefillData = $this->getAddressesByGUID($focus->id, $focus->module_dir);
946 956
 
947 957
         foreach($prefillData as $addressItem) {
@@ -970,8 +980,9 @@  discard block
 block discarded – undo
970 980
      */
971 981
     function getEmailAddressWidgetDuplicatesView($focus)
972 982
     {
973
-        if ( !($this->smarty instanceOf Sugar_Smarty ) )
974
-            $this->smarty = new Sugar_Smarty();
983
+        if ( !($this->smarty instanceOf Sugar_Smarty ) ) {
984
+                    $this->smarty = new Sugar_Smarty();
985
+        }
975 986
 
976 987
         $count = 0;
977 988
         $emails = array();
@@ -1131,7 +1142,9 @@  discard block
 block discarded – undo
1131 1142
 
1132 1143
         if($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
1133 1144
             $module = $focus->module_dir;
1134
-            if ($view == 'ConvertLead' && $module == "Contacts")  $module = "Leads";
1145
+            if ($view == 'ConvertLead' && $module == "Contacts") {
1146
+                $module = "Leads";
1147
+            }
1135 1148
 
1136 1149
             return $sea->getEmailAddressWidgetEditView($focus->id, $module, false,'',$tabindex);
1137 1150
         }
Please login to merge, or discard this patch.
include/SugarOauth.php 3 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -145,34 +145,34 @@  discard block
 block discarded – undo
145 145
          * @return array
146 146
          */
147 147
         public function getAccessToken($url,
148
-                                       Zend_Oauth_Token_Request $token = null,
149
-                                       $httpMethod = null,
150
-                                       Zend_Oauth_Http_AccessToken $request = null)
148
+                                        Zend_Oauth_Token_Request $token = null,
149
+                                        $httpMethod = null,
150
+                                        Zend_Oauth_Http_AccessToken $request = null)
151 151
         {
152 152
             $this->setAccessTokenUrl($url);
153 153
             $this->_last = $token = parent::getAccessToken($_REQUEST, $this->makeRequestToken());
154 154
             return array('oauth_token' => $token->getToken(), 'oauth_token_secret' => $token->getTokenSecret());
155 155
         }
156 156
 
157
-       /**
158
-        * Fetch URL with OAuth
159
-        * @param string $url
160
-        * @param string $params Query params
161
-        * @param string $method HTTP method
162
-        * @param array $headers HTTP headers
163
-        * @return string
164
-        */
157
+        /**
158
+         * Fetch URL with OAuth
159
+         * @param string $url
160
+         * @param string $params Query params
161
+         * @param string $method HTTP method
162
+         * @param array $headers HTTP headers
163
+         * @return string
164
+         */
165 165
         
166 166
         public function fetch($url, $params = null, $method = 'GET', $headers = null)
167 167
         {
168 168
             $acc = $this->makeAccessToken();
169 169
             if ( strpos($url,'?') ) {
170
-               list($clean_url, $query) = explode('?', $url);
171
-               if($query) {
172
-                   $url = $clean_url;
173
-                   parse_str($query, $query_params);
174
-                   $params = array_merge($params?$params:array(), $query_params);
175
-               }
170
+                list($clean_url, $query) = explode('?', $url);
171
+                if($query) {
172
+                    $url = $clean_url;
173
+                    parse_str($query, $query_params);
174
+                    $params = array_merge($params?$params:array(), $query_params);
175
+                }
176 176
             }
177 177
             $client = $acc->getHttpClient($this->_oauth_config, $url);
178 178
             
@@ -212,33 +212,33 @@  discard block
 block discarded – undo
212 212
             $this->_last = $resp = $client->request();
213 213
             $this->_lastReq = $client->getLastRequest();
214 214
             return $resp->getBody();
215
-       }
215
+        }
216 216
 
217
-       /**
218
-        * Get HTTP client
219
-        * @return Zend_Oauth_Client
220
-        */
221
-       public function getClient()
222
-       {
217
+        /**
218
+         * Get HTTP client
219
+         * @return Zend_Oauth_Client
220
+         */
221
+        public function getClient()
222
+        {
223 223
             $acc = $this->makeAccessToken();
224 224
             return $acc->getHttpClient($this->_oauth_config);
225
-       }
225
+        }
226 226
 
227
-       /**
228
-        * Get last response
229
-        * @return string
230
-        */
231
-       public function getLastResponse()
232
-       {
227
+        /**
228
+         * Get last response
229
+         * @return string
230
+         */
231
+        public function getLastResponse()
232
+        {
233 233
             return $this->_last;
234
-       }
234
+        }
235 235
 
236
-       /**
237
-        * Get last request
238
-        * @return string
239
-        */
240
-       public function getLastRequest()
241
-       {
236
+        /**
237
+         * Get last request
238
+         * @return string
239
+         */
240
+        public function getLastRequest()
241
+        {
242 242
             return $this->_lastReq;
243
-       }
243
+        }
244 244
     }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
          * @param string $consumer_secret
56 56
          * @param array $params OAuth options
57 57
          */
58
-        public function __construct($consumer_key , $consumer_secret, $params = null)
58
+        public function __construct($consumer_key, $consumer_secret, $params = null)
59 59
         {
60 60
             $this->_oauth_config = array(
61 61
                 'consumerKey' => $consumer_key,
62 62
                 'consumerSecret' => $consumer_secret,
63 63
             );
64
-            if(!empty($params)) {
64
+            if (!empty($params)) {
65 65
                 $this->_oauth_config = array_merge($this->_oauth_config, $params);
66 66
             }
67 67
             parent::__construct($this->_oauth_config);
@@ -120,20 +120,20 @@  discard block
 block discarded – undo
120 120
          */
121 121
         public function getRequestTokenByUrl($url, $callback = null, $params = array())
122 122
         {
123
-            if(!empty($callback)) {
123
+            if (!empty($callback)) {
124 124
                 $this->setCallbackUrl($callback);
125 125
             }
126 126
             list($clean_url, $query) = explode('?', $url);
127
-            if($query) {
127
+            if ($query) {
128 128
                 $url = $clean_url;
129 129
                 parse_str($query, $query_params);
130 130
                 $params = array_merge($params, $query_params);
131 131
             }
132 132
             $this->setRequestTokenUrl($url);
133
-            try{
133
+            try {
134 134
                 $this->_last = $token = parent::getRequestToken($params);
135 135
                 return array('oauth_token' => $token->getToken(), 'oauth_token_secret' => $token->getTokenSecret());
136
-            }catch(Zend_Oauth_Exception $e){
136
+            }catch (Zend_Oauth_Exception $e) {
137 137
                 return array('oauth_token' => '', 'oauth_token_secret' => '');
138 138
             }
139 139
         }
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
         public function fetch($url, $params = null, $method = 'GET', $headers = null)
167 167
         {
168 168
             $acc = $this->makeAccessToken();
169
-            if ( strpos($url,'?') ) {
169
+            if (strpos($url, '?')) {
170 170
                list($clean_url, $query) = explode('?', $url);
171
-               if($query) {
171
+               if ($query) {
172 172
                    $url = $clean_url;
173 173
                    parse_str($query, $query_params);
174
-                   $params = array_merge($params?$params:array(), $query_params);
174
+                   $params = array_merge($params ? $params : array(), $query_params);
175 175
                }
176 176
             }
177 177
             $client = $acc->getHttpClient($this->_oauth_config, $url);
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             $proxy_config = SugarModule::get('Administration')->loadBean();
181 181
             $proxy_config->retrieveSettings('proxy');
182 182
             
183
-            if( !empty($proxy_config) && 
183
+            if (!empty($proxy_config) && 
184 184
                 !empty($proxy_config->settings['proxy_on']) &&
185 185
                 $proxy_config->settings['proxy_on'] == 1) {
186 186
                 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                 $proxy_settings['proxy_host'] = $proxy_config->settings['proxy_host'];
189 189
                 $proxy_settings['proxy_port'] = $proxy_config->settings['proxy_port'];
190 190
     
191
-                if(!empty($proxy_config->settings['proxy_auth'])){
191
+                if (!empty($proxy_config->settings['proxy_auth'])) {
192 192
                     $proxy_settings['proxy_user'] = $proxy_config->settings['proxy_username'];
193 193
                     $proxy_settings['proxy_pass'] = $proxy_config->settings['proxy_password'];
194 194
                 }
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
             }
200 200
             
201 201
             $client->setMethod($method);
202
-            if(!empty($headers)) {
202
+            if (!empty($headers)) {
203 203
                 $client->setHeaders($headers);
204 204
             }
205
-            if(!empty($params)) {
206
-                if($method == 'GET') {
205
+            if (!empty($params)) {
206
+                if ($method == 'GET') {
207 207
                     $client->setParameterGet($params);
208 208
                 } else {
209 209
                     $client->setParameterPost($params);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@
 block discarded – undo
133 133
             try{
134 134
                 $this->_last = $token = parent::getRequestToken($params);
135 135
                 return array('oauth_token' => $token->getToken(), 'oauth_token_secret' => $token->getTokenSecret());
136
-            }catch(Zend_Oauth_Exception $e){
136
+            } catch(Zend_Oauth_Exception $e){
137 137
                 return array('oauth_token' => '', 'oauth_token_secret' => '');
138 138
             }
139 139
         }
Please login to merge, or discard this patch.
include/phpmailer/language/phpmailer.lang-ar.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 $PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.';
20 20
 $PHPMAILER_LANG['provide_address']      = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.';
21 21
 $PHPMAILER_LANG['recipients_failed']    = 'خطأ SMTP: الأخطاء التالية ' .
22
-                                          'فشل في الارسال لكل من : ';
22
+                                            'فشل في الارسال لكل من : ';
23 23
 $PHPMAILER_LANG['signing']              = 'خطأ في التوقيع: ';
24 24
 $PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() غير ممكن.';
25 25
 $PHPMAILER_LANG['smtp_error']           = 'خطأ على مستوى الخادم SMTP: ';
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 $PHPMAILER_LANG['invalid_address']      = 'الإرسال غير ممكن لأن عنوان البريد الإلكتروني غير صالح.';
19 19
 $PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.';
20 20
 $PHPMAILER_LANG['provide_address']      = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.';
21
-$PHPMAILER_LANG['recipients_failed']    = 'خطأ SMTP: الأخطاء التالية ' .
21
+$PHPMAILER_LANG['recipients_failed']    = 'خطأ SMTP: الأخطاء التالية '.
22 22
                                           'فشل في الارسال لكل من : ';
23 23
 $PHPMAILER_LANG['signing']              = 'خطأ في التوقيع: ';
24 24
 $PHPMAILER_LANG['smtp_connect_failed']  = 'SMTP Connect() غير ممكن.';
Please login to merge, or discard this patch.
include/formbase.php 3 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function checkRequired($prefix, $required)
56 56
 {
57
-	foreach($required as $key)
58
-	{
59
-		if(!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key]))
60
-		{
61
-			return false;
62
-		}
63
-	}
64
-	return true;
57
+    foreach($required as $key)
58
+    {
59
+        if(!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key]))
60
+        {
61
+            return false;
62
+        }
63
+    }
64
+    return true;
65 65
 }
66 66
 
67 67
 /**
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
  */
76 76
 function populateFromPost($prefix, &$focus, $skipRetrieve = false, $checkACL = false)
77 77
 {
78
-	global $current_user;
78
+    global $current_user;
79 79
 
80
-	if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve)
81
-		$focus->retrieve($_REQUEST[$prefix.'record']);
80
+    if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve)
81
+        $focus->retrieve($_REQUEST[$prefix.'record']);
82 82
 
83
-	if(!empty($_POST['assigned_user_id']) && 
84
-	    ($focus->assigned_user_id != $_POST['assigned_user_id']) && 
85
-	    ($_POST['assigned_user_id'] != $current_user->id)) {
86
-		$GLOBALS['check_notify'] = true;
87
-	}
83
+    if(!empty($_POST['assigned_user_id']) && 
84
+        ($focus->assigned_user_id != $_POST['assigned_user_id']) && 
85
+        ($_POST['assigned_user_id'] != $current_user->id)) {
86
+        $GLOBALS['check_notify'] = true;
87
+    }
88 88
     if(isset($_POST['dup_checked']) && $_POST['dup_checked'] && isset($_POST['id']) && $_POST['id'] != '' ){
89 89
         $focus->new_with_id = true;
90 90
     }
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
         $relatedFields[$def['id_name']] = $field;
107 107
     }
108 108
 
109
-	foreach($focus->field_defs as $field=>$def) {
109
+    foreach($focus->field_defs as $field=>$def) {
110 110
         if ( $field == 'id' && !empty($focus->id) ) {
111 111
             // Don't try and overwrite the ID
112 112
             continue;
113 113
         }
114 114
 
115 115
 
116
-	    $type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type'];
117
-		$sf = $sfh->getSugarField($type);
116
+        $type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type'];
117
+        $sf = $sfh->getSugarField($type);
118 118
         if($sf != null){
119 119
             $sf->save($focus, $_POST, $field, $def, $prefix);
120 120
         } else {
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 			$focus->$field = '';
153 153
 		}
154 154
 */
155
-	}
155
+    }
156 156
 
157
-	foreach($focus->additional_column_fields as $field) {
158
-		if(isset($_POST[$prefix.$field])) {
159
-			$value = $_POST[$prefix.$field];
160
-			$focus->$field = $value;
161
-		}
162
-	}
163
-	return $focus;
157
+    foreach($focus->additional_column_fields as $field) {
158
+        if(isset($_POST[$prefix.$field])) {
159
+            $value = $_POST[$prefix.$field];
160
+            $focus->$field = $value;
161
+        }
162
+    }
163
+    return $focus;
164 164
 }
165 165
 
166 166
 function add_hidden_elements($key, $value) {
@@ -182,73 +182,73 @@  discard block
 block discarded – undo
182 182
 
183 183
 function getPostToForm($ignore='', $isRegularExpression=false)
184 184
 {
185
-	$fields = '';
186
-	if(!empty($ignore) && $isRegularExpression) {
187
-		foreach ($_POST as $key=>$value){
188
-			if(!preg_match($ignore, $key)) {
185
+    $fields = '';
186
+    if(!empty($ignore) && $isRegularExpression) {
187
+        foreach ($_POST as $key=>$value){
188
+            if(!preg_match($ignore, $key)) {
189 189
                                 $fields .= add_hidden_elements($key, $value);
190
-			}
191
-		}	
192
-	} else {
193
-		foreach ($_POST as $key=>$value){
194
-			if($key != $ignore) {
190
+            }
191
+        }	
192
+    } else {
193
+        foreach ($_POST as $key=>$value){
194
+            if($key != $ignore) {
195 195
                                 $fields .= add_hidden_elements($key, $value);
196
-			}
197
-		}
198
-	}
199
-	return $fields;
196
+            }
197
+        }
198
+    }
199
+    return $fields;
200 200
 }
201 201
 
202 202
 function getGetToForm($ignore='', $usePostAsAuthority = false)
203 203
 {
204
-	$fields = '';
205
-	foreach ($_GET as $key=>$value)
206
-	{
207
-		if($key != $ignore){
208
-			if(!$usePostAsAuthority || !isset($_POST[$key])){
209
-				$fields.= "<input type='hidden' name='$key' value='$value'>";
210
-			}
211
-		}
212
-	}
213
-	return $fields;
204
+    $fields = '';
205
+    foreach ($_GET as $key=>$value)
206
+    {
207
+        if($key != $ignore){
208
+            if(!$usePostAsAuthority || !isset($_POST[$key])){
209
+                $fields.= "<input type='hidden' name='$key' value='$value'>";
210
+            }
211
+        }
212
+    }
213
+    return $fields;
214 214
 
215 215
 }
216 216
 function getAnyToForm($ignore='', $usePostAsAuthority = false)
217 217
 {
218
-	$fields = getPostToForm($ignore);
219
-	$fields .= getGetToForm($ignore, $usePostAsAuthority);
220
-	return $fields;
218
+    $fields = getPostToForm($ignore);
219
+    $fields .= getGetToForm($ignore, $usePostAsAuthority);
220
+    return $fields;
221 221
 
222 222
 }
223 223
 
224 224
 function handleRedirect($return_id='', $return_module='', $additionalFlags = false)
225 225
 {
226
-	if(isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "")
227
-	{
228
-		header("Location: ". $_REQUEST['return_url']);
229
-		exit;
230
-	}
231
-
232
-	$url = buildRedirectURL($return_id, $return_module);
233
-	header($url);
234
-	exit;	
226
+    if(isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "")
227
+    {
228
+        header("Location: ". $_REQUEST['return_url']);
229
+        exit;
230
+    }
231
+
232
+    $url = buildRedirectURL($return_id, $return_module);
233
+    header($url);
234
+    exit;	
235 235
 }
236 236
 
237 237
 //eggsurplus: abstract to simplify unit testing
238 238
 function buildRedirectURL($return_id='', $return_module='') 
239 239
 {
240 240
     if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "")
241
-	{
242
-		$return_module = $_REQUEST['return_module'];
243
-	}
244
-	else
245
-	{
246
-		$return_module = $return_module;
247
-	}
248
-	if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "")
249
-	{
241
+    {
242
+        $return_module = $_REQUEST['return_module'];
243
+    }
244
+    else
245
+    {
246
+        $return_module = $return_module;
247
+    }
248
+    if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "")
249
+    {
250 250
 	    
251
-	   //if we are doing a "Close and Create New"
251
+        //if we are doing a "Close and Create New"
252 252
         if(isCloseAndCreateNewPressed())
253 253
         {
254 254
             $return_action = "EditView";    
@@ -257,40 +257,40 @@  discard block
 block discarded – undo
257 257
             
258 258
             // Meeting Integration
259 259
             if(isset($_REQUEST['meetingIntegrationFlag']) && $_REQUEST['meetingIntegrationFlag'] == 1) {
260
-            	$additionalFlags = array('meetingIntegrationShowForm' => '1');
260
+                $additionalFlags = array('meetingIntegrationShowForm' => '1');
261 261
             }
262 262
             // END Meeting Integration
263 263
         } 
264
-		// if we create a new record "Save", we want to redirect to the DetailView
265
-		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" 
266
-			&& $_REQUEST['return_module'] != 'Activities'
267
-			&& $_REQUEST['return_module'] != 'Home' 
268
-			&& $_REQUEST['return_module'] != 'Forecasts' 
269
-			&& $_REQUEST['return_module'] != 'Calendar'
270
-			&& $_REQUEST['return_module'] != 'MailMerge'
271
-			) 
272
-			{
273
-			    $return_action = 'DetailView';
274
-			} elseif($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') {
275
-			$return_module = $_REQUEST['module'];
276
-			$return_action = $_REQUEST['return_action']; 
277
-			// wp: return action needs to be set for one-click close in task list
278
-		} 
279
-		else 
280
-		{
281
-			// if we "Cancel", we go back to the list view.
282
-			$return_action = $_REQUEST['return_action'];
283
-		}
284
-	}
285
-	else
286
-	{
287
-		$return_action = "DetailView";
288
-	}
264
+        // if we create a new record "Save", we want to redirect to the DetailView
265
+        else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" 
266
+            && $_REQUEST['return_module'] != 'Activities'
267
+            && $_REQUEST['return_module'] != 'Home' 
268
+            && $_REQUEST['return_module'] != 'Forecasts' 
269
+            && $_REQUEST['return_module'] != 'Calendar'
270
+            && $_REQUEST['return_module'] != 'MailMerge'
271
+            ) 
272
+            {
273
+                $return_action = 'DetailView';
274
+            } elseif($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') {
275
+            $return_module = $_REQUEST['module'];
276
+            $return_action = $_REQUEST['return_action']; 
277
+            // wp: return action needs to be set for one-click close in task list
278
+        } 
279
+        else 
280
+        {
281
+            // if we "Cancel", we go back to the list view.
282
+            $return_action = $_REQUEST['return_action'];
283
+        }
284
+    }
285
+    else
286
+    {
287
+        $return_action = "DetailView";
288
+    }
289 289
 	
290
-	if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "")
291
-	{
292
-		$return_id = $_REQUEST['return_id'];
293
-	}
290
+    if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "")
291
+    {
292
+        $return_id = $_REQUEST['return_id'];
293
+    }
294 294
 
295 295
     $add = "";
296 296
     if(isset($additionalFlags) && !empty($additionalFlags)) {
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
             return "Location: $url";
321 321
         }
322 322
     } else {
323
-    	$standard = "action=$return_action&module=$return_module&record=$return_id&isDuplicate=true&return_module=$return_module&return_action=$return_action&status=$status";
323
+        $standard = "action=$return_action&module=$return_module&record=$return_id&isDuplicate=true&return_module=$return_module&return_action=$return_action&status=$status";
324 324
         $url="index.php?{$standard}{$add}";
325 325
         if(!empty($_REQUEST['ajax_load']))
326 326
         {
327 327
             $ajax_ret = array(
328
-                 'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n",
329
-                 'menu' => array(
330
-                     'module' => $return_module,
331
-                     'label' => translate($return_module),
332
-                 ),
328
+                    'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n",
329
+                    'menu' => array(
330
+                        'module' => $return_module,
331
+                        'label' => translate($return_module),
332
+                    ),
333 333
             );
334 334
             $json = getJSONobj();
335 335
             echo $json->encode($ajax_ret);
@@ -341,21 +341,21 @@  discard block
 block discarded – undo
341 341
 
342 342
 function getLikeForEachWord($fieldname, $value, $minsize=4)
343 343
 {
344
-	$value = trim($value);
345
-	$values = explode(' ',$value);
346
-	$ret = '';
347
-	foreach($values as $val)
348
-	{
349
-		if(strlen($val) >= $minsize)
350
-		{
351
-			if(!empty($ret))
352
-			{
353
-				$ret .= ' or';
354
-			}
355
-			$ret .= ' '. $fieldname . ' LIKE %'.$val.'%';
356
-		}
344
+    $value = trim($value);
345
+    $values = explode(' ',$value);
346
+    $ret = '';
347
+    foreach($values as $val)
348
+    {
349
+        if(strlen($val) >= $minsize)
350
+        {
351
+            if(!empty($ret))
352
+            {
353
+                $ret .= ' or';
354
+            }
355
+            $ret .= ' '. $fieldname . ' LIKE %'.$val.'%';
356
+        }
357 357
 
358
-	}
358
+    }
359 359
 
360 360
 
361 361
 }
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function checkRequired($prefix, $required)
56 56
 {
57
-	foreach($required as $key)
57
+	foreach ($required as $key)
58 58
 	{
59
-		if(!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key]))
59
+		if (!isset($_POST[$prefix.$key]) || number_empty($_POST[$prefix.$key]))
60 60
 		{
61 61
 			return false;
62 62
 		}
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 {
78 78
 	global $current_user;
79 79
 
80
-	if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve)
80
+	if (!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve)
81 81
 		$focus->retrieve($_REQUEST[$prefix.'record']);
82 82
 
83
-	if(!empty($_POST['assigned_user_id']) && 
83
+	if (!empty($_POST['assigned_user_id']) && 
84 84
 	    ($focus->assigned_user_id != $_POST['assigned_user_id']) && 
85 85
 	    ($_POST['assigned_user_id'] != $current_user->id)) {
86 86
 		$GLOBALS['check_notify'] = true;
87 87
 	}
88
-    if(isset($_POST['dup_checked']) && $_POST['dup_checked'] && isset($_POST['id']) && $_POST['id'] != '' ){
88
+    if (isset($_POST['dup_checked']) && $_POST['dup_checked'] && isset($_POST['id']) && $_POST['id'] != '') {
89 89
         $focus->new_with_id = true;
90 90
     }
91 91
     require_once('include/SugarFields/SugarFieldHandler.php');
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
         $relatedFields[$def['id_name']] = $field;
107 107
     }
108 108
 
109
-	foreach($focus->field_defs as $field=>$def) {
110
-        if ( $field == 'id' && !empty($focus->id) ) {
109
+	foreach ($focus->field_defs as $field=>$def) {
110
+        if ($field == 'id' && !empty($focus->id)) {
111 111
             // Don't try and overwrite the ID
112 112
             continue;
113 113
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 	    $type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type'];
117 117
 		$sf = $sfh->getSugarField($type);
118
-        if($sf != null){
118
+        if ($sf != null) {
119 119
             $sf->save($focus, $_POST, $field, $def, $prefix);
120 120
         } else {
121 121
             $GLOBALS['log']->fatal("Field '$field' does not have a SugarField handler");
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 */
155 155
 	}
156 156
 
157
-	foreach($focus->additional_column_fields as $field) {
158
-		if(isset($_POST[$prefix.$field])) {
157
+	foreach ($focus->additional_column_fields as $field) {
158
+		if (isset($_POST[$prefix.$field])) {
159 159
 			$value = $_POST[$prefix.$field];
160 160
 			$focus->$field = $value;
161 161
 		}
@@ -180,18 +180,18 @@  discard block
 block discarded – undo
180 180
 }
181 181
 
182 182
 
183
-function getPostToForm($ignore='', $isRegularExpression=false)
183
+function getPostToForm($ignore = '', $isRegularExpression = false)
184 184
 {
185 185
 	$fields = '';
186
-	if(!empty($ignore) && $isRegularExpression) {
187
-		foreach ($_POST as $key=>$value){
188
-			if(!preg_match($ignore, $key)) {
186
+	if (!empty($ignore) && $isRegularExpression) {
187
+		foreach ($_POST as $key=>$value) {
188
+			if (!preg_match($ignore, $key)) {
189 189
                                 $fields .= add_hidden_elements($key, $value);
190 190
 			}
191 191
 		}	
192 192
 	} else {
193
-		foreach ($_POST as $key=>$value){
194
-			if($key != $ignore) {
193
+		foreach ($_POST as $key=>$value) {
194
+			if ($key != $ignore) {
195 195
                                 $fields .= add_hidden_elements($key, $value);
196 196
 			}
197 197
 		}
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
 	return $fields;
200 200
 }
201 201
 
202
-function getGetToForm($ignore='', $usePostAsAuthority = false)
202
+function getGetToForm($ignore = '', $usePostAsAuthority = false)
203 203
 {
204 204
 	$fields = '';
205 205
 	foreach ($_GET as $key=>$value)
206 206
 	{
207
-		if($key != $ignore){
208
-			if(!$usePostAsAuthority || !isset($_POST[$key])){
209
-				$fields.= "<input type='hidden' name='$key' value='$value'>";
207
+		if ($key != $ignore) {
208
+			if (!$usePostAsAuthority || !isset($_POST[$key])) {
209
+				$fields .= "<input type='hidden' name='$key' value='$value'>";
210 210
 			}
211 211
 		}
212 212
 	}
213 213
 	return $fields;
214 214
 
215 215
 }
216
-function getAnyToForm($ignore='', $usePostAsAuthority = false)
216
+function getAnyToForm($ignore = '', $usePostAsAuthority = false)
217 217
 {
218 218
 	$fields = getPostToForm($ignore);
219 219
 	$fields .= getGetToForm($ignore, $usePostAsAuthority);
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 
222 222
 }
223 223
 
224
-function handleRedirect($return_id='', $return_module='', $additionalFlags = false)
224
+function handleRedirect($return_id = '', $return_module = '', $additionalFlags = false)
225 225
 {
226
-	if(isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "")
226
+	if (isset($_REQUEST['return_url']) && $_REQUEST['return_url'] != "")
227 227
 	{
228
-		header("Location: ". $_REQUEST['return_url']);
228
+		header("Location: ".$_REQUEST['return_url']);
229 229
 		exit;
230 230
 	}
231 231
 
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 }
236 236
 
237 237
 //eggsurplus: abstract to simplify unit testing
238
-function buildRedirectURL($return_id='', $return_module='') 
238
+function buildRedirectURL($return_id = '', $return_module = '') 
239 239
 {
240
-    if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "")
240
+    if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "")
241 241
 	{
242 242
 		$return_module = $_REQUEST['return_module'];
243 243
 	}
@@ -245,24 +245,24 @@  discard block
 block discarded – undo
245 245
 	{
246 246
 		$return_module = $return_module;
247 247
 	}
248
-	if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "")
248
+	if (isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "")
249 249
 	{
250 250
 	    
251 251
 	   //if we are doing a "Close and Create New"
252
-        if(isCloseAndCreateNewPressed())
252
+        if (isCloseAndCreateNewPressed())
253 253
         {
254 254
             $return_action = "EditView";    
255 255
             $isDuplicate = "true";        
256 256
             $status = "";
257 257
             
258 258
             // Meeting Integration
259
-            if(isset($_REQUEST['meetingIntegrationFlag']) && $_REQUEST['meetingIntegrationFlag'] == 1) {
259
+            if (isset($_REQUEST['meetingIntegrationFlag']) && $_REQUEST['meetingIntegrationFlag'] == 1) {
260 260
             	$additionalFlags = array('meetingIntegrationShowForm' => '1');
261 261
             }
262 262
             // END Meeting Integration
263 263
         } 
264 264
 		// if we create a new record "Save", we want to redirect to the DetailView
265
-		else if(isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" 
265
+		else if (isset($_REQUEST['action']) && $_REQUEST['action'] == "Save" 
266 266
 			&& $_REQUEST['return_module'] != 'Activities'
267 267
 			&& $_REQUEST['return_module'] != 'Home' 
268 268
 			&& $_REQUEST['return_module'] != 'Forecasts' 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 			) 
272 272
 			{
273 273
 			    $return_action = 'DetailView';
274
-			} elseif($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') {
274
+			} elseif ($_REQUEST['return_module'] == 'Activities' || $_REQUEST['return_module'] == 'Calendar') {
275 275
 			$return_module = $_REQUEST['module'];
276 276
 			$return_action = $_REQUEST['return_action']; 
277 277
 			// wp: return action needs to be set for one-click close in task list
@@ -287,25 +287,25 @@  discard block
 block discarded – undo
287 287
 		$return_action = "DetailView";
288 288
 	}
289 289
 	
290
-	if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "")
290
+	if (isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "")
291 291
 	{
292 292
 		$return_id = $_REQUEST['return_id'];
293 293
 	}
294 294
 
295 295
     $add = "";
296
-    if(isset($additionalFlags) && !empty($additionalFlags)) {
297
-        foreach($additionalFlags as $k => $v) {
296
+    if (isset($additionalFlags) && !empty($additionalFlags)) {
297
+        foreach ($additionalFlags as $k => $v) {
298 298
             $add .= "&{$k}={$v}";
299 299
         }
300 300
     }
301 301
     
302 302
     if (!isset($isDuplicate) || !$isDuplicate)
303 303
     {
304
-        $url="index.php?action=$return_action&module=$return_module&record=$return_id&return_module=$return_module&return_action=$return_action{$add}";
305
-        if(isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) {
304
+        $url = "index.php?action=$return_action&module=$return_module&record=$return_id&return_module=$return_module&return_action=$return_action{$add}";
305
+        if (isset($_REQUEST['offset']) && empty($_REQUEST['duplicateSave'])) {
306 306
             $url .= "&offset=".$_REQUEST['offset'];
307 307
         }
308
-        if(!empty($_REQUEST['ajax_load']))
308
+        if (!empty($_REQUEST['ajax_load']))
309 309
         {
310 310
             $ajax_ret = array(
311 311
                 'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n",
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
         }
322 322
     } else {
323 323
     	$standard = "action=$return_action&module=$return_module&record=$return_id&isDuplicate=true&return_module=$return_module&return_action=$return_action&status=$status";
324
-        $url="index.php?{$standard}{$add}";
325
-        if(!empty($_REQUEST['ajax_load']))
324
+        $url = "index.php?{$standard}{$add}";
325
+        if (!empty($_REQUEST['ajax_load']))
326 326
         {
327 327
             $ajax_ret = array(
328 328
                  'content' => "<script>SUGAR.ajaxUI.loadContent('$url');</script>\n",
@@ -339,20 +339,20 @@  discard block
 block discarded – undo
339 339
     }
340 340
 }
341 341
 
342
-function getLikeForEachWord($fieldname, $value, $minsize=4)
342
+function getLikeForEachWord($fieldname, $value, $minsize = 4)
343 343
 {
344 344
 	$value = trim($value);
345
-	$values = explode(' ',$value);
345
+	$values = explode(' ', $value);
346 346
 	$ret = '';
347
-	foreach($values as $val)
347
+	foreach ($values as $val)
348 348
 	{
349
-		if(strlen($val) >= $minsize)
349
+		if (strlen($val) >= $minsize)
350 350
 		{
351
-			if(!empty($ret))
351
+			if (!empty($ret))
352 352
 			{
353 353
 				$ret .= ' or';
354 354
 			}
355
-			$ret .= ' '. $fieldname . ' LIKE %'.$val.'%';
355
+			$ret .= ' '.$fieldname.' LIKE %'.$val.'%';
356 356
 		}
357 357
 
358 358
 	}
@@ -373,36 +373,36 @@  discard block
 block discarded – undo
373 373
  * @see include/generic/Save2.php
374 374
  */
375 375
 
376
-function add_prospects_to_prospect_list($parent_id,$child_id)
376
+function add_prospects_to_prospect_list($parent_id, $child_id)
377 377
 {
378
-    $focus=BeanFactory::getBean('Prospects');
379
-    if(is_array($child_id)){
378
+    $focus = BeanFactory::getBean('Prospects');
379
+    if (is_array($child_id)) {
380 380
         $uids = $child_id;
381 381
     }
382
-    else{
382
+    else {
383 383
         $uids = array($child_id);
384 384
     }
385 385
 
386 386
     $relationship = '';
387
-    foreach($focus->get_linked_fields() as $field => $def) {
387
+    foreach ($focus->get_linked_fields() as $field => $def) {
388 388
         if ($focus->load_relationship($field)) {
389
-            if ( $focus->$field->getRelatedModuleName() == 'ProspectLists' ) {
389
+            if ($focus->$field->getRelatedModuleName() == 'ProspectLists') {
390 390
                 $relationship = $field;
391 391
                 break;
392 392
             }
393 393
         }
394 394
     }
395 395
 
396
-    if ( $relationship != '' ) {
397
-        foreach ( $uids as $id) {
396
+    if ($relationship != '') {
397
+        foreach ($uids as $id) {
398 398
             $focus->retrieve($id);
399 399
             $focus->load_relationship($relationship);
400
-            $focus->prospect_lists->add( $parent_id );
400
+            $focus->prospect_lists->add($parent_id);
401 401
         }
402 402
     }
403 403
 }
404 404
 
405
-function add_to_prospect_list($query_panel,$parent_module,$parent_type,$parent_id,$child_id,$link_attribute,$link_type,$parent)
405
+function add_to_prospect_list($query_panel, $parent_module, $parent_type, $parent_id, $child_id, $link_attribute, $link_type, $parent)
406 406
 {
407 407
     $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$query_panel);
408 408
     $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$parent_module);
@@ -419,21 +419,21 @@  discard block
 block discarded – undo
419 419
     }
420 420
     $focus = new $parent_type();
421 421
     $focus->retrieve($parent_id);
422
-    if(empty($focus->id)) {
422
+    if (empty($focus->id)) {
423 423
         return false;
424 424
     }
425
-    if(empty($parent)) {
425
+    if (empty($parent)) {
426 426
         return false;
427 427
     }
428 428
 
429 429
     //if link_type is default then load relationship once and add all the child ids.
430
-    $relationship_attribute=$link_attribute;
430
+    $relationship_attribute = $link_attribute;
431 431
 
432 432
     //find all prospects based on the query
433 433
 
434 434
     $subpanel = new SubPanelTiles($parent, $parent->module_dir);
435
-    $thisPanel=$subpanel->subpanel_definitions->load_subpanel($query_panel);
436
-    if(empty($thisPanel)) {
435
+    $thisPanel = $subpanel->subpanel_definitions->load_subpanel($query_panel);
436
+    if (empty($thisPanel)) {
437 437
         return false;
438 438
     }
439 439
 
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
         $thisPanel->_instance_properties['function_parameters']['EMAIL_MARKETING_ID_VALUE'] = $_REQUEST['marketing_id'];
444 444
     }
445 445
 
446
-    $result = SugarBean::get_union_related_list($parent, '', '', '', 0, -99,-99,'', $thisPanel);
446
+    $result = SugarBean::get_union_related_list($parent, '', '', '', 0, -99, -99, '', $thisPanel);
447 447
 
448
-    if(!empty($result['list'])) {
449
-        foreach($result['list'] as $object) {
448
+    if (!empty($result['list'])) {
449
+        foreach ($result['list'] as $object) {
450 450
             if ($link_type != 'default') {
451
-                $relationship_attribute=strtolower($object->$link_attribute);
451
+                $relationship_attribute = strtolower($object->$link_attribute);
452 452
             }
453 453
             $GLOBALS['log']->debug('add_prospects_to_prospect_list:relationship_attribute:'.$relationship_attribute);
454 454
             // load relationship for the first time or on change of relationship atribute.
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 }
463 463
 
464 464
 //Link rows returned by a report to parent record.
465
-function save_from_report($report_id,$parent_id, $module_name, $relationship_attr_name) {
465
+function save_from_report($report_id, $parent_id, $module_name, $relationship_attr_name) {
466 466
     global $beanFiles;
467 467
     global $beanList;
468 468
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     $GLOBALS['log']->debug("Save2:Module Name=".$module_name);
473 473
     $GLOBALS['log']->debug("Save2:Relationship Attribute Name=".$relationship_attr_name);
474 474
 
475
-    $GLOBALS['log']->debug("Save2:Bean Name=" . $module_name);
475
+    $GLOBALS['log']->debug("Save2:Bean Name=".$module_name);
476 476
     $focus = BeanFactory::newBean($module_name);
477 477
 
478 478
     $focus->retrieve($parent_id);
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
     //fetch report definition.
482 482
     global $current_language, $report_modules, $modules_report;
483 483
 
484
-    $mod_strings = return_module_language($current_language,"Reports");
484
+    $mod_strings = return_module_language($current_language, "Reports");
485 485
 
486 486
 
487 487
     $saved = new SavedReport();
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     $result = $report->db->query($sql);
499 499
 
500 500
     $reportBean = BeanFactory::newBean($saved->module);
501
-    while($row = $report->db->fetchByAssoc($result))
501
+    while ($row = $report->db->fetchByAssoc($result))
502 502
     {
503 503
         $reportBean->id = $row['primaryid'];
504 504
         $focus->$relationship_attr_name->add($reportBean);
Please login to merge, or discard this patch.
Braces   +10 added lines, -11 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.
@@ -77,8 +79,9 @@  discard block
 block discarded – undo
77 79
 {
78 80
 	global $current_user;
79 81
 
80
-	if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve)
81
-		$focus->retrieve($_REQUEST[$prefix.'record']);
82
+	if(!empty($_REQUEST[$prefix.'record']) && !$skipRetrieve) {
83
+			$focus->retrieve($_REQUEST[$prefix.'record']);
84
+	}
82 85
 
83 86
 	if(!empty($_POST['assigned_user_id']) && 
84 87
 	    ($focus->assigned_user_id != $_POST['assigned_user_id']) && 
@@ -240,8 +243,7 @@  discard block
 block discarded – undo
240 243
     if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "")
241 244
 	{
242 245
 		$return_module = $_REQUEST['return_module'];
243
-	}
244
-	else
246
+	} else
245 247
 	{
246 248
 		$return_module = $return_module;
247 249
 	}
@@ -275,14 +277,12 @@  discard block
 block discarded – undo
275 277
 			$return_module = $_REQUEST['module'];
276 278
 			$return_action = $_REQUEST['return_action']; 
277 279
 			// wp: return action needs to be set for one-click close in task list
278
-		} 
279
-		else 
280
+		} else 
280 281
 		{
281 282
 			// if we "Cancel", we go back to the list view.
282 283
 			$return_action = $_REQUEST['return_action'];
283 284
 		}
284
-	}
285
-	else
285
+	} else
286 286
 	{
287 287
 		$return_action = "DetailView";
288 288
 	}
@@ -378,8 +378,7 @@  discard block
 block discarded – undo
378 378
     $focus=BeanFactory::getBean('Prospects');
379 379
     if(is_array($child_id)){
380 380
         $uids = $child_id;
381
-    }
382
-    else{
381
+    } else{
383 382
         $uids = array($child_id);
384 383
     }
385 384
 
Please login to merge, or discard this patch.
include/utils.php 3 patches
Indentation   +2374 added lines, -2374 removed lines patch added patch discarded remove patch
@@ -51,381 +51,381 @@  discard block
 block discarded – undo
51 51
 
52 52
 function make_sugar_config(&$sugar_config)
53 53
 {
54
-	/* used to convert non-array config.php file to array format */
55
-	global $admin_export_only;
56
-	global $cache_dir;
57
-	global $calculate_response_time;
58
-	global $create_default_user;
59
-	global $dateFormats;
60
-	global $dbconfig;
61
-	global $dbconfigoption;
62
-	global $default_action;
63
-	global $default_charset;
64
-	global $default_currency_name;
65
-	global $default_currency_symbol;
54
+    /* used to convert non-array config.php file to array format */
55
+    global $admin_export_only;
56
+    global $cache_dir;
57
+    global $calculate_response_time;
58
+    global $create_default_user;
59
+    global $dateFormats;
60
+    global $dbconfig;
61
+    global $dbconfigoption;
62
+    global $default_action;
63
+    global $default_charset;
64
+    global $default_currency_name;
65
+    global $default_currency_symbol;
66 66
     global $default_currency_iso4217;
67
-	global $defaultDateFormat;
68
-	global $default_language;
69
-	global $default_module;
70
-	global $default_password;
71
-	global $default_permission_mode;
72
-	global $default_theme;
73
-	global $defaultTimeFormat;
74
-	global $default_user_is_admin;
75
-	global $default_user_name;
76
-	global $disable_export;
77
-	global $disable_persistent_connections;
78
-	global $display_email_template_variable_chooser;
79
-	global $display_inbound_email_buttons;
80
-	global $history_max_viewed;
81
-	global $host_name;
82
-	global $import_dir;
83
-	global $languages;
84
-	global $list_max_entries_per_page;
85
-	global $lock_default_user_name;
86
-	global $log_memory_usage;
67
+    global $defaultDateFormat;
68
+    global $default_language;
69
+    global $default_module;
70
+    global $default_password;
71
+    global $default_permission_mode;
72
+    global $default_theme;
73
+    global $defaultTimeFormat;
74
+    global $default_user_is_admin;
75
+    global $default_user_name;
76
+    global $disable_export;
77
+    global $disable_persistent_connections;
78
+    global $display_email_template_variable_chooser;
79
+    global $display_inbound_email_buttons;
80
+    global $history_max_viewed;
81
+    global $host_name;
82
+    global $import_dir;
83
+    global $languages;
84
+    global $list_max_entries_per_page;
85
+    global $lock_default_user_name;
86
+    global $log_memory_usage;
87 87
     global $nameFormats;
88
-	global $requireAccounts;
89
-	global $RSS_CACHE_TIME;
90
-	global $session_dir;
91
-	global $site_URL;
92
-	global $site_url;
93
-	global $sugar_version;
94
-	global $timeFormats;
95
-	global $tmp_dir;
96
-	global $translation_string_prefix;
97
-	global $unique_key;
98
-	global $upload_badext;
99
-	global $upload_dir;
100
-	global $upload_maxsize;
101
-	global $import_max_execution_time;
102
-	global $list_max_entries_per_subpanel;
103
-	global $passwordsetting;
104
-
105
-	// assumes the following variables must be set:
106
-	// $dbconfig, $dbconfigoption, $cache_dir,  $session_dir, $site_URL, $upload_dir
107
-
108
-	$sugar_config = array (
109
-	'admin_export_only' => empty($admin_export_only) ? false : $admin_export_only,
110
-	'export_delimiter' => empty($export_delimiter) ? ',' : $export_delimiter,
111
-	'cache_dir' => empty($cache_dir) ? 'cache/' : $cache_dir,
112
-	'calculate_response_time' => empty($calculate_response_time) ? true : $calculate_response_time,
113
-	'create_default_user' => empty($create_default_user) ? false : $create_default_user,
114
-	'chartEngine' => 'Jit',
115
-	'date_formats' => empty($dateFormats) ? array(
116
-	'Y-m-d'=>'2010-12-23',
117
-	'd-m-Y' => '23-12-2010',
118
-	'm-d-Y'=>'12-23-2010',
119
-	'Y/m/d'=>'2010/12/23',
120
-	'd/m/Y' => '23/12/2010',
121
-	'm/d/Y'=>'12/23/2010',
122
-	'Y.m.d' => '2010.12.23',
123
-	'd.m.Y' => '23.12.2010',
124
-	'm.d.Y' => '12.23.2010'
125
-		) : $dateFormats,
126
-	'dbconfig' => $dbconfig,  // this must be set!!
127
-	'dbconfigoption' => $dbconfigoption,  // this must be set!!
128
-	'default_action' => empty($default_action) ? 'index' : $default_action,
129
-	'default_charset' => empty($default_charset) ? 'UTF-8' : $default_charset,
130
-	'default_currency_name' => empty($default_currency_name) ? 'US Dollar' : $default_currency_name,
131
-	'default_currency_symbol' => empty($default_currency_symbol) ? '$' : $default_currency_symbol,
132
-	'default_currency_iso4217' => empty($default_currency_iso4217) ? '$' : $default_currency_iso4217,
133
-	'default_date_format' => empty($defaultDateFormat) ? 'm/d/Y' : $defaultDateFormat,
88
+    global $requireAccounts;
89
+    global $RSS_CACHE_TIME;
90
+    global $session_dir;
91
+    global $site_URL;
92
+    global $site_url;
93
+    global $sugar_version;
94
+    global $timeFormats;
95
+    global $tmp_dir;
96
+    global $translation_string_prefix;
97
+    global $unique_key;
98
+    global $upload_badext;
99
+    global $upload_dir;
100
+    global $upload_maxsize;
101
+    global $import_max_execution_time;
102
+    global $list_max_entries_per_subpanel;
103
+    global $passwordsetting;
104
+
105
+    // assumes the following variables must be set:
106
+    // $dbconfig, $dbconfigoption, $cache_dir,  $session_dir, $site_URL, $upload_dir
107
+
108
+    $sugar_config = array (
109
+    'admin_export_only' => empty($admin_export_only) ? false : $admin_export_only,
110
+    'export_delimiter' => empty($export_delimiter) ? ',' : $export_delimiter,
111
+    'cache_dir' => empty($cache_dir) ? 'cache/' : $cache_dir,
112
+    'calculate_response_time' => empty($calculate_response_time) ? true : $calculate_response_time,
113
+    'create_default_user' => empty($create_default_user) ? false : $create_default_user,
114
+    'chartEngine' => 'Jit',
115
+    'date_formats' => empty($dateFormats) ? array(
116
+    'Y-m-d'=>'2010-12-23',
117
+    'd-m-Y' => '23-12-2010',
118
+    'm-d-Y'=>'12-23-2010',
119
+    'Y/m/d'=>'2010/12/23',
120
+    'd/m/Y' => '23/12/2010',
121
+    'm/d/Y'=>'12/23/2010',
122
+    'Y.m.d' => '2010.12.23',
123
+    'd.m.Y' => '23.12.2010',
124
+    'm.d.Y' => '12.23.2010'
125
+        ) : $dateFormats,
126
+    'dbconfig' => $dbconfig,  // this must be set!!
127
+    'dbconfigoption' => $dbconfigoption,  // this must be set!!
128
+    'default_action' => empty($default_action) ? 'index' : $default_action,
129
+    'default_charset' => empty($default_charset) ? 'UTF-8' : $default_charset,
130
+    'default_currency_name' => empty($default_currency_name) ? 'US Dollar' : $default_currency_name,
131
+    'default_currency_symbol' => empty($default_currency_symbol) ? '$' : $default_currency_symbol,
132
+    'default_currency_iso4217' => empty($default_currency_iso4217) ? '$' : $default_currency_iso4217,
133
+    'default_date_format' => empty($defaultDateFormat) ? 'm/d/Y' : $defaultDateFormat,
134 134
     'default_locale_name_format' => empty($defaultNameFormat) ? 's f l' : $defaultNameFormat,
135
-	'default_export_charset' => 'UTF-8',
136
-	'default_language' => empty($default_language) ? 'en_us' : $default_language,
137
-	'default_module' => empty($default_module) ? 'Home' : $default_module,
138
-	'default_password' => empty($default_password) ? '' : $default_password,
139
-	'default_permissions' => array (
140
-		'dir_mode' => 02770,
141
-		'file_mode' => 0755,
142
-		'chown' => '',
143
-		'chgrp' => '',
144
-	),
135
+    'default_export_charset' => 'UTF-8',
136
+    'default_language' => empty($default_language) ? 'en_us' : $default_language,
137
+    'default_module' => empty($default_module) ? 'Home' : $default_module,
138
+    'default_password' => empty($default_password) ? '' : $default_password,
139
+    'default_permissions' => array (
140
+        'dir_mode' => 02770,
141
+        'file_mode' => 0755,
142
+        'chown' => '',
143
+        'chgrp' => '',
144
+    ),
145 145
     'default_theme' => empty($default_theme) ? 'Sugar5' : $default_theme,
146 146
     'default_time_format' => empty($defaultTimeFormat) ? 'h:ia' : $defaultTimeFormat,
147
-	'default_user_is_admin' => empty($default_user_is_admin) ? false : $default_user_is_admin,
148
-	'default_user_name' => empty($default_user_name) ? '' : $default_user_name,
149
-	'disable_export' => empty($disable_export) ? false : $disable_export,
147
+    'default_user_is_admin' => empty($default_user_is_admin) ? false : $default_user_is_admin,
148
+    'default_user_name' => empty($default_user_name) ? '' : $default_user_name,
149
+    'disable_export' => empty($disable_export) ? false : $disable_export,
150 150
     'disable_persistent_connections' => empty($disable_persistent_connections) ? false : $disable_persistent_connections,
151 151
     'display_email_template_variable_chooser' => empty($display_email_template_variable_chooser) ? false : $display_email_template_variable_chooser,
152
-	'display_inbound_email_buttons' => empty($display_inbound_email_buttons) ? false : $display_inbound_email_buttons,
153
-	'history_max_viewed' => empty($history_max_viewed) ? 50 : $history_max_viewed,
154
-	'host_name' => empty($host_name) ? 'localhost' : $host_name,
155
-	'import_dir' => $import_dir,  // this must be set!!
156
-	'import_max_records_per_file' => 100,
152
+    'display_inbound_email_buttons' => empty($display_inbound_email_buttons) ? false : $display_inbound_email_buttons,
153
+    'history_max_viewed' => empty($history_max_viewed) ? 50 : $history_max_viewed,
154
+    'host_name' => empty($host_name) ? 'localhost' : $host_name,
155
+    'import_dir' => $import_dir,  // this must be set!!
156
+    'import_max_records_per_file' => 100,
157 157
     'import_max_records_total_limit' => '',
158
-	'languages' => empty($languages) ? array('en_us' => 'English (US)') : $languages,
159
-	'list_max_entries_per_page' => empty($list_max_entries_per_page) ? 20 : $list_max_entries_per_page,
160
-	'list_max_entries_per_subpanel' => empty($list_max_entries_per_subpanel) ? 10 : $list_max_entries_per_subpanel,
161
-	'lock_default_user_name' => empty($lock_default_user_name) ? false : $lock_default_user_name,
162
-	'log_memory_usage' => empty($log_memory_usage) ? false : $log_memory_usage,
158
+    'languages' => empty($languages) ? array('en_us' => 'English (US)') : $languages,
159
+    'list_max_entries_per_page' => empty($list_max_entries_per_page) ? 20 : $list_max_entries_per_page,
160
+    'list_max_entries_per_subpanel' => empty($list_max_entries_per_subpanel) ? 10 : $list_max_entries_per_subpanel,
161
+    'lock_default_user_name' => empty($lock_default_user_name) ? false : $lock_default_user_name,
162
+    'log_memory_usage' => empty($log_memory_usage) ? false : $log_memory_usage,
163 163
     'name_formats' => empty($nameFormats) ? array(
164 164
         's f l' => 's f l', 'f l' => 'f l', 's l' => 's l', 'l, s f' => 'l, s f',
165 165
         'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s'
166 166
     ) : $nameFormats,
167 167
     'portal_view' => 'single_user',
168
-	'resource_management' => array (
169
-	    'special_query_limit' => 50000,
170
-	    'special_query_modules' => array('Reports', 'Export', 'Import', 'Administration', 'Sync'),
171
-	    'default_limit' => 1000,
168
+    'resource_management' => array (
169
+        'special_query_limit' => 50000,
170
+        'special_query_modules' => array('Reports', 'Export', 'Import', 'Administration', 'Sync'),
171
+        'default_limit' => 1000,
172 172
     ),
173
-	'require_accounts' => empty($requireAccounts) ? true : $requireAccounts,
174
-	'rss_cache_time' => empty($RSS_CACHE_TIME) ? '10800' : $RSS_CACHE_TIME,
175
-	'session_dir' => $session_dir,  // this must be set!!
176
-	'site_url' => empty($site_URL) ? $site_url : $site_URL,  // this must be set!!
177
-	'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable
178
-	'showThemePicker' => true,
179
-	'sugar_version' => empty($sugar_version) ? 'unknown' : $sugar_version,
180
-	'time_formats' => empty($timeFormats) ? array (
181
-	'H:i'=>'23:00', 'h:ia'=>'11:00 pm', 'h:iA'=>'11:00PM',
182
-	'H.i'=>'23.00', 'h.ia'=>'11.00 pm', 'h.iA'=>'11.00PM' ) : $timeFormats,
183
-	'tmp_dir' => $tmp_dir,  // this must be set!!
184
-	'translation_string_prefix' => empty($translation_string_prefix) ? false : $translation_string_prefix,
185
-	'unique_key' => empty($unique_key) ? md5(create_guid()) : $unique_key,
186
-	'upload_badext' => empty($upload_badext) ? array (
187
-	'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py',
188
-	'asp', 'cfm', 'js', 'vbs', 'html', 'htm' ) : $upload_badext,
189
-	'upload_dir' => $upload_dir,  // this must be set!!
190
-	'upload_maxsize' => empty($upload_maxsize) ? 30000000 : $upload_maxsize,
191
-	'import_max_execution_time' => empty($import_max_execution_time) ? 3600 : $import_max_execution_time,
192
-	'lock_homepage' => false,
193
-	'lock_subpanels' => false,
194
-	'max_dashlets_homepage' => 15,
195
-	'dashlet_display_row_options' => array('1','3','5','10'),
196
-	'default_max_tabs' => empty($max_tabs) ? '7' : $max_tabs,
197
-	'default_subpanel_tabs' =>  empty($subpanel_tabs) ? true : $subpanel_tabs,
198
-	'default_subpanel_links' => empty($subpanel_links) ? false : $subpanel_links,
199
-	'default_swap_last_viewed' => empty($swap_last_viewed) ? false : $swap_last_viewed,
200
-	'default_swap_shortcuts' => empty($swap_shortcuts) ? false : $swap_shortcuts,
201
-	'default_navigation_paradigm' => empty($navigation_paradigm) ? 'gm' : $navigation_paradigm,
173
+    'require_accounts' => empty($requireAccounts) ? true : $requireAccounts,
174
+    'rss_cache_time' => empty($RSS_CACHE_TIME) ? '10800' : $RSS_CACHE_TIME,
175
+    'session_dir' => $session_dir,  // this must be set!!
176
+    'site_url' => empty($site_URL) ? $site_url : $site_URL,  // this must be set!!
177
+    'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable
178
+    'showThemePicker' => true,
179
+    'sugar_version' => empty($sugar_version) ? 'unknown' : $sugar_version,
180
+    'time_formats' => empty($timeFormats) ? array (
181
+    'H:i'=>'23:00', 'h:ia'=>'11:00 pm', 'h:iA'=>'11:00PM',
182
+    'H.i'=>'23.00', 'h.ia'=>'11.00 pm', 'h.iA'=>'11.00PM' ) : $timeFormats,
183
+    'tmp_dir' => $tmp_dir,  // this must be set!!
184
+    'translation_string_prefix' => empty($translation_string_prefix) ? false : $translation_string_prefix,
185
+    'unique_key' => empty($unique_key) ? md5(create_guid()) : $unique_key,
186
+    'upload_badext' => empty($upload_badext) ? array (
187
+    'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py',
188
+    'asp', 'cfm', 'js', 'vbs', 'html', 'htm' ) : $upload_badext,
189
+    'upload_dir' => $upload_dir,  // this must be set!!
190
+    'upload_maxsize' => empty($upload_maxsize) ? 30000000 : $upload_maxsize,
191
+    'import_max_execution_time' => empty($import_max_execution_time) ? 3600 : $import_max_execution_time,
192
+    'lock_homepage' => false,
193
+    'lock_subpanels' => false,
194
+    'max_dashlets_homepage' => 15,
195
+    'dashlet_display_row_options' => array('1','3','5','10'),
196
+    'default_max_tabs' => empty($max_tabs) ? '7' : $max_tabs,
197
+    'default_subpanel_tabs' =>  empty($subpanel_tabs) ? true : $subpanel_tabs,
198
+    'default_subpanel_links' => empty($subpanel_links) ? false : $subpanel_links,
199
+    'default_swap_last_viewed' => empty($swap_last_viewed) ? false : $swap_last_viewed,
200
+    'default_swap_shortcuts' => empty($swap_shortcuts) ? false : $swap_shortcuts,
201
+    'default_navigation_paradigm' => empty($navigation_paradigm) ? 'gm' : $navigation_paradigm,
202 202
     'default_call_status' => 'Planned',
203
-	'js_lang_version' => 1,
204
-	'passwordsetting' => empty($passwordsetting) ? array (
205
-	    'SystemGeneratedPasswordON' => '',
206
-	    'generatepasswordtmpl' => '',
207
-	    'lostpasswordtmpl' => '',
208
-	    'forgotpasswordON' => true,
209
-    	'linkexpiration' => '1',
210
-    	'linkexpirationtime' => '30',
211
-    	'linkexpirationtype' => '1',
212
-	    'systexpiration' => '0',
213
-	    'systexpirationtime' => '',
214
-	    'systexpirationtype' => '0',
215
-	    'systexpirationlogin' => '',
216
-		) : $passwordsetting,
217
-		'use_sprites' => function_exists('imagecreatetruecolor'),
218
-    	'search_wildcard_infront' => false,
203
+    'js_lang_version' => 1,
204
+    'passwordsetting' => empty($passwordsetting) ? array (
205
+        'SystemGeneratedPasswordON' => '',
206
+        'generatepasswordtmpl' => '',
207
+        'lostpasswordtmpl' => '',
208
+        'forgotpasswordON' => true,
209
+        'linkexpiration' => '1',
210
+        'linkexpirationtime' => '30',
211
+        'linkexpirationtype' => '1',
212
+        'systexpiration' => '0',
213
+        'systexpirationtime' => '',
214
+        'systexpirationtype' => '0',
215
+        'systexpirationlogin' => '',
216
+        ) : $passwordsetting,
217
+        'use_sprites' => function_exists('imagecreatetruecolor'),
218
+        'search_wildcard_infront' => false,
219 219
         'search_wildcard_char' => '%',
220
-		'jobs' => array(
221
-		    'min_retry_interval' => 60, // minimal job retry delay
222
-		    'max_retries' => 5, // how many times to retry the job
223
-		    'timeout' => 86400, // how long a job may spend as running before being force-failed
224
-		    'soft_lifetime' => 7, // how many days until job record will be soft deleted after completion
225
-		    'hard_lifetime' => 21, // how many days until job record will be purged from DB
226
-		),
227
-		"cron" => array(
228
-			'max_cron_jobs' => 10, // max jobs per cron schedule run
229
-		    'max_cron_runtime' => 60, // max runtime for cron jobs
230
-		    'min_cron_interval' => 30, // minimal interval between cron jobs
231
-		),
232
-	);
220
+        'jobs' => array(
221
+            'min_retry_interval' => 60, // minimal job retry delay
222
+            'max_retries' => 5, // how many times to retry the job
223
+            'timeout' => 86400, // how long a job may spend as running before being force-failed
224
+            'soft_lifetime' => 7, // how many days until job record will be soft deleted after completion
225
+            'hard_lifetime' => 21, // how many days until job record will be purged from DB
226
+        ),
227
+        "cron" => array(
228
+            'max_cron_jobs' => 10, // max jobs per cron schedule run
229
+            'max_cron_runtime' => 60, // max runtime for cron jobs
230
+            'min_cron_interval' => 30, // minimal interval between cron jobs
231
+        ),
232
+    );
233 233
 }
234 234
 
235 235
 function get_sugar_config_defaults() {
236
-	global $locale;
237
-	/**
238
-	 * used for getting base values for array style config.php.  used by the
239
-	 * installer and to fill in new entries on upgrades.  see also:
240
-	 * sugar_config_union
241
-	 */
236
+    global $locale;
237
+    /**
238
+     * used for getting base values for array style config.php.  used by the
239
+     * installer and to fill in new entries on upgrades.  see also:
240
+     * sugar_config_union
241
+     */
242 242
 
243
-	$sugar_config_defaults = array (
244
-	'admin_export_only' => false,
245
-	'export_delimiter' => ',',
246
-	'export_excel_compatible' => false,
247
-	'cache_dir' => 'cache/',
248
-	'calculate_response_time' => true,
249
-	'create_default_user' => false,
250
- 	'chartEngine' => 'Jit',
251
-	'date_formats' => array (
252
-	'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010',
253
-	'Y/m/d' => '2010/12/23', 'm/d/Y' => '12/23/2010', 'd/m/Y' => '23/12/2010',
254
-	'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010',),
243
+    $sugar_config_defaults = array (
244
+    'admin_export_only' => false,
245
+    'export_delimiter' => ',',
246
+    'export_excel_compatible' => false,
247
+    'cache_dir' => 'cache/',
248
+    'calculate_response_time' => true,
249
+    'create_default_user' => false,
250
+        'chartEngine' => 'Jit',
251
+    'date_formats' => array (
252
+    'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010',
253
+    'Y/m/d' => '2010/12/23', 'm/d/Y' => '12/23/2010', 'd/m/Y' => '23/12/2010',
254
+    'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010',),
255 255
     'name_formats' => array (
256 256
         's f l' => 's f l', 'f l' => 'f l', 's l' => 's l', 'l, s f' => 'l, s f',
257 257
         'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s'
258 258
     ),
259
-	'dbconfigoption' => array (
260
-	'persistent' => true,
261
-	'autofree' => false,
262
-	'debug' => 0,
263
-	'ssl' => false ),
264
-	'default_action' => 'index',
265
-	'default_charset' => return_session_value_or_default('default_charset',
266
-	'UTF-8'),
267
-	'default_currency_name' => return_session_value_or_default('default_currency_name', 'US Dollar'),
268
-	'default_currency_symbol' => return_session_value_or_default('default_currency_symbol', '$'),
269
-	'default_currency_iso4217' => return_session_value_or_default('default_currency_iso4217', 'USD'),
270
-	'default_currency_significant_digits' => return_session_value_or_default('default_currency_significant_digits', 2),
271
-	'default_number_grouping_seperator' => return_session_value_or_default('default_number_grouping_seperator', ','),
272
-	'default_decimal_seperator' => return_session_value_or_default('default_decimal_seperator', '.'),
273
-	'default_date_format' => 'm/d/Y',
259
+    'dbconfigoption' => array (
260
+    'persistent' => true,
261
+    'autofree' => false,
262
+    'debug' => 0,
263
+    'ssl' => false ),
264
+    'default_action' => 'index',
265
+    'default_charset' => return_session_value_or_default('default_charset',
266
+    'UTF-8'),
267
+    'default_currency_name' => return_session_value_or_default('default_currency_name', 'US Dollar'),
268
+    'default_currency_symbol' => return_session_value_or_default('default_currency_symbol', '$'),
269
+    'default_currency_iso4217' => return_session_value_or_default('default_currency_iso4217', 'USD'),
270
+    'default_currency_significant_digits' => return_session_value_or_default('default_currency_significant_digits', 2),
271
+    'default_number_grouping_seperator' => return_session_value_or_default('default_number_grouping_seperator', ','),
272
+    'default_decimal_seperator' => return_session_value_or_default('default_decimal_seperator', '.'),
273
+    'default_date_format' => 'm/d/Y',
274 274
     'default_locale_name_format' => 's f l',
275
-	'default_export_charset' => 'UTF-8',
276
-	'default_language' => return_session_value_or_default('default_language',
277
-	'en_us'),
278
-	'default_module' => 'Home',
279
-	'default_password' => '',
280
-	'default_permissions' => array (
281
-		'dir_mode' => 02770,
282
-		'file_mode' => 0755,
283
-		'user' => '',
284
-		'group' => '',
285
-	),
286
-	'default_theme' => return_session_value_or_default('site_default_theme', 'Sugar5'),
287
-	'default_time_format' => 'h:ia',
288
-	'default_user_is_admin' => false,
289
-	'default_user_name' => '',
290
-	'disable_export' => false,
291
-	'disable_persistent_connections' =>
292
-	return_session_value_or_default('disable_persistent_connections',
293
-	'false'),
275
+    'default_export_charset' => 'UTF-8',
276
+    'default_language' => return_session_value_or_default('default_language',
277
+    'en_us'),
278
+    'default_module' => 'Home',
279
+    'default_password' => '',
280
+    'default_permissions' => array (
281
+        'dir_mode' => 02770,
282
+        'file_mode' => 0755,
283
+        'user' => '',
284
+        'group' => '',
285
+    ),
286
+    'default_theme' => return_session_value_or_default('site_default_theme', 'Sugar5'),
287
+    'default_time_format' => 'h:ia',
288
+    'default_user_is_admin' => false,
289
+    'default_user_name' => '',
290
+    'disable_export' => false,
291
+    'disable_persistent_connections' =>
292
+    return_session_value_or_default('disable_persistent_connections',
293
+    'false'),
294 294
     'display_email_template_variable_chooser' => false,
295
-	'display_inbound_email_buttons' => false,
296
-	'dump_slow_queries' => false,
297
-	'email_address_separator' => ',', // use RFC2368 spec unless we have a noncompliant email client
295
+    'display_inbound_email_buttons' => false,
296
+    'dump_slow_queries' => false,
297
+    'email_address_separator' => ',', // use RFC2368 spec unless we have a noncompliant email client
298 298
     'email_default_editor' => 'html',
299
-	'email_default_client' => 'sugar',
300
-	'email_default_delete_attachments' => true,
301
-	'history_max_viewed' => 50,
302
-	'installer_locked' => true,
303
-	'import_max_records_per_file' => 100,
299
+    'email_default_client' => 'sugar',
300
+    'email_default_delete_attachments' => true,
301
+    'history_max_viewed' => 50,
302
+    'installer_locked' => true,
303
+    'import_max_records_per_file' => 100,
304 304
     'import_max_records_total_limit' => '',
305
-	'languages' => array('en_us' => 'English (US)'),
306
-	'large_scale_test' => false,
307
-	'list_max_entries_per_page' => 20,
308
-	'list_max_entries_per_subpanel' => 10,
309
-	'lock_default_user_name' => false,
310
-	'log_memory_usage' => false,
311
-	'portal_view' => 'single_user',
305
+    'languages' => array('en_us' => 'English (US)'),
306
+    'large_scale_test' => false,
307
+    'list_max_entries_per_page' => 20,
308
+    'list_max_entries_per_subpanel' => 10,
309
+    'lock_default_user_name' => false,
310
+    'log_memory_usage' => false,
311
+    'portal_view' => 'single_user',
312 312
     'resource_management' => array (
313
-	    'special_query_limit' => 50000,
314
-	    'special_query_modules' => array('Reports', 'Export', 'Import', 'Administration', 'Sync'),
315
-	    'default_limit' => 1000,
313
+        'special_query_limit' => 50000,
314
+        'special_query_modules' => array('Reports', 'Export', 'Import', 'Administration', 'Sync'),
315
+        'default_limit' => 1000,
316 316
     ),
317
-	'require_accounts' => true,
318
-	'rss_cache_time' => return_session_value_or_default('rss_cache_time',
319
-	'10800'),
320
-	'save_query' => 'all',
321
-	'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable
322
-	'showThemePicker' => true,
323
-	'slow_query_time_msec' => '100',
317
+    'require_accounts' => true,
318
+    'rss_cache_time' => return_session_value_or_default('rss_cache_time',
319
+    '10800'),
320
+    'save_query' => 'all',
321
+    'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable
322
+    'showThemePicker' => true,
323
+    'slow_query_time_msec' => '100',
324 324
     'sugarbeet' => true,
325 325
     'time_formats' => array (
326 326
         'H:i'=>'23:00', 'h:ia'=>'11:00pm', 'h:iA'=>'11:00PM', 'h:i a'=>'11:00 pm', 'h:i A'=>'11:00 PM',
327 327
         'H.i'=>'23.00', 'h.ia'=>'11.00pm', 'h.iA'=>'11.00PM', 'h.i a'=>'11.00 pm', 'h.i A'=>'11.00 PM' ),
328 328
     'tracker_max_display_length' => 15,
329
-	'translation_string_prefix' =>
330
-	return_session_value_or_default('translation_string_prefix', false),
331
-	'upload_badext' => array (
332
-	'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py',
333
-	'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml' ),
334
-	'upload_maxsize' => 30000000,
335
-	'import_max_execution_time' => 3600,
329
+    'translation_string_prefix' =>
330
+    return_session_value_or_default('translation_string_prefix', false),
331
+    'upload_badext' => array (
332
+    'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py',
333
+    'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml' ),
334
+    'upload_maxsize' => 30000000,
335
+    'import_max_execution_time' => 3600,
336 336
 //	'use_php_code_json' => returnPhpJsonStatus(),
337
-	'verify_client_ip' => true,
338
-	'js_custom_version' => '',
339
-	'js_lang_version' => 1,
337
+    'verify_client_ip' => true,
338
+    'js_custom_version' => '',
339
+    'js_lang_version' => 1,
340 340
         'lead_conv_activity_opt' => 'donothing',
341
-	'default_number_grouping_seperator' => ',',
342
-	'default_decimal_seperator' => '.',
343
-	'lock_homepage' => false,
344
-	'lock_subpanels' => false,
345
-	'max_dashlets_homepage' => '15',
346
-	'default_max_tabs' => '7',
347
-	'dashlet_display_row_options' => array('1','3','5','10'),
348
-	'default_subpanel_tabs' =>  true,
349
-	'default_subpanel_links' => false,
350
-	'default_swap_last_viewed' => false,
351
-	'default_swap_shortcuts' => false,
352
-	'default_navigation_paradigm' => 'gm',
353
-	'admin_access_control' => false,
354
-  	'use_common_ml_dir'	=> false,
355
-  	'common_ml_dir' => '',
356
-	'vcal_time' => '2',
357
-	'calendar' => array(
358
-	  'default_view' => 'week',
359
-	  'show_calls_by_default' => true,
360
-	  'show_tasks_by_default' => true,
361
-	  'show_completed_by_default' => true,
362
-	  'editview_width' => 990,
363
-	  'editview_height' => 485,
364
-	  'day_timestep' => 15,
365
-	  'week_timestep' => 30,
366
-	  'items_draggable' => true,
367
-	  'items_resizable' => true,
368
-	  'enable_repeat' => true,
369
-	  'max_repeat_count' => 1000,
370
-	),
371
-	'passwordsetting' => empty($passwordsetting) ? array (
372
-	    'SystemGeneratedPasswordON' => '',
373
-	    'generatepasswordtmpl' => '',
374
-	    'lostpasswordtmpl' => '',
375
-	    'forgotpasswordON' => false,
376
-    	'linkexpiration' => '1',
377
-    	'linkexpirationtime' => '30',
378
-    	'linkexpirationtype' => '1',
379
-	    'systexpiration' => '0',
380
-	    'systexpirationtime' => '',
381
-	    'systexpirationtype' => '0',
382
-	    'systexpirationlogin' => '',
383
-		) : $passwordsetting,
384
-		'use_real_names' => true,
385
-
386
-		'search_wildcard_infront' => false,
341
+    'default_number_grouping_seperator' => ',',
342
+    'default_decimal_seperator' => '.',
343
+    'lock_homepage' => false,
344
+    'lock_subpanels' => false,
345
+    'max_dashlets_homepage' => '15',
346
+    'default_max_tabs' => '7',
347
+    'dashlet_display_row_options' => array('1','3','5','10'),
348
+    'default_subpanel_tabs' =>  true,
349
+    'default_subpanel_links' => false,
350
+    'default_swap_last_viewed' => false,
351
+    'default_swap_shortcuts' => false,
352
+    'default_navigation_paradigm' => 'gm',
353
+    'admin_access_control' => false,
354
+        'use_common_ml_dir'	=> false,
355
+        'common_ml_dir' => '',
356
+    'vcal_time' => '2',
357
+    'calendar' => array(
358
+        'default_view' => 'week',
359
+        'show_calls_by_default' => true,
360
+        'show_tasks_by_default' => true,
361
+        'show_completed_by_default' => true,
362
+        'editview_width' => 990,
363
+        'editview_height' => 485,
364
+        'day_timestep' => 15,
365
+        'week_timestep' => 30,
366
+        'items_draggable' => true,
367
+        'items_resizable' => true,
368
+        'enable_repeat' => true,
369
+        'max_repeat_count' => 1000,
370
+    ),
371
+    'passwordsetting' => empty($passwordsetting) ? array (
372
+        'SystemGeneratedPasswordON' => '',
373
+        'generatepasswordtmpl' => '',
374
+        'lostpasswordtmpl' => '',
375
+        'forgotpasswordON' => false,
376
+        'linkexpiration' => '1',
377
+        'linkexpirationtime' => '30',
378
+        'linkexpirationtype' => '1',
379
+        'systexpiration' => '0',
380
+        'systexpirationtime' => '',
381
+        'systexpirationtype' => '0',
382
+        'systexpirationlogin' => '',
383
+        ) : $passwordsetting,
384
+        'use_real_names' => true,
385
+
386
+        'search_wildcard_infront' => false,
387 387
         'search_wildcard_char' => '%',
388
-		'jobs' => array(
389
-		    'min_retry_interval' => 30, // 30 seconds minimal job retry
390
-		    'max_retries' => 5, // how many times to retry the job
391
-		    'timeout' => 86400, // how long a job may spend as running before being force-failed
392
-		),
393
-		"cron" => array(
394
-			'max_cron_jobs' => 10, // max jobs per cron schedule run
395
-		    'max_cron_runtime' => 30, // max runtime for cron jobs
396
-		    'min_cron_interval' => 30, // minimal interval between cron jobs
397
-		),
388
+        'jobs' => array(
389
+            'min_retry_interval' => 30, // 30 seconds minimal job retry
390
+            'max_retries' => 5, // how many times to retry the job
391
+            'timeout' => 86400, // how long a job may spend as running before being force-failed
392
+        ),
393
+        "cron" => array(
394
+            'max_cron_jobs' => 10, // max jobs per cron schedule run
395
+            'max_cron_runtime' => 30, // max runtime for cron jobs
396
+            'min_cron_interval' => 30, // minimal interval between cron jobs
397
+        ),
398 398
     );
399 399
 
400
-	if(!is_object($locale)) {
401
-		$locale = new Localization();
402
-	}
400
+    if(!is_object($locale)) {
401
+        $locale = new Localization();
402
+    }
403 403
 
404
-	$sugar_config_defaults['default_currencies'] = $locale->getDefaultCurrencies();
404
+    $sugar_config_defaults['default_currencies'] = $locale->getDefaultCurrencies();
405 405
 
406
-	$sugar_config_defaults = sugarArrayMerge($locale->getLocaleConfigDefaults(), $sugar_config_defaults);
407
-	return( $sugar_config_defaults );
406
+    $sugar_config_defaults = sugarArrayMerge($locale->getLocaleConfigDefaults(), $sugar_config_defaults);
407
+    return( $sugar_config_defaults );
408 408
 }
409 409
 
410 410
 /**
411 411
  * @deprecated use SugarView::getMenu() instead
412 412
  */
413 413
 function load_menu($path){
414
-	global $module_menu;
414
+    global $module_menu;
415 415
 
416
-	if(file_exists($path . 'Menu.php'))
417
-	{
418
-		require($path . 'Menu.php');
419
-	}
420
-	if(file_exists('custom/' . $path . 'Ext/Menus/menu.ext.php'))
421
-	{
422
-		require('custom/' . $path . 'Ext/Menus/menu.ext.php');
423
-	}
424
-	if(file_exists('custom/application/Ext/Menus/menu.ext.php'))
425
-	{
426
-		require('custom/application/Ext/Menus/menu.ext.php');
427
-	}
428
-	return $module_menu;
416
+    if(file_exists($path . 'Menu.php'))
417
+    {
418
+        require($path . 'Menu.php');
419
+    }
420
+    if(file_exists('custom/' . $path . 'Ext/Menus/menu.ext.php'))
421
+    {
422
+        require('custom/' . $path . 'Ext/Menus/menu.ext.php');
423
+    }
424
+    if(file_exists('custom/application/Ext/Menus/menu.ext.php'))
425
+    {
426
+        require('custom/application/Ext/Menus/menu.ext.php');
427
+    }
428
+    return $module_menu;
429 429
 }
430 430
 
431 431
 /**
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
  * @return string relative file path to email notifications template file
436 436
  */
437 437
 function get_notify_template_file($language){
438
-	/*
438
+    /*
439 439
 	 * Order of operation:
440 440
 	 * 1) custom version of specified language
441 441
 	 * 2) stock version of specified language
@@ -443,61 +443,61 @@  discard block
 block discarded – undo
443 443
 	 * 4) stock en_us template
444 444
 	 */
445 445
 
446
-	// set $file to the base code template so it's set if none of the conditions pass
447
-	$file = "include/language/en_us.notify_template.html";
446
+    // set $file to the base code template so it's set if none of the conditions pass
447
+    $file = "include/language/en_us.notify_template.html";
448 448
 
449
-	if(file_exists("custom/include/language/{$language}.notify_template.html")){
450
-		$file = "custom/include/language/{$language}.notify_template.html";
451
-	}
452
-	else if(file_exists("include/language/{$language}.notify_template.html")){
453
-		$file = "include/language/{$language}.notify_template.html";
454
-	}
455
-	else if(file_exists("custom/include/language/en_us.notify_template.html")){
456
-		$file = "custom/include/language/en_us.notify_template.html";
457
-	}
449
+    if(file_exists("custom/include/language/{$language}.notify_template.html")){
450
+        $file = "custom/include/language/{$language}.notify_template.html";
451
+    }
452
+    else if(file_exists("include/language/{$language}.notify_template.html")){
453
+        $file = "include/language/{$language}.notify_template.html";
454
+    }
455
+    else if(file_exists("custom/include/language/en_us.notify_template.html")){
456
+        $file = "custom/include/language/en_us.notify_template.html";
457
+    }
458 458
 
459
-	return $file;
459
+    return $file;
460 460
 }
461 461
 
462 462
 function sugar_config_union( $default, $override ){
463
-	// a little different then array_merge and array_merge_recursive.  we want
464
-	// the second array to override the first array if the same value exists,
465
-	// otherwise merge the unique keys.  it handles arrays of arrays recursively
466
-	// might be suitable for a generic array_union
467
-	if( !is_array( $override ) ){
468
-		$override = array();
469
-	}
470
-	foreach( $default as $key => $value ){
471
-		if( !array_key_exists($key, $override) ){
472
-			$override[$key] = $value;
473
-		}
474
-		else if( is_array( $key ) ){
475
-			$override[$key] = sugar_config_union( $value, $override[$key] );
476
-		}
477
-	}
478
-	return( $override );
463
+    // a little different then array_merge and array_merge_recursive.  we want
464
+    // the second array to override the first array if the same value exists,
465
+    // otherwise merge the unique keys.  it handles arrays of arrays recursively
466
+    // might be suitable for a generic array_union
467
+    if( !is_array( $override ) ){
468
+        $override = array();
469
+    }
470
+    foreach( $default as $key => $value ){
471
+        if( !array_key_exists($key, $override) ){
472
+            $override[$key] = $value;
473
+        }
474
+        else if( is_array( $key ) ){
475
+            $override[$key] = sugar_config_union( $value, $override[$key] );
476
+        }
477
+    }
478
+    return( $override );
479 479
 }
480 480
 
481 481
 function make_not_writable( $file ){
482
-	// Returns true if the given file/dir has been made not writable
483
-	$ret_val = false;
484
-	if( is_file($file) || is_dir($file) ){
485
-		if( !is_writable($file) ){
486
-			$ret_val = true;
487
-		}
488
-		else {
489
-			$original_fileperms = fileperms($file);
490
-
491
-			// take away writable permissions
492
-			$new_fileperms = $original_fileperms & ~0x0092;
493
-			@sugar_chmod($file, $new_fileperms);
494
-
495
-			if( !is_writable($file) ){
496
-				$ret_val = true;
497
-			}
498
-		}
499
-	}
500
-	return $ret_val;
482
+    // Returns true if the given file/dir has been made not writable
483
+    $ret_val = false;
484
+    if( is_file($file) || is_dir($file) ){
485
+        if( !is_writable($file) ){
486
+            $ret_val = true;
487
+        }
488
+        else {
489
+            $original_fileperms = fileperms($file);
490
+
491
+            // take away writable permissions
492
+            $new_fileperms = $original_fileperms & ~0x0092;
493
+            @sugar_chmod($file, $new_fileperms);
494
+
495
+            if( !is_writable($file) ){
496
+                $ret_val = true;
497
+            }
498
+        }
499
+    }
500
+    return $ret_val;
501 501
 }
502 502
 
503 503
 
@@ -511,76 +511,76 @@  discard block
 block discarded – undo
511 511
  */
512 512
 function return_name($row, $first_column, $last_column)
513 513
 {
514
-	$first_name = "";
515
-	$last_name = "";
516
-	$full_name = "";
514
+    $first_name = "";
515
+    $last_name = "";
516
+    $full_name = "";
517 517
 
518
-	if(isset($row[$first_column]))
519
-	{
520
-		$first_name = stripslashes($row[$first_column]);
521
-	}
518
+    if(isset($row[$first_column]))
519
+    {
520
+        $first_name = stripslashes($row[$first_column]);
521
+    }
522 522
 
523
-	if(isset($row[$last_column]))
524
-	{
525
-		$last_name = stripslashes($row[$last_column]);
526
-	}
523
+    if(isset($row[$last_column]))
524
+    {
525
+        $last_name = stripslashes($row[$last_column]);
526
+    }
527 527
 
528
-	$full_name = $first_name;
528
+    $full_name = $first_name;
529 529
 
530
-	// If we have a first name and we have a last name
531
-	if($full_name != "" && $last_name != "")
532
-	{
533
-		// append a space, then the last name
534
-		$full_name .= " ".$last_name;
535
-	}
536
-	// If we have no first name, but we have a last name
537
-	else if($last_name != "")
538
-	{
539
-		// append the last name without the space.
540
-		$full_name .= $last_name;
541
-	}
530
+    // If we have a first name and we have a last name
531
+    if($full_name != "" && $last_name != "")
532
+    {
533
+        // append a space, then the last name
534
+        $full_name .= " ".$last_name;
535
+    }
536
+    // If we have no first name, but we have a last name
537
+    else if($last_name != "")
538
+    {
539
+        // append the last name without the space.
540
+        $full_name .= $last_name;
541
+    }
542 542
 
543
-	return $full_name;
543
+    return $full_name;
544 544
 }
545 545
 
546 546
 
547 547
 function get_languages()
548 548
 {
549
-	global $sugar_config;
550
-	$lang = $sugar_config['languages'];
549
+    global $sugar_config;
550
+    $lang = $sugar_config['languages'];
551 551
     if(!empty($sugar_config['disabled_languages'])){
552 552
         foreach(explode(',', $sugar_config['disabled_languages']) as $disable) {
553 553
             unset($lang[$disable]);
554 554
         }
555 555
     }
556
-	return $lang;
556
+    return $lang;
557 557
 }
558 558
 
559 559
 function get_all_languages()
560 560
 {
561
-	global $sugar_config;
562
-	return $sugar_config['languages'];
561
+    global $sugar_config;
562
+    return $sugar_config['languages'];
563 563
 }
564 564
 
565 565
 
566 566
 function get_language_display($key)
567 567
 {
568
-	global $sugar_config;
569
-	return $sugar_config['languages'][$key];
568
+    global $sugar_config;
569
+    return $sugar_config['languages'][$key];
570 570
 }
571 571
 
572 572
 function get_assigned_user_name($assigned_user_id, $is_group = '') {
573
-	static $saved_user_list = null;
573
+    static $saved_user_list = null;
574 574
 
575
-	if(empty($saved_user_list)) {
576
-		$saved_user_list = get_user_array(false, '', '', false, null, $is_group);
577
-	}
575
+    if(empty($saved_user_list)) {
576
+        $saved_user_list = get_user_array(false, '', '', false, null, $is_group);
577
+    }
578 578
 
579
-	if(isset($saved_user_list[$assigned_user_id])) {
580
-		return $saved_user_list[$assigned_user_id];
581
-	}
579
+    if(isset($saved_user_list[$assigned_user_id])) {
580
+        return $saved_user_list[$assigned_user_id];
581
+    }
582 582
 
583
-	return '';
583
+    return '';
584 584
 }
585 585
 
586 586
 /**
@@ -589,16 +589,16 @@  discard block
 block discarded – undo
589 589
  * @return string
590 590
  */
591 591
 function get_user_name($id) {
592
-	global $db;
592
+    global $db;
593 593
 
594
-	if(empty($db))
595
-	$db = DBManagerFactory::getInstance();
594
+    if(empty($db))
595
+    $db = DBManagerFactory::getInstance();
596 596
 
597
-	$q = "SELECT user_name FROM users WHERE id='{$id}'";
598
-	$r = $db->query($q);
599
-	$a = $db->fetchByAssoc($r);
597
+    $q = "SELECT user_name FROM users WHERE id='{$id}'";
598
+    $r = $db->query($q);
599
+    $a = $db->fetchByAssoc($r);
600 600
 
601
-	return (empty($a)) ? '' : $a['user_name'];
601
+    return (empty($a)) ? '' : $a['user_name'];
602 602
 }
603 603
 
604 604
 
@@ -620,27 +620,27 @@  discard block
 block discarded – undo
620 620
  * @return array Array of users matching the filter criteria that may be from cache (if similar search was previously run)
621 621
  */
622 622
 function get_user_array($add_blank=true, $status="Active", $user_id='', $use_real_name=false, $user_name_filter='', $portal_filter=' AND portal_only=0 ', $from_cache = true) {
623
-	global $locale, $sugar_config, $current_user;
623
+    global $locale, $sugar_config, $current_user;
624 624
 
625
-	if(empty($locale)) {
626
-		$locale = new Localization();
627
-	}
625
+    if(empty($locale)) {
626
+        $locale = new Localization();
627
+    }
628 628
 
629
-	if($from_cache) {
629
+    if($from_cache) {
630 630
         $key_name = $add_blank. $status . $user_id . $use_real_name . $user_name_filter . $portal_filter;
631
-		$user_array = get_register_value('user_array', $key_name);
632
-    }
633
-
634
-	if(empty($user_array)) {
635
-		$db = DBManagerFactory::getInstance();
636
-		$temp_result = Array();
637
-		// Including deleted users for now.
638
-		if (empty($status)) {
639
-			$query = "SELECT id, first_name, last_name, user_name from users WHERE 1=1".$portal_filter;
640
-		}
641
-		else {
642
-			$query = "SELECT id, first_name, last_name, user_name from users WHERE status='$status'".$portal_filter;
643
-		}
631
+        $user_array = get_register_value('user_array', $key_name);
632
+    }
633
+
634
+    if(empty($user_array)) {
635
+        $db = DBManagerFactory::getInstance();
636
+        $temp_result = Array();
637
+        // Including deleted users for now.
638
+        if (empty($status)) {
639
+            $query = "SELECT id, first_name, last_name, user_name from users WHERE 1=1".$portal_filter;
640
+        }
641
+        else {
642
+            $query = "SELECT id, first_name, last_name, user_name from users WHERE status='$status'".$portal_filter;
643
+        }
644 644
         /* BEGIN - SECURITY GROUPS */
645 645
         global $current_user, $sugar_config;
646 646
         if(!is_admin($current_user)
@@ -655,13 +655,13 @@  discard block
 block discarded – undo
655 655
             $query .= " AND (".$group_where.") ";
656 656
         }
657 657
         /* END - SECURITY GROUPS */
658
-		if (!empty($user_name_filter)) {
659
-		    $user_name_filter = $db->quote($user_name_filter);
660
-			$query .= " AND user_name LIKE '$user_name_filter%' ";
661
-		}
662
-		if (!empty($user_id)) {
663
-			$query .= " OR id='{$user_id}'";
664
-		}
658
+        if (!empty($user_name_filter)) {
659
+            $user_name_filter = $db->quote($user_name_filter);
660
+            $query .= " AND user_name LIKE '$user_name_filter%' ";
661
+        }
662
+        if (!empty($user_id)) {
663
+            $query .= " OR id='{$user_id}'";
664
+        }
665 665
 
666 666
         //get the user preference for name formatting, to be used in order by
667 667
         $order_by_string =' user_name ASC ';
@@ -683,37 +683,37 @@  discard block
 block discarded – undo
683 683
             }
684 684
         }
685 685
 
686
-		$query = $query.' ORDER BY '.$order_by_string;
687
-		$GLOBALS['log']->debug("get_user_array query: $query");
688
-		$result = $db->query($query, true, "Error filling in user array: ");
689
-
690
-		if ($add_blank==true) {
691
-			// Add in a blank row
692
-			$temp_result[''] = '';
693
-		}
694
-
695
-		// Get the id and the name.
696
-		while($row = $db->fetchByAssoc($result)) {
697
-			if($use_real_name == true || showFullName()) {
698
-				if(isset($row['last_name'])) { // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
699
-					$temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'],$row['last_name']);
700
-				} else {
701
-					$temp_result[$row['id']] = $row['user_name'];
702
-				}
703
-			} else {
704
-				$temp_result[$row['id']] = $row['user_name'];
705
-			}
706
-		}
686
+        $query = $query.' ORDER BY '.$order_by_string;
687
+        $GLOBALS['log']->debug("get_user_array query: $query");
688
+        $result = $db->query($query, true, "Error filling in user array: ");
689
+
690
+        if ($add_blank==true) {
691
+            // Add in a blank row
692
+            $temp_result[''] = '';
693
+        }
694
+
695
+        // Get the id and the name.
696
+        while($row = $db->fetchByAssoc($result)) {
697
+            if($use_real_name == true || showFullName()) {
698
+                if(isset($row['last_name'])) { // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
699
+                    $temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'],$row['last_name']);
700
+                } else {
701
+                    $temp_result[$row['id']] = $row['user_name'];
702
+                }
703
+            } else {
704
+                $temp_result[$row['id']] = $row['user_name'];
705
+            }
706
+        }
707 707
 
708
-		$user_array = $temp_result;
709
-		if($from_cache)
708
+        $user_array = $temp_result;
709
+        if($from_cache)
710 710
         {
711
-			set_register_value('user_array', $key_name, $temp_result);
711
+            set_register_value('user_array', $key_name, $temp_result);
712 712
         }
713
-	}
713
+    }
714 714
 
715 715
 
716
-	return $user_array;
716
+    return $user_array;
717 717
 }
718 718
 
719 719
 
@@ -724,11 +724,11 @@  discard block
 block discarded – undo
724 724
  * @return array Array of Users' details that match passed criteria
725 725
  */
726 726
 function getUserArrayFromFullName($args, $hide_portal_users = false) {
727
-	global $locale;
728
-	$db = DBManagerFactory::getInstance();
727
+    global $locale;
728
+    $db = DBManagerFactory::getInstance();
729 729
 
730
-	// jmorais@dri - Bug #51411
731
-	//
730
+    // jmorais@dri - Bug #51411
731
+    //
732 732
     // Refactor the code responsible for parsing supplied $args, this way we
733 733
     // ensure that if $args has at least one space (after trim), the $inClause
734 734
     // will be composed by several clauses ($inClauses) inside parenthesis.
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
     }
755 755
     // ~jmorais@dri
756 756
 
757
-	$query  = "SELECT id, first_name, last_name, user_name FROM users WHERE status='Active' AND deleted=0 AND ";
758
-	if ( $hide_portal_users ) {
759
-	    $query .= " portal_only=0 AND ";
760
-	}
761
-	$query .= $inClause;
757
+    $query  = "SELECT id, first_name, last_name, user_name FROM users WHERE status='Active' AND deleted=0 AND ";
758
+    if ( $hide_portal_users ) {
759
+        $query .= " portal_only=0 AND ";
760
+    }
761
+    $query .= $inClause;
762 762
     /* BEGIN - SECURITY GROUPS */
763 763
     global $current_user, $sugar_config;
764 764
     if(!is_admin($current_user)
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
         $query .= " AND (".$group_where.") ";
772 772
     }
773 773
     /* END - SECURITY GROUPS */
774
-	$query .= " ORDER BY last_name ASC";
774
+    $query .= " ORDER BY last_name ASC";
775 775
 
776
-	$r = $db->query($query);
777
-	$ret = array();
778
-	while($a = $db->fetchByAssoc($r)) {
779
-		$ret[$a['id']] = $locale->getLocaleFormattedName($a['first_name'], $a['last_name']);
780
-	}
776
+    $r = $db->query($query);
777
+    $ret = array();
778
+    while($a = $db->fetchByAssoc($r)) {
779
+        $ret[$a['id']] = $locale->getLocaleFormattedName($a['first_name'], $a['last_name']);
780
+    }
781 781
 
782
-	return $ret;
782
+    return $ret;
783 783
 }
784 784
 
785 785
 /**
@@ -787,28 +787,28 @@  discard block
 block discarded – undo
787 787
  * based on user pref then system pref
788 788
  */
789 789
 function showFullName() {
790
-	global $sugar_config;
791
-	global $current_user;
792
-	static $showFullName = null;
793
-
794
-	if (is_null($showFullName)) {
795
-		$sysPref = !empty($sugar_config['use_real_names']);
796
-		$userPref = (is_object($current_user)) ? $current_user->getPreference('use_real_names') : null;
797
-
798
-		if($userPref != null) {
799
-			$showFullName = ($userPref == 'on');
800
-		} else {
801
-			$showFullName = $sysPref;
802
-		}
803
-	}
790
+    global $sugar_config;
791
+    global $current_user;
792
+    static $showFullName = null;
793
+
794
+    if (is_null($showFullName)) {
795
+        $sysPref = !empty($sugar_config['use_real_names']);
796
+        $userPref = (is_object($current_user)) ? $current_user->getPreference('use_real_names') : null;
797
+
798
+        if($userPref != null) {
799
+            $showFullName = ($userPref == 'on');
800
+        } else {
801
+            $showFullName = $sysPref;
802
+        }
803
+    }
804 804
 
805
-	return $showFullName;
805
+    return $showFullName;
806 806
 }
807 807
 
808 808
 function clean($string, $maxLength)
809 809
 {
810
-	$string = substr($string, 0, $maxLength);
811
-	return escapeshellcmd($string);
810
+    $string = substr($string, 0, $maxLength);
811
+    return escapeshellcmd($string);
812 812
 }
813 813
 
814 814
 /**
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
  */
821 821
 function safe_map($request_var, & $focus, $always_copy = false)
822 822
 {
823
-	safe_map_named($request_var, $focus, $request_var, $always_copy);
823
+    safe_map_named($request_var, $focus, $request_var, $always_copy);
824 824
 }
825 825
 
826 826
 /**
@@ -832,10 +832,10 @@  discard block
 block discarded – undo
832 832
  */
833 833
 function safe_map_named($request_var, & $focus, $member_var, $always_copy)
834 834
 {
835
-	if (isset($_REQUEST[$request_var]) && ($always_copy || is_null($focus->$member_var))) {
836
-		$GLOBALS['log']->debug("safe map named called assigning '{$_REQUEST[$request_var]}' to $member_var");
837
-		$focus->$member_var = $_REQUEST[$request_var];
838
-	}
835
+    if (isset($_REQUEST[$request_var]) && ($always_copy || is_null($focus->$member_var))) {
836
+        $GLOBALS['log']->debug("safe map named called assigning '{$_REQUEST[$request_var]}' to $member_var");
837
+        $focus->$member_var = $_REQUEST[$request_var];
838
+    }
839 839
 }
840 840
 
841 841
 /**
@@ -846,35 +846,35 @@  discard block
 block discarded – undo
846 846
  */
847 847
 function return_app_list_strings_language($language)
848 848
 {
849
-	global $app_list_strings;
850
-	global $sugar_config;
849
+    global $app_list_strings;
850
+    global $sugar_config;
851 851
 
852
-	$cache_key = 'app_list_strings.'.$language;
852
+    $cache_key = 'app_list_strings.'.$language;
853 853
 
854
-	// Check for cached value
855
-	$cache_entry = sugar_cache_retrieve($cache_key);
856
-	if(!empty($cache_entry))
857
-	{
858
-		return $cache_entry;
859
-	}
854
+    // Check for cached value
855
+    $cache_entry = sugar_cache_retrieve($cache_key);
856
+    if(!empty($cache_entry))
857
+    {
858
+        return $cache_entry;
859
+    }
860 860
 
861
-	$default_language = isset($sugar_config['default_language']) ? $sugar_config['default_language'] : 'en_us';
862
-	$temp_app_list_strings = $app_list_strings;
861
+    $default_language = isset($sugar_config['default_language']) ? $sugar_config['default_language'] : 'en_us';
862
+    $temp_app_list_strings = $app_list_strings;
863 863
 
864
-	$langs = array();
865
-	if ($language != 'en_us') {
866
-	    $langs[] = 'en_us';
867
-	}
868
-	if ($default_language != 'en_us' && $language != $default_language) {
869
-	    $langs[] = $default_language;
870
-	}
871
-	$langs[] = $language;
864
+    $langs = array();
865
+    if ($language != 'en_us') {
866
+        $langs[] = 'en_us';
867
+    }
868
+    if ($default_language != 'en_us' && $language != $default_language) {
869
+        $langs[] = $default_language;
870
+    }
871
+    $langs[] = $language;
872 872
 
873
-	$app_list_strings_array = array();
873
+    $app_list_strings_array = array();
874 874
 
875
-	foreach ( $langs as $lang ) {
876
-	    $app_list_strings = array();
877
-	    if(file_exists("include/language/$lang.lang.php")) {
875
+    foreach ( $langs as $lang ) {
876
+        $app_list_strings = array();
877
+        if(file_exists("include/language/$lang.lang.php")) {
878 878
             include("include/language/$lang.lang.php");
879 879
             $GLOBALS['log']->info("Found language file: $lang.lang.php");
880 880
         }
@@ -906,17 +906,17 @@  discard block
 block discarded – undo
906 906
         }
907 907
     }
908 908
 
909
-	if(!isset($app_list_strings)) {
910
-		$GLOBALS['log']->fatal("Unable to load the application language file for the selected language ($language) or the default language ($default_language) or the en_us language");
911
-		return null;
912
-	}
909
+    if(!isset($app_list_strings)) {
910
+        $GLOBALS['log']->fatal("Unable to load the application language file for the selected language ($language) or the default language ($default_language) or the en_us language");
911
+        return null;
912
+    }
913 913
 
914
-	$return_value = $app_list_strings;
915
-	$app_list_strings = $temp_app_list_strings;
914
+    $return_value = $app_list_strings;
915
+    $app_list_strings = $temp_app_list_strings;
916 916
 
917
-	sugar_cache_put($cache_key, $return_value);
917
+    sugar_cache_put($cache_key, $return_value);
918 918
 
919
-	return $return_value;
919
+    return $return_value;
920 920
 }
921 921
 
922 922
 /**
@@ -926,33 +926,33 @@  discard block
 block discarded – undo
926 926
  * @param app_list_strings array the golbal strings
927 927
  * @return array
928 928
  */
929
- //jchi 25347
929
+    //jchi 25347
930 930
 function _mergeCustomAppListStrings($file , $app_list_strings){
931
-	$app_list_strings_original = $app_list_strings;
932
-	unset($app_list_strings);
931
+    $app_list_strings_original = $app_list_strings;
932
+    unset($app_list_strings);
933 933
         // FG - bug 45525 - $exemptDropdown array is defined (once) here, not inside the foreach
934 934
         //                  This way, language file can add items to save specific standard codelist from being overwritten
935 935
         $exemptDropdowns = array();
936
-	include($file);
937
-	if(!isset($app_list_strings) || !is_array($app_list_strings)){
938
-		return $app_list_strings_original;
939
-	}
940
-	//Bug 25347: We should not merge custom dropdown fields unless they relate to parent fields or the module list.
936
+    include($file);
937
+    if(!isset($app_list_strings) || !is_array($app_list_strings)){
938
+        return $app_list_strings_original;
939
+    }
940
+    //Bug 25347: We should not merge custom dropdown fields unless they relate to parent fields or the module list.
941 941
 
942 942
         // FG - bug 45525 - Specific codelists must NOT be overwritten
943
-	$exemptDropdowns[] = "moduleList";
944
-	$exemptDropdowns[] = "moduleListSingular";
943
+    $exemptDropdowns[] = "moduleList";
944
+    $exemptDropdowns[] = "moduleListSingular";
945 945
         $exemptDropdowns = array_merge($exemptDropdowns, getTypeDisplayList());
946 946
 
947
-	foreach($app_list_strings as $key=>$value)
948
-	{
949
-		if (!in_array($key, $exemptDropdowns) && array_key_exists($key, $app_list_strings_original))
950
-		{
951
-	   		unset($app_list_strings_original["$key"]);
952
-		}
953
-   }
954
-   $app_list_strings = sugarArrayMergeRecursive($app_list_strings_original , $app_list_strings);
955
-   return $app_list_strings;
947
+    foreach($app_list_strings as $key=>$value)
948
+    {
949
+        if (!in_array($key, $exemptDropdowns) && array_key_exists($key, $app_list_strings_original))
950
+        {
951
+                unset($app_list_strings_original["$key"]);
952
+        }
953
+    }
954
+    $app_list_strings = sugarArrayMergeRecursive($app_list_strings_original , $app_list_strings);
955
+    return $app_list_strings;
956 956
 }
957 957
 
958 958
 /**
@@ -963,35 +963,35 @@  discard block
 block discarded – undo
963 963
  */
964 964
 function return_application_language($language)
965 965
 {
966
-	global $app_strings, $sugar_config;
966
+    global $app_strings, $sugar_config;
967 967
 
968
-	$cache_key = 'app_strings.'.$language;
968
+    $cache_key = 'app_strings.'.$language;
969 969
 
970
-	// Check for cached value
971
-	$cache_entry = sugar_cache_retrieve($cache_key);
972
-	if(!empty($cache_entry))
973
-	{
974
-		return $cache_entry;
975
-	}
970
+    // Check for cached value
971
+    $cache_entry = sugar_cache_retrieve($cache_key);
972
+    if(!empty($cache_entry))
973
+    {
974
+        return $cache_entry;
975
+    }
976 976
 
977
-	$temp_app_strings = $app_strings;
978
-	$default_language = $sugar_config['default_language'];
977
+    $temp_app_strings = $app_strings;
978
+    $default_language = $sugar_config['default_language'];
979 979
 
980
-	$langs = array();
981
-	if ($language != 'en_us') {
982
-	    $langs[] = 'en_us';
983
-	}
984
-	if ($default_language != 'en_us' && $language != $default_language) {
985
-	    $langs[] = $default_language;
986
-	}
980
+    $langs = array();
981
+    if ($language != 'en_us') {
982
+        $langs[] = 'en_us';
983
+    }
984
+    if ($default_language != 'en_us' && $language != $default_language) {
985
+        $langs[] = $default_language;
986
+    }
987 987
 
988
-	$langs[] = $language;
988
+    $langs[] = $language;
989 989
 
990
-	$app_strings_array = array();
990
+    $app_strings_array = array();
991 991
 
992
-	foreach ( $langs as $lang ) {
993
-	    $app_strings = array();
994
-	    if(file_exists("include/language/$lang.lang.php")) {
992
+    foreach ( $langs as $lang ) {
993
+        $app_strings = array();
994
+        if(file_exists("include/language/$lang.lang.php")) {
995 995
             include("include/language/$lang.lang.php");
996 996
             $GLOBALS['log']->info("Found language file: $lang.lang.php");
997 997
         }
@@ -1012,40 +1012,40 @@  discard block
 block discarded – undo
1012 1012
             $GLOBALS['log']->info("Found custom language file: $lang.lang.php");
1013 1013
         }
1014 1014
         $app_strings_array[] = $app_strings;
1015
-	}
1015
+    }
1016 1016
 
1017
-	$app_strings = array();
1017
+    $app_strings = array();
1018 1018
     foreach ( $app_strings_array as $app_strings_item ) {
1019 1019
         $app_strings = sugarLangArrayMerge($app_strings, $app_strings_item);
1020 1020
     }
1021 1021
 
1022
-	if(!isset($app_strings)) {
1023
-		$GLOBALS['log']->fatal("Unable to load the application language strings");
1024
-		return null;
1025
-	}
1022
+    if(!isset($app_strings)) {
1023
+        $GLOBALS['log']->fatal("Unable to load the application language strings");
1024
+        return null;
1025
+    }
1026 1026
 
1027
-	// If we are in debug mode for translating, turn on the prefix now!
1027
+    // If we are in debug mode for translating, turn on the prefix now!
1028 1028
     if(!empty($sugar_config['translation_string_prefix']))
1029 1029
     {
1030
-		foreach($app_strings as $entry_key=>$entry_value) {
1031
-			$app_strings[$entry_key] = $language.' '.$entry_value;
1032
-		}
1033
-	}
1034
-	if(isset($_SESSION['show_deleted'])) {
1035
-		$app_strings['LBL_DELETE_BUTTON'] = $app_strings['LBL_UNDELETE_BUTTON'];
1036
-		$app_strings['LBL_DELETE_BUTTON_LABEL'] = $app_strings['LBL_UNDELETE_BUTTON_LABEL'];
1037
-		$app_strings['LBL_DELETE_BUTTON_TITLE'] = $app_strings['LBL_UNDELETE_BUTTON_TITLE'];
1038
-		$app_strings['LBL_DELETE'] = $app_strings['LBL_UNDELETE'];
1039
-	}
1030
+        foreach($app_strings as $entry_key=>$entry_value) {
1031
+            $app_strings[$entry_key] = $language.' '.$entry_value;
1032
+        }
1033
+    }
1034
+    if(isset($_SESSION['show_deleted'])) {
1035
+        $app_strings['LBL_DELETE_BUTTON'] = $app_strings['LBL_UNDELETE_BUTTON'];
1036
+        $app_strings['LBL_DELETE_BUTTON_LABEL'] = $app_strings['LBL_UNDELETE_BUTTON_LABEL'];
1037
+        $app_strings['LBL_DELETE_BUTTON_TITLE'] = $app_strings['LBL_UNDELETE_BUTTON_TITLE'];
1038
+        $app_strings['LBL_DELETE'] = $app_strings['LBL_UNDELETE'];
1039
+    }
1040 1040
 
1041
-	$app_strings['LBL_ALT_HOT_KEY'] = get_alt_hot_key();
1041
+    $app_strings['LBL_ALT_HOT_KEY'] = get_alt_hot_key();
1042 1042
 
1043
-	$return_value = $app_strings;
1044
-	$app_strings = $temp_app_strings;
1043
+    $return_value = $app_strings;
1044
+    $app_strings = $temp_app_strings;
1045 1045
 
1046
-	sugar_cache_put($cache_key, $return_value);
1046
+    sugar_cache_put($cache_key, $return_value);
1047 1047
 
1048
-	return $return_value;
1048
+    return $return_value;
1049 1049
 }
1050 1050
 
1051 1051
 /**
@@ -1058,16 +1058,16 @@  discard block
 block discarded – undo
1058 1058
  */
1059 1059
 function return_module_language($language, $module, $refresh=false)
1060 1060
 {
1061
-	global $mod_strings;
1062
-	global $sugar_config;
1063
-	global $currentModule;
1064
-
1065
-	// Jenny - Bug 8119: Need to check if $module is not empty
1066
-	if (empty($module)) {
1067
-		$stack  = debug_backtrace();
1068
-		$GLOBALS['log']->warn("Variable module is not in return_module_language ". var_export($stack, true));
1069
-		return array();
1070
-	}
1061
+    global $mod_strings;
1062
+    global $sugar_config;
1063
+    global $currentModule;
1064
+
1065
+    // Jenny - Bug 8119: Need to check if $module is not empty
1066
+    if (empty($module)) {
1067
+        $stack  = debug_backtrace();
1068
+        $GLOBALS['log']->warn("Variable module is not in return_module_language ". var_export($stack, true));
1069
+        return array();
1070
+    }
1071 1071
 
1072 1072
     if( !$refresh )
1073 1073
     {
@@ -1079,28 +1079,28 @@  discard block
 block discarded – undo
1079 1079
             return $cache_entry;
1080 1080
         }
1081 1081
     }
1082
-	// Store the current mod strings for later
1083
-	$temp_mod_strings = $mod_strings;
1084
-	$loaded_mod_strings = array();
1085
-	$language_used = $language;
1086
-	$default_language = $sugar_config['default_language'];
1087
-
1088
-	if(empty($language)) {
1089
-		$language = $default_language;
1090
-	}
1082
+    // Store the current mod strings for later
1083
+    $temp_mod_strings = $mod_strings;
1084
+    $loaded_mod_strings = array();
1085
+    $language_used = $language;
1086
+    $default_language = $sugar_config['default_language'];
1087
+
1088
+    if(empty($language)) {
1089
+        $language = $default_language;
1090
+    }
1091 1091
 
1092
-	// Bug 21559 - So we can get all the strings defined in the template, refresh
1093
-	// the vardefs file if the cached language file doesn't exist.
1092
+    // Bug 21559 - So we can get all the strings defined in the template, refresh
1093
+    // the vardefs file if the cached language file doesn't exist.
1094 1094
     if(!file_exists(sugar_cached('modules/'). $module . '/language/'.$language.'.lang.php')
1095
-			&& !empty($GLOBALS['beanList'][$module])){
1096
-		$object = BeanFactory::getObjectName($module);
1097
-		VardefManager::refreshVardefs($module,$object);
1098
-	}
1095
+            && !empty($GLOBALS['beanList'][$module])){
1096
+        $object = BeanFactory::getObjectName($module);
1097
+        VardefManager::refreshVardefs($module,$object);
1098
+    }
1099 1099
 
1100
-	$loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language,$refresh);
1100
+    $loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language,$refresh);
1101 1101
 
1102
-	// cn: bug 6048 - merge en_us with requested language
1103
-	if($language != $sugar_config['default_language'])
1102
+    // cn: bug 6048 - merge en_us with requested language
1103
+    if($language != $sugar_config['default_language'])
1104 1104
         $loaded_mod_strings = sugarLangArrayMerge(
1105 1105
             LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'],$refresh),
1106 1106
                 $loaded_mod_strings
@@ -1113,23 +1113,23 @@  discard block
 block discarded – undo
1113 1113
                 $loaded_mod_strings
1114 1114
             );
1115 1115
 
1116
-	// If we are in debug mode for translating, turn on the prefix now!
1117
-	if($sugar_config['translation_string_prefix']) {
1118
-		foreach($loaded_mod_strings as $entry_key=>$entry_value) {
1119
-			$loaded_mod_strings[$entry_key] = $language_used.' '.$entry_value;
1120
-		}
1121
-	}
1116
+    // If we are in debug mode for translating, turn on the prefix now!
1117
+    if($sugar_config['translation_string_prefix']) {
1118
+        foreach($loaded_mod_strings as $entry_key=>$entry_value) {
1119
+            $loaded_mod_strings[$entry_key] = $language_used.' '.$entry_value;
1120
+        }
1121
+    }
1122 1122
 
1123
-	$return_value = $loaded_mod_strings;
1124
-	if(!isset($mod_strings)){
1125
-		$mod_strings = $return_value;
1126
-	}
1127
-	else
1128
-		$mod_strings = $temp_mod_strings;
1123
+    $return_value = $loaded_mod_strings;
1124
+    if(!isset($mod_strings)){
1125
+        $mod_strings = $return_value;
1126
+    }
1127
+    else
1128
+        $mod_strings = $temp_mod_strings;
1129 1129
 
1130 1130
     $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
1131 1131
     sugar_cache_put($cache_key, $return_value);
1132
-	return $return_value;
1132
+    return $return_value;
1133 1133
 }
1134 1134
 
1135 1135
 
@@ -1139,61 +1139,61 @@  discard block
 block discarded – undo
1139 1139
  * Contributor(s): ______________________________________..
1140 1140
  * If you are using the current language, do not call this function unless you are loading it for the first time */
1141 1141
 function return_mod_list_strings_language($language,$module) {
1142
-	global $mod_list_strings;
1143
-	global $sugar_config;
1144
-	global $currentModule;
1142
+    global $mod_list_strings;
1143
+    global $sugar_config;
1144
+    global $currentModule;
1145 1145
 
1146
-	$cache_key = "mod_list_str_lang.".$language.$module;
1146
+    $cache_key = "mod_list_str_lang.".$language.$module;
1147 1147
 
1148
-	// Check for cached value
1149
-	$cache_entry = sugar_cache_retrieve($cache_key);
1150
-	if(!empty($cache_entry))
1151
-	{
1152
-		return $cache_entry;
1153
-	}
1148
+    // Check for cached value
1149
+    $cache_entry = sugar_cache_retrieve($cache_key);
1150
+    if(!empty($cache_entry))
1151
+    {
1152
+        return $cache_entry;
1153
+    }
1154 1154
 
1155
-	$language_used = $language;
1156
-	$temp_mod_list_strings = $mod_list_strings;
1157
-	$default_language = $sugar_config['default_language'];
1155
+    $language_used = $language;
1156
+    $temp_mod_list_strings = $mod_list_strings;
1157
+    $default_language = $sugar_config['default_language'];
1158 1158
 
1159
-	if($currentModule == $module && isset($mod_list_strings) && $mod_list_strings != null) {
1160
-		return $mod_list_strings;
1161
-	}
1159
+    if($currentModule == $module && isset($mod_list_strings) && $mod_list_strings != null) {
1160
+        return $mod_list_strings;
1161
+    }
1162 1162
 
1163
-	// cn: bug 6351 - include en_us if file langpack not available
1164
-	// cn: bug 6048 - merge en_us with requested language
1165
-	include("modules/$module/language/en_us.lang.php");
1166
-	$en_mod_list_strings = array();
1167
-	if($language_used != $default_language)
1168
-	$en_mod_list_strings = $mod_list_strings;
1163
+    // cn: bug 6351 - include en_us if file langpack not available
1164
+    // cn: bug 6048 - merge en_us with requested language
1165
+    include("modules/$module/language/en_us.lang.php");
1166
+    $en_mod_list_strings = array();
1167
+    if($language_used != $default_language)
1168
+    $en_mod_list_strings = $mod_list_strings;
1169 1169
 
1170
-	if(file_exists("modules/$module/language/$language.lang.php")) {
1171
-		include("modules/$module/language/$language.lang.php");
1172
-	}
1170
+    if(file_exists("modules/$module/language/$language.lang.php")) {
1171
+        include("modules/$module/language/$language.lang.php");
1172
+    }
1173 1173
 
1174
-	if(file_exists("modules/$module/language/$language.lang.override.php")){
1175
-		include("modules/$module/language/$language.lang.override.php");
1176
-	}
1174
+    if(file_exists("modules/$module/language/$language.lang.override.php")){
1175
+        include("modules/$module/language/$language.lang.override.php");
1176
+    }
1177 1177
 
1178
-	if(file_exists("modules/$module/language/$language.lang.php.override")){
1179
-		echo 'Please Change:<br>' . "modules/$module/language/$language.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . "modules/$module/language/$language.lang.override.php";
1180
-		include("modules/$module/language/$language.lang.php.override");
1181
-	}
1178
+    if(file_exists("modules/$module/language/$language.lang.php.override")){
1179
+        echo 'Please Change:<br>' . "modules/$module/language/$language.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . "modules/$module/language/$language.lang.override.php";
1180
+        include("modules/$module/language/$language.lang.php.override");
1181
+    }
1182 1182
 
1183
-	// cn: bug 6048 - merge en_us with requested language
1184
-	$mod_list_strings = sugarLangArrayMerge($en_mod_list_strings, $mod_list_strings);
1183
+    // cn: bug 6048 - merge en_us with requested language
1184
+    $mod_list_strings = sugarLangArrayMerge($en_mod_list_strings, $mod_list_strings);
1185 1185
 
1186
-	// if we still don't have a language pack, then log an error
1187
-	if(!isset($mod_list_strings)) {
1188
-		$GLOBALS['log']->fatal("Unable to load the application list language file for the selected language($language) or the default language($default_language) for module({$module})");
1189
-		return null;
1190
-	}
1186
+    // if we still don't have a language pack, then log an error
1187
+    if(!isset($mod_list_strings)) {
1188
+        $GLOBALS['log']->fatal("Unable to load the application list language file for the selected language($language) or the default language($default_language) for module({$module})");
1189
+        return null;
1190
+    }
1191 1191
 
1192
-	$return_value = $mod_list_strings;
1193
-	$mod_list_strings = $temp_mod_list_strings;
1192
+    $return_value = $mod_list_strings;
1193
+    $mod_list_strings = $temp_mod_list_strings;
1194 1194
 
1195
-	sugar_cache_put($cache_key, $return_value);
1196
-	return $return_value;
1195
+    sugar_cache_put($cache_key, $return_value);
1196
+    return $return_value;
1197 1197
 }
1198 1198
 
1199 1199
 
@@ -1204,42 +1204,42 @@  discard block
 block discarded – undo
1204 1204
  */
1205 1205
 function return_theme_language($language, $theme)
1206 1206
 {
1207
-	global $mod_strings, $sugar_config, $current_language;
1207
+    global $mod_strings, $sugar_config, $current_language;
1208 1208
 
1209
-	$language_used = $language;
1210
-	$default_language = $sugar_config['default_language'];
1209
+    $language_used = $language;
1210
+    $default_language = $sugar_config['default_language'];
1211 1211
 
1212
-	include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php");
1213
-	if(file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php")){
1214
-		include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php");
1215
-	}
1216
-	if(file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override")){
1217
-		echo 'Please Change:<br>' . SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php";
1218
-		include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override");
1219
-	}
1220
-	if(!isset($theme_strings))
1221
-	{
1222
-		$GLOBALS['log']->warn("Unable to find the theme file for language: ".$language." and theme: ".$theme);
1223
-		require(SugarThemeRegistry::get($theme)->getFilePath()."/language/$default_language.lang.php");
1224
-		$language_used = $default_language;
1225
-	}
1212
+    include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php");
1213
+    if(file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php")){
1214
+        include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php");
1215
+    }
1216
+    if(file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override")){
1217
+        echo 'Please Change:<br>' . SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php";
1218
+        include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override");
1219
+    }
1220
+    if(!isset($theme_strings))
1221
+    {
1222
+        $GLOBALS['log']->warn("Unable to find the theme file for language: ".$language." and theme: ".$theme);
1223
+        require(SugarThemeRegistry::get($theme)->getFilePath()."/language/$default_language.lang.php");
1224
+        $language_used = $default_language;
1225
+    }
1226 1226
 
1227
-	if(!isset($theme_strings))
1228
-	{
1229
-		$GLOBALS['log']->fatal("Unable to load the theme($theme) language file for the selected language($language) or the default language($default_language)");
1230
-		return null;
1231
-	}
1227
+    if(!isset($theme_strings))
1228
+    {
1229
+        $GLOBALS['log']->fatal("Unable to load the theme($theme) language file for the selected language($language) or the default language($default_language)");
1230
+        return null;
1231
+    }
1232 1232
 
1233
-	// If we are in debug mode for translating, turn on the prefix now!
1234
-	if($sugar_config['translation_string_prefix'])
1235
-	{
1236
-		foreach($theme_strings as $entry_key=>$entry_value)
1237
-		{
1238
-			$theme_strings[$entry_key] = $language_used.' '.$entry_value;
1239
-		}
1240
-	}
1233
+    // If we are in debug mode for translating, turn on the prefix now!
1234
+    if($sugar_config['translation_string_prefix'])
1235
+    {
1236
+        foreach($theme_strings as $entry_key=>$entry_value)
1237
+        {
1238
+            $theme_strings[$entry_key] = $language_used.' '.$entry_value;
1239
+        }
1240
+    }
1241 1241
 
1242
-	return $theme_strings;
1242
+    return $theme_strings;
1243 1243
 }
1244 1244
 
1245 1245
 
@@ -1251,12 +1251,12 @@  discard block
 block discarded – undo
1251 1251
  */
1252 1252
 function return_session_value_or_default($varname, $default)
1253 1253
 {
1254
-	if(isset($_SESSION[$varname]) && $_SESSION[$varname] != "")
1255
-	{
1256
-		return $_SESSION[$varname];
1257
-	}
1254
+    if(isset($_SESSION[$varname]) && $_SESSION[$varname] != "")
1255
+    {
1256
+        return $_SESSION[$varname];
1257
+    }
1258 1258
 
1259
-	return $default;
1259
+    return $default;
1260 1260
 }
1261 1261
 
1262 1262
 /**
@@ -1271,15 +1271,15 @@  discard block
 block discarded – undo
1271 1271
  */
1272 1272
 function append_where_clause(&$where_clauses, $variable_name, $SQL_name = null)
1273 1273
 {
1274
-	if($SQL_name == null)
1275
-	{
1276
-		$SQL_name = $variable_name;
1277
-	}
1274
+    if($SQL_name == null)
1275
+    {
1276
+        $SQL_name = $variable_name;
1277
+    }
1278 1278
 
1279
-	if(isset($_REQUEST[$variable_name]) && $_REQUEST[$variable_name] != "")
1280
-	{
1281
-		array_push($where_clauses, "$SQL_name like '".$GLOBALS['db']->quote($_REQUEST[$variable_name])."%'");
1282
-	}
1279
+    if(isset($_REQUEST[$variable_name]) && $_REQUEST[$variable_name] != "")
1280
+    {
1281
+        array_push($where_clauses, "$SQL_name like '".$GLOBALS['db']->quote($_REQUEST[$variable_name])."%'");
1282
+    }
1283 1283
 }
1284 1284
 
1285 1285
 /**
@@ -1292,16 +1292,16 @@  discard block
 block discarded – undo
1292 1292
  */
1293 1293
 function generate_where_statement($where_clauses)
1294 1294
 {
1295
-	$where = "";
1296
-	foreach($where_clauses as $clause)
1297
-	{
1298
-		if($where != "")
1299
-		$where .= " and ";
1300
-		$where .= $clause;
1301
-	}
1295
+    $where = "";
1296
+    foreach($where_clauses as $clause)
1297
+    {
1298
+        if($where != "")
1299
+        $where .= " and ";
1300
+        $where .= $clause;
1301
+    }
1302 1302
 
1303
-	$GLOBALS['log']->info("Here is the where clause for the list view: $where");
1304
-	return $where;
1303
+    $GLOBALS['log']->info("Here is the where clause for the list view: $where");
1304
+    return $where;
1305 1305
 }
1306 1306
 
1307 1307
 /**
@@ -1310,15 +1310,15 @@  discard block
 block discarded – undo
1310 1310
  * @return bool False on failure
1311 1311
  */
1312 1312
 function is_guid($guid) {
1313
-	if(strlen($guid) != 36) {
1314
-		return false;
1315
-	}
1313
+    if(strlen($guid) != 36) {
1314
+        return false;
1315
+    }
1316 1316
 
1317
-	if(preg_match("/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/i", $guid)) {
1318
-		return true;
1319
-	}
1317
+    if(preg_match("/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/i", $guid)) {
1318
+        return true;
1319
+    }
1320 1320
 
1321
-	return true;;
1321
+    return true;;
1322 1322
 }
1323 1323
 
1324 1324
 
@@ -1332,59 +1332,59 @@  discard block
 block discarded – undo
1332 1332
  */
1333 1333
 function create_guid()
1334 1334
 {
1335
-	$microTime = microtime();
1336
-	list($a_dec, $a_sec) = explode(" ", $microTime);
1335
+    $microTime = microtime();
1336
+    list($a_dec, $a_sec) = explode(" ", $microTime);
1337 1337
 
1338
-	$dec_hex = dechex($a_dec* 1000000);
1339
-	$sec_hex = dechex($a_sec);
1338
+    $dec_hex = dechex($a_dec* 1000000);
1339
+    $sec_hex = dechex($a_sec);
1340 1340
 
1341
-	ensure_length($dec_hex, 5);
1342
-	ensure_length($sec_hex, 6);
1341
+    ensure_length($dec_hex, 5);
1342
+    ensure_length($sec_hex, 6);
1343 1343
 
1344
-	$guid = "";
1345
-	$guid .= $dec_hex;
1346
-	$guid .= create_guid_section(3);
1347
-	$guid .= '-';
1348
-	$guid .= create_guid_section(4);
1349
-	$guid .= '-';
1350
-	$guid .= create_guid_section(4);
1351
-	$guid .= '-';
1352
-	$guid .= create_guid_section(4);
1353
-	$guid .= '-';
1354
-	$guid .= $sec_hex;
1355
-	$guid .= create_guid_section(6);
1344
+    $guid = "";
1345
+    $guid .= $dec_hex;
1346
+    $guid .= create_guid_section(3);
1347
+    $guid .= '-';
1348
+    $guid .= create_guid_section(4);
1349
+    $guid .= '-';
1350
+    $guid .= create_guid_section(4);
1351
+    $guid .= '-';
1352
+    $guid .= create_guid_section(4);
1353
+    $guid .= '-';
1354
+    $guid .= $sec_hex;
1355
+    $guid .= create_guid_section(6);
1356 1356
 
1357
-	return $guid;
1357
+    return $guid;
1358 1358
 
1359 1359
 }
1360 1360
 
1361 1361
 function create_guid_section($characters)
1362 1362
 {
1363
-	$return = "";
1364
-	for($i=0; $i<$characters; $i++)
1365
-	{
1366
-		$return .= dechex(mt_rand(0,15));
1367
-	}
1368
-	return $return;
1363
+    $return = "";
1364
+    for($i=0; $i<$characters; $i++)
1365
+    {
1366
+        $return .= dechex(mt_rand(0,15));
1367
+    }
1368
+    return $return;
1369 1369
 }
1370 1370
 
1371 1371
 function ensure_length(&$string, $length)
1372 1372
 {
1373
-	$strlen = strlen($string);
1374
-	if($strlen < $length)
1375
-	{
1376
-		$string = str_pad($string,$length,"0");
1377
-	}
1378
-	else if($strlen > $length)
1379
-	{
1380
-		$string = substr($string, 0, $length);
1381
-	}
1373
+    $strlen = strlen($string);
1374
+    if($strlen < $length)
1375
+    {
1376
+        $string = str_pad($string,$length,"0");
1377
+    }
1378
+    else if($strlen > $length)
1379
+    {
1380
+        $string = substr($string, 0, $length);
1381
+    }
1382 1382
 }
1383 1383
 
1384 1384
 function microtime_diff($a, $b) {
1385
-	list($a_dec, $a_sec) = explode(" ", $a);
1386
-	list($b_dec, $b_sec) = explode(" ", $b);
1387
-	return $b_sec - $a_sec + $b_dec - $a_dec;
1385
+    list($a_dec, $a_sec) = explode(" ", $a);
1386
+    list($b_dec, $b_sec) = explode(" ", $b);
1387
+    return $b_sec - $a_sec + $b_dec - $a_dec;
1388 1388
 }
1389 1389
 
1390 1390
 // check if Studio is displayed.
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 
1398 1398
 
1399 1399
 
1400
-	return true;
1400
+    return true;
1401 1401
 
1402 1402
 }
1403 1403
 
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 
1421 1421
 }
1422 1422
 
1423
- function get_workflow_admin_modules_for_user($user){
1423
+    function get_workflow_admin_modules_for_user($user){
1424 1424
     if (isset($_SESSION['get_workflow_admin_modules_for_user'])) {
1425 1425
         return $_SESSION['get_workflow_admin_modules_for_user'];
1426 1426
     }
@@ -1428,22 +1428,22 @@  discard block
 block discarded – undo
1428 1428
     global $moduleList;
1429 1429
     $workflow_mod_list = array();
1430 1430
     foreach($moduleList as $module){
1431
-		$workflow_mod_list[$module] = $module;
1432
-	}
1431
+        $workflow_mod_list[$module] = $module;
1432
+    }
1433 1433
 
1434
-	// This list is taken from teh previous version of workflow_utils.php
1434
+    // This list is taken from teh previous version of workflow_utils.php
1435 1435
     $workflow_mod_list['Tasks'] = "Tasks";
1436 1436
     $workflow_mod_list['Calls'] = "Calls";
1437 1437
     $workflow_mod_list['Meetings'] = "Meetings";
1438 1438
     $workflow_mod_list['Notes'] = "Notes";
1439 1439
     $workflow_mod_list['ProjectTask'] = "Project Tasks";
1440
-	$workflow_mod_list['Leads'] = "Leads";
1441
-	$workflow_mod_list['Opportunities'] = "Opportunities";
1442
-	// End of list
1440
+    $workflow_mod_list['Leads'] = "Leads";
1441
+    $workflow_mod_list['Opportunities'] = "Opportunities";
1442
+    // End of list
1443 1443
 
1444 1444
     $workflow_admin_modules = array();
1445 1445
     if(empty($user)) {
1446
-    	return $workflow_admin_modules;
1446
+        return $workflow_admin_modules;
1447 1447
     }
1448 1448
     $actions = ACLAction::getUserActions($user->id);
1449 1449
     //check for ForecastSchedule because it doesn't exist in $workflow_mod_list
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
         return false;
1498 1498
     }
1499 1499
 
1500
-	return $user->isAdmin();
1500
+    return $user->isAdmin();
1501 1501
 }
1502 1502
 
1503 1503
 /**
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
  */
1511 1511
 function get_theme_display($theme)
1512 1512
 {
1513
-	return SugarThemeRegistry::get($theme)->name;
1513
+    return SugarThemeRegistry::get($theme)->name;
1514 1514
 }
1515 1515
 
1516 1516
 /**
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
  * Contributor(s): ______________________________________..
1538 1538
  */
1539 1539
 function get_select_options ($option_list, $selected) {
1540
-	return get_select_options_with_id($option_list, $selected);
1540
+    return get_select_options_with_id($option_list, $selected);
1541 1541
 }
1542 1542
 
1543 1543
 /**
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
  * Contributor(s): ______________________________________..
1551 1551
  */
1552 1552
 function get_select_options_with_id ($option_list, $selected_key) {
1553
-	return get_select_options_with_id_separate_key($option_list, $option_list, $selected_key);
1553
+    return get_select_options_with_id_separate_key($option_list, $option_list, $selected_key);
1554 1554
 }
1555 1555
 
1556 1556
 
@@ -1565,23 +1565,23 @@  discard block
 block discarded – undo
1565 1565
  * Contributor(s): ______________________________________..
1566 1566
  */
1567 1567
 function get_select_options_with_id_separate_key ($label_list, $key_list, $selected_key, $massupdate=false) {
1568
-	global $app_strings;
1569
-	$select_options = "";
1568
+    global $app_strings;
1569
+    $select_options = "";
1570 1570
 
1571
-	//for setting null selection values to human readable --None--
1572
-	$pattern = "/'0?'></";
1573
-	$replacement = "''>".$app_strings['LBL_NONE']."<";
1571
+    //for setting null selection values to human readable --None--
1572
+    $pattern = "/'0?'></";
1573
+    $replacement = "''>".$app_strings['LBL_NONE']."<";
1574 1574
     if($massupdate){
1575 1575
         $replacement .= "/OPTION>\n<OPTION value='__SugarMassUpdateClearField__'><"; // Giving the user the option to unset a drop down list. I.e. none means that it won't get updated
1576 1576
     }
1577 1577
 
1578
-	if (empty($key_list)) $key_list = array();
1579
-	//create the type dropdown domain and set the selected value if $opp value already exists
1580
-	foreach ($key_list as $option_key=>$option_value) {
1578
+    if (empty($key_list)) $key_list = array();
1579
+    //create the type dropdown domain and set the selected value if $opp value already exists
1580
+    foreach ($key_list as $option_key=>$option_value) {
1581 1581
 
1582
-		$selected_string = '';
1583
-		// the system is evaluating $selected_key == 0 || '' to true.  Be very careful when changing this.  Test all cases.
1584
-		// The bug was only happening with one of the users in the drop down.  It was being replaced by none.
1582
+        $selected_string = '';
1583
+        // the system is evaluating $selected_key == 0 || '' to true.  Be very careful when changing this.  Test all cases.
1584
+        // The bug was only happening with one of the users in the drop down.  It was being replaced by none.
1585 1585
         if (
1586 1586
             ($option_key != '' && $selected_key == $option_key)
1587 1587
             || (
@@ -1590,15 +1590,15 @@  discard block
 block discarded – undo
1590 1590
             )
1591 1591
             || (is_array($selected_key) &&  in_array($option_key, $selected_key))
1592 1592
         ) {
1593
-			$selected_string = 'selected ';
1594
-		}
1593
+            $selected_string = 'selected ';
1594
+        }
1595 1595
 
1596
-		$html_value = $option_key;
1596
+        $html_value = $option_key;
1597 1597
 
1598
-		$select_options .= "\n<OPTION ".$selected_string."value='$html_value'>$label_list[$option_key]</OPTION>";
1599
-	}
1600
-	$select_options = preg_replace($pattern, $replacement, $select_options);
1601
-	return $select_options;
1598
+        $select_options .= "\n<OPTION ".$selected_string."value='$html_value'>$label_list[$option_key]</OPTION>";
1599
+    }
1600
+    $select_options = preg_replace($pattern, $replacement, $select_options);
1601
+    return $select_options;
1602 1602
 }
1603 1603
 
1604 1604
 
@@ -1609,10 +1609,10 @@  discard block
 block discarded – undo
1609 1609
  */
1610 1610
 function sugar_die($error_message, $exit_code = 1)
1611 1611
 {
1612
-	global $focus;
1613
-	sugar_cleanup();
1614
-	echo $error_message;
1615
-	die($exit_code);
1612
+    global $focus;
1613
+    sugar_cleanup();
1614
+    echo $error_message;
1615
+    die($exit_code);
1616 1616
 }
1617 1617
 
1618 1618
 
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
  * Contributor(s): ______________________________________..
1624 1624
  */
1625 1625
 function get_clear_form_js () {
1626
-	$the_script = <<<EOQ
1626
+    $the_script = <<<EOQ
1627 1627
 <script type="text/javascript" language="JavaScript">
1628 1628
 function clear_form(form) {
1629 1629
 	var newLoc = 'index.php?action=' + form.action.value + '&module=' + form.module.value + '&query=true&clear_query=true';
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 </script>
1636 1636
 EOQ;
1637 1637
 
1638
-	return $the_script;
1638
+    return $the_script;
1639 1639
 }
1640 1640
 
1641 1641
 /**
@@ -1647,8 +1647,8 @@  discard block
 block discarded – undo
1647 1647
  * Contributor(s): ______________________________________..
1648 1648
  */
1649 1649
 function get_set_focus_js () {
1650
-	//TODO Clint 5/20 - Make this function more generic so that it can take in the target form and field names as variables
1651
-	$the_script = <<<EOQ
1650
+    //TODO Clint 5/20 - Make this function more generic so that it can take in the target form and field names as variables
1651
+    $the_script = <<<EOQ
1652 1652
 <script type="text/javascript" language="JavaScript">
1653 1653
 <!--
1654 1654
 function set_focus() {
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 </script>
1673 1673
 EOQ;
1674 1674
 
1675
-	return $the_script;
1675
+    return $the_script;
1676 1676
 }
1677 1677
 
1678 1678
 /**
@@ -1688,26 +1688,26 @@  discard block
 block discarded – undo
1688 1688
  * Contributor(s): ______________________________________..
1689 1689
  */
1690 1690
 function array_csort() {
1691
-	$args = func_get_args();
1692
-	$marray = array_shift($args);
1693
-	$i = 0;
1694
-
1695
-	$msortline = "return(array_multisort(";
1696
-	foreach ($args as $arg) {
1697
-		$i++;
1698
-		if (is_string($arg)) {
1699
-			foreach ($marray as $row) {
1700
-				$sortarr[$i][] = $row[$arg];
1701
-			}
1702
-		} else {
1703
-			$sortarr[$i] = $arg;
1704
-		}
1705
-		$msortline .= "\$sortarr[".$i."],";
1706
-	}
1707
-	$msortline .= "\$marray));";
1691
+    $args = func_get_args();
1692
+    $marray = array_shift($args);
1693
+    $i = 0;
1694
+
1695
+    $msortline = "return(array_multisort(";
1696
+    foreach ($args as $arg) {
1697
+        $i++;
1698
+        if (is_string($arg)) {
1699
+            foreach ($marray as $row) {
1700
+                $sortarr[$i][] = $row[$arg];
1701
+            }
1702
+        } else {
1703
+            $sortarr[$i] = $arg;
1704
+        }
1705
+        $msortline .= "\$sortarr[".$i."],";
1706
+    }
1707
+    $msortline .= "\$marray));";
1708 1708
 
1709
-	eval($msortline);
1710
-	return $marray;
1709
+    eval($msortline);
1710
+    return $marray;
1711 1711
 }
1712 1712
 
1713 1713
 /**
@@ -1718,9 +1718,9 @@  discard block
 block discarded – undo
1718 1718
  * Contributor(s): ______________________________________..
1719 1719
  */
1720 1720
 function parse_calendardate($local_format) {
1721
-	preg_match('/\(?([^-]{1})[^-]*-([^-]{1})[^-]*-([^-]{1})[^-]*\)/', $local_format, $matches);
1722
-	$calendar_format = "%" . $matches[1] . "-%" . $matches[2] . "-%" . $matches[3];
1723
-	return str_replace(array("y", "ᅣ1�7", "a", "j"), array("Y", "Y", "Y", "d"), $calendar_format);
1721
+    preg_match('/\(?([^-]{1})[^-]*-([^-]{1})[^-]*-([^-]{1})[^-]*\)/', $local_format, $matches);
1722
+    $calendar_format = "%" . $matches[1] . "-%" . $matches[2] . "-%" . $matches[3];
1723
+    return str_replace(array("y", "ᅣ1�7", "a", "j"), array("Y", "Y", "Y", "d"), $calendar_format);
1724 1724
 }
1725 1725
 
1726 1726
 
@@ -1728,24 +1728,24 @@  discard block
 block discarded – undo
1728 1728
 
1729 1729
 
1730 1730
 function translate($string, $mod='', $selectedValue=''){
1731
-	//$test_start = microtime();
1732
-	//static $mod_strings_results = array();
1733
-	if(!empty($mod)){
1734
-		global $current_language;
1735
-		//Bug 31275
1736
-		if(isset($_REQUEST['login_language'])){
1737
-		    $current_language = ($_REQUEST['login_language'] == $current_language)? $current_language : $_REQUEST['login_language'];
1738
-		}
1739
-		$mod_strings = return_module_language($current_language, $mod);
1731
+    //$test_start = microtime();
1732
+    //static $mod_strings_results = array();
1733
+    if(!empty($mod)){
1734
+        global $current_language;
1735
+        //Bug 31275
1736
+        if(isset($_REQUEST['login_language'])){
1737
+            $current_language = ($_REQUEST['login_language'] == $current_language)? $current_language : $_REQUEST['login_language'];
1738
+        }
1739
+        $mod_strings = return_module_language($current_language, $mod);
1740 1740
         if ($mod == "")
1741 1741
         echo "Language is <pre>" . $mod_strings . "</pre>";
1742 1742
 
1743
-	}else{
1744
-		global $mod_strings;
1745
-	}
1743
+    }else{
1744
+        global $mod_strings;
1745
+    }
1746 1746
 
1747
-	$returnValue = '';
1748
-	global $app_strings, $app_list_strings;
1747
+    $returnValue = '';
1748
+    global $app_strings, $app_list_strings;
1749 1749
 
1750 1750
     if (isset($mod_strings[$string]))
1751 1751
         $returnValue = $mod_strings[$string];
@@ -1757,34 +1757,34 @@  discard block
 block discarded – undo
1757 1757
         $returnValue = $app_list_strings['moduleList'][$string];
1758 1758
 
1759 1759
 
1760
-	//$test_end = microtime();
1761
-	//
1762
-	//    $mod_strings_results[$mod] = microtime_diff($test_start,$test_end);
1763
-	//
1764
-	//    echo("translate results:");
1765
-	//    $total_time = 0;
1766
-	//    $total_strings = 0;
1767
-	//    foreach($mod_strings_results as $key=>$value)
1768
-	//    {
1769
-	//        echo("Module $key \t\t time $value \t\t<br>");
1770
-	//        $total_time += $value;
1771
-	//    }
1772
-	//
1773
-	//    echo("Total time: $total_time<br>");
1760
+    //$test_end = microtime();
1761
+    //
1762
+    //    $mod_strings_results[$mod] = microtime_diff($test_start,$test_end);
1763
+    //
1764
+    //    echo("translate results:");
1765
+    //    $total_time = 0;
1766
+    //    $total_strings = 0;
1767
+    //    foreach($mod_strings_results as $key=>$value)
1768
+    //    {
1769
+    //        echo("Module $key \t\t time $value \t\t<br>");
1770
+    //        $total_time += $value;
1771
+    //    }
1772
+    //
1773
+    //    echo("Total time: $total_time<br>");
1774 1774
 
1775 1775
 
1776 1776
 
1777
-	if(empty($returnValue)){
1778
-		return $string;
1779
-	}
1777
+    if(empty($returnValue)){
1778
+        return $string;
1779
+    }
1780 1780
 
1781 1781
     // Bug 48996 - Custom enums with '0' value were not returning because of empty check
1782 1782
     // Added a numeric 0 checker to the conditional to allow 0 value indexed to pass
1783
-	if(is_array($returnValue) && (!empty($selectedValue) || (is_numeric($selectedValue) && $selectedValue == 0))  && isset($returnValue[$selectedValue]) ){
1784
-		return $returnValue[$selectedValue];
1785
-	}
1783
+    if(is_array($returnValue) && (!empty($selectedValue) || (is_numeric($selectedValue) && $selectedValue == 0))  && isset($returnValue[$selectedValue]) ){
1784
+        return $returnValue[$selectedValue];
1785
+    }
1786 1786
 
1787
-	return $returnValue;
1787
+    return $returnValue;
1788 1788
 }
1789 1789
 
1790 1790
 function unTranslateNum($num) {
@@ -1808,16 +1808,16 @@  discard block
 block discarded – undo
1808 1808
 }
1809 1809
 
1810 1810
 function add_http($url) {
1811
-	if(!preg_match("@://@i", $url)) {
1812
-		$scheme = "http";
1813
-		if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
1814
-			$scheme = 'https';
1815
-		}
1811
+    if(!preg_match("@://@i", $url)) {
1812
+        $scheme = "http";
1813
+        if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
1814
+            $scheme = 'https';
1815
+        }
1816 1816
 
1817
-		return "{$scheme}://{$url}";
1818
-	}
1817
+        return "{$scheme}://{$url}";
1818
+    }
1819 1819
 
1820
-	return $url;
1820
+    return $url;
1821 1821
 }
1822 1822
 
1823 1823
 /**
@@ -1825,25 +1825,25 @@  discard block
 block discarded – undo
1825 1825
  * @return array
1826 1826
  */
1827 1827
 function getDefaultXssTags() {
1828
-	$tmp = array(
1829
-	"applet" => "applet",
1830
-	"base" => "base",
1831
-	"embed" => "embed",
1832
-	"form" => "form",
1833
-	"frame" => "frame",
1834
-	"frameset" => "frameset",
1835
-	"iframe" => "iframe",
1836
-	"import" => "\?import",
1837
-	"layer" => "layer",
1838
-	"link" => "link",
1839
-	"object" => "object",
1840
-	"script" => "script",
1841
-	"xmp" => "xmp",
1842
-	);
1843
-
1844
-	$ret = base64_encode(serialize($tmp));
1845
-
1846
-	return $ret;
1828
+    $tmp = array(
1829
+    "applet" => "applet",
1830
+    "base" => "base",
1831
+    "embed" => "embed",
1832
+    "form" => "form",
1833
+    "frame" => "frame",
1834
+    "frameset" => "frameset",
1835
+    "iframe" => "iframe",
1836
+    "import" => "\?import",
1837
+    "layer" => "layer",
1838
+    "link" => "link",
1839
+    "object" => "object",
1840
+    "script" => "script",
1841
+    "xmp" => "xmp",
1842
+    );
1843
+
1844
+    $ret = base64_encode(serialize($tmp));
1845
+
1846
+    return $ret;
1847 1847
 }
1848 1848
 
1849 1849
 /**
@@ -1865,28 +1865,28 @@  discard block
 block discarded – undo
1865 1865
  * @return array Array of matches, empty on clean string
1866 1866
  */
1867 1867
 function clean_xss($str, $cleanImg=true) {
1868
-	global $sugar_config;
1868
+    global $sugar_config;
1869 1869
 
1870
-	if(empty($sugar_config['email_xss']))
1871
-	$sugar_config['email_xss'] = getDefaultXssTags();
1870
+    if(empty($sugar_config['email_xss']))
1871
+    $sugar_config['email_xss'] = getDefaultXssTags();
1872 1872
 
1873
-	$xsstags = unserialize(base64_decode($sugar_config['email_xss']));
1873
+    $xsstags = unserialize(base64_decode($sugar_config['email_xss']));
1874 1874
 
1875
-	// cn: bug 13079 - "on\w" matched too many non-events (cONTact, strONG, etc.)
1876
-	$jsEvents  = "onblur|onfocus|oncontextmenu|onresize|onscroll|onunload|ondblclick|onclick|";
1877
-	$jsEvents .= "onmouseup|onmouseover|onmousedown|onmouseenter|onmouseleave|onmousemove|onload|onchange|";
1878
-	$jsEvents .= "onreset|onselect|onsubmit|onkeydown|onkeypress|onkeyup|onabort|onerror|ondragdrop";
1875
+    // cn: bug 13079 - "on\w" matched too many non-events (cONTact, strONG, etc.)
1876
+    $jsEvents  = "onblur|onfocus|oncontextmenu|onresize|onscroll|onunload|ondblclick|onclick|";
1877
+    $jsEvents .= "onmouseup|onmouseover|onmousedown|onmouseenter|onmouseleave|onmousemove|onload|onchange|";
1878
+    $jsEvents .= "onreset|onselect|onsubmit|onkeydown|onkeypress|onkeyup|onabort|onerror|ondragdrop";
1879 1879
 
1880
-	$attribute_regex	= "#\b({$jsEvents})\s*=\s*(?|(?!['\"])\S+|['\"].+?['\"])#sim";
1881
-	$javascript_regex	= '@<[^/>][^>]+(expression\(|j\W*a\W*v\W*a|v\W*b\W*s\W*c\W*r|&#|/\*|\*/)[^>]*>@sim';
1882
-	$imgsrc_regex		= '#<[^>]+src[^=]*=([^>]*?http(s)?://[^>]*)>#sim';
1883
-	$css_url			= '#url\(.*\.\w+\)#';
1880
+    $attribute_regex	= "#\b({$jsEvents})\s*=\s*(?|(?!['\"])\S+|['\"].+?['\"])#sim";
1881
+    $javascript_regex	= '@<[^/>][^>]+(expression\(|j\W*a\W*v\W*a|v\W*b\W*s\W*c\W*r|&#|/\*|\*/)[^>]*>@sim';
1882
+    $imgsrc_regex		= '#<[^>]+src[^=]*=([^>]*?http(s)?://[^>]*)>#sim';
1883
+    $css_url			= '#url\(.*\.\w+\)#';
1884 1884
 
1885
-	$tagsrex = '#<\/?(\w+)((?:\s+(?:\w|\w[\w-]*\w)(?:\s*=\s*(?:\".*?\"|\'.*?\'|[^\'\">\s]+))?)+\s*|\s*)\/?>#im';
1885
+    $tagsrex = '#<\/?(\w+)((?:\s+(?:\w|\w[\w-]*\w)(?:\s*=\s*(?:\".*?\"|\'.*?\'|[^\'\">\s]+))?)+\s*|\s*)\/?>#im';
1886 1886
 
1887
-	$tagmatches = array();
1888
-	$matches = array();
1889
-	preg_match_all($tagsrex, $str, $tagmatches, PREG_PATTERN_ORDER);
1887
+    $tagmatches = array();
1888
+    $matches = array();
1889
+    preg_match_all($tagsrex, $str, $tagmatches, PREG_PATTERN_ORDER);
1890 1890
     foreach($tagmatches[1] as $no => $tag) {
1891 1891
         if(in_array($tag, $xsstags)) {
1892 1892
             // dangerous tag - take out whole
@@ -1900,38 +1900,38 @@  discard block
 block discarded – undo
1900 1900
         }
1901 1901
     }
1902 1902
 
1903
-	$matches = array_merge($matches, xss_check_pattern($javascript_regex, $str));
1903
+    $matches = array_merge($matches, xss_check_pattern($javascript_regex, $str));
1904 1904
 
1905
-	if($cleanImg) {
1906
-		$matches = array_merge($matches,
1907
-		xss_check_pattern($imgsrc_regex, $str)
1908
-		);
1909
-	}
1905
+    if($cleanImg) {
1906
+        $matches = array_merge($matches,
1907
+        xss_check_pattern($imgsrc_regex, $str)
1908
+        );
1909
+    }
1910 1910
 
1911
-	// cn: bug 13498 - custom white-list of allowed domains that vet remote images
1912
-	preg_match_all($css_url, $str, $cssUrlMatches, PREG_PATTERN_ORDER);
1911
+    // cn: bug 13498 - custom white-list of allowed domains that vet remote images
1912
+    preg_match_all($css_url, $str, $cssUrlMatches, PREG_PATTERN_ORDER);
1913 1913
 
1914
-	if(isset($sugar_config['security_trusted_domains']) && !empty($sugar_config['security_trusted_domains']) && is_array($sugar_config['security_trusted_domains'])) {
1915
-		if(is_array($cssUrlMatches) && count($cssUrlMatches) > 0) {
1916
-			// normalize whitelist
1917
-			foreach($sugar_config['security_trusted_domains'] as $k => $v) {
1918
-				$sugar_config['security_trusted_domains'][$k] = strtolower($v);
1919
-			}
1914
+    if(isset($sugar_config['security_trusted_domains']) && !empty($sugar_config['security_trusted_domains']) && is_array($sugar_config['security_trusted_domains'])) {
1915
+        if(is_array($cssUrlMatches) && count($cssUrlMatches) > 0) {
1916
+            // normalize whitelist
1917
+            foreach($sugar_config['security_trusted_domains'] as $k => $v) {
1918
+                $sugar_config['security_trusted_domains'][$k] = strtolower($v);
1919
+            }
1920 1920
 
1921
-			foreach($cssUrlMatches[0] as $match) {
1922
-				$domain = strtolower(substr(strstr($match, "://"), 3));
1923
-				$baseUrl = substr($domain, 0, strpos($domain, "/"));
1921
+            foreach($cssUrlMatches[0] as $match) {
1922
+                $domain = strtolower(substr(strstr($match, "://"), 3));
1923
+                $baseUrl = substr($domain, 0, strpos($domain, "/"));
1924 1924
 
1925
-				if(!in_array($baseUrl, $sugar_config['security_trusted_domains'])) {
1926
-					$matches[] = $match;
1927
-				}
1928
-			}
1929
-		}
1930
-	} else {
1931
-		$matches = array_merge($matches, $cssUrlMatches[0]);
1932
-	}
1925
+                if(!in_array($baseUrl, $sugar_config['security_trusted_domains'])) {
1926
+                    $matches[] = $match;
1927
+                }
1928
+            }
1929
+        }
1930
+    } else {
1931
+        $matches = array_merge($matches, $cssUrlMatches[0]);
1932
+    }
1933 1933
 
1934
-	return $matches;
1934
+    return $matches;
1935 1935
 }
1936 1936
 
1937 1937
 /**
@@ -1941,8 +1941,8 @@  discard block
 block discarded – undo
1941 1941
  * @return array
1942 1942
  */
1943 1943
 function xss_check_pattern($pattern, $str) {
1944
-	preg_match_all($pattern, $str, $matches, PREG_PATTERN_ORDER);
1945
-	return $matches[1];
1944
+    preg_match_all($pattern, $str, $matches, PREG_PATTERN_ORDER);
1945
+    return $matches[1];
1946 1946
 }
1947 1947
 
1948 1948
 /**
@@ -1964,80 +1964,80 @@  discard block
 block discarded – undo
1964 1964
  */
1965 1965
 function clean_string($str, $filter = "STANDARD", $dieOnBadData = true)
1966 1966
 {
1967
-	global  $sugar_config;
1968
-
1969
-	$filters = Array(
1970
-	"STANDARD"        => '#[^A-Z0-9\-_\.\@]#i',
1971
-	"STANDARDSPACE"   => '#[^A-Z0-9\-_\.\@\ ]#i',
1972
-	"FILE"            => '#[^A-Z0-9\-_\.]#i',
1973
-	"NUMBER"          => '#[^0-9\-]#i',
1974
-	"SQL_COLUMN_LIST" => '#[^A-Z0-9\(\),_\.]#i',
1975
-	"PATH_NO_URL"     => '#://#i',
1976
-	"SAFED_GET"		  => '#[^A-Z0-9\@\=\&\?\.\/\-_~+]#i', /* range of allowed characters in a GET string */
1977
-	"UNIFIED_SEARCH"	=> "#[\\x00]#", /* cn: bug 3356 & 9236 - MBCS search strings */
1978
-	"AUTO_INCREMENT"	=> '#[^0-9\-,\ ]#i',
1979
-	"ALPHANUM"        => '#[^A-Z0-9\-]#i',
1980
-	);
1981
-
1982
-	if (preg_match($filters[$filter], $str)) {
1983
-		if (isset($GLOBALS['log']) && is_object($GLOBALS['log'])) {
1984
-			$GLOBALS['log']->fatal("SECURITY[$filter]: bad data passed in; string: {$str}");
1985
-		}
1986
-		if ( $dieOnBadData ) {
1987
-			die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>");
1988
-		}
1989
-		return false;
1990
-	}
1991
-	else {
1992
-		return $str;
1993
-	}
1967
+    global  $sugar_config;
1968
+
1969
+    $filters = Array(
1970
+    "STANDARD"        => '#[^A-Z0-9\-_\.\@]#i',
1971
+    "STANDARDSPACE"   => '#[^A-Z0-9\-_\.\@\ ]#i',
1972
+    "FILE"            => '#[^A-Z0-9\-_\.]#i',
1973
+    "NUMBER"          => '#[^0-9\-]#i',
1974
+    "SQL_COLUMN_LIST" => '#[^A-Z0-9\(\),_\.]#i',
1975
+    "PATH_NO_URL"     => '#://#i',
1976
+    "SAFED_GET"		  => '#[^A-Z0-9\@\=\&\?\.\/\-_~+]#i', /* range of allowed characters in a GET string */
1977
+    "UNIFIED_SEARCH"	=> "#[\\x00]#", /* cn: bug 3356 & 9236 - MBCS search strings */
1978
+    "AUTO_INCREMENT"	=> '#[^0-9\-,\ ]#i',
1979
+    "ALPHANUM"        => '#[^A-Z0-9\-]#i',
1980
+    );
1981
+
1982
+    if (preg_match($filters[$filter], $str)) {
1983
+        if (isset($GLOBALS['log']) && is_object($GLOBALS['log'])) {
1984
+            $GLOBALS['log']->fatal("SECURITY[$filter]: bad data passed in; string: {$str}");
1985
+        }
1986
+        if ( $dieOnBadData ) {
1987
+            die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>");
1988
+        }
1989
+        return false;
1990
+    }
1991
+    else {
1992
+        return $str;
1993
+    }
1994 1994
 }
1995 1995
 
1996 1996
 function clean_special_arguments() {
1997
-	if(isset($_SERVER['PHP_SELF'])) {
1998
-		if (!empty($_SERVER['PHP_SELF'])) clean_string($_SERVER['PHP_SELF'], 'SAFED_GET');
1999
-	}
2000
-	if (!empty($_REQUEST) && !empty($_REQUEST['login_theme'])) clean_string($_REQUEST['login_theme'], "STANDARD");
2001
-	if (!empty($_REQUEST) && !empty($_REQUEST['login_module'])) clean_string($_REQUEST['login_module'], "STANDARD");
2002
-	if (!empty($_REQUEST) && !empty($_REQUEST['login_action'])) clean_string($_REQUEST['login_action'], "STANDARD");
2003
-	if (!empty($_REQUEST) && !empty($_REQUEST['ck_login_theme_20'])) clean_string($_REQUEST['ck_login_theme_20'], "STANDARD");
2004
-	if (!empty($_SESSION) && !empty($_SESSION['authenticated_user_theme'])) clean_string($_SESSION['authenticated_user_theme'], "STANDARD");
2005
-	if (!empty($_REQUEST) && !empty($_REQUEST['module_name'])) clean_string($_REQUEST['module_name'], "STANDARD");
2006
-	if (!empty($_REQUEST) && !empty($_REQUEST['module'])) clean_string($_REQUEST['module'], "STANDARD");
2007
-	if (!empty($_POST) && !empty($_POST['parent_type'])) clean_string($_POST['parent_type'], "STANDARD");
2008
-	if (!empty($_REQUEST) && !empty($_REQUEST['mod_lang'])) clean_string($_REQUEST['mod_lang'], "STANDARD");
2009
-	if (!empty($_SESSION) && !empty($_SESSION['authenticated_user_language'])) clean_string($_SESSION['authenticated_user_language'], "STANDARD");
2010
-	if (!empty($_SESSION) && !empty($_SESSION['dyn_layout_file'])) clean_string($_SESSION['dyn_layout_file'], "PATH_NO_URL");
2011
-	if (!empty($_GET) && !empty($_GET['from'])) clean_string($_GET['from']);
2012
-	if (!empty($_GET) && !empty($_GET['gmto'])) clean_string($_GET['gmto'], "NUMBER");
2013
-	if (!empty($_GET) && !empty($_GET['case_number'])) clean_string($_GET['case_number'], "AUTO_INCREMENT");
2014
-	if (!empty($_GET) && !empty($_GET['bug_number'])) clean_string($_GET['bug_number'], "AUTO_INCREMENT");
2015
-	if (!empty($_GET) && !empty($_GET['quote_num'])) clean_string($_GET['quote_num'], "AUTO_INCREMENT");
2016
-	clean_superglobals('stamp', 'ALPHANUM'); // for vcr controls
2017
-	clean_superglobals('offset', 'ALPHANUM');
2018
-	clean_superglobals('return_action');
2019
-	clean_superglobals('return_module');
2020
-	return TRUE;
1997
+    if(isset($_SERVER['PHP_SELF'])) {
1998
+        if (!empty($_SERVER['PHP_SELF'])) clean_string($_SERVER['PHP_SELF'], 'SAFED_GET');
1999
+    }
2000
+    if (!empty($_REQUEST) && !empty($_REQUEST['login_theme'])) clean_string($_REQUEST['login_theme'], "STANDARD");
2001
+    if (!empty($_REQUEST) && !empty($_REQUEST['login_module'])) clean_string($_REQUEST['login_module'], "STANDARD");
2002
+    if (!empty($_REQUEST) && !empty($_REQUEST['login_action'])) clean_string($_REQUEST['login_action'], "STANDARD");
2003
+    if (!empty($_REQUEST) && !empty($_REQUEST['ck_login_theme_20'])) clean_string($_REQUEST['ck_login_theme_20'], "STANDARD");
2004
+    if (!empty($_SESSION) && !empty($_SESSION['authenticated_user_theme'])) clean_string($_SESSION['authenticated_user_theme'], "STANDARD");
2005
+    if (!empty($_REQUEST) && !empty($_REQUEST['module_name'])) clean_string($_REQUEST['module_name'], "STANDARD");
2006
+    if (!empty($_REQUEST) && !empty($_REQUEST['module'])) clean_string($_REQUEST['module'], "STANDARD");
2007
+    if (!empty($_POST) && !empty($_POST['parent_type'])) clean_string($_POST['parent_type'], "STANDARD");
2008
+    if (!empty($_REQUEST) && !empty($_REQUEST['mod_lang'])) clean_string($_REQUEST['mod_lang'], "STANDARD");
2009
+    if (!empty($_SESSION) && !empty($_SESSION['authenticated_user_language'])) clean_string($_SESSION['authenticated_user_language'], "STANDARD");
2010
+    if (!empty($_SESSION) && !empty($_SESSION['dyn_layout_file'])) clean_string($_SESSION['dyn_layout_file'], "PATH_NO_URL");
2011
+    if (!empty($_GET) && !empty($_GET['from'])) clean_string($_GET['from']);
2012
+    if (!empty($_GET) && !empty($_GET['gmto'])) clean_string($_GET['gmto'], "NUMBER");
2013
+    if (!empty($_GET) && !empty($_GET['case_number'])) clean_string($_GET['case_number'], "AUTO_INCREMENT");
2014
+    if (!empty($_GET) && !empty($_GET['bug_number'])) clean_string($_GET['bug_number'], "AUTO_INCREMENT");
2015
+    if (!empty($_GET) && !empty($_GET['quote_num'])) clean_string($_GET['quote_num'], "AUTO_INCREMENT");
2016
+    clean_superglobals('stamp', 'ALPHANUM'); // for vcr controls
2017
+    clean_superglobals('offset', 'ALPHANUM');
2018
+    clean_superglobals('return_action');
2019
+    clean_superglobals('return_module');
2020
+    return TRUE;
2021 2021
 }
2022 2022
 
2023 2023
 /**
2024 2024
  * cleans the given key in superglobals $_GET, $_POST, $_REQUEST
2025 2025
  */
2026 2026
 function clean_superglobals($key, $filter = 'STANDARD') {
2027
-	if(isset($_GET[$key])) clean_string($_GET[$key], $filter);
2028
-	if(isset($_POST[$key])) clean_string($_POST[$key], $filter);
2029
-	if(isset($_REQUEST[$key])) clean_string($_REQUEST[$key], $filter);
2027
+    if(isset($_GET[$key])) clean_string($_GET[$key], $filter);
2028
+    if(isset($_POST[$key])) clean_string($_POST[$key], $filter);
2029
+    if(isset($_REQUEST[$key])) clean_string($_REQUEST[$key], $filter);
2030 2030
 }
2031 2031
 
2032 2032
 function set_superglobals($key, $val){
2033
-	$_GET[$key] = $val;
2034
-	$_POST[$key] = $val;
2035
-	$_REQUEST[$key] = $val;
2033
+    $_GET[$key] = $val;
2034
+    $_POST[$key] = $val;
2035
+    $_REQUEST[$key] = $val;
2036 2036
 }
2037 2037
 
2038 2038
 // Works in conjunction with clean_string() to defeat SQL injection, file inclusion attacks, and XSS
2039 2039
 function clean_incoming_data() {
2040
-	global $sugar_config;
2040
+    global $sugar_config;
2041 2041
     global $RAW_REQUEST;
2042 2042
 
2043 2043
     if(get_magic_quotes_gpc()) {
@@ -2047,120 +2047,120 @@  discard block
 block discarded – undo
2047 2047
         $RAW_REQUEST = $_REQUEST;
2048 2048
     }
2049 2049
 
2050
-	if (get_magic_quotes_gpc() == 1) {
2051
-		$req  = array_map("preprocess_param", $_REQUEST);
2052
-		$post = array_map("preprocess_param", $_POST);
2053
-		$get  = array_map("preprocess_param", $_GET);
2054
-	} else {
2050
+    if (get_magic_quotes_gpc() == 1) {
2051
+        $req  = array_map("preprocess_param", $_REQUEST);
2052
+        $post = array_map("preprocess_param", $_POST);
2053
+        $get  = array_map("preprocess_param", $_GET);
2054
+    } else {
2055 2055
 
2056
-		$req  = array_map("securexss", $_REQUEST);
2057
-		$post = array_map("securexss", $_POST);
2058
-		$get  = array_map("securexss", $_GET);
2059
-	}
2056
+        $req  = array_map("securexss", $_REQUEST);
2057
+        $post = array_map("securexss", $_POST);
2058
+        $get  = array_map("securexss", $_GET);
2059
+    }
2060 2060
 
2061
-	// PHP cannot stomp out superglobals reliably
2062
-	foreach($post as $k => $v) { $_POST[$k] = $v; }
2063
-	foreach($get  as $k => $v) { $_GET[$k] = $v; }
2064
-	foreach($req  as $k => $v) {
2065
-		 $_REQUEST[$k] = $v;
2061
+    // PHP cannot stomp out superglobals reliably
2062
+    foreach($post as $k => $v) { $_POST[$k] = $v; }
2063
+    foreach($get  as $k => $v) { $_GET[$k] = $v; }
2064
+    foreach($req  as $k => $v) {
2065
+            $_REQUEST[$k] = $v;
2066 2066
 
2067
-	    //ensure the keys are safe as well.  If mbstring encoding translation is on, the post keys don't
2067
+        //ensure the keys are safe as well.  If mbstring encoding translation is on, the post keys don't
2068 2068
         //get translated, so scrub the data but don't die
2069
-	    if(ini_get('mbstring.encoding_translation')==='1'){
2069
+        if(ini_get('mbstring.encoding_translation')==='1'){
2070 2070
             securexsskey($k,false);
2071 2071
         }else{
2072
-		    securexsskey($k,true);
2072
+            securexsskey($k,true);
2073 2073
         }
2074 2074
 
2075
-	}
2076
-	// Any additional variables that need to be cleaned should be added here
2077
-	if (isset($_REQUEST['login_theme'])) clean_string($_REQUEST['login_theme']);
2078
-	if (isset($_REQUEST['login_module'])) clean_string($_REQUEST['login_module']);
2079
-	if (isset($_REQUEST['login_action'])) clean_string($_REQUEST['login_action']);
2080
-	if (isset($_REQUEST['login_language'])) clean_string($_REQUEST['login_language']);
2081
-	if (isset($_REQUEST['action'])) clean_string($_REQUEST['action']);
2082
-	if (isset($_REQUEST['module'])) clean_string($_REQUEST['module']);
2083
-	if (isset($_REQUEST['record'])) clean_string($_REQUEST['record'], 'STANDARDSPACE');
2084
-	if (isset($_SESSION['authenticated_user_theme'])) clean_string($_SESSION['authenticated_user_theme']);
2085
-	if (isset($_SESSION['authenticated_user_language'])) clean_string($_SESSION['authenticated_user_language']);
2086
-	if (isset($_REQUEST['language'])) clean_string($_REQUEST['language']);
2087
-	if (isset($sugar_config['default_theme'])) clean_string($sugar_config['default_theme']);
2088
-	if (isset($_REQUEST['offset'])) clean_string($_REQUEST['offset']);
2089
-	if (isset($_REQUEST['stamp'])) clean_string($_REQUEST['stamp']);
2090
-
2091
-	if(isset($_REQUEST['lvso'])){
2092
-			set_superglobals('lvso', (strtolower($_REQUEST['lvso']) === 'desc')?'desc':'asc');
2093
-	}
2094
-	// Clean "offset" and "order_by" parameters in URL
2095
-	foreach ($_REQUEST as $key => $val) {
2096
-		if (str_end($key, "_offset")) {
2097
-			clean_string($_REQUEST[$key], "ALPHANUM"); // keep this ALPHANUM for disable_count_query
2098
-			set_superglobals($key, $_REQUEST[$key]);
2099
-		}
2100
-		elseif (str_end($key, "_ORDER_BY")) {
2101
-			clean_string($_REQUEST[$key], "SQL_COLUMN_LIST");
2102
-			set_superglobals($key, $_REQUEST[$key]);
2103
-		}
2104
-	}
2075
+    }
2076
+    // Any additional variables that need to be cleaned should be added here
2077
+    if (isset($_REQUEST['login_theme'])) clean_string($_REQUEST['login_theme']);
2078
+    if (isset($_REQUEST['login_module'])) clean_string($_REQUEST['login_module']);
2079
+    if (isset($_REQUEST['login_action'])) clean_string($_REQUEST['login_action']);
2080
+    if (isset($_REQUEST['login_language'])) clean_string($_REQUEST['login_language']);
2081
+    if (isset($_REQUEST['action'])) clean_string($_REQUEST['action']);
2082
+    if (isset($_REQUEST['module'])) clean_string($_REQUEST['module']);
2083
+    if (isset($_REQUEST['record'])) clean_string($_REQUEST['record'], 'STANDARDSPACE');
2084
+    if (isset($_SESSION['authenticated_user_theme'])) clean_string($_SESSION['authenticated_user_theme']);
2085
+    if (isset($_SESSION['authenticated_user_language'])) clean_string($_SESSION['authenticated_user_language']);
2086
+    if (isset($_REQUEST['language'])) clean_string($_REQUEST['language']);
2087
+    if (isset($sugar_config['default_theme'])) clean_string($sugar_config['default_theme']);
2088
+    if (isset($_REQUEST['offset'])) clean_string($_REQUEST['offset']);
2089
+    if (isset($_REQUEST['stamp'])) clean_string($_REQUEST['stamp']);
2090
+
2091
+    if(isset($_REQUEST['lvso'])){
2092
+            set_superglobals('lvso', (strtolower($_REQUEST['lvso']) === 'desc')?'desc':'asc');
2093
+    }
2094
+    // Clean "offset" and "order_by" parameters in URL
2095
+    foreach ($_REQUEST as $key => $val) {
2096
+        if (str_end($key, "_offset")) {
2097
+            clean_string($_REQUEST[$key], "ALPHANUM"); // keep this ALPHANUM for disable_count_query
2098
+            set_superglobals($key, $_REQUEST[$key]);
2099
+        }
2100
+        elseif (str_end($key, "_ORDER_BY")) {
2101
+            clean_string($_REQUEST[$key], "SQL_COLUMN_LIST");
2102
+            set_superglobals($key, $_REQUEST[$key]);
2103
+        }
2104
+    }
2105 2105
 
2106 2106
 
2107
-	return 0;
2107
+    return 0;
2108 2108
 }
2109 2109
 
2110 2110
 // Returns TRUE if $str begins with $begin
2111 2111
 function str_begin($str, $begin) {
2112
-	return (substr($str, 0, strlen($begin)) == $begin);
2112
+    return (substr($str, 0, strlen($begin)) == $begin);
2113 2113
 }
2114 2114
 
2115 2115
 // Returns TRUE if $str ends with $end
2116 2116
 function str_end($str, $end) {
2117
-	return (substr($str, strlen($str) - strlen($end)) == $end);
2117
+    return (substr($str, strlen($str) - strlen($end)) == $end);
2118 2118
 }
2119 2119
 
2120 2120
 function securexss($value) {
2121
-	if(is_array($value)){
2122
-    	$new = array();
2121
+    if(is_array($value)){
2122
+        $new = array();
2123 2123
         foreach($value as $key=>$val){
2124
-       		$new[$key] = securexss($val);
2124
+                $new[$key] = securexss($val);
2125 2125
         }
2126 2126
         return $new;
2127 2127
     }
2128
-	static $xss_cleanup=  array("&quot;" => "&#38;", '"' =>'&quot;', "'" =>  '&#039;' , '<' =>'&lt;' , '>'=>'&gt;');
2129
-	$value = preg_replace(array('/javascript:/i', '/\0/'), array('java script:', ''), $value);
2130
-	$value = preg_replace('/javascript:/i', 'java script:', $value);
2131
-	return str_replace(array_keys($xss_cleanup), array_values($xss_cleanup), $value);
2128
+    static $xss_cleanup=  array("&quot;" => "&#38;", '"' =>'&quot;', "'" =>  '&#039;' , '<' =>'&lt;' , '>'=>'&gt;');
2129
+    $value = preg_replace(array('/javascript:/i', '/\0/'), array('java script:', ''), $value);
2130
+    $value = preg_replace('/javascript:/i', 'java script:', $value);
2131
+    return str_replace(array_keys($xss_cleanup), array_values($xss_cleanup), $value);
2132 2132
 }
2133 2133
 
2134 2134
 function securexsskey($value, $die=true){
2135
-	global $sugar_config;
2136
-	$matches = array();
2137
-	preg_match('/[\'"<>]/', $value, $matches);
2138
-	if(!empty($matches)){
2139
-		if($die){
2140
-			die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>");
2141
-		}else{
2142
-			unset($_REQUEST[$value]);
2143
-			unset($_POST[$value]);
2144
-			unset($_GET[$value]);
2145
-		}
2146
-	}
2135
+    global $sugar_config;
2136
+    $matches = array();
2137
+    preg_match('/[\'"<>]/', $value, $matches);
2138
+    if(!empty($matches)){
2139
+        if($die){
2140
+            die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>");
2141
+        }else{
2142
+            unset($_REQUEST[$value]);
2143
+            unset($_POST[$value]);
2144
+            unset($_GET[$value]);
2145
+        }
2146
+    }
2147 2147
 }
2148 2148
 
2149 2149
 function preprocess_param($value){
2150
-	if(is_string($value)){
2151
-		if(get_magic_quotes_gpc() == 1){
2152
-			$value = stripslashes($value);
2153
-		}
2150
+    if(is_string($value)){
2151
+        if(get_magic_quotes_gpc() == 1){
2152
+            $value = stripslashes($value);
2153
+        }
2154 2154
 
2155
-		$value = securexss($value);
2156
-	}
2157
-	else if (is_array($value)){
2158
-	    foreach ($value as $key => $element) {
2159
-	        $value[$key] = preprocess_param($element);
2160
-	    }
2161
-	}
2155
+        $value = securexss($value);
2156
+    }
2157
+    else if (is_array($value)){
2158
+        foreach ($value as $key => $element) {
2159
+            $value[$key] = preprocess_param($element);
2160
+        }
2161
+    }
2162 2162
 
2163
-	return $value;
2163
+    return $value;
2164 2164
 }
2165 2165
 
2166 2166
 function cleanup_slashes($value)
@@ -2184,13 +2184,13 @@  discard block
 block discarded – undo
2184 2184
 // this function cleans id's when being imported
2185 2185
 function convert_id($string)
2186 2186
 {
2187
-	return preg_replace_callback( '|[^A-Za-z0-9\-]|',
2188
-	create_function(
2189
-	// single quotes are essential here,
2190
-	// or alternative escape all $ as \$
2191
-	'$matches',
2192
-	'return ord($matches[0]);'
2193
-         ) ,$string);
2187
+    return preg_replace_callback( '|[^A-Za-z0-9\-]|',
2188
+    create_function(
2189
+    // single quotes are essential here,
2190
+    // or alternative escape all $ as \$
2191
+    '$matches',
2192
+    'return ord($matches[0]);'
2193
+            ) ,$string);
2194 2194
 }
2195 2195
 
2196 2196
 /**
@@ -2201,41 +2201,41 @@  discard block
 block discarded – undo
2201 2201
     return SugarThemeRegistry::current()->getImage(basename($image), $other_attributes, empty($width) ? null : $width, empty($height) ? null : $height, $ext, $alt );
2202 2202
 }
2203 2203
 /**
2204
- * @deprecated use SugarTheme::getImageURL()
2205
- */
2204
+     * @deprecated use SugarTheme::getImageURL()
2205
+     */
2206 2206
 function getImagePath($image_name)
2207 2207
 {
2208 2208
     return SugarThemeRegistry::current()->getImageURL($image_name);
2209 2209
 }
2210 2210
 
2211 2211
 function getWebPath($relative_path){
2212
-	//if it has  a :// then it isn't a relative path
2213
-	if(substr_count($relative_path, '://') > 0) return $relative_path;
2214
-	if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2215
-	return $relative_path;
2212
+    //if it has  a :// then it isn't a relative path
2213
+    if(substr_count($relative_path, '://') > 0) return $relative_path;
2214
+    if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2215
+    return $relative_path;
2216 2216
 }
2217 2217
 
2218 2218
 function getVersionedPath($path, $additional_attrs='')
2219 2219
 {
2220
-	if(empty($GLOBALS['sugar_config']['js_custom_version'])) $GLOBALS['sugar_config']['js_custom_version'] = 1;
2221
-	$js_version_key = isset($GLOBALS['js_version_key'])?$GLOBALS['js_version_key']:'';
2222
-	if(inDeveloperMode()) {
2223
-	    static $rand;
2224
-	    if(empty($rand)) $rand = mt_rand();
2225
-	    $dev = $rand;
2226
-	} else {
2227
-	    $dev = '';
2228
-	}
2229
-	if(is_array($additional_attrs)) {
2230
-	    $additional_attrs = join("|",$additional_attrs);
2231
-	}
2232
-	// cutting 2 last chars here because since md5 is 32 chars, it's always ==
2233
-	$str = substr(base64_encode(md5("$js_version_key|{$GLOBALS['sugar_config']['js_custom_version']}|$dev|$additional_attrs", true)), 0, -2);
2234
-	// remove / - it confuses some parsers
2235
-	$str = strtr($str, '/+', '-_');
2236
-	if(empty($path)) return $str;
2220
+    if(empty($GLOBALS['sugar_config']['js_custom_version'])) $GLOBALS['sugar_config']['js_custom_version'] = 1;
2221
+    $js_version_key = isset($GLOBALS['js_version_key'])?$GLOBALS['js_version_key']:'';
2222
+    if(inDeveloperMode()) {
2223
+        static $rand;
2224
+        if(empty($rand)) $rand = mt_rand();
2225
+        $dev = $rand;
2226
+    } else {
2227
+        $dev = '';
2228
+    }
2229
+    if(is_array($additional_attrs)) {
2230
+        $additional_attrs = join("|",$additional_attrs);
2231
+    }
2232
+    // cutting 2 last chars here because since md5 is 32 chars, it's always ==
2233
+    $str = substr(base64_encode(md5("$js_version_key|{$GLOBALS['sugar_config']['js_custom_version']}|$dev|$additional_attrs", true)), 0, -2);
2234
+    // remove / - it confuses some parsers
2235
+    $str = strtr($str, '/+', '-_');
2236
+    if(empty($path)) return $str;
2237 2237
 
2238
-	return $path . "?v=$str";
2238
+    return $path . "?v=$str";
2239 2239
 }
2240 2240
 
2241 2241
 function getVersionedScript($path, $additional_attrs='')
@@ -2245,19 +2245,19 @@  discard block
 block discarded – undo
2245 2245
 
2246 2246
 function getJSPath($relative_path, $additional_attrs='')
2247 2247
 {
2248
-	if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2249
-	return getVersionedPath($relative_path).(!empty($additional_attrs)?"&$additional_attrs":"");
2248
+    if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2249
+    return getVersionedPath($relative_path).(!empty($additional_attrs)?"&$additional_attrs":"");
2250 2250
 }
2251 2251
 
2252 2252
 function getSWFPath($relative_path, $additional_params=''){
2253
-	$path = $relative_path;
2254
-	if (!empty($additional_params)){
2255
-		$path .= '?' . $additional_params;
2256
-	}
2257
-	if (defined('TEMPLATE_URL')){
2258
-		$path = TEMPLATE_URL . '/' . $path;
2259
-	}
2260
-	return $path;
2253
+    $path = $relative_path;
2254
+    if (!empty($additional_params)){
2255
+        $path .= '?' . $additional_params;
2256
+    }
2257
+    if (defined('TEMPLATE_URL')){
2258
+        $path = TEMPLATE_URL . '/' . $path;
2259
+    }
2260
+    return $path;
2261 2261
 }
2262 2262
 
2263 2263
 
@@ -2266,158 +2266,158 @@  discard block
 block discarded – undo
2266 2266
 
2267 2267
 function getSQLDate($date_str)
2268 2268
 {
2269
-	if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/',$date_str,$match))
2270
-	{
2271
-		if ( strlen($match[2]) == 1)
2272
-		{
2273
-			$match[2] = "0".$match[2];
2274
-		}
2275
-		if ( strlen($match[1]) == 1)
2276
-		{
2277
-			$match[1] = "0".$match[1];
2278
-		}
2279
-		return "{$match[3]}-{$match[1]}-{$match[2]}";
2280
-	}
2281
-	else if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/',$date_str,$match))
2282
-	{
2283
-		if ( strlen($match[2]) == 1)
2284
-		{
2285
-			$match[2] = "0".$match[2];
2286
-		}
2287
-		if ( strlen($match[1]) == 1)
2288
-		{
2289
-			$match[1] = "0".$match[1];
2290
-		}
2291
-		return "{$match[3]}-{$match[1]}-{$match[2]}";
2292
-	}
2293
-	else
2294
-	{
2295
-		return "";
2296
-	}
2269
+    if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/',$date_str,$match))
2270
+    {
2271
+        if ( strlen($match[2]) == 1)
2272
+        {
2273
+            $match[2] = "0".$match[2];
2274
+        }
2275
+        if ( strlen($match[1]) == 1)
2276
+        {
2277
+            $match[1] = "0".$match[1];
2278
+        }
2279
+        return "{$match[3]}-{$match[1]}-{$match[2]}";
2280
+    }
2281
+    else if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/',$date_str,$match))
2282
+    {
2283
+        if ( strlen($match[2]) == 1)
2284
+        {
2285
+            $match[2] = "0".$match[2];
2286
+        }
2287
+        if ( strlen($match[1]) == 1)
2288
+        {
2289
+            $match[1] = "0".$match[1];
2290
+        }
2291
+        return "{$match[3]}-{$match[1]}-{$match[2]}";
2292
+    }
2293
+    else
2294
+    {
2295
+        return "";
2296
+    }
2297 2297
 }
2298 2298
 
2299 2299
 function clone_history(&$db, $from_id,$to_id, $to_type)
2300 2300
 {
2301
-	global $timedate;
2302
-	$old_note_id=null;
2303
-	$old_filename=null;
2304
-	require_once('include/upload_file.php');
2305
-	$tables = array('calls'=>'Call', 'meetings'=>'Meeting', 'notes'=>'Note', 'tasks'=>'Task');
2306
-
2307
-	$location=array('Email'=>"modules/Emails/Email.php",
2308
-	'Call'=>"modules/Calls/Call.php",
2309
-	'Meeting'=>"modules/Meetings/Meeting.php",
2310
-	'Note'=>"modules/Notes/Note.php",
2311
-	'Tasks'=>"modules/Tasks/Task.php",
2312
-	);
2313
-
2314
-
2315
-	foreach($tables as $table=>$bean_class)
2316
-	{
2317
-
2318
-		if (!class_exists($bean_class))
2319
-		{
2320
-			require_once($location[$bean_class]);
2321
-		}
2322
-
2323
-		$bProcessingNotes=false;
2324
-		if ($table=='notes')
2325
-		{
2326
-			$bProcessingNotes=true;
2327
-		}
2328
-		$query = "SELECT id FROM $table WHERE parent_id='$from_id'";
2329
-		$results = $db->query($query);
2330
-		while($row = $db->fetchByAssoc($results))
2331
-		{
2332
-			//retrieve existing record.
2333
-			$bean= new $bean_class();
2334
-			$bean->retrieve($row['id']);
2335
-			//process for new instance.
2336
-			if ($bProcessingNotes)
2337
-			{
2338
-				$old_note_id=$row['id'];
2339
-				$old_filename=$bean->filename;
2340
-			}
2341
-			$bean->id=null;
2342
-			$bean->parent_id=$to_id;
2343
-			$bean->parent_type=$to_type;
2344
-			if ($to_type=='Contacts' and in_array('contact_id',$bean->column_fields))
2345
-			{
2346
-				$bean->contact_id=$to_id;
2347
-			}
2348
-			$bean->update_date_modified = false;
2301
+    global $timedate;
2302
+    $old_note_id=null;
2303
+    $old_filename=null;
2304
+    require_once('include/upload_file.php');
2305
+    $tables = array('calls'=>'Call', 'meetings'=>'Meeting', 'notes'=>'Note', 'tasks'=>'Task');
2306
+
2307
+    $location=array('Email'=>"modules/Emails/Email.php",
2308
+    'Call'=>"modules/Calls/Call.php",
2309
+    'Meeting'=>"modules/Meetings/Meeting.php",
2310
+    'Note'=>"modules/Notes/Note.php",
2311
+    'Tasks'=>"modules/Tasks/Task.php",
2312
+    );
2313
+
2314
+
2315
+    foreach($tables as $table=>$bean_class)
2316
+    {
2317
+
2318
+        if (!class_exists($bean_class))
2319
+        {
2320
+            require_once($location[$bean_class]);
2321
+        }
2322
+
2323
+        $bProcessingNotes=false;
2324
+        if ($table=='notes')
2325
+        {
2326
+            $bProcessingNotes=true;
2327
+        }
2328
+        $query = "SELECT id FROM $table WHERE parent_id='$from_id'";
2329
+        $results = $db->query($query);
2330
+        while($row = $db->fetchByAssoc($results))
2331
+        {
2332
+            //retrieve existing record.
2333
+            $bean= new $bean_class();
2334
+            $bean->retrieve($row['id']);
2335
+            //process for new instance.
2336
+            if ($bProcessingNotes)
2337
+            {
2338
+                $old_note_id=$row['id'];
2339
+                $old_filename=$bean->filename;
2340
+            }
2341
+            $bean->id=null;
2342
+            $bean->parent_id=$to_id;
2343
+            $bean->parent_type=$to_type;
2344
+            if ($to_type=='Contacts' and in_array('contact_id',$bean->column_fields))
2345
+            {
2346
+                $bean->contact_id=$to_id;
2347
+            }
2348
+            $bean->update_date_modified = false;
2349 2349
             $bean->update_modified_by = false;
2350 2350
             if(isset($bean->date_modified))
2351 2351
                 $bean->date_modified = $timedate->to_db($bean->date_modified);
2352 2352
             if(isset($bean->date_entered))
2353 2353
                 $bean->date_entered = $timedate->to_db($bean->date_entered);
2354
-			//save
2355
-			$new_id=$bean->save();
2354
+            //save
2355
+            $new_id=$bean->save();
2356 2356
 
2357
-			//duplicate the file now. for notes.
2358
-			if ($bProcessingNotes && !empty($old_filename))
2359
-			{
2360
-				UploadFile::duplicate_file($old_note_id,$new_id,$old_filename);
2361
-			}
2362
-			//reset the values needed for attachment duplication.
2363
-			$old_note_id=null;
2364
-			$old_filename=null;
2365
-		}
2366
-	}
2357
+            //duplicate the file now. for notes.
2358
+            if ($bProcessingNotes && !empty($old_filename))
2359
+            {
2360
+                UploadFile::duplicate_file($old_note_id,$new_id,$old_filename);
2361
+            }
2362
+            //reset the values needed for attachment duplication.
2363
+            $old_note_id=null;
2364
+            $old_filename=null;
2365
+        }
2366
+    }
2367 2367
 }
2368 2368
 
2369 2369
 function values_to_keys($array)
2370 2370
 {
2371
-	$new_array = array();
2372
-	if(!is_array($array))
2373
-	{
2374
-		return $new_array;
2375
-	}
2376
-	foreach($array as $arr){
2377
-		$new_array[$arr] = $arr;
2378
-	}
2379
-	return $new_array;
2371
+    $new_array = array();
2372
+    if(!is_array($array))
2373
+    {
2374
+        return $new_array;
2375
+    }
2376
+    foreach($array as $arr){
2377
+        $new_array[$arr] = $arr;
2378
+    }
2379
+    return $new_array;
2380 2380
 }
2381 2381
 
2382 2382
 function clone_relationship(&$db, $tables = array(), $from_column, $from_id, $to_id)
2383 2383
 {
2384
-	foreach($tables as $table)
2385
-	{
2386
-
2387
-		if ($table == 'emails_beans') {
2388
-			$query = "SELECT * FROM $table WHERE $from_column='$from_id' and bean_module='Leads'";
2389
-		} else {
2390
-			$query = "SELECT * FROM $table WHERE $from_column='$from_id'";
2391
-		}
2392
-		$results = $db->query($query);
2393
-		while($row = $db->fetchByAssoc($results))
2394
-		{
2395
-			$query = "INSERT INTO $table ";
2396
-			$names = '';
2397
-			$values = '';
2398
-			$row[$from_column] = $to_id;
2399
-			$row['id'] = create_guid();
2400
-			if ($table=='emails_beans') {
2401
-				$row['bean_module'] =='Contacts';
2402
-			}
2384
+    foreach($tables as $table)
2385
+    {
2403 2386
 
2404
-			foreach($row as $name=>$value)
2405
-			{
2406
-
2407
-				if(empty($names))
2408
-				{
2409
-					$names .= $name;
2410
-					$values .= "'$value'";
2411
-				} else
2412
-				{
2413
-					$names .= ', '. $name;
2414
-					$values .= ", '$value'";
2415
-				}
2416
-			}
2417
-			$query .= "($names)	VALUES ($values)";
2418
-			$db->query($query);
2419
-		}
2420
-	}
2387
+        if ($table == 'emails_beans') {
2388
+            $query = "SELECT * FROM $table WHERE $from_column='$from_id' and bean_module='Leads'";
2389
+        } else {
2390
+            $query = "SELECT * FROM $table WHERE $from_column='$from_id'";
2391
+        }
2392
+        $results = $db->query($query);
2393
+        while($row = $db->fetchByAssoc($results))
2394
+        {
2395
+            $query = "INSERT INTO $table ";
2396
+            $names = '';
2397
+            $values = '';
2398
+            $row[$from_column] = $to_id;
2399
+            $row['id'] = create_guid();
2400
+            if ($table=='emails_beans') {
2401
+                $row['bean_module'] =='Contacts';
2402
+            }
2403
+
2404
+            foreach($row as $name=>$value)
2405
+            {
2406
+
2407
+                if(empty($names))
2408
+                {
2409
+                    $names .= $name;
2410
+                    $values .= "'$value'";
2411
+                } else
2412
+                {
2413
+                    $names .= ', '. $name;
2414
+                    $values .= ", '$value'";
2415
+                }
2416
+            }
2417
+            $query .= "($names)	VALUES ($values)";
2418
+            $db->query($query);
2419
+        }
2420
+    }
2421 2421
 }
2422 2422
 
2423 2423
 function get_unlinked_email_query($type, $bean) {
@@ -2426,7 +2426,7 @@  discard block
 block discarded – undo
2426 2426
     $return_array['select']='SELECT emails.id ';
2427 2427
     $return_array['from']='FROM emails ';
2428 2428
     $return_array['where']="";
2429
-	$return_array['join'] = " JOIN (select DISTINCT email_id from emails_email_addr_rel eear
2429
+    $return_array['join'] = " JOIN (select DISTINCT email_id from emails_email_addr_rel eear
2430 2430
 
2431 2431
 	join email_addr_bean_rel eabr on eabr.bean_id ='$bean->id' and eabr.bean_module = '$bean->module_dir' and
2432 2432
 	eabr.email_address_id = eear.email_address_id and eabr.deleted=0
@@ -2435,17 +2435,17 @@  discard block
 block discarded – undo
2435 2435
 	) derivedemails on derivedemails.email_id = emails.id";
2436 2436
     $return_array['join_tables'][0] = '';
2437 2437
 
2438
-	if (isset($type) and !empty($type['return_as_array'])) {
2439
-		return $return_array;
2440
-	}
2438
+    if (isset($type) and !empty($type['return_as_array'])) {
2439
+        return $return_array;
2440
+    }
2441 2441
 
2442
-	return $return_array['select'] . $return_array['from'] . $return_array['where'] . $return_array['join'] ;
2442
+    return $return_array['select'] . $return_array['from'] . $return_array['where'] . $return_array['join'] ;
2443 2443
 } // fn
2444 2444
 
2445 2445
 function get_emails_by_assign_or_link($params)
2446 2446
 {
2447 2447
     $relation = $params['link'];
2448
-	$bean = $GLOBALS['app']->controller->bean;
2448
+    $bean = $GLOBALS['app']->controller->bean;
2449 2449
     if(empty($bean->$relation)) {
2450 2450
         $bean->load_relationship($relation);
2451 2451
     }
@@ -2455,8 +2455,8 @@  discard block
 block discarded – undo
2455 2455
     }
2456 2456
     $rel_module = $bean->$relation->getRelatedModuleName();
2457 2457
     $rel_join = $bean->$relation->getJoin(array(
2458
-    	'join_table_alias' => 'link_bean',
2459
-    	'join_table_link_alias' => 'linkt',
2458
+        'join_table_alias' => 'link_bean',
2459
+        'join_table_link_alias' => 'linkt',
2460 2460
     ));
2461 2461
     $rel_join = str_replace("{$bean->table_name}.id", "'{$bean->id}'", $rel_join);
2462 2462
     $return_array['select']='SELECT DISTINCT emails.id ';
@@ -2535,12 +2535,12 @@  discard block
 block discarded – undo
2535 2535
 
2536 2536
     $return_array['where']=" WHERE emails.deleted=0 ";
2537 2537
 
2538
-    	//$return_array['join'] = '';
2538
+        //$return_array['join'] = '';
2539 2539
         $return_array['join_tables'][0] = '';
2540 2540
 
2541 2541
         if($bean->object_name == "Case" && !empty($bean->case_number)) {
2542 2542
             $where = str_replace("%1", $bean->case_number, 	$bean->getEmailSubjectMacro());
2543
-    	    $return_array["where"] .= "\n AND (email_ids.source = 'direct' OR emails.name LIKE '%$where%')";
2543
+            $return_array["where"] .= "\n AND (email_ids.source = 'direct' OR emails.name LIKE '%$where%')";
2544 2544
         }
2545 2545
 
2546 2546
         return $return_array;
@@ -2553,32 +2553,32 @@  discard block
 block discarded – undo
2553 2553
  **/
2554 2554
 function number_empty($value)
2555 2555
 {
2556
-	return empty($value) && $value != '0';
2556
+    return empty($value) && $value != '0';
2557 2557
 }
2558 2558
 
2559 2559
 function get_bean_select_array($add_blank=true, $bean_name, $display_columns, $where='', $order_by='', $blank_is_none=false)
2560 2560
 {
2561
-	global $beanFiles;
2562
-	require_once($beanFiles[$bean_name]);
2563
-	$focus = new $bean_name();
2564
-	$user_array = array();
2561
+    global $beanFiles;
2562
+    require_once($beanFiles[$bean_name]);
2563
+    $focus = new $bean_name();
2564
+    $user_array = array();
2565 2565
 
2566 2566
     $key = ($bean_name == 'EmailTemplate') ?  $bean_name : $bean_name . $display_columns. $where . $order_by;
2567
-	$user_array = get_register_value('select_array', $key );
2568
-	if(!$user_array)
2569
-	{
2567
+    $user_array = get_register_value('select_array', $key );
2568
+    if(!$user_array)
2569
+    {
2570 2570
 
2571
-		$db = DBManagerFactory::getInstance();
2571
+        $db = DBManagerFactory::getInstance();
2572 2572
 
2573
-		$temp_result = Array();
2574
-		$query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} ";
2575
-		$query .= "where ";
2576
-		if ( $where != '')
2577
-		{
2578
-			$query .= $where." AND ";
2579
-		}
2573
+        $temp_result = Array();
2574
+        $query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} ";
2575
+        $query .= "where ";
2576
+        if ( $where != '')
2577
+        {
2578
+            $query .= $where." AND ";
2579
+        }
2580 2580
 
2581
-		$query .=  " {$focus->table_name}.deleted=0";
2581
+        $query .=  " {$focus->table_name}.deleted=0";
2582 2582
 
2583 2583
         /* BEGIN - SECURITY GROUPS */
2584 2584
         global $current_user, $sugar_config;
@@ -2603,35 +2603,35 @@  discard block
 block discarded – undo
2603 2603
         }
2604 2604
         /* END - SECURITY GROUPS */
2605 2605
 
2606
-		if ( $order_by != '')
2607
-		{
2608
-			$query .= " order by {$focus->table_name}.{$order_by}";
2609
-		}
2610
-
2611
-		$GLOBALS['log']->debug("get_user_array query: $query");
2612
-		$result = $db->query($query, true, "Error filling in user array: ");
2613
-
2614
-		if ($add_blank==true){
2615
-			// Add in a blank row
2616
-			if($blank_is_none == true) { // set 'blank row' to "--None--"
2617
-				global $app_strings;
2618
-				$temp_result[''] = $app_strings['LBL_NONE'];
2619
-			} else {
2620
-				$temp_result[''] = '';
2621
-			}
2622
-		}
2606
+        if ( $order_by != '')
2607
+        {
2608
+            $query .= " order by {$focus->table_name}.{$order_by}";
2609
+        }
2623 2610
 
2624
-		// Get the id and the name.
2625
-		while($row = $db->fetchByAssoc($result))
2626
-		{
2627
-			$temp_result[$row['id']] = $row['display'];
2628
-		}
2611
+        $GLOBALS['log']->debug("get_user_array query: $query");
2612
+        $result = $db->query($query, true, "Error filling in user array: ");
2629 2613
 
2630
-		$user_array = $temp_result;
2631
-		set_register_value('select_array', $key ,$temp_result);
2632
-	}
2614
+        if ($add_blank==true){
2615
+            // Add in a blank row
2616
+            if($blank_is_none == true) { // set 'blank row' to "--None--"
2617
+                global $app_strings;
2618
+                $temp_result[''] = $app_strings['LBL_NONE'];
2619
+            } else {
2620
+                $temp_result[''] = '';
2621
+            }
2622
+        }
2623
+
2624
+        // Get the id and the name.
2625
+        while($row = $db->fetchByAssoc($result))
2626
+        {
2627
+            $temp_result[$row['id']] = $row['display'];
2628
+        }
2629
+
2630
+        $user_array = $temp_result;
2631
+        set_register_value('select_array', $key ,$temp_result);
2632
+    }
2633 2633
 
2634
-	return $user_array;
2634
+    return $user_array;
2635 2635
 
2636 2636
 }
2637 2637
 /**
@@ -2643,50 +2643,50 @@  discard block
 block discarded – undo
2643 2643
 // searches a list for items in a user's allowed tabs and returns an array that removes unallowed tabs from list
2644 2644
 function parse_list_modules(&$listArray)
2645 2645
 {
2646
-	global $modListHeader;
2647
-	$returnArray = array();
2648
-
2649
-	foreach($listArray as $optionName => $optionVal)
2650
-	{
2651
-		if(array_key_exists($optionName, $modListHeader))
2652
-		{
2653
-			$returnArray[$optionName] = $optionVal;
2654
-		}
2655
-
2656
-		// special case for projects
2657
-		if(array_key_exists('Project', $modListHeader))
2658
-		{
2659
-			$returnArray['ProjectTask'] = $listArray['ProjectTask'];
2660
-		}
2661
-	}
2662
-	$acldenied = ACLController::disabledModuleList($listArray,false);
2663
-	foreach($acldenied as $denied){
2664
-		unset($returnArray[$denied]);
2665
-	}
2666
-	asort($returnArray);
2646
+    global $modListHeader;
2647
+    $returnArray = array();
2648
+
2649
+    foreach($listArray as $optionName => $optionVal)
2650
+    {
2651
+        if(array_key_exists($optionName, $modListHeader))
2652
+        {
2653
+            $returnArray[$optionName] = $optionVal;
2654
+        }
2655
+
2656
+        // special case for projects
2657
+        if(array_key_exists('Project', $modListHeader))
2658
+        {
2659
+            $returnArray['ProjectTask'] = $listArray['ProjectTask'];
2660
+        }
2661
+    }
2662
+    $acldenied = ACLController::disabledModuleList($listArray,false);
2663
+    foreach($acldenied as $denied){
2664
+        unset($returnArray[$denied]);
2665
+    }
2666
+    asort($returnArray);
2667 2667
 
2668
-	return $returnArray;
2668
+    return $returnArray;
2669 2669
 }
2670 2670
 
2671 2671
 function display_notice($msg = false){
2672
-	global $error_notice;
2673
-	//no error notice - lets just display the error to the user
2674
-	if(!isset($error_notice)){
2675
-		echo '<br>'.$msg . '<br>';
2676
-	}else{
2677
-		$error_notice .= $msg . '<br>';
2678
-	}
2672
+    global $error_notice;
2673
+    //no error notice - lets just display the error to the user
2674
+    if(!isset($error_notice)){
2675
+        echo '<br>'.$msg . '<br>';
2676
+    }else{
2677
+        $error_notice .= $msg . '<br>';
2678
+    }
2679 2679
 }
2680 2680
 
2681 2681
 /* checks if it is a number that at least has the plus at the beginning.
2682 2682
  */
2683 2683
 function skype_formatted($number){
2684
-	//kbrill - BUG #15375
2685
-	if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
2686
-		return false;
2687
-	} else {
2688
-		return substr($number, 0, 1) == '+' || substr($number, 0, 2) == '00' || substr($number, 0, 3) == '011';
2689
-	}
2684
+    //kbrill - BUG #15375
2685
+    if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
2686
+        return false;
2687
+    } else {
2688
+        return substr($number, 0, 1) == '+' || substr($number, 0, 2) == '00' || substr($number, 0, 3) == '011';
2689
+    }
2690 2690
 //	return substr($number, 0, 1) == '+' || substr($number, 0, 2) == '00' || substr($number, 0, 2) == '011';
2691 2691
 }
2692 2692
 
@@ -2695,72 +2695,72 @@  discard block
 block discarded – undo
2695 2695
 }
2696 2696
 
2697 2697
 function insert_charset_header() {
2698
-	header('Content-Type: text/html; charset=UTF-8');
2698
+    header('Content-Type: text/html; charset=UTF-8');
2699 2699
 }
2700 2700
 
2701 2701
 function getCurrentURL()
2702 2702
 {
2703
-	$href = "http:";
2704
-	if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
2705
-	{
2706
-		$href = 'https:';
2707
-	}
2703
+    $href = "http:";
2704
+    if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
2705
+    {
2706
+        $href = 'https:';
2707
+    }
2708 2708
 
2709
-	$href.= "//".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
2710
-	return $href;
2709
+    $href.= "//".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
2710
+    return $href;
2711 2711
 }
2712 2712
 
2713 2713
 function javascript_escape($str) {
2714
-	$new_str = '';
2715
-
2716
-	for($i = 0; $i < strlen($str); $i++) {
2717
-
2718
-		if(ord(substr($str, $i, 1))==10){
2719
-			$new_str .= '\n';
2720
-		}elseif(ord(substr($str, $i, 1))==13){
2721
-			$new_str .= '\r';
2722
-		}
2723
-		else {
2724
-			$new_str .= $str{$i};
2725
-		}
2726
-	}
2714
+    $new_str = '';
2715
+
2716
+    for($i = 0; $i < strlen($str); $i++) {
2717
+
2718
+        if(ord(substr($str, $i, 1))==10){
2719
+            $new_str .= '\n';
2720
+        }elseif(ord(substr($str, $i, 1))==13){
2721
+            $new_str .= '\r';
2722
+        }
2723
+        else {
2724
+            $new_str .= $str{$i};
2725
+        }
2726
+    }
2727 2727
 
2728
-	$new_str = str_replace("'", "\\'", $new_str);
2728
+    $new_str = str_replace("'", "\\'", $new_str);
2729 2729
 
2730
-	return $new_str;
2730
+    return $new_str;
2731 2731
 }
2732 2732
 
2733 2733
 function js_escape($str, $keep=true){
2734
-	$str = html_entity_decode(str_replace("\\", "", $str), ENT_QUOTES);
2734
+    $str = html_entity_decode(str_replace("\\", "", $str), ENT_QUOTES);
2735 2735
 
2736
-	if($keep){
2737
-		$str = javascript_escape($str);
2738
-	}
2739
-	else {
2740
-		$str = str_replace("'", " ", $str);
2741
-		$str = str_replace('"', " ", $str);
2742
-	}
2736
+    if($keep){
2737
+        $str = javascript_escape($str);
2738
+    }
2739
+    else {
2740
+        $str = str_replace("'", " ", $str);
2741
+        $str = str_replace('"', " ", $str);
2742
+    }
2743 2743
 
2744
-	return $str;
2744
+    return $str;
2745 2745
 
2746
-	//end function js_escape
2746
+    //end function js_escape
2747 2747
 }
2748 2748
 
2749 2749
 function br2nl($str) {
2750
-	$regex = "#<[^>]+br.+?>#i";
2751
-	preg_match_all($regex, $str, $matches);
2750
+    $regex = "#<[^>]+br.+?>#i";
2751
+    preg_match_all($regex, $str, $matches);
2752 2752
 
2753
-	foreach($matches[0] as $match) {
2754
-		$str = str_replace($match, "<br>", $str);
2755
-	}
2753
+    foreach($matches[0] as $match) {
2754
+        $str = str_replace($match, "<br>", $str);
2755
+    }
2756 2756
 
2757
-	$brs = array('<br>','<br/>', '<br />');
2758
-	$str = str_replace("\r\n", "\n", $str); // make from windows-returns, *nix-returns
2759
-	$str = str_replace("\n\r", "\n", $str); // make from windows-returns, *nix-returns
2760
-	$str = str_replace("\r", "\n", $str); // make from windows-returns, *nix-returns
2761
-	$str = str_ireplace($brs, "\n", $str); // to retrieve it
2757
+    $brs = array('<br>','<br/>', '<br />');
2758
+    $str = str_replace("\r\n", "\n", $str); // make from windows-returns, *nix-returns
2759
+    $str = str_replace("\n\r", "\n", $str); // make from windows-returns, *nix-returns
2760
+    $str = str_replace("\r", "\n", $str); // make from windows-returns, *nix-returns
2761
+    $str = str_ireplace($brs, "\n", $str); // to retrieve it
2762 2762
 
2763
-	return $str;
2763
+    return $str;
2764 2764
 }
2765 2765
 
2766 2766
 /**
@@ -2782,29 +2782,29 @@  discard block
 block discarded – undo
2782 2782
  * @param $displayStackTrace also show stack trace
2783 2783
  */
2784 2784
 function _ppl($mixed, $die=false, $displayStackTrace=false, $loglevel="fatal") {
2785
-	if(!isset($GLOBALS['log']) || empty($GLOBALS['log'])) {
2785
+    if(!isset($GLOBALS['log']) || empty($GLOBALS['log'])) {
2786 2786
 
2787
-		$GLOBALS['log'] = LoggerManager :: getLogger('SugarCRM');
2788
-	}
2787
+        $GLOBALS['log'] = LoggerManager :: getLogger('SugarCRM');
2788
+    }
2789 2789
 
2790 2790
 
2791
-	$mix	= print_r($mixed, true); // send print_r() output to $mix
2792
-	$stack	= debug_backtrace();
2791
+    $mix	= print_r($mixed, true); // send print_r() output to $mix
2792
+    $stack	= debug_backtrace();
2793 2793
 
2794
-	$GLOBALS['log']->$loglevel('------------------------------ _ppLogger() output start -----------------------------');
2795
-	$GLOBALS['log']->$loglevel($mix);
2796
-	if($displayStackTrace) {
2797
-		foreach($stack as $position) {
2798
-			$GLOBALS['log']->$loglevel($position['file']."({$position['line']})");
2799
-		}
2800
-	}
2794
+    $GLOBALS['log']->$loglevel('------------------------------ _ppLogger() output start -----------------------------');
2795
+    $GLOBALS['log']->$loglevel($mix);
2796
+    if($displayStackTrace) {
2797
+        foreach($stack as $position) {
2798
+            $GLOBALS['log']->$loglevel($position['file']."({$position['line']})");
2799
+        }
2800
+    }
2801 2801
 
2802
-	$GLOBALS['log']->$loglevel('------------------------------ _ppLogger() output end -----------------------------');
2803
-	$GLOBALS['log']->$loglevel('------------------------------ _ppLogger() file: '.$stack[0]['file'].' line#: '.$stack[0]['line'].'-----------------------------');
2802
+    $GLOBALS['log']->$loglevel('------------------------------ _ppLogger() output end -----------------------------');
2803
+    $GLOBALS['log']->$loglevel('------------------------------ _ppLogger() file: '.$stack[0]['file'].' line#: '.$stack[0]['line'].'-----------------------------');
2804 2804
 
2805
-	if($die) {
2806
-		die();
2807
-	}
2805
+    if($die) {
2806
+        die();
2807
+    }
2808 2808
 }
2809 2809
 
2810 2810
 /**
@@ -2869,47 +2869,47 @@  discard block
 block discarded – undo
2869 2869
  * @return 1 implies supported, 0 implies unsupported, -1 implies invalid
2870 2870
  */
2871 2871
 function check_php_version($sys_php_version = '') {
2872
-	$sys_php_version = empty($sys_php_version) ? constant('PHP_VERSION') : $sys_php_version;
2873
-	// versions below $min_considered_php_version considered invalid by default,
2874
-	// versions equal to or above this ver will be considered depending
2875
-	// on the rules that follow
2876
-	$min_considered_php_version = '5.3.0';
2877
-
2878
-	// only the supported versions,
2879
-	// should be mutually exclusive with $invalid_php_versions
2880
-	$supported_php_versions = array (
2881
-    	'5.3.0'
2882
-	);
2883
-
2884
-	// invalid versions above the $min_considered_php_version,
2885
-	// should be mutually exclusive with $supported_php_versions
2886
-
2887
-	// SugarCRM prohibits install on PHP 5.2.7 on all platforms
2888
-	$invalid_php_versions = array('5.2.7');
2889
-
2890
-	// default unsupported
2891
-	$retval = 0;
2892
-
2893
-	// versions below $min_considered_php_version are invalid
2894
-	if(1 == version_compare($sys_php_version, $min_considered_php_version, '<')) {
2895
-		$retval = -1;
2896
-	}
2872
+    $sys_php_version = empty($sys_php_version) ? constant('PHP_VERSION') : $sys_php_version;
2873
+    // versions below $min_considered_php_version considered invalid by default,
2874
+    // versions equal to or above this ver will be considered depending
2875
+    // on the rules that follow
2876
+    $min_considered_php_version = '5.3.0';
2897 2877
 
2898
-	// supported version check overrides default unsupported
2899
-	foreach($supported_php_versions as $ver) {
2900
-		if(1 == version_compare($sys_php_version, $ver, 'eq') || strpos($sys_php_version,$ver) !== false) {
2901
-			$retval = 1;
2902
-			break;
2903
-		}
2904
-	}
2878
+    // only the supported versions,
2879
+    // should be mutually exclusive with $invalid_php_versions
2880
+    $supported_php_versions = array (
2881
+        '5.3.0'
2882
+    );
2905 2883
 
2906
-	// invalid version check overrides default unsupported
2907
-	foreach($invalid_php_versions as $ver) {
2908
-		if(1 == version_compare($sys_php_version, $ver, 'eq') && strpos($sys_php_version,$ver) !== false) {
2909
-			$retval = -1;
2910
-			break;
2911
-		}
2912
-	}
2884
+    // invalid versions above the $min_considered_php_version,
2885
+    // should be mutually exclusive with $supported_php_versions
2886
+
2887
+    // SugarCRM prohibits install on PHP 5.2.7 on all platforms
2888
+    $invalid_php_versions = array('5.2.7');
2889
+
2890
+    // default unsupported
2891
+    $retval = 0;
2892
+
2893
+    // versions below $min_considered_php_version are invalid
2894
+    if(1 == version_compare($sys_php_version, $min_considered_php_version, '<')) {
2895
+        $retval = -1;
2896
+    }
2897
+
2898
+    // supported version check overrides default unsupported
2899
+    foreach($supported_php_versions as $ver) {
2900
+        if(1 == version_compare($sys_php_version, $ver, 'eq') || strpos($sys_php_version,$ver) !== false) {
2901
+            $retval = 1;
2902
+            break;
2903
+        }
2904
+    }
2905
+
2906
+    // invalid version check overrides default unsupported
2907
+    foreach($invalid_php_versions as $ver) {
2908
+        if(1 == version_compare($sys_php_version, $ver, 'eq') && strpos($sys_php_version,$ver) !== false) {
2909
+            $retval = -1;
2910
+            break;
2911
+        }
2912
+    }
2913 2913
 
2914 2914
     //allow a redhat distro to install, regardless of version.  We are assuming the redhat naming convention is followed
2915 2915
     //and the php version contains 'rh' characters
@@ -2917,7 +2917,7 @@  discard block
 block discarded – undo
2917 2917
         $retval = 1;
2918 2918
     }
2919 2919
 
2920
-	return $retval;
2920
+    return $retval;
2921 2921
 }
2922 2922
 
2923 2923
 /**
@@ -2929,10 +2929,10 @@  discard block
 block discarded – undo
2929 2929
  */
2930 2930
 function check_iis_version($sys_iis_version = '') {
2931 2931
 
2932
-	$server_software = $_SERVER["SERVER_SOFTWARE"];
2933
-	$iis_version = '';
2934
-	if(strpos($server_software,'Microsoft-IIS') !== false && preg_match_all("/^.*\/(\d+\.?\d*)$/",  $server_software, $out))
2935
-	    $iis_version = $out[1][0];
2932
+    $server_software = $_SERVER["SERVER_SOFTWARE"];
2933
+    $iis_version = '';
2934
+    if(strpos($server_software,'Microsoft-IIS') !== false && preg_match_all("/^.*\/(\d+\.?\d*)$/",  $server_software, $out))
2935
+        $iis_version = $out[1][0];
2936 2936
 
2937 2937
     $sys_iis_version = empty($sys_iis_version) ? $iis_version : $sys_iis_version;
2938 2938
 
@@ -2983,14 +2983,14 @@  discard block
 block discarded – undo
2983 2983
 }
2984 2984
 
2985 2985
 function pre_login_check(){
2986
-	global $action, $login_error;
2987
-	if(!empty($action)&& $action == 'Login'){
2988
-
2989
-		if(!empty($login_error)){
2990
-			$login_error = htmlentities($login_error);
2991
-			$login_error = str_replace(array("&lt;pre&gt;","&lt;/pre&gt;","\r\n", "\n"), "<br>", $login_error);
2992
-			$_SESSION['login_error'] = $login_error;
2993
-			echo '<script>
2986
+    global $action, $login_error;
2987
+    if(!empty($action)&& $action == 'Login'){
2988
+
2989
+        if(!empty($login_error)){
2990
+            $login_error = htmlentities($login_error);
2991
+            $login_error = str_replace(array("&lt;pre&gt;","&lt;/pre&gt;","\r\n", "\n"), "<br>", $login_error);
2992
+            $_SESSION['login_error'] = $login_error;
2993
+            echo '<script>
2994 2994
 						function set_focus() {}
2995 2995
 						if(document.getElementById("post_error")) {
2996 2996
 							document.getElementById("post_error").innerHTML="'. $login_error. '";
@@ -3000,66 +3000,66 @@  discard block
 block discarded – undo
3000 3000
 							//document.getElementById("user_password").disabled = true;
3001 3001
 						}
3002 3002
 						</script>';
3003
-		}
3004
-	}
3003
+        }
3004
+    }
3005 3005
 }
3006 3006
 
3007 3007
 
3008 3008
 
3009 3009
 function sugar_cleanup($exit = false) {
3010
-	static $called = false;
3011
-	if($called)return;
3012
-	$called = true;
3013
-	set_include_path(realpath(dirname(__FILE__) . '/..') . PATH_SEPARATOR . get_include_path());
3014
-	chdir(realpath(dirname(__FILE__) . '/..'));
3015
-	global $sugar_config;
3016
-	require_once('include/utils/LogicHook.php');
3017
-	LogicHook::initialize();
3018
-	$GLOBALS['logic_hook']->call_custom_logic('', 'server_round_trip');
3019
-
3020
-	//added this check to avoid errors during install.
3021
-	if (empty($sugar_config['dbconfig'])) {
3022
-		if ($exit) exit; else return;
3023
-	}
3010
+    static $called = false;
3011
+    if($called)return;
3012
+    $called = true;
3013
+    set_include_path(realpath(dirname(__FILE__) . '/..') . PATH_SEPARATOR . get_include_path());
3014
+    chdir(realpath(dirname(__FILE__) . '/..'));
3015
+    global $sugar_config;
3016
+    require_once('include/utils/LogicHook.php');
3017
+    LogicHook::initialize();
3018
+    $GLOBALS['logic_hook']->call_custom_logic('', 'server_round_trip');
3019
+
3020
+    //added this check to avoid errors during install.
3021
+    if (empty($sugar_config['dbconfig'])) {
3022
+        if ($exit) exit; else return;
3023
+    }
3024 3024
 
3025 3025
     if (!class_exists('Tracker', true)) {
3026
-		require_once 'modules/Trackers/Tracker.php';
3027
-	}
3028
-	Tracker::logPage();
3029
-	// Now write the cached tracker_queries
3030
-	if(!empty($GLOBALS['savePreferencesToDB']) && $GLOBALS['savePreferencesToDB']) {
3031
-	    if ( isset($GLOBALS['current_user']) && $GLOBALS['current_user'] instanceOf User )
3032
-	        $GLOBALS['current_user']->savePreferencesToDB();
3033
-	}
3026
+        require_once 'modules/Trackers/Tracker.php';
3027
+    }
3028
+    Tracker::logPage();
3029
+    // Now write the cached tracker_queries
3030
+    if(!empty($GLOBALS['savePreferencesToDB']) && $GLOBALS['savePreferencesToDB']) {
3031
+        if ( isset($GLOBALS['current_user']) && $GLOBALS['current_user'] instanceOf User )
3032
+            $GLOBALS['current_user']->savePreferencesToDB();
3033
+    }
3034 3034
 
3035
-	//check to see if this is not an `ajax call AND the user preference error flag is set
3036
-	if(
3037
-		(isset($_SESSION['USER_PREFRENCE_ERRORS']) && $_SESSION['USER_PREFRENCE_ERRORS'])
3038
-		&& ($_REQUEST['action']!='modulelistmenu' && $_REQUEST['action']!='DynamicAction')
3039
-		&& ($_REQUEST['action']!='favorites' && $_REQUEST['action']!='DynamicAction')
3040
-		&& (empty($_REQUEST['to_pdf']) || !$_REQUEST['to_pdf'] )
3041
-		&& (empty($_REQUEST['sugar_body_only']) || !$_REQUEST['sugar_body_only'] )
3042
-
3043
-	){
3044
-		global $app_strings;
3045
-		//this is not an ajax call and the user preference error flag is set, so reset the flag and print js to flash message
3046
-		$err_mess = $app_strings['ERROR_USER_PREFS'];
3047
-		$_SESSION['USER_PREFRENCE_ERRORS'] = false;
3048
-		echo "
3035
+    //check to see if this is not an `ajax call AND the user preference error flag is set
3036
+    if(
3037
+        (isset($_SESSION['USER_PREFRENCE_ERRORS']) && $_SESSION['USER_PREFRENCE_ERRORS'])
3038
+        && ($_REQUEST['action']!='modulelistmenu' && $_REQUEST['action']!='DynamicAction')
3039
+        && ($_REQUEST['action']!='favorites' && $_REQUEST['action']!='DynamicAction')
3040
+        && (empty($_REQUEST['to_pdf']) || !$_REQUEST['to_pdf'] )
3041
+        && (empty($_REQUEST['sugar_body_only']) || !$_REQUEST['sugar_body_only'] )
3042
+
3043
+    ){
3044
+        global $app_strings;
3045
+        //this is not an ajax call and the user preference error flag is set, so reset the flag and print js to flash message
3046
+        $err_mess = $app_strings['ERROR_USER_PREFS'];
3047
+        $_SESSION['USER_PREFRENCE_ERRORS'] = false;
3048
+        echo "
3049 3049
 		<script>
3050 3050
 			ajaxStatus.flashStatus('$err_mess',7000);
3051 3051
 		</script>";
3052 3052
 
3053
-	}
3053
+    }
3054 3054
 
3055
-	pre_login_check();
3056
-	if(class_exists('DBManagerFactory')) {
3057
-		$db = DBManagerFactory::getInstance();
3058
-		$db->disconnect();
3059
-		if($exit) {
3060
-			exit;
3061
-		}
3062
-	}
3055
+    pre_login_check();
3056
+    if(class_exists('DBManagerFactory')) {
3057
+        $db = DBManagerFactory::getInstance();
3058
+        $db->disconnect();
3059
+        if($exit) {
3060
+            exit;
3061
+        }
3062
+    }
3063 3063
 }
3064 3064
 
3065 3065
 register_shutdown_function('sugar_cleanup');
@@ -3071,64 +3071,64 @@  discard block
 block discarded – undo
3071 3071
 
3072 3072
  */
3073 3073
 function check_logic_hook_file($module_name, $event, $action_array){
3074
-	require_once('include/utils/logic_utils.php');
3075
-	$add_logic = false;
3074
+    require_once('include/utils/logic_utils.php');
3075
+    $add_logic = false;
3076 3076
 
3077
-	if(file_exists("custom/modules/$module_name/logic_hooks.php")){
3077
+    if(file_exists("custom/modules/$module_name/logic_hooks.php")){
3078 3078
 
3079
-		$hook_array = get_hook_array($module_name);
3079
+        $hook_array = get_hook_array($module_name);
3080 3080
 
3081
-		if(check_existing_element($hook_array, $event, $action_array)==true){
3082
-			//the hook at hand is present, so do nothing
3083
-		} else {
3084
-			$add_logic = true;
3081
+        if(check_existing_element($hook_array, $event, $action_array)==true){
3082
+            //the hook at hand is present, so do nothing
3083
+        } else {
3084
+            $add_logic = true;
3085 3085
 
3086 3086
             $logic_count = 0;
3087 3087
             if(!empty($hook_array[$event]))
3088 3088
             {
3089
-			    $logic_count = count($hook_array[$event]);
3089
+                $logic_count = count($hook_array[$event]);
3090 3090
             }
3091 3091
 
3092
-			if($action_array[0]==""){
3093
-				$action_array[0] = $logic_count  + 1;
3094
-			}
3095
-			$hook_array[$event][] = $action_array;
3096
-
3097
-		}
3098
-		//end if the file exists already
3099
-	} else {
3100
-		$add_logic = true;
3101
-		if($action_array[0]==""){
3102
-			$action_array[0] = 1;
3103
-		}
3104
-		$hook_array = array();
3105
-		$hook_array[$event][] = $action_array;
3106
-		//end if else file exists already
3107
-	}
3108
-	if($add_logic == true){
3092
+            if($action_array[0]==""){
3093
+                $action_array[0] = $logic_count  + 1;
3094
+            }
3095
+            $hook_array[$event][] = $action_array;
3096
+
3097
+        }
3098
+        //end if the file exists already
3099
+    } else {
3100
+        $add_logic = true;
3101
+        if($action_array[0]==""){
3102
+            $action_array[0] = 1;
3103
+        }
3104
+        $hook_array = array();
3105
+        $hook_array[$event][] = $action_array;
3106
+        //end if else file exists already
3107
+    }
3108
+    if($add_logic == true){
3109 3109
 
3110
-		//reorder array by element[0]
3111
-		//$hook_array = reorder_array($hook_array, $event);
3112
-		//!!!Finish this above TODO
3110
+        //reorder array by element[0]
3111
+        //$hook_array = reorder_array($hook_array, $event);
3112
+        //!!!Finish this above TODO
3113 3113
 
3114
-		$new_contents = replace_or_add_logic_type($hook_array);
3115
-		write_logic_file($module_name, $new_contents);
3114
+        $new_contents = replace_or_add_logic_type($hook_array);
3115
+        write_logic_file($module_name, $new_contents);
3116 3116
 
3117
-		//end if add_element is true
3118
-	}
3117
+        //end if add_element is true
3118
+    }
3119 3119
 
3120
-	//end function check_logic_hook_file
3120
+    //end function check_logic_hook_file
3121 3121
 }
3122 3122
 
3123 3123
 function remove_logic_hook($module_name, $event, $action_array) {
3124 3124
     require_once('include/utils/logic_utils.php');
3125
-	$add_logic = false;
3125
+    $add_logic = false;
3126 3126
 
3127
-	if(file_exists("custom/modules/".$module_name."/logic_hooks.php")){
3127
+    if(file_exists("custom/modules/".$module_name."/logic_hooks.php")){
3128 3128
         // The file exists, let's make sure the hook is there
3129
-		$hook_array = get_hook_array($module_name);
3129
+        $hook_array = get_hook_array($module_name);
3130 3130
 
3131
-		if(check_existing_element($hook_array, $event, $action_array)==true){
3131
+        if(check_existing_element($hook_array, $event, $action_array)==true){
3132 3132
             // The hook is there, time to take it out.
3133 3133
 
3134 3134
             foreach ( $hook_array[$event] as $i => $hook ) {
@@ -3150,111 +3150,111 @@  discard block
 block discarded – undo
3150 3150
 
3151 3151
 function display_stack_trace($textOnly=false){
3152 3152
 
3153
-	$stack  = debug_backtrace();
3153
+    $stack  = debug_backtrace();
3154 3154
 
3155
-	echo "\n\n display_stack_trace caller, file: " . $stack[0]['file']. ' line#: ' .$stack[0]['line'];
3155
+    echo "\n\n display_stack_trace caller, file: " . $stack[0]['file']. ' line#: ' .$stack[0]['line'];
3156 3156
 
3157
-	if(!$textOnly)
3158
-	echo '<br>';
3157
+    if(!$textOnly)
3158
+    echo '<br>';
3159 3159
 
3160
-	$first = true;
3161
-	$out = '';
3160
+    $first = true;
3161
+    $out = '';
3162 3162
 
3163
-	foreach($stack as $item) {
3164
-		$file  = '';
3165
-		$class = '';
3166
-		$line  = '';
3167
-		$function  = '';
3163
+    foreach($stack as $item) {
3164
+        $file  = '';
3165
+        $class = '';
3166
+        $line  = '';
3167
+        $function  = '';
3168 3168
 
3169
-		if(isset($item['file']))
3170
-		$file = $item['file'];
3171
-		if(isset($item['class']))
3172
-		$class = $item['class'];
3173
-		if(isset($item['line']))
3174
-		$line = $item['line'];
3175
-		if(isset($item['function']))
3176
-		$function = $item['function'];
3169
+        if(isset($item['file']))
3170
+        $file = $item['file'];
3171
+        if(isset($item['class']))
3172
+        $class = $item['class'];
3173
+        if(isset($item['line']))
3174
+        $line = $item['line'];
3175
+        if(isset($item['function']))
3176
+        $function = $item['function'];
3177 3177
 
3178
-		if(!$first) {
3179
-			if(!$textOnly) {
3180
-				$out .= '<font color="black"><b>';
3181
-			}
3178
+        if(!$first) {
3179
+            if(!$textOnly) {
3180
+                $out .= '<font color="black"><b>';
3181
+            }
3182 3182
 
3183
-			$out .= $file;
3183
+            $out .= $file;
3184 3184
 
3185
-			if(!$textOnly) {
3186
-				$out .= '</b></font><font color="blue">';
3187
-			}
3185
+            if(!$textOnly) {
3186
+                $out .= '</b></font><font color="blue">';
3187
+            }
3188 3188
 
3189
-			$out .= "[L:{$line}]";
3189
+            $out .= "[L:{$line}]";
3190 3190
 
3191
-			if(!$textOnly) {
3192
-				$out .= '</font><font color="red">';
3193
-			}
3191
+            if(!$textOnly) {
3192
+                $out .= '</font><font color="red">';
3193
+            }
3194 3194
 
3195
-			$out .= "({$class}:{$function})";
3195
+            $out .= "({$class}:{$function})";
3196 3196
 
3197
-			if(!$textOnly) {
3198
-				$out .= '</font><br>';
3199
-			} else {
3200
-				$out .= "\n";
3201
-			}
3202
-		} else {
3203
-			$first = false;
3204
-		}
3205
-	}
3197
+            if(!$textOnly) {
3198
+                $out .= '</font><br>';
3199
+            } else {
3200
+                $out .= "\n";
3201
+            }
3202
+        } else {
3203
+            $first = false;
3204
+        }
3205
+    }
3206 3206
 
3207
-	echo $out;
3207
+    echo $out;
3208 3208
 }
3209 3209
 
3210 3210
 function StackTraceErrorHandler($errno, $errstr, $errfile,$errline, $errcontext) {
3211
-	$error_msg = " $errstr occurred in <b>$errfile</b> on line $errline [" . date("Y-m-d H:i:s") . ']';
3212
-	$halt_script = true;
3213
-	switch($errno){
3214
-		case 2048: return; //depricated we have lots of these ignore them
3215
-		case E_USER_NOTICE:
3216
-		case E_NOTICE:
3217
-		    if ( error_reporting() & E_NOTICE ) {
3218
-		        $halt_script = false;
3219
-		        $type = 'Notice';
3220
-		    }
3221
-		    else
3222
-		        return;
3223
-			break;
3224
-		case E_USER_WARNING:
3225
-		case E_COMPILE_WARNING:
3226
-		case E_CORE_WARNING:
3227
-		case E_WARNING:
3228
-
3229
-			$halt_script = false;
3230
-			$type = "Warning";
3231
-			break;
3232
-
3233
-		case E_USER_ERROR:
3234
-		case E_COMPILE_ERROR:
3235
-		case E_CORE_ERROR:
3236
-		case E_ERROR:
3237
-
3238
-			$type = "Fatal Error";
3239
-			break;
3240
-
3241
-		case E_PARSE:
3242
-
3243
-			$type = "Parse Error";
3244
-			break;
3245
-
3246
-		default:
3247
-			//don't know what it is might not be so bad
3248
-			$halt_script = false;
3249
-			$type = "Unknown Error ($errno)";
3250
-			break;
3251
-	}
3252
-	$error_msg = '<b>'.$type.'</b>:' . $error_msg;
3253
-	echo $error_msg;
3254
-	display_stack_trace();
3255
-	if($halt_script){
3256
-		exit -1;
3257
-	}
3211
+    $error_msg = " $errstr occurred in <b>$errfile</b> on line $errline [" . date("Y-m-d H:i:s") . ']';
3212
+    $halt_script = true;
3213
+    switch($errno){
3214
+        case 2048: return; //depricated we have lots of these ignore them
3215
+        case E_USER_NOTICE:
3216
+        case E_NOTICE:
3217
+            if ( error_reporting() & E_NOTICE ) {
3218
+                $halt_script = false;
3219
+                $type = 'Notice';
3220
+            }
3221
+            else
3222
+                return;
3223
+            break;
3224
+        case E_USER_WARNING:
3225
+        case E_COMPILE_WARNING:
3226
+        case E_CORE_WARNING:
3227
+        case E_WARNING:
3228
+
3229
+            $halt_script = false;
3230
+            $type = "Warning";
3231
+            break;
3232
+
3233
+        case E_USER_ERROR:
3234
+        case E_COMPILE_ERROR:
3235
+        case E_CORE_ERROR:
3236
+        case E_ERROR:
3237
+
3238
+            $type = "Fatal Error";
3239
+            break;
3240
+
3241
+        case E_PARSE:
3242
+
3243
+            $type = "Parse Error";
3244
+            break;
3245
+
3246
+        default:
3247
+            //don't know what it is might not be so bad
3248
+            $halt_script = false;
3249
+            $type = "Unknown Error ($errno)";
3250
+            break;
3251
+    }
3252
+    $error_msg = '<b>'.$type.'</b>:' . $error_msg;
3253
+    echo $error_msg;
3254
+    display_stack_trace();
3255
+    if($halt_script){
3256
+        exit -1;
3257
+    }
3258 3258
 
3259 3259
 
3260 3260
 
@@ -3263,45 +3263,45 @@  discard block
 block discarded – undo
3263 3263
 
3264 3264
 if(isset($sugar_config['stack_trace_errors']) && $sugar_config['stack_trace_errors']){
3265 3265
 
3266
-	set_error_handler('StackTraceErrorHandler');
3266
+    set_error_handler('StackTraceErrorHandler');
3267 3267
 }
3268 3268
 function get_sub_cookies($name){
3269
-	$cookies = array();
3270
-	if(isset($_COOKIE[$name])){
3271
-		$subs = explode('#', $_COOKIE[$name]);
3272
-		foreach($subs as $cookie){
3273
-			if(!empty($cookie)){
3274
-				$cookie = explode('=', $cookie);
3275
-
3276
-				$cookies[$cookie[0]] = $cookie[1];
3277
-			}
3278
-		}
3279
-	}
3280
-	return $cookies;
3269
+    $cookies = array();
3270
+    if(isset($_COOKIE[$name])){
3271
+        $subs = explode('#', $_COOKIE[$name]);
3272
+        foreach($subs as $cookie){
3273
+            if(!empty($cookie)){
3274
+                $cookie = explode('=', $cookie);
3275
+
3276
+                $cookies[$cookie[0]] = $cookie[1];
3277
+            }
3278
+        }
3279
+    }
3280
+    return $cookies;
3281 3281
 
3282 3282
 }
3283 3283
 
3284 3284
 
3285 3285
 function mark_delete_components($sub_object_array, $run_second_level=false, $sub_sub_array=""){
3286 3286
 
3287
-	if(!empty($sub_object_array)){
3287
+    if(!empty($sub_object_array)){
3288 3288
 
3289
-		foreach($sub_object_array as $sub_object){
3289
+        foreach($sub_object_array as $sub_object){
3290 3290
 
3291
-			//run_second level is set to true if you need to remove sub-sub components
3292
-			if($run_second_level==true){
3291
+            //run_second level is set to true if you need to remove sub-sub components
3292
+            if($run_second_level==true){
3293 3293
 
3294
-				mark_delete_components($sub_object->get_linked_beans($sub_sub_array['rel_field'],$sub_sub_array['rel_module']));
3294
+                mark_delete_components($sub_object->get_linked_beans($sub_sub_array['rel_field'],$sub_sub_array['rel_module']));
3295 3295
 
3296
-				//end if run_second_level is true
3297
-			}
3298
-			$sub_object->mark_deleted($sub_object->id);
3299
-			//end foreach sub component
3300
-		}
3301
-		//end if this is not empty
3302
-	}
3296
+                //end if run_second_level is true
3297
+            }
3298
+            $sub_object->mark_deleted($sub_object->id);
3299
+            //end foreach sub component
3300
+        }
3301
+        //end if this is not empty
3302
+    }
3303 3303
 
3304
-	//end function mark_delete_components
3304
+    //end function mark_delete_components
3305 3305
 }
3306 3306
 
3307 3307
 /**
@@ -3309,30 +3309,30 @@  discard block
 block discarded – undo
3309 3309
  */
3310 3310
 function return_bytes($val)
3311 3311
 {
3312
-	$val = trim($val);
3313
-	$last = strtolower($val{strlen($val)-1});
3314
-
3315
-	switch($last)
3316
-	{
3317
-		// The 'G' modifier is available since PHP 5.1.0
3318
-		case 'g':
3319
-			$val *= 1024;
3320
-		case 'm':
3321
-			$val *= 1024;
3322
-		case 'k':
3323
-			$val *= 1024;
3324
-	}
3312
+    $val = trim($val);
3313
+    $last = strtolower($val{strlen($val)-1});
3325 3314
 
3326
-	return $val;
3315
+    switch($last)
3316
+    {
3317
+        // The 'G' modifier is available since PHP 5.1.0
3318
+        case 'g':
3319
+            $val *= 1024;
3320
+        case 'm':
3321
+            $val *= 1024;
3322
+        case 'k':
3323
+            $val *= 1024;
3324
+    }
3325
+
3326
+    return $val;
3327 3327
 }
3328 3328
 
3329 3329
 /**
3330 3330
  * Adds the href HTML tags around any URL in the $string
3331 3331
  */
3332 3332
 function url2html($string) {
3333
-	//
3334
-	$return_string = preg_replace('/(\w+:\/\/)(\S+)/', ' <a href="\\1\\2" target="_new"  style="font-weight: normal;">\\1\\2</a>', $string);
3335
-	return $return_string;
3333
+    //
3334
+    $return_string = preg_replace('/(\w+:\/\/)(\S+)/', ' <a href="\\1\\2" target="_new"  style="font-weight: normal;">\\1\\2</a>', $string);
3335
+    return $return_string;
3336 3336
 }
3337 3337
 // End customization by Julian
3338 3338
 
@@ -3353,31 +3353,31 @@  discard block
 block discarded – undo
3353 3353
  * @return bool true if writable
3354 3354
  */
3355 3355
 function is_writable_windows($file) {
3356
-	if($file{strlen($file)-1}=='/') {
3357
-		return is_writable_windows($file.uniqid(mt_rand()).'.tmp');
3358
-	}
3356
+    if($file{strlen($file)-1}=='/') {
3357
+        return is_writable_windows($file.uniqid(mt_rand()).'.tmp');
3358
+    }
3359 3359
 
3360
-	// the assumption here is that Windows has an inherited permissions scheme
3361
-	// any file that is a descendant of an unwritable directory will inherit
3362
-	// that property and will trigger a failure below.
3363
-	if(is_dir($file)) {
3364
-		return true;
3365
-	}
3360
+    // the assumption here is that Windows has an inherited permissions scheme
3361
+    // any file that is a descendant of an unwritable directory will inherit
3362
+    // that property and will trigger a failure below.
3363
+    if(is_dir($file)) {
3364
+        return true;
3365
+    }
3366 3366
 
3367
-	$file = str_replace("/", '\\', $file);
3367
+    $file = str_replace("/", '\\', $file);
3368 3368
 
3369
-	if(file_exists($file)) {
3370
-		if (!($f = @sugar_fopen($file, 'r+')))
3371
-		return false;
3372
-		fclose($f);
3373
-		return true;
3374
-	}
3369
+    if(file_exists($file)) {
3370
+        if (!($f = @sugar_fopen($file, 'r+')))
3371
+        return false;
3372
+        fclose($f);
3373
+        return true;
3374
+    }
3375 3375
 
3376
-	if(!($f = @sugar_fopen($file, 'w')))
3377
-	return false;
3378
-	fclose($f);
3379
-	unlink($file);
3380
-	return true;
3376
+    if(!($f = @sugar_fopen($file, 'w')))
3377
+    return false;
3378
+    fclose($f);
3379
+    unlink($file);
3380
+    return true;
3381 3381
 }
3382 3382
 
3383 3383
 
@@ -3390,23 +3390,23 @@  discard block
 block discarded – undo
3390 3390
 }
3391 3391
 
3392 3392
 function convert_module_to_singular($module_array){
3393
-	global $beanList;
3394
-
3395
-	foreach($module_array as $key => $value){
3396
-		if(!empty($beanList[$value])) $module_array[$key] = $beanList[$value];
3397
-
3398
-		if($value=="Cases") {
3399
-			$module_array[$key] = "Case";
3400
-		}
3401
-		if($key=="projecttask"){
3402
-			$module_array['ProjectTask'] = "Project Task";
3403
-			unset($module_array[$key]);
3404
-		}
3405
-	}
3393
+    global $beanList;
3406 3394
 
3407
-	return $module_array;
3395
+    foreach($module_array as $key => $value){
3396
+        if(!empty($beanList[$value])) $module_array[$key] = $beanList[$value];
3397
+
3398
+        if($value=="Cases") {
3399
+            $module_array[$key] = "Case";
3400
+        }
3401
+        if($key=="projecttask"){
3402
+            $module_array['ProjectTask'] = "Project Task";
3403
+            unset($module_array[$key]);
3404
+        }
3405
+    }
3408 3406
 
3409
-	//end function convert_module_to_singular
3407
+    return $module_array;
3408
+
3409
+    //end function convert_module_to_singular
3410 3410
 }
3411 3411
 
3412 3412
 /*
@@ -3414,13 +3414,13 @@  discard block
 block discarded – undo
3414 3414
  * bean_name. This is important when you need to include files.
3415 3415
  */
3416 3416
 function get_singular_bean_name($bean_name){
3417
-	global $beanFiles, $beanList;
3418
-	if(array_key_exists($bean_name, $beanList)){
3419
-		return $beanList[$bean_name];
3420
-	}
3421
-	else{
3422
-		return $bean_name;
3423
-	}
3417
+    global $beanFiles, $beanList;
3418
+    if(array_key_exists($bean_name, $beanList)){
3419
+        return $beanList[$bean_name];
3420
+    }
3421
+    else{
3422
+        return $bean_name;
3423
+    }
3424 3424
 }
3425 3425
 
3426 3426
 /*
@@ -3458,105 +3458,105 @@  discard block
 block discarded – undo
3458 3458
 }
3459 3459
 
3460 3460
 function get_label($label_tag, $temp_module_strings){
3461
-	global $app_strings;
3462
-	if(!empty($temp_module_strings[$label_tag])){
3463
-
3464
-		$label_name = $temp_module_strings[$label_tag];
3465
-	} else {
3466
-		if(!empty($app_strings[$label_tag])){
3467
-			$label_name = $app_strings[$label_tag];
3468
-		} else {
3469
-			$label_name = $label_tag;
3470
-		}
3471
-	}
3472
-	return $label_name;
3461
+    global $app_strings;
3462
+    if(!empty($temp_module_strings[$label_tag])){
3463
+
3464
+        $label_name = $temp_module_strings[$label_tag];
3465
+    } else {
3466
+        if(!empty($app_strings[$label_tag])){
3467
+            $label_name = $app_strings[$label_tag];
3468
+        } else {
3469
+            $label_name = $label_tag;
3470
+        }
3471
+    }
3472
+    return $label_name;
3473 3473
 
3474
-	//end function get_label
3474
+    //end function get_label
3475 3475
 }
3476 3476
 
3477 3477
 
3478 3478
 function search_filter_rel_info(& $focus, $tar_rel_module, $relationship_name){
3479 3479
 
3480
-	$rel_list = array();
3480
+    $rel_list = array();
3481 3481
 
3482
-	foreach($focus->relationship_fields as $rel_key => $rel_value){
3483
-		if($rel_value == $relationship_name){
3484
-			$temp_bean = get_module_info($tar_rel_module);
3485
-	//		echo $focus->$rel_key;
3486
-			$temp_bean->retrieve($focus->$rel_key);
3487
-			if($temp_bean->id!=""){
3482
+    foreach($focus->relationship_fields as $rel_key => $rel_value){
3483
+        if($rel_value == $relationship_name){
3484
+            $temp_bean = get_module_info($tar_rel_module);
3485
+    //		echo $focus->$rel_key;
3486
+            $temp_bean->retrieve($focus->$rel_key);
3487
+            if($temp_bean->id!=""){
3488 3488
 
3489
-				$rel_list[] = $temp_bean;
3490
-				return $rel_list;
3491
-			}
3492
-		}
3493
-	}
3489
+                $rel_list[] = $temp_bean;
3490
+                return $rel_list;
3491
+            }
3492
+        }
3493
+    }
3494 3494
 
3495
-	foreach($focus->field_defs as $field_name => $field_def){
3496
-		//Check if the relationship_name matches a "relate" field
3497
-		if(!empty($field_def['type']) && $field_def['type'] == 'relate'
3498
-		&& !empty($field_def['id_name']) && !empty($focus->field_defs[$field_def['id_name']])
3499
-		&& !empty($focus->field_defs[$field_def['id_name']]['relationship'])
3500
-		&& $focus->field_defs[$field_def['id_name']]['relationship'] == $relationship_name)
3501
-		{
3502
-			$temp_bean = get_module_info($tar_rel_module);
3503
-		//	echo $focus->$field_def['id_name'];
3504
-			$temp_bean->retrieve($focus->$field_def['id_name']);
3505
-			if($temp_bean->id!=""){
3506
-
3507
-				$rel_list[] = $temp_bean;
3508
-				return $rel_list;
3509
-			}
3510
-		//Check if the relationship_name matches a "link" in a relate field
3511
-		} else if(!empty($rel_value['link']) && !empty($rel_value['id_name']) && $rel_value['link'] == $relationship_name){
3512
-			$temp_bean = get_module_info($tar_rel_module);
3513
-		//	echo $focus->$rel_value['id_name'];
3514
-			$temp_bean->retrieve($focus->$rel_value['id_name']);
3515
-			if($temp_bean->id!=""){
3516
-
3517
-				$rel_list[] = $temp_bean;
3518
-				return $rel_list;
3519
-			}
3520
-		}
3521
-	}
3495
+    foreach($focus->field_defs as $field_name => $field_def){
3496
+        //Check if the relationship_name matches a "relate" field
3497
+        if(!empty($field_def['type']) && $field_def['type'] == 'relate'
3498
+        && !empty($field_def['id_name']) && !empty($focus->field_defs[$field_def['id_name']])
3499
+        && !empty($focus->field_defs[$field_def['id_name']]['relationship'])
3500
+        && $focus->field_defs[$field_def['id_name']]['relationship'] == $relationship_name)
3501
+        {
3502
+            $temp_bean = get_module_info($tar_rel_module);
3503
+        //	echo $focus->$field_def['id_name'];
3504
+            $temp_bean->retrieve($focus->$field_def['id_name']);
3505
+            if($temp_bean->id!=""){
3522 3506
 
3523
-	// special case for unlisted parent-type relationships
3524
-	if( !empty($focus->parent_type) && $focus->parent_type == $tar_rel_module && !empty($focus->parent_id)) {
3525
-		$temp_bean = get_module_info($tar_rel_module);
3526
-		$temp_bean->retrieve($focus->parent_id);
3527
-		if($temp_bean->id!=""){
3528
-			$rel_list[] = $temp_bean;
3529
-			return $rel_list;
3530
-		}
3531
-	}
3507
+                $rel_list[] = $temp_bean;
3508
+                return $rel_list;
3509
+            }
3510
+        //Check if the relationship_name matches a "link" in a relate field
3511
+        } else if(!empty($rel_value['link']) && !empty($rel_value['id_name']) && $rel_value['link'] == $relationship_name){
3512
+            $temp_bean = get_module_info($tar_rel_module);
3513
+        //	echo $focus->$rel_value['id_name'];
3514
+            $temp_bean->retrieve($focus->$rel_value['id_name']);
3515
+            if($temp_bean->id!=""){
3516
+
3517
+                $rel_list[] = $temp_bean;
3518
+                return $rel_list;
3519
+            }
3520
+        }
3521
+    }
3522
+
3523
+    // special case for unlisted parent-type relationships
3524
+    if( !empty($focus->parent_type) && $focus->parent_type == $tar_rel_module && !empty($focus->parent_id)) {
3525
+        $temp_bean = get_module_info($tar_rel_module);
3526
+        $temp_bean->retrieve($focus->parent_id);
3527
+        if($temp_bean->id!=""){
3528
+            $rel_list[] = $temp_bean;
3529
+            return $rel_list;
3530
+        }
3531
+    }
3532 3532
 
3533
-	return $rel_list;
3533
+    return $rel_list;
3534 3534
 
3535
-	//end function search_filter_rel_info
3535
+    //end function search_filter_rel_info
3536 3536
 }
3537 3537
 
3538 3538
 function get_module_info($module_name){
3539
-	global $beanList;
3540
-	global $dictionary;
3539
+    global $beanList;
3540
+    global $dictionary;
3541 3541
 
3542
-	//Get dictionary and focus data for module
3543
-	$vardef_name = $beanList[$module_name];
3542
+    //Get dictionary and focus data for module
3543
+    $vardef_name = $beanList[$module_name];
3544 3544
 
3545
-	if($vardef_name=="aCase"){
3546
-		$class_name = "Case";
3547
-	} else {
3548
-		$class_name = $vardef_name;
3549
-	}
3545
+    if($vardef_name=="aCase"){
3546
+        $class_name = "Case";
3547
+    } else {
3548
+        $class_name = $vardef_name;
3549
+    }
3550 3550
 
3551
-	if(!file_exists('modules/'. $module_name . '/'.$class_name.'.php')){
3552
-		return;
3553
-	}
3551
+    if(!file_exists('modules/'. $module_name . '/'.$class_name.'.php')){
3552
+        return;
3553
+    }
3554 3554
 
3555
-	include_once('modules/'. $module_name . '/'.$class_name.'.php');
3555
+    include_once('modules/'. $module_name . '/'.$class_name.'.php');
3556 3556
 
3557
-	$module_bean = new $vardef_name();
3558
-	return $module_bean;
3559
-	//end function get_module_table
3557
+    $module_bean = new $vardef_name();
3558
+    return $module_bean;
3559
+    //end function get_module_table
3560 3560
 }
3561 3561
 
3562 3562
 /**
@@ -3565,22 +3565,22 @@  discard block
 block discarded – undo
3565 3565
  * @param string $moduleName
3566 3566
  */
3567 3567
 function get_valid_bean_name($module_name){
3568
-	global $beanList;
3568
+    global $beanList;
3569 3569
 
3570
-	$vardef_name = $beanList[$module_name];
3571
-	if($vardef_name=="aCase"){
3572
-		$bean_name = "Case";
3573
-	} else {
3574
-		$bean_name = $vardef_name;
3575
-	}
3576
-	return $bean_name;
3570
+    $vardef_name = $beanList[$module_name];
3571
+    if($vardef_name=="aCase"){
3572
+        $bean_name = "Case";
3573
+    } else {
3574
+        $bean_name = $vardef_name;
3575
+    }
3576
+    return $bean_name;
3577 3577
 }
3578 3578
 
3579 3579
 
3580 3580
 
3581 3581
 function  checkAuthUserStatus(){
3582 3582
 
3583
-	//authUserStatus();
3583
+    //authUserStatus();
3584 3584
 }
3585 3585
 
3586 3586
 
@@ -3593,7 +3593,7 @@  discard block
 block discarded – undo
3593 3593
  * @author	customized for Sugar by Chris N.
3594 3594
  */
3595 3595
 function getPhpInfo($level=-1) {
3596
-	/**	Name (constant)		Value	Description
3596
+    /**	Name (constant)		Value	Description
3597 3597
 		INFO_GENERAL		1		The configuration line, php.ini location, build date, Web Server, System and more.
3598 3598
 		INFO_CREDITS		2		PHP Credits. See also phpcredits().
3599 3599
 		INFO_CONFIGURATION	4		Current Local and Master values for PHP directives. See also ini_get().
@@ -3602,47 +3602,47 @@  discard block
 block discarded – undo
3602 3602
 		INFO_VARIABLES		32		Shows all predefined variables from EGPCS (Environment, GET, POST, Cookie, Server).
3603 3603
 		INFO_LICENSE		64		PHP License information. See also the license FAQ.
3604 3604
 		INFO_ALL			-1		Shows all of the above. This is the default value.
3605
-	 */
3606
-	ob_start();
3607
-	phpinfo($level);
3608
-	$phpinfo = ob_get_contents();
3609
-	ob_end_clean();
3610
-
3611
-	$phpinfo	= strip_tags($phpinfo,'<h1><h2><th><td>');
3612
-	$phpinfo	= preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$phpinfo);
3613
-	$phpinfo	= preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$phpinfo);
3614
-	$parsedInfo	= preg_split('/(<h.?>[^<]+<\/h.>)/', $phpinfo, -1, PREG_SPLIT_DELIM_CAPTURE);
3615
-	$match		= '';
3616
-	$version	= '';
3617
-	$returnInfo	= array();
3618
-
3619
-	if(preg_match('/<h1 class\=\"p\">PHP Version ([^<]+)<\/h1>/', $phpinfo, $version)) {
3620
-		$returnInfo['PHP Version'] = $version[1];
3621
-	}
3605
+     */
3606
+    ob_start();
3607
+    phpinfo($level);
3608
+    $phpinfo = ob_get_contents();
3609
+    ob_end_clean();
3610
+
3611
+    $phpinfo	= strip_tags($phpinfo,'<h1><h2><th><td>');
3612
+    $phpinfo	= preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$phpinfo);
3613
+    $phpinfo	= preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$phpinfo);
3614
+    $parsedInfo	= preg_split('/(<h.?>[^<]+<\/h.>)/', $phpinfo, -1, PREG_SPLIT_DELIM_CAPTURE);
3615
+    $match		= '';
3616
+    $version	= '';
3617
+    $returnInfo	= array();
3618
+
3619
+    if(preg_match('/<h1 class\=\"p\">PHP Version ([^<]+)<\/h1>/', $phpinfo, $version)) {
3620
+        $returnInfo['PHP Version'] = $version[1];
3621
+    }
3622 3622
 
3623 3623
 
3624
-	for ($i=1; $i<count($parsedInfo); $i++) {
3625
-		if (preg_match('/<h.>([^<]+)<\/h.>/', $parsedInfo[$i], $match)) {
3626
-			$vName = trim($match[1]);
3627
-			$parsedInfo2 = explode("\n",$parsedInfo[$i+1]);
3624
+    for ($i=1; $i<count($parsedInfo); $i++) {
3625
+        if (preg_match('/<h.>([^<]+)<\/h.>/', $parsedInfo[$i], $match)) {
3626
+            $vName = trim($match[1]);
3627
+            $parsedInfo2 = explode("\n",$parsedInfo[$i+1]);
3628 3628
 
3629
-			foreach ($parsedInfo2 AS $vOne) {
3630
-				$vPat	= '<info>([^<]+)<\/info>';
3631
-				$vPat3	= "/$vPat\s*$vPat\s*$vPat/";
3632
-				$vPat2	= "/$vPat\s*$vPat/";
3629
+            foreach ($parsedInfo2 AS $vOne) {
3630
+                $vPat	= '<info>([^<]+)<\/info>';
3631
+                $vPat3	= "/$vPat\s*$vPat\s*$vPat/";
3632
+                $vPat2	= "/$vPat\s*$vPat/";
3633 3633
 
3634
-				if (preg_match($vPat3,$vOne,$match)) { // 3cols
3635
-					$returnInfo[$vName][trim($match[1])] = array(trim($match[2]),trim($match[3]));
3636
-				} elseif (preg_match($vPat2,$vOne,$match)) { // 2cols
3637
-					$returnInfo[$vName][trim($match[1])] = trim($match[2]);
3638
-				}
3639
-			}
3640
-		} elseif(true) {
3634
+                if (preg_match($vPat3,$vOne,$match)) { // 3cols
3635
+                    $returnInfo[$vName][trim($match[1])] = array(trim($match[2]),trim($match[3]));
3636
+                } elseif (preg_match($vPat2,$vOne,$match)) { // 2cols
3637
+                    $returnInfo[$vName][trim($match[1])] = trim($match[2]);
3638
+                }
3639
+            }
3640
+        } elseif(true) {
3641 3641
 
3642
-		}
3643
-	}
3642
+        }
3643
+    }
3644 3644
 
3645
-	return $returnInfo;
3645
+    return $returnInfo;
3646 3646
 }
3647 3647
 
3648 3648
 /**
@@ -3653,7 +3653,7 @@  discard block
 block discarded – undo
3653 3653
  * @return	$result a formatted string
3654 3654
  */
3655 3655
 function string_format($format, $args){
3656
-	$result = $format;
3656
+    $result = $format;
3657 3657
 
3658 3658
     /** Bug47277 fix.
3659 3659
      * If args array has only one argument, and it's empty, so empty single quotes are used '' . That's because
@@ -3670,10 +3670,10 @@  discard block
 block discarded – undo
3670 3670
     }
3671 3671
     /* End of fix */
3672 3672
 
3673
-	for($i = 0; $i < count($args); $i++){
3674
-		$result = str_replace('{'.$i.'}', $args[$i], $result);
3675
-	}
3676
-	return $result;
3673
+    for($i = 0; $i < count($args); $i++){
3674
+        $result = str_replace('{'.$i.'}', $args[$i], $result);
3675
+    }
3676
+    return $result;
3677 3677
 }
3678 3678
 
3679 3679
 /**
@@ -3687,16 +3687,16 @@  discard block
 block discarded – undo
3687 3687
  * @return	$result a formatted string
3688 3688
  */
3689 3689
 function format_number_display($num, $system_id){
3690
-	global $sugar_config;
3691
-	if(isset($num) && !empty($num)){
3692
-		$num=unformat_number($num);
3693
-		if(isset($system_id) && $system_id == 1){
3694
-			return sprintf("%d", $num);
3695
-		}
3696
-		else{
3697
-			return sprintf("%d-%d", $num, $system_id);
3698
-		}
3699
-	}
3690
+    global $sugar_config;
3691
+    if(isset($num) && !empty($num)){
3692
+        $num=unformat_number($num);
3693
+        if(isset($system_id) && $system_id == 1){
3694
+            return sprintf("%d", $num);
3695
+        }
3696
+        else{
3697
+            return sprintf("%d-%d", $num, $system_id);
3698
+        }
3699
+    }
3700 3700
 }
3701 3701
 function checkLoginUserStatus(){
3702 3702
 }
@@ -3709,28 +3709,28 @@  discard block
 block discarded – undo
3709 3709
  */
3710 3710
 function appendPortToHost($url, $port)
3711 3711
 {
3712
-	$resulturl = $url;
3713
-
3714
-	// if no port, don't change the url
3715
-	if($port != '')
3716
-	{
3717
-		$split = explode("/", $url);
3718
-		//check if it starts with http, in case they didn't include that in url
3719
-		if(str_begin($url, 'http'))
3720
-		{
3721
-			//third index ($split[2]) will be the host
3722
-			$split[2] .= ":".$port;
3723
-		}
3724
-		else // otherwise assumed to start with host name
3725
-		{
3726
-			//first index ($split[0]) will be the host
3727
-			$split[0] .= ":".$port;
3728
-		}
3729
-
3730
-		$resulturl = implode("/", $split);
3731
-	}
3712
+    $resulturl = $url;
3713
+
3714
+    // if no port, don't change the url
3715
+    if($port != '')
3716
+    {
3717
+        $split = explode("/", $url);
3718
+        //check if it starts with http, in case they didn't include that in url
3719
+        if(str_begin($url, 'http'))
3720
+        {
3721
+            //third index ($split[2]) will be the host
3722
+            $split[2] .= ":".$port;
3723
+        }
3724
+        else // otherwise assumed to start with host name
3725
+        {
3726
+            //first index ($split[0]) will be the host
3727
+            $split[0] .= ":".$port;
3728
+        }
3729
+
3730
+        $resulturl = implode("/", $split);
3731
+    }
3732 3732
 
3733
-	return $resulturl;
3733
+    return $resulturl;
3734 3734
 }
3735 3735
 
3736 3736
 /**
@@ -3738,12 +3738,12 @@  discard block
 block discarded – undo
3738 3738
  * @return	JSON object
3739 3739
  */
3740 3740
 function getJSONobj() {
3741
-	static $json = null;
3742
-	if(!isset($json)) {
3743
-		require_once('include/JSON.php');
3744
-		$json = new JSON(JSON_LOOSE_TYPE);
3745
-	}
3746
-	return $json;
3741
+    static $json = null;
3742
+    if(!isset($json)) {
3743
+        require_once('include/JSON.php');
3744
+        $json = new JSON(JSON_LOOSE_TYPE);
3745
+    }
3746
+    return $json;
3747 3747
 }
3748 3748
 
3749 3749
 require_once('include/utils/db_utils.php');
@@ -3752,28 +3752,28 @@  discard block
 block discarded – undo
3752 3752
  * Set default php.ini settings for entry points
3753 3753
  */
3754 3754
 function setPhpIniSettings() {
3755
-	// zlib module
3756
-	// Bug 37579 - Comment out force enabling zlib.output_compression, since it can cause problems on certain hosts
3757
-	/*
3755
+    // zlib module
3756
+    // Bug 37579 - Comment out force enabling zlib.output_compression, since it can cause problems on certain hosts
3757
+    /*
3758 3758
     if(function_exists('gzclose') && headers_sent() == false) {
3759 3759
 		ini_set('zlib.output_compression', 1);
3760 3760
 	}
3761 3761
 	*/
3762
-	// mbstring module
3763
-	//nsingh: breaks zip/unzip functionality. Commenting out 4/23/08
3762
+    // mbstring module
3763
+    //nsingh: breaks zip/unzip functionality. Commenting out 4/23/08
3764 3764
 
3765
-	/*if(function_exists('mb_strlen')) {
3765
+    /*if(function_exists('mb_strlen')) {
3766 3766
 		ini_set('mbstring.func_overload', 7);
3767 3767
 		ini_set('mbstring.internal_encoding', 'UTF-8');
3768 3768
 	}*/
3769 3769
 
3770 3770
 
3771
-	// http://us3.php.net/manual/en/ref.pcre.php#ini.pcre.backtrack-limit
3772
-	// starting with 5.2.0, backtrack_limit breaks JSON decoding
3773
-	$backtrack_limit = ini_get('pcre.backtrack_limit');
3774
-	if(!empty($backtrack_limit)) {
3775
-		ini_set('pcre.backtrack_limit', '-1');
3776
-	}
3771
+    // http://us3.php.net/manual/en/ref.pcre.php#ini.pcre.backtrack-limit
3772
+    // starting with 5.2.0, backtrack_limit breaks JSON decoding
3773
+    $backtrack_limit = ini_get('pcre.backtrack_limit');
3774
+    if(!empty($backtrack_limit)) {
3775
+        ini_set('pcre.backtrack_limit', '-1');
3776
+    }
3777 3777
 }
3778 3778
 
3779 3779
 /**
@@ -3788,80 +3788,80 @@  discard block
 block discarded – undo
3788 3788
  */
3789 3789
 function sugarLangArrayMerge($gimp, $dom)
3790 3790
 {
3791
-	if(is_array($gimp) && is_array($dom))
3791
+    if(is_array($gimp) && is_array($dom))
3792 3792
     {
3793
-		foreach($dom as $domKey => $domVal)
3793
+        foreach($dom as $domKey => $domVal)
3794 3794
         {
3795
-			if(isset($gimp[$domKey]))
3795
+            if(isset($gimp[$domKey]))
3796 3796
             {
3797
-				if(is_array($domVal))
3797
+                if(is_array($domVal))
3798 3798
                 {
3799
-					$tempArr = array();
3799
+                    $tempArr = array();
3800 3800
                     foreach ( $domVal as $domArrKey => $domArrVal )
3801 3801
                         $tempArr[$domArrKey] = $domArrVal;
3802 3802
                     foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal )
3803 3803
                         if ( !isset($tempArr[$gimpArrKey]) )
3804 3804
                             $tempArr[$gimpArrKey] = $gimpArrVal;
3805 3805
                     $gimp[$domKey] = $tempArr;
3806
-				}
3806
+                }
3807 3807
                 else
3808 3808
                 {
3809
-					$gimp[$domKey] = $domVal;
3810
-				}
3811
-			}
3809
+                    $gimp[$domKey] = $domVal;
3810
+                }
3811
+            }
3812 3812
             else
3813 3813
             {
3814
-				$gimp[$domKey] = $domVal;
3815
-			}
3816
-		}
3817
-	}
3814
+                $gimp[$domKey] = $domVal;
3815
+            }
3816
+        }
3817
+    }
3818 3818
     // if the passed value for gimp isn't an array, then return the $dom
3819 3819
     elseif(is_array($dom))
3820 3820
     {
3821 3821
         return $dom;
3822 3822
     }
3823 3823
 
3824
-	return $gimp;
3824
+    return $gimp;
3825 3825
 }
3826 3826
 /**
3827
- * like array_merge() but will handle array elements that are themselves arrays;
3828
- * PHP's version just overwrites the element with the new one.
3829
- *
3830
- * @internal Note that this function deviates from the internal array_merge()
3831
- *           functions in that it does does not treat numeric keys differently
3832
- *           than string keys.  Additionally, it deviates from
3833
- *           array_merge_recursive() by not creating an array when like values
3834
- *           found.
3835
- *
3836
- * @param array gimp the array whose values will be overloaded
3837
- * @param array dom the array whose values will pwn the gimp's
3838
- * @return array beaten gimp
3839
- */
3827
+     * like array_merge() but will handle array elements that are themselves arrays;
3828
+     * PHP's version just overwrites the element with the new one.
3829
+     *
3830
+     * @internal Note that this function deviates from the internal array_merge()
3831
+     *           functions in that it does does not treat numeric keys differently
3832
+     *           than string keys.  Additionally, it deviates from
3833
+     *           array_merge_recursive() by not creating an array when like values
3834
+     *           found.
3835
+     *
3836
+     * @param array gimp the array whose values will be overloaded
3837
+     * @param array dom the array whose values will pwn the gimp's
3838
+     * @return array beaten gimp
3839
+     */
3840 3840
 function sugarArrayMerge($gimp, $dom) {
3841
-	if(is_array($gimp) && is_array($dom)) {
3842
-		foreach($dom as $domKey => $domVal) {
3843
-			if(array_key_exists($domKey, $gimp)) {
3844
-				if(is_array($domVal)) {
3845
-					$tempArr = array();
3841
+    if(is_array($gimp) && is_array($dom)) {
3842
+        foreach($dom as $domKey => $domVal) {
3843
+            if(array_key_exists($domKey, $gimp)) {
3844
+                if(is_array($domVal)) {
3845
+                    $tempArr = array();
3846 3846
                     foreach ( $domVal as $domArrKey => $domArrVal )
3847 3847
                         $tempArr[$domArrKey] = $domArrVal;
3848 3848
                     foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal )
3849 3849
                         if ( !array_key_exists($gimpArrKey, $tempArr) )
3850 3850
                             $tempArr[$gimpArrKey] = $gimpArrVal;
3851 3851
                     $gimp[$domKey] = $tempArr;
3852
-				} else {
3853
-					$gimp[$domKey] = $domVal;
3854
-				}
3855
-			} else {
3856
-				$gimp[$domKey] = $domVal;
3857
-			}
3858
-		}
3859
-	}
3852
+                } else {
3853
+                    $gimp[$domKey] = $domVal;
3854
+                }
3855
+            } else {
3856
+                $gimp[$domKey] = $domVal;
3857
+            }
3858
+        }
3859
+    }
3860 3860
     // if the passed value for gimp isn't an array, then return the $dom
3861 3861
     elseif(is_array($dom))
3862 3862
         return $dom;
3863 3863
 
3864
-	return $gimp;
3864
+    return $gimp;
3865 3865
 }
3866 3866
 
3867 3867
 /**
@@ -3872,24 +3872,24 @@  discard block
 block discarded – undo
3872 3872
  * @return array beaten gimp
3873 3873
  */
3874 3874
 function sugarArrayMergeRecursive($gimp, $dom) {
3875
-	if(is_array($gimp) && is_array($dom)) {
3876
-		foreach($dom as $domKey => $domVal) {
3877
-			if(array_key_exists($domKey, $gimp)) {
3878
-				if(is_array($domVal) && is_array($gimp[$domKey])) {
3879
-					$gimp[$domKey] = sugarArrayMergeRecursive($gimp[$domKey], $domVal);
3880
-				} else {
3881
-					$gimp[$domKey] = $domVal;
3882
-				}
3883
-			} else {
3884
-				$gimp[$domKey] = $domVal;
3885
-			}
3886
-		}
3887
-	}
3875
+    if(is_array($gimp) && is_array($dom)) {
3876
+        foreach($dom as $domKey => $domVal) {
3877
+            if(array_key_exists($domKey, $gimp)) {
3878
+                if(is_array($domVal) && is_array($gimp[$domKey])) {
3879
+                    $gimp[$domKey] = sugarArrayMergeRecursive($gimp[$domKey], $domVal);
3880
+                } else {
3881
+                    $gimp[$domKey] = $domVal;
3882
+                }
3883
+            } else {
3884
+                $gimp[$domKey] = $domVal;
3885
+            }
3886
+        }
3887
+    }
3888 3888
     // if the passed value for gimp isn't an array, then return the $dom
3889 3889
     elseif(is_array($dom))
3890 3890
         return $dom;
3891 3891
 
3892
-	return $gimp;
3892
+    return $gimp;
3893 3893
 }
3894 3894
 
3895 3895
 /**
@@ -3897,11 +3897,11 @@  discard block
 block discarded – undo
3897 3897
  * @return bool True if NOT found or WRONG version
3898 3898
  */
3899 3899
 function returnPhpJsonStatus() {
3900
-	if(function_exists('json_encode')) {
3901
-		$phpInfo = getPhpInfo(8);
3900
+    if(function_exists('json_encode')) {
3901
+        $phpInfo = getPhpInfo(8);
3902 3902
         return version_compare($phpInfo['json']['json version'], '1.1.1', '<');
3903
-	}
3904
-	return true; // not found
3903
+    }
3904
+    return true; // not found
3905 3905
 }
3906 3906
 
3907 3907
 
@@ -3916,114 +3916,114 @@  discard block
 block discarded – undo
3916 3916
  * @return string [number]-char formatted string if length of string exceeds the max allowed
3917 3917
  */
3918 3918
 function getTrackerSubstring($name) {
3919
-	static $max_tracker_item_length;
3919
+    static $max_tracker_item_length;
3920 3920
 
3921
-	//Trim the name
3922
-	$name = html_entity_decode($name, ENT_QUOTES, 'UTF-8');
3923
-	$strlen = function_exists('mb_strlen') ? mb_strlen($name) : strlen($name);
3921
+    //Trim the name
3922
+    $name = html_entity_decode($name, ENT_QUOTES, 'UTF-8');
3923
+    $strlen = function_exists('mb_strlen') ? mb_strlen($name) : strlen($name);
3924 3924
 
3925
-	global $sugar_config;
3925
+    global $sugar_config;
3926 3926
 
3927
-	if(!isset($max_tracker_item_length)) {
3928
-		if(isset($sugar_config['tracker_max_display_length'])) {
3929
-	      $max_tracker_item_length = (is_int($sugar_config['tracker_max_display_length']) && $sugar_config['tracker_max_display_length'] > 0 && $sugar_config['tracker_max_display_length'] < 50) ? $sugar_config['tracker_max_display_length'] : 15;
3930
-		} else {
3931
-	      $max_tracker_item_length = 15;
3932
-		}
3933
-	}
3927
+    if(!isset($max_tracker_item_length)) {
3928
+        if(isset($sugar_config['tracker_max_display_length'])) {
3929
+            $max_tracker_item_length = (is_int($sugar_config['tracker_max_display_length']) && $sugar_config['tracker_max_display_length'] > 0 && $sugar_config['tracker_max_display_length'] < 50) ? $sugar_config['tracker_max_display_length'] : 15;
3930
+        } else {
3931
+            $max_tracker_item_length = 15;
3932
+        }
3933
+    }
3934 3934
 
3935
-	if($strlen > $max_tracker_item_length) {
3936
-		$chopped = function_exists('mb_substr') ? mb_substr($name, 0, $max_tracker_item_length-3, "UTF-8") : substr($name, 0, $max_tracker_item_length-3);
3937
-		$chopped .= "...";
3938
-	} else {
3939
-		$chopped = $name;
3940
-	}
3935
+    if($strlen > $max_tracker_item_length) {
3936
+        $chopped = function_exists('mb_substr') ? mb_substr($name, 0, $max_tracker_item_length-3, "UTF-8") : substr($name, 0, $max_tracker_item_length-3);
3937
+        $chopped .= "...";
3938
+    } else {
3939
+        $chopped = $name;
3940
+    }
3941 3941
 
3942
-	return $chopped;
3942
+    return $chopped;
3943 3943
 }
3944 3944
 function generate_search_where ($field_list=array(),$values=array(),&$bean,$add_custom_fields=false,$module='') {
3945
-	$where_clauses= array();
3946
-	$like_char='%';
3947
-	$table_name=$bean->object_name;
3948
-	foreach ($field_list[$module] as $field=>$parms) {
3949
-		if(isset($values[$field]) && $values[$field] != "") {
3950
-			$operator='like';
3951
-			if (!empty($parms['operator'])) {
3952
-				$operator=$parms['operator'];
3953
-			}
3954
-			if (is_array($values[$field])) {
3955
-				$operator='in';
3956
-				$field_value='';
3957
-				foreach ($values[$field] as $key => $val) {
3958
-					if ($val != ' ' and $val != '') {
3959
-						if (!empty($field_value)) {
3960
-							$field_value.=',';
3961
-						}
3962
-						$field_value .= "'".$GLOBALS['db']->quote($val)."'";
3963
-					}
3964
-				}
3965
-			} else {
3966
-				$field_value=$GLOBALS['db']->quote($values[$field]);
3967
-			}
3968
-			//set db_fields array.
3969
-			if (!isset($parms['db_field']) )  {
3970
-				$parms['db_field'] = array($field);
3971
-			}
3972
-			if (isset($parms['my_items']) and $parms['my_items'] == true) {
3973
-				global $current_user;
3974
-				$field_value = $GLOBALS['db']->quote($current_user->id);
3975
-				$operator='=';
3976
-			}
3945
+    $where_clauses= array();
3946
+    $like_char='%';
3947
+    $table_name=$bean->object_name;
3948
+    foreach ($field_list[$module] as $field=>$parms) {
3949
+        if(isset($values[$field]) && $values[$field] != "") {
3950
+            $operator='like';
3951
+            if (!empty($parms['operator'])) {
3952
+                $operator=$parms['operator'];
3953
+            }
3954
+            if (is_array($values[$field])) {
3955
+                $operator='in';
3956
+                $field_value='';
3957
+                foreach ($values[$field] as $key => $val) {
3958
+                    if ($val != ' ' and $val != '') {
3959
+                        if (!empty($field_value)) {
3960
+                            $field_value.=',';
3961
+                        }
3962
+                        $field_value .= "'".$GLOBALS['db']->quote($val)."'";
3963
+                    }
3964
+                }
3965
+            } else {
3966
+                $field_value=$GLOBALS['db']->quote($values[$field]);
3967
+            }
3968
+            //set db_fields array.
3969
+            if (!isset($parms['db_field']) )  {
3970
+                $parms['db_field'] = array($field);
3971
+            }
3972
+            if (isset($parms['my_items']) and $parms['my_items'] == true) {
3973
+                global $current_user;
3974
+                $field_value = $GLOBALS['db']->quote($current_user->id);
3975
+                $operator='=';
3976
+            }
3977 3977
 
3978
-			$where='';
3979
-			$itr=0;
3980
-			if ($field_value != '') {
3981
-
3982
-				foreach ($parms['db_field'] as $db_field) {
3983
-					if (strstr($db_field,'.')===false) {
3984
-						$db_field=$bean->table_name.".".$db_field;
3985
-					}
3986
-					if ($GLOBALS['db']->supports('case_sensitive') &&  isset($parms['query_type']) && $parms['query_type']=='case_insensitive') {
3987
-						$db_field='upper('.$db_field.")";
3988
-						$field_value=strtoupper($field_value);
3989
-					}
3990
-
3991
-					$itr++;
3992
-					if (!empty($where)) {
3993
-						$where .= " OR ";
3994
-					}
3995
-					switch (strtolower($operator)) {
3996
-						case 'like' :
3997
-							$where .=  $db_field . " like '".$field_value.$like_char."'";
3998
-							break;
3999
-						case 'in':
4000
-							$where .=  $db_field . " in (".$field_value.')';
4001
-							break;
4002
-						case '=':
4003
-							$where .=  $db_field . " = '".$field_value ."'";
4004
-							break;
4005
-					}
4006
-				}
4007
-			}
4008
-			if (!empty($where)) {
4009
-				if ($itr>1) {
4010
-					array_push($where_clauses, '( '.$where.' )');
4011
-				} else {
4012
-					array_push($where_clauses, $where);
4013
-				}
4014
-			}
4015
-		}
4016
-	}
4017
-	if ($add_custom_fields) {
4018
-		require_once('modules/DynamicFields/DynamicField.php');
4019
-		$bean->setupCustomFields($module);
4020
-		$bean->custom_fields->setWhereClauses($where_clauses);
4021
-	}
4022
-	return $where_clauses;
3978
+            $where='';
3979
+            $itr=0;
3980
+            if ($field_value != '') {
3981
+
3982
+                foreach ($parms['db_field'] as $db_field) {
3983
+                    if (strstr($db_field,'.')===false) {
3984
+                        $db_field=$bean->table_name.".".$db_field;
3985
+                    }
3986
+                    if ($GLOBALS['db']->supports('case_sensitive') &&  isset($parms['query_type']) && $parms['query_type']=='case_insensitive') {
3987
+                        $db_field='upper('.$db_field.")";
3988
+                        $field_value=strtoupper($field_value);
3989
+                    }
3990
+
3991
+                    $itr++;
3992
+                    if (!empty($where)) {
3993
+                        $where .= " OR ";
3994
+                    }
3995
+                    switch (strtolower($operator)) {
3996
+                        case 'like' :
3997
+                            $where .=  $db_field . " like '".$field_value.$like_char."'";
3998
+                            break;
3999
+                        case 'in':
4000
+                            $where .=  $db_field . " in (".$field_value.')';
4001
+                            break;
4002
+                        case '=':
4003
+                            $where .=  $db_field . " = '".$field_value ."'";
4004
+                            break;
4005
+                    }
4006
+                }
4007
+            }
4008
+            if (!empty($where)) {
4009
+                if ($itr>1) {
4010
+                    array_push($where_clauses, '( '.$where.' )');
4011
+                } else {
4012
+                    array_push($where_clauses, $where);
4013
+                }
4014
+            }
4015
+        }
4016
+    }
4017
+    if ($add_custom_fields) {
4018
+        require_once('modules/DynamicFields/DynamicField.php');
4019
+        $bean->setupCustomFields($module);
4020
+        $bean->custom_fields->setWhereClauses($where_clauses);
4021
+    }
4022
+    return $where_clauses;
4023 4023
 }
4024 4024
 
4025 4025
 function add_quotes($str) {
4026
-	return "'{$str}'";
4026
+    return "'{$str}'";
4027 4027
 }
4028 4028
 
4029 4029
 /**
@@ -4033,19 +4033,19 @@  discard block
 block discarded – undo
4033 4033
  * @return	bool true if successful
4034 4034
  */
4035 4035
 function rebuildConfigFile($sugar_config, $sugar_version) {
4036
-	// add defaults to missing values of in-memory sugar_config
4037
-	$sugar_config = sugarArrayMerge(get_sugar_config_defaults(), $sugar_config );
4038
-	// need to override version with default no matter what
4039
-	$sugar_config['sugar_version'] = $sugar_version;
4036
+    // add defaults to missing values of in-memory sugar_config
4037
+    $sugar_config = sugarArrayMerge(get_sugar_config_defaults(), $sugar_config );
4038
+    // need to override version with default no matter what
4039
+    $sugar_config['sugar_version'] = $sugar_version;
4040 4040
 
4041
-	ksort( $sugar_config );
4041
+    ksort( $sugar_config );
4042 4042
 
4043
-	if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
4044
-		return true;
4045
-	}
4046
-	else {
4047
-		return false;
4048
-	}
4043
+    if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
4044
+        return true;
4045
+    }
4046
+    else {
4047
+        return false;
4048
+    }
4049 4049
 }
4050 4050
 
4051 4051
 /**
@@ -4072,44 +4072,44 @@  discard block
 block discarded – undo
4072 4072
  * @return $site_url The url used to refer to the website
4073 4073
  */
4074 4074
 function getJavascriptSiteURL() {
4075
-	global $sugar_config;
4076
-	if(!empty($_SERVER['HTTP_REFERER'])) {
4077
-		$url = parse_url($_SERVER['HTTP_REFERER']);
4078
-		$replacement_url = $url['scheme']."://".$url['host'];
4079
-		if(!empty($url['port']))
4080
-		$replacement_url .= ':'.$url['port'];
4081
-		$site_url = preg_replace('/^http[s]?\:\/\/[^\/]+/',$replacement_url,$sugar_config['site_url']);
4082
-	} else {
4083
-		$site_url = preg_replace('/^http(s)?\:\/\/[^\/]+/',"http$1://".$_SERVER['HTTP_HOST'],$sugar_config['site_url']);
4084
-		if(!empty($_SERVER['SERVER_PORT']) &&$_SERVER['SERVER_PORT'] == '443') {
4085
-			$site_url = preg_replace('/^http\:/','https:',$site_url);
4086
-		}
4087
-	}
4088
-	$GLOBALS['log']->debug("getJavascriptSiteURL(), site_url=".  $site_url);
4089
-	return $site_url;
4075
+    global $sugar_config;
4076
+    if(!empty($_SERVER['HTTP_REFERER'])) {
4077
+        $url = parse_url($_SERVER['HTTP_REFERER']);
4078
+        $replacement_url = $url['scheme']."://".$url['host'];
4079
+        if(!empty($url['port']))
4080
+        $replacement_url .= ':'.$url['port'];
4081
+        $site_url = preg_replace('/^http[s]?\:\/\/[^\/]+/',$replacement_url,$sugar_config['site_url']);
4082
+    } else {
4083
+        $site_url = preg_replace('/^http(s)?\:\/\/[^\/]+/',"http$1://".$_SERVER['HTTP_HOST'],$sugar_config['site_url']);
4084
+        if(!empty($_SERVER['SERVER_PORT']) &&$_SERVER['SERVER_PORT'] == '443') {
4085
+            $site_url = preg_replace('/^http\:/','https:',$site_url);
4086
+        }
4087
+    }
4088
+    $GLOBALS['log']->debug("getJavascriptSiteURL(), site_url=".  $site_url);
4089
+    return $site_url;
4090 4090
 }
4091 4091
 
4092 4092
 // works nicely with array_map() -- can be used to wrap single quotes around each element in an array
4093 4093
 function add_squotes($str) {
4094
-	return "'" . $str . "'";
4094
+    return "'" . $str . "'";
4095 4095
 }
4096 4096
 
4097 4097
 
4098 4098
 // recursive function to count the number of levels within an array
4099 4099
 function array_depth($array, $depth_count=-1, $depth_array=array()){
4100
-	$depth_count++;
4101
-	if (is_array($array)){
4102
-		foreach ($array as $key => $value){
4103
-			$depth_array[] = array_depth($value, $depth_count);
4104
-		}
4105
-	}
4106
-	else{
4107
-		return $depth_count;
4108
-	}
4109
-	foreach ($depth_array as $value){
4110
-		$depth_count = $value > $depth_count ? $value : $depth_count;
4111
-	}
4112
-	return $depth_count;
4100
+    $depth_count++;
4101
+    if (is_array($array)){
4102
+        foreach ($array as $key => $value){
4103
+            $depth_array[] = array_depth($value, $depth_count);
4104
+        }
4105
+    }
4106
+    else{
4107
+        return $depth_count;
4108
+    }
4109
+    foreach ($depth_array as $value){
4110
+        $depth_count = $value > $depth_count ? $value : $depth_count;
4111
+    }
4112
+    return $depth_count;
4113 4113
 }
4114 4114
 
4115 4115
 /**
@@ -4120,16 +4120,16 @@  discard block
 block discarded – undo
4120 4120
 function createGroupUser($name) {
4121 4121
 
4122 4122
 
4123
-	$group = new User();
4124
-	$group->user_name	= $name;
4125
-	$group->last_name	= $name;
4126
-	$group->is_group	= 1;
4127
-	$group->deleted		= 0;
4128
-	$group->status		= 'Active'; // cn: bug 6711
4129
-	$group->setPreference('timezone', TimeDate::userTimezone());
4130
-	$group->save();
4123
+    $group = new User();
4124
+    $group->user_name	= $name;
4125
+    $group->last_name	= $name;
4126
+    $group->is_group	= 1;
4127
+    $group->deleted		= 0;
4128
+    $group->status		= 'Active'; // cn: bug 6711
4129
+    $group->setPreference('timezone', TimeDate::userTimezone());
4130
+    $group->save();
4131 4131
 
4132
-	return $group->id;
4132
+    return $group->id;
4133 4133
 }
4134 4134
 
4135 4135
 /*
@@ -4142,48 +4142,48 @@  discard block
 block discarded – undo
4142 4142
 function _getIcon($iconFileName)
4143 4143
 {
4144 4144
 
4145
-	$iconName = "icon_{$iconFileName}.gif";
4145
+    $iconName = "icon_{$iconFileName}.gif";
4146 4146
     $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4147 4147
 
4148 4148
     //First try un-ucfirst-ing the icon name
4149 4149
     if ( empty($iconFound) )
4150
-		$iconName = "icon_" . strtolower(substr($iconFileName,0,1)).substr($iconFileName,1) . ".gif";
4150
+        $iconName = "icon_" . strtolower(substr($iconFileName,0,1)).substr($iconFileName,1) . ".gif";
4151 4151
         $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4152 4152
 
4153
-	//Next try removing the icon prefix
4153
+    //Next try removing the icon prefix
4154 4154
     if ( empty($iconFound) )
4155
-		$iconName = "{$iconFileName}.gif";
4156
-		$iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4155
+        $iconName = "{$iconFileName}.gif";
4156
+        $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4157 4157
 
4158
-	if ( empty($iconFound) )
4159
-		$iconName = '';
4158
+    if ( empty($iconFound) )
4159
+        $iconName = '';
4160 4160
 
4161
-  	return $iconName;
4161
+        return $iconName;
4162 4162
 }
4163 4163
 /**
4164
- * Function to grab the correct icon image for Studio
4165
- * @param string $iconFileName Name of the icon file
4166
- * @param string $altfilename Name of a fallback icon file (displayed if the imagefilename doesn't exist)
4167
- * @param string $width Width of image
4168
- * @param string $height Height of image
4169
- * @param string $align Alignment of image
4170
- * @param string $alt Alt tag of image
4171
- * @return string $string <img> tag with corresponding image
4172
- */
4164
+         * Function to grab the correct icon image for Studio
4165
+         * @param string $iconFileName Name of the icon file
4166
+         * @param string $altfilename Name of a fallback icon file (displayed if the imagefilename doesn't exist)
4167
+         * @param string $width Width of image
4168
+         * @param string $height Height of image
4169
+         * @param string $align Alignment of image
4170
+         * @param string $alt Alt tag of image
4171
+         * @return string $string <img> tag with corresponding image
4172
+         */
4173 4173
 
4174 4174
 function getStudioIcon($iconFileName='', $altFileName='', $width='48', $height='48', $align='baseline', $alt='' )
4175 4175
 {
4176
-	global $app_strings, $theme;
4176
+    global $app_strings, $theme;
4177 4177
 
4178 4178
     $iconName = _getIcon($iconFileName);
4179
- 	if(empty($iconName)){
4180
- 	    $iconName = _getIcon($altFileName);
4181
- 	    if (empty($iconName))
4182
- 	    {
4179
+        if(empty($iconName)){
4180
+            $iconName = _getIcon($altFileName);
4181
+            if (empty($iconName))
4182
+            {
4183 4183
             return $app_strings['LBL_NO_IMAGE'];
4184
- 	    }
4185
- 	}
4186
-	return SugarThemeRegistry::current()->getImage($iconName, "align=\"$align\" border=\"0\"", $width, $height);
4184
+            }
4185
+        }
4186
+    return SugarThemeRegistry::current()->getImage($iconName, "align=\"$align\" border=\"0\"", $width, $height);
4187 4187
 }
4188 4188
 
4189 4189
 /**
@@ -4198,16 +4198,16 @@  discard block
 block discarded – undo
4198 4198
  */
4199 4199
 
4200 4200
 function get_dashlets_dialog_icon($module='', $width='32', $height='32', $align='absmiddle',$alt=''){
4201
-	global $app_strings, $theme;
4202
- 	$iconName = _getIcon($module . "_32");
4203
- 	if (empty($iconName))
4204
- 	{
4205
- 		$iconName = _getIcon($module);
4206
- 	}
4207
- 	if(empty($iconName)){
4208
- 		return $app_strings['LBL_NO_IMAGE'];
4209
- 	}
4210
-	return SugarThemeRegistry::current()->getImage($iconName, "align=\"$align\" border=\"0\"", $width, $height);
4201
+    global $app_strings, $theme;
4202
+        $iconName = _getIcon($module . "_32");
4203
+        if (empty($iconName))
4204
+        {
4205
+            $iconName = _getIcon($module);
4206
+        }
4207
+        if(empty($iconName)){
4208
+            return $app_strings['LBL_NO_IMAGE'];
4209
+        }
4210
+    return SugarThemeRegistry::current()->getImage($iconName, "align=\"$align\" border=\"0\"", $width, $height);
4211 4211
 }
4212 4212
 
4213 4213
 // works nicely to change UTF8 strings that are html entities - good for PDF conversions
@@ -4239,23 +4239,23 @@  discard block
 block discarded – undo
4239 4239
 }
4240 4240
 
4241 4241
 function str_split_php4($string, $length = 1) {
4242
-	$string_length = strlen($string);
4243
-	$return = array();
4244
-	$cursor = 0;
4245
-	if ($length > $string_length) {
4246
-		// use the string_length as the string is shorter than the length
4247
-		$length = $string_length;
4248
-	}
4249
-	for ($cursor = 0; $cursor < $string_length; $cursor = $cursor + $length) {
4250
-		$return[] = substr($string, $cursor, $length);
4251
-	}
4252
-	return $return;
4242
+    $string_length = strlen($string);
4243
+    $return = array();
4244
+    $cursor = 0;
4245
+    if ($length > $string_length) {
4246
+        // use the string_length as the string is shorter than the length
4247
+        $length = $string_length;
4248
+    }
4249
+    for ($cursor = 0; $cursor < $string_length; $cursor = $cursor + $length) {
4250
+        $return[] = substr($string, $cursor, $length);
4251
+    }
4252
+    return $return;
4253 4253
 }
4254 4254
 
4255 4255
 if (version_compare(phpversion(), '5.0.0', '<')) {
4256
-	function str_split($string, $length = 1) {
4257
-		return str_split_php4($string, $length);
4258
-	}
4256
+    function str_split($string, $length = 1) {
4257
+        return str_split_php4($string, $length);
4258
+    }
4259 4259
 }
4260 4260
 
4261 4261
 /*
@@ -4287,8 +4287,8 @@  discard block
 block discarded – undo
4287 4287
  */
4288 4288
 function chartColors()
4289 4289
 {
4290
-	if (SugarThemeRegistry::current()->getCSSURL('sugarColors.xml')=='')
4291
-	return SugarThemeRegistry::current()->getImageURL('sugarColors.xml');
4290
+    if (SugarThemeRegistry::current()->getCSSURL('sugarColors.xml')=='')
4291
+    return SugarThemeRegistry::current()->getImageURL('sugarColors.xml');
4292 4292
     return SugarThemeRegistry::current()->getCSSURL('sugarColors.xml');
4293 4293
 }
4294 4294
 /* End Chart Dashlet helper functions */
@@ -4299,7 +4299,7 @@  discard block
 block discarded – undo
4299 4299
  */
4300 4300
 
4301 4301
 function ajaxInit() {
4302
-	ini_set('display_errors', 'false');
4302
+    ini_set('display_errors', 'false');
4303 4303
 }
4304 4304
 
4305 4305
 /**
@@ -4366,33 +4366,33 @@  discard block
 block discarded – undo
4366 4366
  * @return String value of the shortcut keys
4367 4367
  */
4368 4368
 function get_alt_hot_key() {
4369
-	$ua = '';
4369
+    $ua = '';
4370 4370
     if ( isset($_SERVER['HTTP_USER_AGENT']) )
4371 4371
         $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
4372
-	$isMac = strpos($ua, 'mac') !== false;
4373
-	$isLinux = strpos($ua, 'linux') !== false;
4372
+    $isMac = strpos($ua, 'mac') !== false;
4373
+    $isLinux = strpos($ua, 'linux') !== false;
4374 4374
 
4375
-	if(!$isMac && !$isLinux && strpos($ua, 'mozilla') !== false) {
4376
-	   if(preg_match('/firefox\/(\d)?\./', $ua, $matches)) {
4377
-	   	  return $matches[1] < 2 ? 'Alt+' : 'Alt+Shift+';
4378
-	   }
4379
-	}
4380
-	return $isMac ? 'Ctrl+' : 'Alt+';
4375
+    if(!$isMac && !$isLinux && strpos($ua, 'mozilla') !== false) {
4376
+        if(preg_match('/firefox\/(\d)?\./', $ua, $matches)) {
4377
+                return $matches[1] < 2 ? 'Alt+' : 'Alt+Shift+';
4378
+        }
4379
+    }
4380
+    return $isMac ? 'Ctrl+' : 'Alt+';
4381 4381
 }
4382 4382
 
4383 4383
 function can_start_session(){
4384
-	if(!empty($_GET['PHPSESSID'])) {
4385
-	   return true;
4386
-	}
4387
-	$session_id = session_id();
4388
-	return empty($session_id) ? true : false;
4384
+    if(!empty($_GET['PHPSESSID'])) {
4385
+        return true;
4386
+    }
4387
+    $session_id = session_id();
4388
+    return empty($session_id) ? true : false;
4389 4389
 }
4390 4390
 
4391 4391
 function load_link_class($properties){
4392
-	$class = 'Link2';
4393
-	if(!empty($properties['link_class']) && !empty($properties['link_file'])){
4394
-    	require_once($properties['link_file']);
4395
-    	$class = $properties['link_class'];
4392
+    $class = 'Link2';
4393
+    if(!empty($properties['link_class']) && !empty($properties['link_file'])){
4394
+        require_once($properties['link_file']);
4395
+        $class = $properties['link_class'];
4396 4396
     }
4397 4397
     return $class;
4398 4398
 }
@@ -4413,7 +4413,7 @@  discard block
 block discarded – undo
4413 4413
     if ( !isset($GLOBALS['sugar_config']['allow_pop_inbound']) || ! $GLOBALS['sugar_config']['allow_pop_inbound'] )
4414 4414
     {
4415 4415
         if( isset($protocol['pop3']) )
4416
-			unset($protocol['pop3']);
4416
+            unset($protocol['pop3']);
4417 4417
     }
4418 4418
     else
4419 4419
         $protocol['pop3'] = 'POP3';
@@ -4448,15 +4448,15 @@  discard block
 block discarded – undo
4448 4448
  *
4449 4449
  */
4450 4450
 function unencodeMultienum($string) {
4451
-	if (is_array($string))
4452
-	{
4453
-	   return $string;
4454
-	}
4455
-	if (substr($string, 0 ,1) == "^" && substr($string, -1) == "^") {
4456
-          $string = substr(substr($string, 1), 0, strlen($string) -2);
4457
-	}
4451
+    if (is_array($string))
4452
+    {
4453
+        return $string;
4454
+    }
4455
+    if (substr($string, 0 ,1) == "^" && substr($string, -1) == "^") {
4456
+            $string = substr(substr($string, 1), 0, strlen($string) -2);
4457
+    }
4458 4458
 
4459
-	return explode('^,^', $string);
4459
+    return explode('^,^', $string);
4460 4460
 }
4461 4461
 
4462 4462
 function encodeMultienumValue($arr) {
@@ -4466,7 +4466,7 @@  discard block
 block discarded – undo
4466 4466
     if (empty($arr))
4467 4467
         return "";
4468 4468
 
4469
-	$string = "^" . implode('^,^', $arr) . "^";
4469
+    $string = "^" . implode('^,^', $arr) . "^";
4470 4470
 
4471 4471
     return $string;
4472 4472
 }
@@ -4482,86 +4482,86 @@  discard block
 block discarded – undo
4482 4482
  * @return $ret_array['join']: extra join condition
4483 4483
  */
4484 4484
 function create_export_query_relate_link_patch($module, $searchFields, $where){
4485
-	if(file_exists('modules/'.$module.'/SearchForm.html')){
4486
-		$ret_array['where'] = $where;
4487
-		return $ret_array;
4488
-	}
4489
-	$seed = loadBean($module);
4485
+    if(file_exists('modules/'.$module.'/SearchForm.html')){
4486
+        $ret_array['where'] = $where;
4487
+        return $ret_array;
4488
+    }
4489
+    $seed = loadBean($module);
4490 4490
     foreach($seed->field_defs as $name=>$field)
4491
-	{
4492
-
4493
-		if( $field['type'] == 'relate' && isset($field['link']) && !empty($searchFields[$name]['value']) ){
4494
-			$seed->load_relationship($field['link']);
4495
-			$params = array();
4496
-			if(empty($join_type))
4497
-			{
4498
-				$params['join_type'] = ' LEFT JOIN ';
4499
-			}
4500
-			else
4501
-			{
4502
-				$params['join_type'] = $join_type;
4503
-			}
4504
-			if(isset($data['join_name']))
4505
-			{
4506
-				$params['join_table_alias'] = $field['join_name'];
4507
-			}
4508
-			else
4509
-			{
4510
-				$params['join_table_alias']	= 'join_'.$field['name'];
4491
+    {
4511 4492
 
4512
-			}
4513
-			if(isset($data['join_link_name']))
4514
-			{
4515
-				$params['join_table_link_alias'] = $field['join_link_name'];
4516
-			}
4517
-			else
4518
-			{
4519
-				$params['join_table_link_alias'] = 'join_link_'.$field['name'];
4520
-			}
4521
-			$join = $seed->$field['link']->getJoin($params, true);
4522
-			$join_table_alias = 'join_'.$field['name'];
4523
-			if(isset($field['db_concat_fields'])){
4524
-				$db_field = db_concat($join_table_alias, $field['db_concat_fields']);
4525
-				$where = preg_replace('/'.$field['name'].'/', $db_field, $where);
4526
-			}else{
4527
-				$where = preg_replace('/(^|[\s(])' . $field['name'] . '/', '${1}' . $join_table_alias . '.'.$field['rname'], $where);
4528
-			}
4529
-		}
4530
-	}
4493
+        if( $field['type'] == 'relate' && isset($field['link']) && !empty($searchFields[$name]['value']) ){
4494
+            $seed->load_relationship($field['link']);
4495
+            $params = array();
4496
+            if(empty($join_type))
4497
+            {
4498
+                $params['join_type'] = ' LEFT JOIN ';
4499
+            }
4500
+            else
4501
+            {
4502
+                $params['join_type'] = $join_type;
4503
+            }
4504
+            if(isset($data['join_name']))
4505
+            {
4506
+                $params['join_table_alias'] = $field['join_name'];
4507
+            }
4508
+            else
4509
+            {
4510
+                $params['join_table_alias']	= 'join_'.$field['name'];
4511
+
4512
+            }
4513
+            if(isset($data['join_link_name']))
4514
+            {
4515
+                $params['join_table_link_alias'] = $field['join_link_name'];
4516
+            }
4517
+            else
4518
+            {
4519
+                $params['join_table_link_alias'] = 'join_link_'.$field['name'];
4520
+            }
4521
+            $join = $seed->$field['link']->getJoin($params, true);
4522
+            $join_table_alias = 'join_'.$field['name'];
4523
+            if(isset($field['db_concat_fields'])){
4524
+                $db_field = db_concat($join_table_alias, $field['db_concat_fields']);
4525
+                $where = preg_replace('/'.$field['name'].'/', $db_field, $where);
4526
+            }else{
4527
+                $where = preg_replace('/(^|[\s(])' . $field['name'] . '/', '${1}' . $join_table_alias . '.'.$field['rname'], $where);
4528
+            }
4529
+        }
4530
+    }
4531 4531
     $ret_array = array('where'=>$where, 'join'=> isset($join['join']) ? $join['join'] : '');
4532
-	return $ret_array;
4532
+    return $ret_array;
4533 4533
 }
4534 4534
 
4535 4535
 /**
4536
-  * We need to clear all the js cache files, including the js language files  in serval places in MB. So I extract them into a util function here.
4537
-  * @Depends on QuickRepairAndRebuild.php
4538
-  * @Relate bug 30642  ,23177
4539
-  */
4536
+ * We need to clear all the js cache files, including the js language files  in serval places in MB. So I extract them into a util function here.
4537
+ * @Depends on QuickRepairAndRebuild.php
4538
+ * @Relate bug 30642  ,23177
4539
+ */
4540 4540
 function clearAllJsAndJsLangFilesWithoutOutput(){
4541
-		global $current_language , $mod_strings;
4542
-		$MBmodStrings = $mod_strings;
4541
+        global $current_language , $mod_strings;
4542
+        $MBmodStrings = $mod_strings;
4543 4543
         $mod_strings = return_module_language ( $current_language, 'Administration' ) ;
4544 4544
         include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
4545 4545
         $repair = new RepairAndClear();
4546 4546
         $repair->module_list = array();
4547
-		$repair->show_output = false;
4548
-		$repair->clearJsLangFiles();
4549
-		$repair->clearJsFiles();
4550
-		$mod_strings = $MBmodStrings;
4547
+        $repair->show_output = false;
4548
+        $repair->clearJsLangFiles();
4549
+        $repair->clearJsFiles();
4550
+        $mod_strings = $MBmodStrings;
4551 4551
 }
4552 4552
 
4553 4553
 /**
4554 4554
  * This function will allow you to get a variable value from query string
4555 4555
  */
4556 4556
 function getVariableFromQueryString($variable, $string){
4557
-	$matches = array();
4558
-	$number = preg_match("/{$variable}=([a-zA-Z0-9_-]+)[&]?/", $string, $matches);
4559
-	if($number){
4560
-		return $matches[1];
4561
-	}
4562
-	else{
4563
-		return false;
4564
-	}
4557
+    $matches = array();
4558
+    $number = preg_match("/{$variable}=([a-zA-Z0-9_-]+)[&]?/", $string, $matches);
4559
+    if($number){
4560
+        return $matches[1];
4561
+    }
4562
+    else{
4563
+        return false;
4564
+    }
4565 4565
 }
4566 4566
 
4567 4567
 /**
@@ -4572,14 +4572,14 @@  discard block
 block discarded – undo
4572 4572
  * @return boolean flag indicating whether or not iframes module should be hidden
4573 4573
  */
4574 4574
 function should_hide_iframes() {
4575
-   //Remove the MySites module
4576
-   if(file_exists('modules/iFrames/iFrame.php')) {
4575
+    //Remove the MySites module
4576
+    if(file_exists('modules/iFrames/iFrame.php')) {
4577 4577
         if(!class_exists("iFrame")) {
4578 4578
                 require_once('modules/iFrames/iFrame.php');
4579 4579
         }
4580 4580
         return false;
4581
-   }
4582
-   return true;
4581
+    }
4582
+    return true;
4583 4583
 }
4584 4584
 
4585 4585
 /**
@@ -4589,11 +4589,11 @@  discard block
 block discarded – undo
4589 4589
  * @return string RC, BETA, GA
4590 4590
  */
4591 4591
 function getVersionStatus($version){
4592
-	if(preg_match('/^[\d\.]+?([a-zA-Z]+?)[\d]*?$/si', $version, $matches)) {
4593
-		return strtoupper($matches[1]);
4594
-	}else{
4595
-		return 'GA';
4596
-	}
4592
+    if(preg_match('/^[\d\.]+?([a-zA-Z]+?)[\d]*?$/si', $version, $matches)) {
4593
+        return strtoupper($matches[1]);
4594
+    }else{
4595
+        return 'GA';
4596
+    }
4597 4597
 }
4598 4598
 
4599 4599
 /**
@@ -4604,16 +4604,16 @@  discard block
 block discarded – undo
4604 4604
  * @return version
4605 4605
  */
4606 4606
 function getMajorMinorVersion($version){
4607
-	if(preg_match('/^([\d\.]+).*$/si', $version, $matches2)){
4608
-		$version = $matches2[1];
4609
-		$arr = explode('.', $version);
4610
-		if(count($arr) > 2){
4611
-			if($arr[2] == '0'){
4612
-				$version = substr($version, 0, 3);
4613
-			}
4614
-		}
4615
-	}
4616
-	return $version;
4607
+    if(preg_match('/^([\d\.]+).*$/si', $version, $matches2)){
4608
+        $version = $matches2[1];
4609
+        $arr = explode('.', $version);
4610
+        if(count($arr) > 2){
4611
+            if($arr[2] == '0'){
4612
+                $version = substr($version, 0, 3);
4613
+            }
4614
+        }
4615
+    }
4616
+    return $version;
4617 4617
 }
4618 4618
 
4619 4619
 /**
@@ -4622,9 +4622,9 @@  discard block
 block discarded – undo
4622 4622
  */
4623 4623
 function sugar_microtime()
4624 4624
 {
4625
-	$now = explode(' ', microtime());
4626
-	$unique_id = $now[1].str_replace('.', '', $now[0]);
4627
-	return $unique_id;
4625
+    $now = explode(' ', microtime());
4626
+    $unique_id = $now[1].str_replace('.', '', $now[0]);
4627
+    return $unique_id;
4628 4628
 }
4629 4629
 
4630 4630
 /**
@@ -4634,15 +4634,15 @@  discard block
 block discarded – undo
4634 4634
  */
4635 4635
 function getUrls($string)
4636 4636
 {
4637
-	$lines = explode("<br>", trim($string));
4638
-	$urls = array();
4639
-	foreach($lines as $line){
4640
-    	$regex = '/http?\:\/\/[^\" ]+/i';
4641
-    	preg_match_all($regex, $line, $matches);
4642
-    	foreach($matches[0] as $match){
4643
-    		$urls[] = $match;
4644
-    	}
4645
-	}
4637
+    $lines = explode("<br>", trim($string));
4638
+    $urls = array();
4639
+    foreach($lines as $line){
4640
+        $regex = '/http?\:\/\/[^\" ]+/i';
4641
+        preg_match_all($regex, $line, $matches);
4642
+        foreach($matches[0] as $match){
4643
+            $urls[] = $match;
4644
+        }
4645
+    }
4646 4646
     return $urls;
4647 4647
 }
4648 4648
 
@@ -4654,14 +4654,14 @@  discard block
 block discarded – undo
4654 4654
  */
4655 4655
 function verify_image_file($path, $jpeg = false)
4656 4656
 {
4657
-	if(function_exists('imagepng') && function_exists('imagejpeg') && function_exists('imagecreatefromstring')) {
4657
+    if(function_exists('imagepng') && function_exists('imagejpeg') && function_exists('imagecreatefromstring')) {
4658 4658
         $img = imagecreatefromstring(file_get_contents($path));
4659
-    	if(!$img) {
4660
-    	    return false;
4661
-    	}
4662
-    	$img_size = getimagesize($path);
4663
-		$filetype = $img_size['mime'];
4664
-		//if filetype is jpeg or if we are only allowing jpegs, create jpg image
4659
+        if(!$img) {
4660
+            return false;
4661
+        }
4662
+        $img_size = getimagesize($path);
4663
+        $filetype = $img_size['mime'];
4664
+        //if filetype is jpeg or if we are only allowing jpegs, create jpg image
4665 4665
         if($filetype == "image/jpeg" || $jpeg) {
4666 4666
             ob_start();
4667 4667
             imagejpeg($img);
@@ -4672,19 +4672,19 @@  discard block
 block discarded – undo
4672 4672
             }
4673 4673
         } elseif ($filetype == "image/png") {
4674 4674
             // else if the filetype is png, create png
4675
-        	imagealphablending($img, true);
4676
-        	imagesavealpha($img, true);
4677
-        	ob_start();
4675
+            imagealphablending($img, true);
4676
+            imagesavealpha($img, true);
4677
+            ob_start();
4678 4678
             imagepng($img);
4679 4679
             $image = ob_get_clean();
4680
-    	    if(file_put_contents($path, $image)) {
4680
+            if(file_put_contents($path, $image)) {
4681 4681
                 return true;
4682
-    	    }
4682
+            }
4683 4683
         } else {
4684
-        	return false;
4684
+            return false;
4685 4685
         }
4686
-	} else {
4687
-	    // check image manually
4686
+    } else {
4687
+        // check image manually
4688 4688
         $fp = fopen($path, "rb");
4689 4689
         if(!$fp) return false;
4690 4690
         $data = '';
@@ -4693,15 +4693,15 @@  discard block
 block discarded – undo
4693 4693
             $data .= fread($fp,8192);
4694 4694
         }
4695 4695
 
4696
-	    fclose($fp);
4697
-	    if(preg_match("/<(\?php|html|!doctype|script|body|head|plaintext|table|img |pre(>| )|frameset|iframe|object|link|base|style|font|applet|meta|center|form|isindex)/i",
4698
-	         $data, $m)) {
4699
-	        $GLOBALS['log']->fatal("Found {$m[0]} in $path, not allowing upload");
4700
-	        return false;
4701
-	    }
4702
-	    return true;
4703
-	}
4704
-	return false;
4696
+        fclose($fp);
4697
+        if(preg_match("/<(\?php|html|!doctype|script|body|head|plaintext|table|img |pre(>| )|frameset|iframe|object|link|base|style|font|applet|meta|center|form|isindex)/i",
4698
+                $data, $m)) {
4699
+            $GLOBALS['log']->fatal("Found {$m[0]} in $path, not allowing upload");
4700
+            return false;
4701
+        }
4702
+        return true;
4703
+    }
4704
+    return false;
4705 4705
 }
4706 4706
 
4707 4707
 /**
@@ -4718,16 +4718,16 @@  discard block
 block discarded – undo
4718 4718
     }
4719 4719
 
4720 4720
     if(!file_exists($path) || !is_file($path)) {
4721
-	    return false;
4722
-	}
4721
+        return false;
4722
+    }
4723 4723
 
4724
-	$img_size = getimagesize($path);
4725
-	$filetype = $img_size['mime'];
4726
-	$ext = end(explode(".", $path));
4727
-	if(substr_count('..', $path) > 0 || ($ext !== $path && !isset($supportedExtensions[strtolower($ext)])) ||
4728
-	    !in_array($filetype, array_values($supportedExtensions))) {
4729
-	        return false;
4730
-	}
4724
+    $img_size = getimagesize($path);
4725
+    $filetype = $img_size['mime'];
4726
+    $ext = end(explode(".", $path));
4727
+    if(substr_count('..', $path) > 0 || ($ext !== $path && !isset($supportedExtensions[strtolower($ext)])) ||
4728
+        !in_array($filetype, array_values($supportedExtensions))) {
4729
+            return false;
4730
+    }
4731 4731
     return verify_image_file($path, $jpeg_only);
4732 4732
 }
4733 4733
 
@@ -4779,7 +4779,7 @@  discard block
 block discarded – undo
4779 4779
     if (isset($GLOBALS['sugar_config']['search_wildcard_infront']) &&
4780 4780
         $GLOBALS['sugar_config']['search_wildcard_infront'] == true) {
4781 4781
         if (substr($str,0,1) <> $wildcard)
4782
-          $str = $wildcard.$str;
4782
+            $str = $wildcard.$str;
4783 4783
     }
4784 4784
 
4785 4785
     // add wildcard at the end of search string (default)
@@ -4794,7 +4794,7 @@  discard block
 block discarded – undo
4794 4794
 
4795 4795
 //check to see if custom utils exists
4796 4796
 if(file_exists('custom/include/custom_utils.php')){
4797
-	include_once('custom/include/custom_utils.php');
4797
+    include_once('custom/include/custom_utils.php');
4798 4798
 }
4799 4799
 
4800 4800
 //check to see if custom utils exists in Extension framework
@@ -4802,12 +4802,12 @@  discard block
 block discarded – undo
4802 4802
     include_once('custom/application/Ext/Utils/custom_utils.ext.php');
4803 4803
 }
4804 4804
 /**
4805
- * @param $input - the input string to sanitize
4806
- * @param int $quotes - use quotes
4807
- * @param string $charset - the default charset
4808
- * @param bool $remove - strip tags or not
4809
- * @return string - the sanitized string
4810
- */
4805
+     * @param $input - the input string to sanitize
4806
+     * @param int $quotes - use quotes
4807
+     * @param string $charset - the default charset
4808
+     * @param bool $remove - strip tags or not
4809
+     * @return string - the sanitized string
4810
+     */
4811 4811
 function sanitize($input, $quotes = ENT_QUOTES, $charset = 'UTF-8', $remove = false)
4812 4812
 {
4813 4813
     return htmlentities($input, $quotes, $charset);
@@ -4854,9 +4854,9 @@  discard block
 block discarded – undo
4854 4854
     $result = array();
4855 4855
     foreach($data as $key=>$val) {
4856 4856
         if(is_array($val)) {
4857
-           $result[$key] = utf8_recursive_encode($val);
4857
+            $result[$key] = utf8_recursive_encode($val);
4858 4858
         } else {
4859
-           $result[$key] = utf8_encode($val);
4859
+            $result[$key] = utf8_encode($val);
4860 4860
         }
4861 4861
     }
4862 4862
     return $result;
@@ -4938,18 +4938,18 @@  discard block
 block discarded – undo
4938 4938
  * @param string $etag ETag to use for this content.
4939 4939
  */
4940 4940
 function generateETagHeader($etag){
4941
-	header("cache-control:");
4942
-	header('Expires: ');
4943
-	header("ETag: " . $etag);
4944
-	header("Pragma:");
4945
-	if(isset($_SERVER["HTTP_IF_NONE_MATCH"])){
4946
-		if($etag == $_SERVER["HTTP_IF_NONE_MATCH"]){
4947
-			ob_clean();
4948
-			header("Status: 304 Not Modified");
4949
-			header("HTTP/1.0 304 Not Modified");
4950
-			die();
4951
-		}
4952
-	}
4941
+    header("cache-control:");
4942
+    header('Expires: ');
4943
+    header("ETag: " . $etag);
4944
+    header("Pragma:");
4945
+    if(isset($_SERVER["HTTP_IF_NONE_MATCH"])){
4946
+        if($etag == $_SERVER["HTTP_IF_NONE_MATCH"]){
4947
+            ob_clean();
4948
+            header("Status: 304 Not Modified");
4949
+            header("HTTP/1.0 304 Not Modified");
4950
+            die();
4951
+        }
4952
+    }
4953 4953
 }
4954 4954
 
4955 4955
 /**
@@ -4962,22 +4962,22 @@  discard block
 block discarded – undo
4962 4962
  * @return string translated report name
4963 4963
  */
4964 4964
 function getReportNameTranslation($reportName) {
4965
-	global $current_language;
4965
+    global $current_language;
4966 4966
 
4967
-	// Used for translating reports
4967
+    // Used for translating reports
4968 4968
     $mod_strings = return_module_language($current_language, 'Reports');
4969 4969
 
4970
-	// Search for the report name in the default language and get the key
4971
-	$key = array_search($reportName, return_module_language("", "Reports"));
4970
+    // Search for the report name in the default language and get the key
4971
+    $key = array_search($reportName, return_module_language("", "Reports"));
4972 4972
 
4973
-	// If the key was found, use it to get a translation, otherwise just use report name
4974
-	if (!empty($key)) {
4975
-		$title = $mod_strings[$key];
4976
-	} else {
4977
-		$title = $reportName;
4978
-	}
4973
+    // If the key was found, use it to get a translation, otherwise just use report name
4974
+    if (!empty($key)) {
4975
+        $title = $mod_strings[$key];
4976
+    } else {
4977
+        $title = $reportName;
4978
+    }
4979 4979
 
4980
-	return $title;
4980
+    return $title;
4981 4981
 }
4982 4982
 
4983 4983
 /**
@@ -5085,47 +5085,47 @@  discard block
 block discarded – undo
5085 5085
 
5086 5086
 function suite_strlen($input, $encoding = DEFAULT_UTIL_SUITE_ENCODING)
5087 5087
 {
5088
-	if(function_exists('mb_strlen'))
5089
-		return mb_strlen($input,$encoding);
5090
-	else
5091
-		return strlen($input);
5088
+    if(function_exists('mb_strlen'))
5089
+        return mb_strlen($input,$encoding);
5090
+    else
5091
+        return strlen($input);
5092 5092
 }
5093 5093
 
5094 5094
 function suite_substr($input, $start, $length = null,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5095 5095
 {
5096
-	if(function_exists('mb_substr'))
5097
-		return mb_substr($input,$start,$length,$encoding);
5098
-	else
5099
-		return substr($input,$start,$length);
5096
+    if(function_exists('mb_substr'))
5097
+        return mb_substr($input,$start,$length,$encoding);
5098
+    else
5099
+        return substr($input,$start,$length);
5100 5100
 }
5101 5101
 
5102 5102
 function suite_strtoupper($input,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5103 5103
 {
5104
-	if(function_exists('mb_strtoupper'))
5105
-		return mb_strtoupper($input,$encoding);
5106
-	else
5107
-		return strtoupper($input);
5104
+    if(function_exists('mb_strtoupper'))
5105
+        return mb_strtoupper($input,$encoding);
5106
+    else
5107
+        return strtoupper($input);
5108 5108
 }
5109 5109
 function suite_strtolower($input,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5110 5110
 {
5111
-	if(function_exists('mb_strtolower'))
5112
-		return mb_strtolower($input,$encoding);
5113
-	else
5114
-		return strtolower($input);
5111
+    if(function_exists('mb_strtolower'))
5112
+        return mb_strtolower($input,$encoding);
5113
+    else
5114
+        return strtolower($input);
5115 5115
 }
5116 5116
 
5117 5117
 function suite_strpos($haystack,$needle,$offset=0,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5118 5118
 {
5119
-	if(function_exists('mb_strpos'))
5120
-		return mb_strpos($haystack,$needle,$offset,$encoding);
5121
-	else
5122
-		return strpos($haystack,$needle,$offset);
5119
+    if(function_exists('mb_strpos'))
5120
+        return mb_strpos($haystack,$needle,$offset,$encoding);
5121
+    else
5122
+        return strpos($haystack,$needle,$offset);
5123 5123
 }
5124 5124
 
5125 5125
 function suite_strrpos($haystack,$needle,$offset=0,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5126 5126
 {
5127
-	if(function_exists('mb_strrpos'))
5128
-		return mb_strrpos($haystack,$needle,$offset,$encoding);
5129
-	else
5130
-		return strrpos($haystack,$needle,$offset);
5127
+    if(function_exists('mb_strrpos'))
5128
+        return mb_strrpos($haystack,$needle,$offset,$encoding);
5129
+    else
5130
+        return strrpos($haystack,$needle,$offset);
5131 5131
 }
5132 5132
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +688 added lines, -688 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	// assumes the following variables must be set:
106 106
 	// $dbconfig, $dbconfigoption, $cache_dir,  $session_dir, $site_URL, $upload_dir
107 107
 
108
-	$sugar_config = array (
108
+	$sugar_config = array(
109 109
 	'admin_export_only' => empty($admin_export_only) ? false : $admin_export_only,
110 110
 	'export_delimiter' => empty($export_delimiter) ? ',' : $export_delimiter,
111 111
 	'cache_dir' => empty($cache_dir) ? 'cache/' : $cache_dir,
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	'd.m.Y' => '23.12.2010',
124 124
 	'm.d.Y' => '12.23.2010'
125 125
 		) : $dateFormats,
126
-	'dbconfig' => $dbconfig,  // this must be set!!
127
-	'dbconfigoption' => $dbconfigoption,  // this must be set!!
126
+	'dbconfig' => $dbconfig, // this must be set!!
127
+	'dbconfigoption' => $dbconfigoption, // this must be set!!
128 128
 	'default_action' => empty($default_action) ? 'index' : $default_action,
129 129
 	'default_charset' => empty($default_charset) ? 'UTF-8' : $default_charset,
130 130
 	'default_currency_name' => empty($default_currency_name) ? 'US Dollar' : $default_currency_name,
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	'default_language' => empty($default_language) ? 'en_us' : $default_language,
137 137
 	'default_module' => empty($default_module) ? 'Home' : $default_module,
138 138
 	'default_password' => empty($default_password) ? '' : $default_password,
139
-	'default_permissions' => array (
139
+	'default_permissions' => array(
140 140
 		'dir_mode' => 02770,
141 141
 		'file_mode' => 0755,
142 142
 		'chown' => '',
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	'display_inbound_email_buttons' => empty($display_inbound_email_buttons) ? false : $display_inbound_email_buttons,
153 153
 	'history_max_viewed' => empty($history_max_viewed) ? 50 : $history_max_viewed,
154 154
 	'host_name' => empty($host_name) ? 'localhost' : $host_name,
155
-	'import_dir' => $import_dir,  // this must be set!!
155
+	'import_dir' => $import_dir, // this must be set!!
156 156
 	'import_max_records_per_file' => 100,
157 157
     'import_max_records_total_limit' => '',
158 158
 	'languages' => empty($languages) ? array('en_us' => 'English (US)') : $languages,
@@ -165,34 +165,34 @@  discard block
 block discarded – undo
165 165
         'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s'
166 166
     ) : $nameFormats,
167 167
     'portal_view' => 'single_user',
168
-	'resource_management' => array (
168
+	'resource_management' => array(
169 169
 	    'special_query_limit' => 50000,
170 170
 	    'special_query_modules' => array('Reports', 'Export', 'Import', 'Administration', 'Sync'),
171 171
 	    'default_limit' => 1000,
172 172
     ),
173 173
 	'require_accounts' => empty($requireAccounts) ? true : $requireAccounts,
174 174
 	'rss_cache_time' => empty($RSS_CACHE_TIME) ? '10800' : $RSS_CACHE_TIME,
175
-	'session_dir' => $session_dir,  // this must be set!!
176
-	'site_url' => empty($site_URL) ? $site_url : $site_URL,  // this must be set!!
175
+	'session_dir' => $session_dir, // this must be set!!
176
+	'site_url' => empty($site_URL) ? $site_url : $site_URL, // this must be set!!
177 177
 	'showDetailData' => true, // if true, read-only ACL fields will still appear on EditViews as non-editable
178 178
 	'showThemePicker' => true,
179 179
 	'sugar_version' => empty($sugar_version) ? 'unknown' : $sugar_version,
180
-	'time_formats' => empty($timeFormats) ? array (
180
+	'time_formats' => empty($timeFormats) ? array(
181 181
 	'H:i'=>'23:00', 'h:ia'=>'11:00 pm', 'h:iA'=>'11:00PM',
182 182
 	'H.i'=>'23.00', 'h.ia'=>'11.00 pm', 'h.iA'=>'11.00PM' ) : $timeFormats,
183
-	'tmp_dir' => $tmp_dir,  // this must be set!!
183
+	'tmp_dir' => $tmp_dir, // this must be set!!
184 184
 	'translation_string_prefix' => empty($translation_string_prefix) ? false : $translation_string_prefix,
185 185
 	'unique_key' => empty($unique_key) ? md5(create_guid()) : $unique_key,
186
-	'upload_badext' => empty($upload_badext) ? array (
186
+	'upload_badext' => empty($upload_badext) ? array(
187 187
 	'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py',
188 188
 	'asp', 'cfm', 'js', 'vbs', 'html', 'htm' ) : $upload_badext,
189
-	'upload_dir' => $upload_dir,  // this must be set!!
189
+	'upload_dir' => $upload_dir, // this must be set!!
190 190
 	'upload_maxsize' => empty($upload_maxsize) ? 30000000 : $upload_maxsize,
191 191
 	'import_max_execution_time' => empty($import_max_execution_time) ? 3600 : $import_max_execution_time,
192 192
 	'lock_homepage' => false,
193 193
 	'lock_subpanels' => false,
194 194
 	'max_dashlets_homepage' => 15,
195
-	'dashlet_display_row_options' => array('1','3','5','10'),
195
+	'dashlet_display_row_options' => array('1', '3', '5', '10'),
196 196
 	'default_max_tabs' => empty($max_tabs) ? '7' : $max_tabs,
197 197
 	'default_subpanel_tabs' =>  empty($subpanel_tabs) ? true : $subpanel_tabs,
198 198
 	'default_subpanel_links' => empty($subpanel_links) ? false : $subpanel_links,
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	'default_navigation_paradigm' => empty($navigation_paradigm) ? 'gm' : $navigation_paradigm,
202 202
     'default_call_status' => 'Planned',
203 203
 	'js_lang_version' => 1,
204
-	'passwordsetting' => empty($passwordsetting) ? array (
204
+	'passwordsetting' => empty($passwordsetting) ? array(
205 205
 	    'SystemGeneratedPasswordON' => '',
206 206
 	    'generatepasswordtmpl' => '',
207 207
 	    'lostpasswordtmpl' => '',
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * sugar_config_union
241 241
 	 */
242 242
 
243
-	$sugar_config_defaults = array (
243
+	$sugar_config_defaults = array(
244 244
 	'admin_export_only' => false,
245 245
 	'export_delimiter' => ',',
246 246
 	'export_excel_compatible' => false,
@@ -248,15 +248,15 @@  discard block
 block discarded – undo
248 248
 	'calculate_response_time' => true,
249 249
 	'create_default_user' => false,
250 250
  	'chartEngine' => 'Jit',
251
-	'date_formats' => array (
251
+	'date_formats' => array(
252 252
 	'Y-m-d' => '2010-12-23', 'm-d-Y' => '12-23-2010', 'd-m-Y' => '23-12-2010',
253 253
 	'Y/m/d' => '2010/12/23', 'm/d/Y' => '12/23/2010', 'd/m/Y' => '23/12/2010',
254 254
 	'Y.m.d' => '2010.12.23', 'd.m.Y' => '23.12.2010', 'm.d.Y' => '12.23.2010',),
255
-    'name_formats' => array (
255
+    'name_formats' => array(
256 256
         's f l' => 's f l', 'f l' => 'f l', 's l' => 's l', 'l, s f' => 'l, s f',
257 257
         'l, f' => 'l, f', 's l, f' => 's l, f', 'l s f' => 'l s f', 'l f s' => 'l f s'
258 258
     ),
259
-	'dbconfigoption' => array (
259
+	'dbconfigoption' => array(
260 260
 	'persistent' => true,
261 261
 	'autofree' => false,
262 262
 	'debug' => 0,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	'en_us'),
278 278
 	'default_module' => 'Home',
279 279
 	'default_password' => '',
280
-	'default_permissions' => array (
280
+	'default_permissions' => array(
281 281
 		'dir_mode' => 02770,
282 282
 		'file_mode' => 0755,
283 283
 		'user' => '',
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	'lock_default_user_name' => false,
310 310
 	'log_memory_usage' => false,
311 311
 	'portal_view' => 'single_user',
312
-    'resource_management' => array (
312
+    'resource_management' => array(
313 313
 	    'special_query_limit' => 50000,
314 314
 	    'special_query_modules' => array('Reports', 'Export', 'Import', 'Administration', 'Sync'),
315 315
 	    'default_limit' => 1000,
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
 	'showThemePicker' => true,
323 323
 	'slow_query_time_msec' => '100',
324 324
     'sugarbeet' => true,
325
-    'time_formats' => array (
325
+    'time_formats' => array(
326 326
         'H:i'=>'23:00', 'h:ia'=>'11:00pm', 'h:iA'=>'11:00PM', 'h:i a'=>'11:00 pm', 'h:i A'=>'11:00 PM',
327 327
         'H.i'=>'23.00', 'h.ia'=>'11.00pm', 'h.iA'=>'11.00PM', 'h.i a'=>'11.00 pm', 'h.i A'=>'11.00 PM' ),
328 328
     'tracker_max_display_length' => 15,
329 329
 	'translation_string_prefix' =>
330 330
 	return_session_value_or_default('translation_string_prefix', false),
331
-	'upload_badext' => array (
331
+	'upload_badext' => array(
332 332
 	'php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py',
333 333
 	'asp', 'cfm', 'js', 'vbs', 'html', 'htm', 'phtml' ),
334 334
 	'upload_maxsize' => 30000000,
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	'lock_subpanels' => false,
345 345
 	'max_dashlets_homepage' => '15',
346 346
 	'default_max_tabs' => '7',
347
-	'dashlet_display_row_options' => array('1','3','5','10'),
347
+	'dashlet_display_row_options' => array('1', '3', '5', '10'),
348 348
 	'default_subpanel_tabs' =>  true,
349 349
 	'default_subpanel_links' => false,
350 350
 	'default_swap_last_viewed' => false,
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	  'enable_repeat' => true,
369 369
 	  'max_repeat_count' => 1000,
370 370
 	),
371
-	'passwordsetting' => empty($passwordsetting) ? array (
371
+	'passwordsetting' => empty($passwordsetting) ? array(
372 372
 	    'SystemGeneratedPasswordON' => '',
373 373
 	    'generatepasswordtmpl' => '',
374 374
 	    'lostpasswordtmpl' => '',
@@ -397,31 +397,31 @@  discard block
 block discarded – undo
397 397
 		),
398 398
     );
399 399
 
400
-	if(!is_object($locale)) {
400
+	if (!is_object($locale)) {
401 401
 		$locale = new Localization();
402 402
 	}
403 403
 
404 404
 	$sugar_config_defaults['default_currencies'] = $locale->getDefaultCurrencies();
405 405
 
406 406
 	$sugar_config_defaults = sugarArrayMerge($locale->getLocaleConfigDefaults(), $sugar_config_defaults);
407
-	return( $sugar_config_defaults );
407
+	return($sugar_config_defaults);
408 408
 }
409 409
 
410 410
 /**
411 411
  * @deprecated use SugarView::getMenu() instead
412 412
  */
413
-function load_menu($path){
413
+function load_menu($path) {
414 414
 	global $module_menu;
415 415
 
416
-	if(file_exists($path . 'Menu.php'))
416
+	if (file_exists($path.'Menu.php'))
417 417
 	{
418
-		require($path . 'Menu.php');
418
+		require($path.'Menu.php');
419 419
 	}
420
-	if(file_exists('custom/' . $path . 'Ext/Menus/menu.ext.php'))
420
+	if (file_exists('custom/'.$path.'Ext/Menus/menu.ext.php'))
421 421
 	{
422
-		require('custom/' . $path . 'Ext/Menus/menu.ext.php');
422
+		require('custom/'.$path.'Ext/Menus/menu.ext.php');
423 423
 	}
424
-	if(file_exists('custom/application/Ext/Menus/menu.ext.php'))
424
+	if (file_exists('custom/application/Ext/Menus/menu.ext.php'))
425 425
 	{
426 426
 		require('custom/application/Ext/Menus/menu.ext.php');
427 427
 	}
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
  *
435 435
  * @return string relative file path to email notifications template file
436 436
  */
437
-function get_notify_template_file($language){
437
+function get_notify_template_file($language) {
438 438
 	/*
439 439
 	 * Order of operation:
440 440
 	 * 1) custom version of specified language
@@ -446,43 +446,43 @@  discard block
 block discarded – undo
446 446
 	// set $file to the base code template so it's set if none of the conditions pass
447 447
 	$file = "include/language/en_us.notify_template.html";
448 448
 
449
-	if(file_exists("custom/include/language/{$language}.notify_template.html")){
449
+	if (file_exists("custom/include/language/{$language}.notify_template.html")) {
450 450
 		$file = "custom/include/language/{$language}.notify_template.html";
451 451
 	}
452
-	else if(file_exists("include/language/{$language}.notify_template.html")){
452
+	else if (file_exists("include/language/{$language}.notify_template.html")) {
453 453
 		$file = "include/language/{$language}.notify_template.html";
454 454
 	}
455
-	else if(file_exists("custom/include/language/en_us.notify_template.html")){
455
+	else if (file_exists("custom/include/language/en_us.notify_template.html")) {
456 456
 		$file = "custom/include/language/en_us.notify_template.html";
457 457
 	}
458 458
 
459 459
 	return $file;
460 460
 }
461 461
 
462
-function sugar_config_union( $default, $override ){
462
+function sugar_config_union($default, $override) {
463 463
 	// a little different then array_merge and array_merge_recursive.  we want
464 464
 	// the second array to override the first array if the same value exists,
465 465
 	// otherwise merge the unique keys.  it handles arrays of arrays recursively
466 466
 	// might be suitable for a generic array_union
467
-	if( !is_array( $override ) ){
467
+	if (!is_array($override)) {
468 468
 		$override = array();
469 469
 	}
470
-	foreach( $default as $key => $value ){
471
-		if( !array_key_exists($key, $override) ){
470
+	foreach ($default as $key => $value) {
471
+		if (!array_key_exists($key, $override)) {
472 472
 			$override[$key] = $value;
473 473
 		}
474
-		else if( is_array( $key ) ){
475
-			$override[$key] = sugar_config_union( $value, $override[$key] );
474
+		else if (is_array($key)) {
475
+			$override[$key] = sugar_config_union($value, $override[$key]);
476 476
 		}
477 477
 	}
478
-	return( $override );
478
+	return($override);
479 479
 }
480 480
 
481
-function make_not_writable( $file ){
481
+function make_not_writable($file) {
482 482
 	// Returns true if the given file/dir has been made not writable
483 483
 	$ret_val = false;
484
-	if( is_file($file) || is_dir($file) ){
485
-		if( !is_writable($file) ){
484
+	if (is_file($file) || is_dir($file)) {
485
+		if (!is_writable($file)) {
486 486
 			$ret_val = true;
487 487
 		}
488 488
 		else {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 			$new_fileperms = $original_fileperms & ~0x0092;
493 493
 			@sugar_chmod($file, $new_fileperms);
494 494
 
495
-			if( !is_writable($file) ){
495
+			if (!is_writable($file)) {
496 496
 				$ret_val = true;
497 497
 			}
498 498
 		}
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 	$last_name = "";
516 516
 	$full_name = "";
517 517
 
518
-	if(isset($row[$first_column]))
518
+	if (isset($row[$first_column]))
519 519
 	{
520 520
 		$first_name = stripslashes($row[$first_column]);
521 521
 	}
522 522
 
523
-	if(isset($row[$last_column]))
523
+	if (isset($row[$last_column]))
524 524
 	{
525 525
 		$last_name = stripslashes($row[$last_column]);
526 526
 	}
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 	$full_name = $first_name;
529 529
 
530 530
 	// If we have a first name and we have a last name
531
-	if($full_name != "" && $last_name != "")
531
+	if ($full_name != "" && $last_name != "")
532 532
 	{
533 533
 		// append a space, then the last name
534 534
 		$full_name .= " ".$last_name;
535 535
 	}
536 536
 	// If we have no first name, but we have a last name
537
-	else if($last_name != "")
537
+	else if ($last_name != "")
538 538
 	{
539 539
 		// append the last name without the space.
540 540
 		$full_name .= $last_name;
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 {
549 549
 	global $sugar_config;
550 550
 	$lang = $sugar_config['languages'];
551
-    if(!empty($sugar_config['disabled_languages'])){
552
-        foreach(explode(',', $sugar_config['disabled_languages']) as $disable) {
551
+    if (!empty($sugar_config['disabled_languages'])) {
552
+        foreach (explode(',', $sugar_config['disabled_languages']) as $disable) {
553 553
             unset($lang[$disable]);
554 554
         }
555 555
     }
@@ -572,11 +572,11 @@  discard block
 block discarded – undo
572 572
 function get_assigned_user_name($assigned_user_id, $is_group = '') {
573 573
 	static $saved_user_list = null;
574 574
 
575
-	if(empty($saved_user_list)) {
575
+	if (empty($saved_user_list)) {
576 576
 		$saved_user_list = get_user_array(false, '', '', false, null, $is_group);
577 577
 	}
578 578
 
579
-	if(isset($saved_user_list[$assigned_user_id])) {
579
+	if (isset($saved_user_list[$assigned_user_id])) {
580 580
 		return $saved_user_list[$assigned_user_id];
581 581
 	}
582 582
 
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 function get_user_name($id) {
592 592
 	global $db;
593 593
 
594
-	if(empty($db))
594
+	if (empty($db))
595 595
 	$db = DBManagerFactory::getInstance();
596 596
 
597 597
 	$q = "SELECT user_name FROM users WHERE id='{$id}'";
@@ -619,19 +619,19 @@  discard block
 block discarded – undo
619 619
  * @param bool $from_cache Boolean value indicating whether or not to use the get_register_value function for caching, true by default
620 620
  * @return array Array of users matching the filter criteria that may be from cache (if similar search was previously run)
621 621
  */
622
-function get_user_array($add_blank=true, $status="Active", $user_id='', $use_real_name=false, $user_name_filter='', $portal_filter=' AND portal_only=0 ', $from_cache = true) {
622
+function get_user_array($add_blank = true, $status = "Active", $user_id = '', $use_real_name = false, $user_name_filter = '', $portal_filter = ' AND portal_only=0 ', $from_cache = true) {
623 623
 	global $locale, $sugar_config, $current_user;
624 624
 
625
-	if(empty($locale)) {
625
+	if (empty($locale)) {
626 626
 		$locale = new Localization();
627 627
 	}
628 628
 
629
-	if($from_cache) {
630
-        $key_name = $add_blank. $status . $user_id . $use_real_name . $user_name_filter . $portal_filter;
629
+	if ($from_cache) {
630
+        $key_name = $add_blank.$status.$user_id.$use_real_name.$user_name_filter.$portal_filter;
631 631
 		$user_array = get_register_value('user_array', $key_name);
632 632
     }
633 633
 
634
-	if(empty($user_array)) {
634
+	if (empty($user_array)) {
635 635
 		$db = DBManagerFactory::getInstance();
636 636
 		$temp_result = Array();
637 637
 		// Including deleted users for now.
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 		}
644 644
         /* BEGIN - SECURITY GROUPS */
645 645
         global $current_user, $sugar_config;
646
-        if(!is_admin($current_user)
646
+        if (!is_admin($current_user)
647 647
             && isset($sugar_config['securitysuite_filter_user_list'])
648 648
             && $sugar_config['securitysuite_filter_user_list'] == true
649 649
             && (empty($_REQUEST['module']) || $_REQUEST['module'] != 'Home')
@@ -664,21 +664,21 @@  discard block
 block discarded – undo
664 664
 		}
665 665
 
666 666
         //get the user preference for name formatting, to be used in order by
667
-        $order_by_string =' user_name ASC ';
668
-        if(!empty($current_user) && !empty($current_user->id))
667
+        $order_by_string = ' user_name ASC ';
668
+        if (!empty($current_user) && !empty($current_user->id))
669 669
         {
670 670
             $formatString = $current_user->getPreference('default_locale_name_format');
671 671
 
672 672
             //create the order by string based on position of first and last name in format string
673
-            $order_by_string =' user_name ASC ';
674
-            $firstNamePos = strpos( $formatString, 'f');
675
-            $lastNamePos = strpos( $formatString, 'l');
676
-            if($firstNamePos !== false || $lastNamePos !== false){
673
+            $order_by_string = ' user_name ASC ';
674
+            $firstNamePos = strpos($formatString, 'f');
675
+            $lastNamePos = strpos($formatString, 'l');
676
+            if ($firstNamePos !== false || $lastNamePos !== false) {
677 677
                 //its possible for first name to be skipped, check for this
678
-                if($firstNamePos===false){
679
-                    $order_by_string =  'last_name ASC';
680
-                }else{
681
-                    $order_by_string =  ($lastNamePos < $firstNamePos) ? "last_name, first_name ASC" : "first_name, last_name ASC";
678
+                if ($firstNamePos === false) {
679
+                    $order_by_string = 'last_name ASC';
680
+                } else {
681
+                    $order_by_string = ($lastNamePos < $firstNamePos) ? "last_name, first_name ASC" : "first_name, last_name ASC";
682 682
                 }
683 683
             }
684 684
         }
@@ -687,16 +687,16 @@  discard block
 block discarded – undo
687 687
 		$GLOBALS['log']->debug("get_user_array query: $query");
688 688
 		$result = $db->query($query, true, "Error filling in user array: ");
689 689
 
690
-		if ($add_blank==true) {
690
+		if ($add_blank == true) {
691 691
 			// Add in a blank row
692 692
 			$temp_result[''] = '';
693 693
 		}
694 694
 
695 695
 		// Get the id and the name.
696
-		while($row = $db->fetchByAssoc($result)) {
697
-			if($use_real_name == true || showFullName()) {
698
-				if(isset($row['last_name'])) { // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
699
-					$temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'],$row['last_name']);
696
+		while ($row = $db->fetchByAssoc($result)) {
697
+			if ($use_real_name == true || showFullName()) {
698
+				if (isset($row['last_name'])) { // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
699
+					$temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
700 700
 				} else {
701 701
 					$temp_result[$row['id']] = $row['user_name'];
702 702
 				}
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 		}
707 707
 
708 708
 		$user_array = $temp_result;
709
-		if($from_cache)
709
+		if ($from_cache)
710 710
         {
711 711
 			set_register_value('user_array', $key_name, $temp_result);
712 712
         }
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
             $inClauses[] = "(first_name LIKE '{$arg}%' OR last_name LIKE '{$arg}%')";
747 747
         }
748 748
 
749
-        $inClause = '(' . implode('OR ', $inClauses) . ')';
749
+        $inClause = '('.implode('OR ', $inClauses).')';
750 750
 
751 751
     } else {
752 752
         $args = $db->quote($args);
@@ -754,14 +754,14 @@  discard block
 block discarded – undo
754 754
     }
755 755
     // ~jmorais@dri
756 756
 
757
-	$query  = "SELECT id, first_name, last_name, user_name FROM users WHERE status='Active' AND deleted=0 AND ";
758
-	if ( $hide_portal_users ) {
757
+	$query = "SELECT id, first_name, last_name, user_name FROM users WHERE status='Active' AND deleted=0 AND ";
758
+	if ($hide_portal_users) {
759 759
 	    $query .= " portal_only=0 AND ";
760 760
 	}
761 761
 	$query .= $inClause;
762 762
     /* BEGIN - SECURITY GROUPS */
763 763
     global $current_user, $sugar_config;
764
-    if(!is_admin($current_user)
764
+    if (!is_admin($current_user)
765 765
         && isset($sugar_config['securitysuite_filter_user_list'])
766 766
         && $sugar_config['securitysuite_filter_user_list'] == true
767 767
     ) {
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 
776 776
 	$r = $db->query($query);
777 777
 	$ret = array();
778
-	while($a = $db->fetchByAssoc($r)) {
778
+	while ($a = $db->fetchByAssoc($r)) {
779 779
 		$ret[$a['id']] = $locale->getLocaleFormattedName($a['first_name'], $a['last_name']);
780 780
 	}
781 781
 
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 		$sysPref = !empty($sugar_config['use_real_names']);
796 796
 		$userPref = (is_object($current_user)) ? $current_user->getPreference('use_real_names') : null;
797 797
 
798
-		if($userPref != null) {
798
+		if ($userPref != null) {
799 799
 			$showFullName = ($userPref == 'on');
800 800
 		} else {
801 801
 			$showFullName = $sysPref;
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 
854 854
 	// Check for cached value
855 855
 	$cache_entry = sugar_cache_retrieve($cache_key);
856
-	if(!empty($cache_entry))
856
+	if (!empty($cache_entry))
857 857
 	{
858 858
 		return $cache_entry;
859 859
 	}
@@ -872,17 +872,17 @@  discard block
 block discarded – undo
872 872
 
873 873
 	$app_list_strings_array = array();
874 874
 
875
-	foreach ( $langs as $lang ) {
875
+	foreach ($langs as $lang) {
876 876
 	    $app_list_strings = array();
877
-	    if(file_exists("include/language/$lang.lang.php")) {
877
+	    if (file_exists("include/language/$lang.lang.php")) {
878 878
             include("include/language/$lang.lang.php");
879 879
             $GLOBALS['log']->info("Found language file: $lang.lang.php");
880 880
         }
881
-        if(file_exists("include/language/$lang.lang.override.php")) {
881
+        if (file_exists("include/language/$lang.lang.override.php")) {
882 882
             include("include/language/$lang.lang.override.php");
883 883
             $GLOBALS['log']->info("Found override language file: $lang.lang.override.php");
884 884
         }
885
-        if(file_exists("include/language/$lang.lang.php.override")) {
885
+        if (file_exists("include/language/$lang.lang.php.override")) {
886 886
             include("include/language/$lang.lang.php.override");
887 887
             $GLOBALS['log']->info("Found override language file: $lang.lang.php.override");
888 888
         }
@@ -891,22 +891,22 @@  discard block
 block discarded – undo
891 891
     }
892 892
 
893 893
     $app_list_strings = array();
894
-    foreach ( $app_list_strings_array as $app_list_strings_item ) {
894
+    foreach ($app_list_strings_array as $app_list_strings_item) {
895 895
         $app_list_strings = sugarLangArrayMerge($app_list_strings, $app_list_strings_item);
896 896
     }
897 897
 
898
-    foreach ( $langs as $lang ) {
899
-        if(file_exists("custom/application/Ext/Language/$lang.lang.ext.php")) {
900
-            $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/$lang.lang.ext.php" , $app_list_strings);
898
+    foreach ($langs as $lang) {
899
+        if (file_exists("custom/application/Ext/Language/$lang.lang.ext.php")) {
900
+            $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/$lang.lang.ext.php", $app_list_strings);
901 901
             $GLOBALS['log']->info("Found extended language file: $lang.lang.ext.php");
902 902
         }
903
-        if(file_exists("custom/include/language/$lang.lang.php")) {
903
+        if (file_exists("custom/include/language/$lang.lang.php")) {
904 904
             include("custom/include/language/$lang.lang.php");
905 905
             $GLOBALS['log']->info("Found custom language file: $lang.lang.php");
906 906
         }
907 907
     }
908 908
 
909
-	if(!isset($app_list_strings)) {
909
+	if (!isset($app_list_strings)) {
910 910
 		$GLOBALS['log']->fatal("Unable to load the application language file for the selected language ($language) or the default language ($default_language) or the en_us language");
911 911
 		return null;
912 912
 	}
@@ -927,14 +927,14 @@  discard block
 block discarded – undo
927 927
  * @return array
928 928
  */
929 929
  //jchi 25347
930
-function _mergeCustomAppListStrings($file , $app_list_strings){
930
+function _mergeCustomAppListStrings($file, $app_list_strings) {
931 931
 	$app_list_strings_original = $app_list_strings;
932 932
 	unset($app_list_strings);
933 933
         // FG - bug 45525 - $exemptDropdown array is defined (once) here, not inside the foreach
934 934
         //                  This way, language file can add items to save specific standard codelist from being overwritten
935 935
         $exemptDropdowns = array();
936 936
 	include($file);
937
-	if(!isset($app_list_strings) || !is_array($app_list_strings)){
937
+	if (!isset($app_list_strings) || !is_array($app_list_strings)) {
938 938
 		return $app_list_strings_original;
939 939
 	}
940 940
 	//Bug 25347: We should not merge custom dropdown fields unless they relate to parent fields or the module list.
@@ -944,14 +944,14 @@  discard block
 block discarded – undo
944 944
 	$exemptDropdowns[] = "moduleListSingular";
945 945
         $exemptDropdowns = array_merge($exemptDropdowns, getTypeDisplayList());
946 946
 
947
-	foreach($app_list_strings as $key=>$value)
947
+	foreach ($app_list_strings as $key=>$value)
948 948
 	{
949 949
 		if (!in_array($key, $exemptDropdowns) && array_key_exists($key, $app_list_strings_original))
950 950
 		{
951 951
 	   		unset($app_list_strings_original["$key"]);
952 952
 		}
953 953
    }
954
-   $app_list_strings = sugarArrayMergeRecursive($app_list_strings_original , $app_list_strings);
954
+   $app_list_strings = sugarArrayMergeRecursive($app_list_strings_original, $app_list_strings);
955 955
    return $app_list_strings;
956 956
 }
957 957
 
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 
970 970
 	// Check for cached value
971 971
 	$cache_entry = sugar_cache_retrieve($cache_key);
972
-	if(!empty($cache_entry))
972
+	if (!empty($cache_entry))
973 973
 	{
974 974
 		return $cache_entry;
975 975
 	}
@@ -989,25 +989,25 @@  discard block
 block discarded – undo
989 989
 
990 990
 	$app_strings_array = array();
991 991
 
992
-	foreach ( $langs as $lang ) {
992
+	foreach ($langs as $lang) {
993 993
 	    $app_strings = array();
994
-	    if(file_exists("include/language/$lang.lang.php")) {
994
+	    if (file_exists("include/language/$lang.lang.php")) {
995 995
             include("include/language/$lang.lang.php");
996 996
             $GLOBALS['log']->info("Found language file: $lang.lang.php");
997 997
         }
998
-        if(file_exists("include/language/$lang.lang.override.php")) {
998
+        if (file_exists("include/language/$lang.lang.override.php")) {
999 999
             include("include/language/$lang.lang.override.php");
1000 1000
             $GLOBALS['log']->info("Found override language file: $lang.lang.override.php");
1001 1001
         }
1002
-        if(file_exists("include/language/$lang.lang.php.override")) {
1002
+        if (file_exists("include/language/$lang.lang.php.override")) {
1003 1003
             include("include/language/$lang.lang.php.override");
1004 1004
             $GLOBALS['log']->info("Found override language file: $lang.lang.php.override");
1005 1005
         }
1006
-        if(file_exists("custom/application/Ext/Language/$lang.lang.ext.php")) {
1006
+        if (file_exists("custom/application/Ext/Language/$lang.lang.ext.php")) {
1007 1007
             include("custom/application/Ext/Language/$lang.lang.ext.php");
1008 1008
             $GLOBALS['log']->info("Found extended language file: $lang.lang.ext.php");
1009 1009
         }
1010
-        if(file_exists("custom/include/language/$lang.lang.php")) {
1010
+        if (file_exists("custom/include/language/$lang.lang.php")) {
1011 1011
             include("custom/include/language/$lang.lang.php");
1012 1012
             $GLOBALS['log']->info("Found custom language file: $lang.lang.php");
1013 1013
         }
@@ -1015,23 +1015,23 @@  discard block
 block discarded – undo
1015 1015
 	}
1016 1016
 
1017 1017
 	$app_strings = array();
1018
-    foreach ( $app_strings_array as $app_strings_item ) {
1018
+    foreach ($app_strings_array as $app_strings_item) {
1019 1019
         $app_strings = sugarLangArrayMerge($app_strings, $app_strings_item);
1020 1020
     }
1021 1021
 
1022
-	if(!isset($app_strings)) {
1022
+	if (!isset($app_strings)) {
1023 1023
 		$GLOBALS['log']->fatal("Unable to load the application language strings");
1024 1024
 		return null;
1025 1025
 	}
1026 1026
 
1027 1027
 	// If we are in debug mode for translating, turn on the prefix now!
1028
-    if(!empty($sugar_config['translation_string_prefix']))
1028
+    if (!empty($sugar_config['translation_string_prefix']))
1029 1029
     {
1030
-		foreach($app_strings as $entry_key=>$entry_value) {
1030
+		foreach ($app_strings as $entry_key=>$entry_value) {
1031 1031
 			$app_strings[$entry_key] = $language.' '.$entry_value;
1032 1032
 		}
1033 1033
 	}
1034
-	if(isset($_SESSION['show_deleted'])) {
1034
+	if (isset($_SESSION['show_deleted'])) {
1035 1035
 		$app_strings['LBL_DELETE_BUTTON'] = $app_strings['LBL_UNDELETE_BUTTON'];
1036 1036
 		$app_strings['LBL_DELETE_BUTTON_LABEL'] = $app_strings['LBL_UNDELETE_BUTTON_LABEL'];
1037 1037
 		$app_strings['LBL_DELETE_BUTTON_TITLE'] = $app_strings['LBL_UNDELETE_BUTTON_TITLE'];
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
  * @param bool $refresh optional, true if you want to rebuild the language strings
1057 1057
  * @return array lang strings
1058 1058
  */
1059
-function return_module_language($language, $module, $refresh=false)
1059
+function return_module_language($language, $module, $refresh = false)
1060 1060
 {
1061 1061
 	global $mod_strings;
1062 1062
 	global $sugar_config;
@@ -1064,17 +1064,17 @@  discard block
 block discarded – undo
1064 1064
 
1065 1065
 	// Jenny - Bug 8119: Need to check if $module is not empty
1066 1066
 	if (empty($module)) {
1067
-		$stack  = debug_backtrace();
1068
-		$GLOBALS['log']->warn("Variable module is not in return_module_language ". var_export($stack, true));
1067
+		$stack = debug_backtrace();
1068
+		$GLOBALS['log']->warn("Variable module is not in return_module_language ".var_export($stack, true));
1069 1069
 		return array();
1070 1070
 	}
1071 1071
 
1072
-    if( !$refresh )
1072
+    if (!$refresh)
1073 1073
     {
1074 1074
         $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
1075 1075
         // Check for cached value
1076 1076
         $cache_entry = sugar_cache_retrieve($cache_key);
1077
-        if(!empty($cache_entry) && is_array($cache_entry))
1077
+        if (!empty($cache_entry) && is_array($cache_entry))
1078 1078
         {
1079 1079
             return $cache_entry;
1080 1080
         }
@@ -1085,43 +1085,43 @@  discard block
 block discarded – undo
1085 1085
 	$language_used = $language;
1086 1086
 	$default_language = $sugar_config['default_language'];
1087 1087
 
1088
-	if(empty($language)) {
1088
+	if (empty($language)) {
1089 1089
 		$language = $default_language;
1090 1090
 	}
1091 1091
 
1092 1092
 	// Bug 21559 - So we can get all the strings defined in the template, refresh
1093 1093
 	// the vardefs file if the cached language file doesn't exist.
1094
-    if(!file_exists(sugar_cached('modules/'). $module . '/language/'.$language.'.lang.php')
1095
-			&& !empty($GLOBALS['beanList'][$module])){
1094
+    if (!file_exists(sugar_cached('modules/').$module.'/language/'.$language.'.lang.php')
1095
+			&& !empty($GLOBALS['beanList'][$module])) {
1096 1096
 		$object = BeanFactory::getObjectName($module);
1097
-		VardefManager::refreshVardefs($module,$object);
1097
+		VardefManager::refreshVardefs($module, $object);
1098 1098
 	}
1099 1099
 
1100
-	$loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language,$refresh);
1100
+	$loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language, $refresh);
1101 1101
 
1102 1102
 	// cn: bug 6048 - merge en_us with requested language
1103
-	if($language != $sugar_config['default_language'])
1103
+	if ($language != $sugar_config['default_language'])
1104 1104
         $loaded_mod_strings = sugarLangArrayMerge(
1105
-            LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'],$refresh),
1105
+            LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'], $refresh),
1106 1106
                 $loaded_mod_strings
1107 1107
             );
1108 1108
 
1109 1109
     // Load in en_us strings by default
1110
-    if($language != 'en_us' && $sugar_config['default_language'] != 'en_us')
1110
+    if ($language != 'en_us' && $sugar_config['default_language'] != 'en_us')
1111 1111
         $loaded_mod_strings = sugarLangArrayMerge(
1112 1112
             LanguageManager::loadModuleLanguage($module, 'en_us', $refresh),
1113 1113
                 $loaded_mod_strings
1114 1114
             );
1115 1115
 
1116 1116
 	// If we are in debug mode for translating, turn on the prefix now!
1117
-	if($sugar_config['translation_string_prefix']) {
1118
-		foreach($loaded_mod_strings as $entry_key=>$entry_value) {
1117
+	if ($sugar_config['translation_string_prefix']) {
1118
+		foreach ($loaded_mod_strings as $entry_key=>$entry_value) {
1119 1119
 			$loaded_mod_strings[$entry_key] = $language_used.' '.$entry_value;
1120 1120
 		}
1121 1121
 	}
1122 1122
 
1123 1123
 	$return_value = $loaded_mod_strings;
1124
-	if(!isset($mod_strings)){
1124
+	if (!isset($mod_strings)) {
1125 1125
 		$mod_strings = $return_value;
1126 1126
 	}
1127 1127
 	else
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
  * All Rights Reserved.
1139 1139
  * Contributor(s): ______________________________________..
1140 1140
  * If you are using the current language, do not call this function unless you are loading it for the first time */
1141
-function return_mod_list_strings_language($language,$module) {
1141
+function return_mod_list_strings_language($language, $module) {
1142 1142
 	global $mod_list_strings;
1143 1143
 	global $sugar_config;
1144 1144
 	global $currentModule;
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
 	// Check for cached value
1149 1149
 	$cache_entry = sugar_cache_retrieve($cache_key);
1150
-	if(!empty($cache_entry))
1150
+	if (!empty($cache_entry))
1151 1151
 	{
1152 1152
 		return $cache_entry;
1153 1153
 	}
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 	$temp_mod_list_strings = $mod_list_strings;
1157 1157
 	$default_language = $sugar_config['default_language'];
1158 1158
 
1159
-	if($currentModule == $module && isset($mod_list_strings) && $mod_list_strings != null) {
1159
+	if ($currentModule == $module && isset($mod_list_strings) && $mod_list_strings != null) {
1160 1160
 		return $mod_list_strings;
1161 1161
 	}
1162 1162
 
@@ -1164,19 +1164,19 @@  discard block
 block discarded – undo
1164 1164
 	// cn: bug 6048 - merge en_us with requested language
1165 1165
 	include("modules/$module/language/en_us.lang.php");
1166 1166
 	$en_mod_list_strings = array();
1167
-	if($language_used != $default_language)
1167
+	if ($language_used != $default_language)
1168 1168
 	$en_mod_list_strings = $mod_list_strings;
1169 1169
 
1170
-	if(file_exists("modules/$module/language/$language.lang.php")) {
1170
+	if (file_exists("modules/$module/language/$language.lang.php")) {
1171 1171
 		include("modules/$module/language/$language.lang.php");
1172 1172
 	}
1173 1173
 
1174
-	if(file_exists("modules/$module/language/$language.lang.override.php")){
1174
+	if (file_exists("modules/$module/language/$language.lang.override.php")) {
1175 1175
 		include("modules/$module/language/$language.lang.override.php");
1176 1176
 	}
1177 1177
 
1178
-	if(file_exists("modules/$module/language/$language.lang.php.override")){
1179
-		echo 'Please Change:<br>' . "modules/$module/language/$language.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . "modules/$module/language/$language.lang.override.php";
1178
+	if (file_exists("modules/$module/language/$language.lang.php.override")) {
1179
+		echo 'Please Change:<br>'."modules/$module/language/$language.lang.php.override".'<br>to<br>'.'Please Change:<br>'."modules/$module/language/$language.lang.override.php";
1180 1180
 		include("modules/$module/language/$language.lang.php.override");
1181 1181
 	}
1182 1182
 
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 	$mod_list_strings = sugarLangArrayMerge($en_mod_list_strings, $mod_list_strings);
1185 1185
 
1186 1186
 	// if we still don't have a language pack, then log an error
1187
-	if(!isset($mod_list_strings)) {
1187
+	if (!isset($mod_list_strings)) {
1188 1188
 		$GLOBALS['log']->fatal("Unable to load the application list language file for the selected language($language) or the default language($default_language) for module({$module})");
1189 1189
 		return null;
1190 1190
 	}
@@ -1210,30 +1210,30 @@  discard block
 block discarded – undo
1210 1210
 	$default_language = $sugar_config['default_language'];
1211 1211
 
1212 1212
 	include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php");
1213
-	if(file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php")){
1213
+	if (file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php")) {
1214 1214
 		include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php");
1215 1215
 	}
1216
-	if(file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override")){
1217
-		echo 'Please Change:<br>' . SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php";
1216
+	if (file_exists(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override")) {
1217
+		echo 'Please Change:<br>'.SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override".'<br>to<br>'.'Please Change:<br>'.SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.override.php";
1218 1218
 		include(SugarThemeRegistry::get($theme)->getFilePath()."/language/$current_language.lang.php.override");
1219 1219
 	}
1220
-	if(!isset($theme_strings))
1220
+	if (!isset($theme_strings))
1221 1221
 	{
1222 1222
 		$GLOBALS['log']->warn("Unable to find the theme file for language: ".$language." and theme: ".$theme);
1223 1223
 		require(SugarThemeRegistry::get($theme)->getFilePath()."/language/$default_language.lang.php");
1224 1224
 		$language_used = $default_language;
1225 1225
 	}
1226 1226
 
1227
-	if(!isset($theme_strings))
1227
+	if (!isset($theme_strings))
1228 1228
 	{
1229 1229
 		$GLOBALS['log']->fatal("Unable to load the theme($theme) language file for the selected language($language) or the default language($default_language)");
1230 1230
 		return null;
1231 1231
 	}
1232 1232
 
1233 1233
 	// If we are in debug mode for translating, turn on the prefix now!
1234
-	if($sugar_config['translation_string_prefix'])
1234
+	if ($sugar_config['translation_string_prefix'])
1235 1235
 	{
1236
-		foreach($theme_strings as $entry_key=>$entry_value)
1236
+		foreach ($theme_strings as $entry_key=>$entry_value)
1237 1237
 		{
1238 1238
 			$theme_strings[$entry_key] = $language_used.' '.$entry_value;
1239 1239
 		}
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
  */
1252 1252
 function return_session_value_or_default($varname, $default)
1253 1253
 {
1254
-	if(isset($_SESSION[$varname]) && $_SESSION[$varname] != "")
1254
+	if (isset($_SESSION[$varname]) && $_SESSION[$varname] != "")
1255 1255
 	{
1256 1256
 		return $_SESSION[$varname];
1257 1257
 	}
@@ -1271,12 +1271,12 @@  discard block
 block discarded – undo
1271 1271
  */
1272 1272
 function append_where_clause(&$where_clauses, $variable_name, $SQL_name = null)
1273 1273
 {
1274
-	if($SQL_name == null)
1274
+	if ($SQL_name == null)
1275 1275
 	{
1276 1276
 		$SQL_name = $variable_name;
1277 1277
 	}
1278 1278
 
1279
-	if(isset($_REQUEST[$variable_name]) && $_REQUEST[$variable_name] != "")
1279
+	if (isset($_REQUEST[$variable_name]) && $_REQUEST[$variable_name] != "")
1280 1280
 	{
1281 1281
 		array_push($where_clauses, "$SQL_name like '".$GLOBALS['db']->quote($_REQUEST[$variable_name])."%'");
1282 1282
 	}
@@ -1293,9 +1293,9 @@  discard block
 block discarded – undo
1293 1293
 function generate_where_statement($where_clauses)
1294 1294
 {
1295 1295
 	$where = "";
1296
-	foreach($where_clauses as $clause)
1296
+	foreach ($where_clauses as $clause)
1297 1297
 	{
1298
-		if($where != "")
1298
+		if ($where != "")
1299 1299
 		$where .= " and ";
1300 1300
 		$where .= $clause;
1301 1301
 	}
@@ -1310,15 +1310,15 @@  discard block
 block discarded – undo
1310 1310
  * @return bool False on failure
1311 1311
  */
1312 1312
 function is_guid($guid) {
1313
-	if(strlen($guid) != 36) {
1313
+	if (strlen($guid) != 36) {
1314 1314
 		return false;
1315 1315
 	}
1316 1316
 
1317
-	if(preg_match("/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/i", $guid)) {
1317
+	if (preg_match("/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/i", $guid)) {
1318 1318
 		return true;
1319 1319
 	}
1320 1320
 
1321
-	return true;;
1321
+	return true; ;
1322 1322
 }
1323 1323
 
1324 1324
 
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 	$microTime = microtime();
1336 1336
 	list($a_dec, $a_sec) = explode(" ", $microTime);
1337 1337
 
1338
-	$dec_hex = dechex($a_dec* 1000000);
1338
+	$dec_hex = dechex($a_dec * 1000000);
1339 1339
 	$sec_hex = dechex($a_sec);
1340 1340
 
1341 1341
 	ensure_length($dec_hex, 5);
@@ -1361,9 +1361,9 @@  discard block
 block discarded – undo
1361 1361
 function create_guid_section($characters)
1362 1362
 {
1363 1363
 	$return = "";
1364
-	for($i=0; $i<$characters; $i++)
1364
+	for ($i = 0; $i < $characters; $i++)
1365 1365
 	{
1366
-		$return .= dechex(mt_rand(0,15));
1366
+		$return .= dechex(mt_rand(0, 15));
1367 1367
 	}
1368 1368
 	return $return;
1369 1369
 }
@@ -1371,11 +1371,11 @@  discard block
 block discarded – undo
1371 1371
 function ensure_length(&$string, $length)
1372 1372
 {
1373 1373
 	$strlen = strlen($string);
1374
-	if($strlen < $length)
1374
+	if ($strlen < $length)
1375 1375
 	{
1376
-		$string = str_pad($string,$length,"0");
1376
+		$string = str_pad($string, $length, "0");
1377 1377
 	}
1378
-	else if($strlen > $length)
1378
+	else if ($strlen > $length)
1379 1379
 	{
1380 1380
 		$string = substr($string, 0, $length);
1381 1381
 	}
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 function displayStudioForCurrentUser()
1392 1392
 {
1393 1393
     global $current_user;
1394
-    if ( $current_user->isAdmin() ) {
1394
+    if ($current_user->isAdmin()) {
1395 1395
         return true;
1396 1396
     }
1397 1397
 
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 function get_admin_modules_for_user($user) {
1412 1412
     $GLOBALS['log']->deprecated("get_admin_modules_for_user() is deprecated as of 6.2.2 and may disappear in the future, use Users->getDeveloperModules() instead");
1413 1413
 
1414
-    if(!isset($user)){
1414
+    if (!isset($user)) {
1415 1415
         $modules = array();
1416 1416
         return $modules;
1417 1417
     }
@@ -1420,14 +1420,14 @@  discard block
 block discarded – undo
1420 1420
 
1421 1421
 }
1422 1422
 
1423
- function get_workflow_admin_modules_for_user($user){
1423
+ function get_workflow_admin_modules_for_user($user) {
1424 1424
     if (isset($_SESSION['get_workflow_admin_modules_for_user'])) {
1425 1425
         return $_SESSION['get_workflow_admin_modules_for_user'];
1426 1426
     }
1427 1427
 
1428 1428
     global $moduleList;
1429 1429
     $workflow_mod_list = array();
1430
-    foreach($moduleList as $module){
1430
+    foreach ($moduleList as $module) {
1431 1431
 		$workflow_mod_list[$module] = $module;
1432 1432
 	}
1433 1433
 
@@ -1442,18 +1442,18 @@  discard block
 block discarded – undo
1442 1442
 	// End of list
1443 1443
 
1444 1444
     $workflow_admin_modules = array();
1445
-    if(empty($user)) {
1445
+    if (empty($user)) {
1446 1446
     	return $workflow_admin_modules;
1447 1447
     }
1448 1448
     $actions = ACLAction::getUserActions($user->id);
1449 1449
     //check for ForecastSchedule because it doesn't exist in $workflow_mod_list
1450
-    if (isset($actions['ForecastSchedule']['module']['admin']['aclaccess']) && ($actions['ForecastSchedule']['module']['admin']['aclaccess']==ACL_ALLOW_DEV ||
1451
-        $actions['ForecastSchedule']['module']['admin']['aclaccess']==ACL_ALLOW_ADMIN_DEV)) {
1450
+    if (isset($actions['ForecastSchedule']['module']['admin']['aclaccess']) && ($actions['ForecastSchedule']['module']['admin']['aclaccess'] == ACL_ALLOW_DEV ||
1451
+        $actions['ForecastSchedule']['module']['admin']['aclaccess'] == ACL_ALLOW_ADMIN_DEV)) {
1452 1452
         $workflow_admin_modules['Forecasts'] = 'Forecasts';
1453 1453
     }
1454 1454
     foreach ($workflow_mod_list as $key=>$val) {
1455
-        if(!in_array($val, $workflow_admin_modules) && ($val!='iFrames' && $val!='Feeds' && $val!='Home' && $val!='Dashboard'
1456
-            && $val!='Calendar' && $val!='Activities' && $val!='Reports') &&
1455
+        if (!in_array($val, $workflow_admin_modules) && ($val != 'iFrames' && $val != 'Feeds' && $val != 'Home' && $val != 'Dashboard'
1456
+            && $val != 'Calendar' && $val != 'Activities' && $val != 'Reports') &&
1457 1457
            ($user->isDeveloperForModule($key))) {
1458 1458
                 $workflow_admin_modules[$key] = $val;
1459 1459
         }
@@ -1464,10 +1464,10 @@  discard block
 block discarded – undo
1464 1464
 
1465 1465
 // Check if user is admin for at least one module.
1466 1466
 function is_admin_for_any_module($user) {
1467
-    if (!isset($user)){
1467
+    if (!isset($user)) {
1468 1468
         return false;
1469 1469
     }
1470
-    if($user->isAdmin()) {
1470
+    if ($user->isAdmin()) {
1471 1471
         return true;
1472 1472
     }
1473 1473
     return false;
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
 
1476 1476
 
1477 1477
 // Check if user is admin for a specific module.
1478
-function is_admin_for_module($user,$module) {
1478
+function is_admin_for_module($user, $module) {
1479 1479
     if (!isset($user)) {
1480 1480
         return false;
1481 1481
     }
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
  * Contributor(s): ______________________________________..
1494 1494
  */
1495 1495
 function is_admin($user) {
1496
-    if(empty($user)) {
1496
+    if (empty($user)) {
1497 1497
         return false;
1498 1498
     }
1499 1499
 
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
  * All Rights Reserved.
1537 1537
  * Contributor(s): ______________________________________..
1538 1538
  */
1539
-function get_select_options ($option_list, $selected) {
1539
+function get_select_options($option_list, $selected) {
1540 1540
 	return get_select_options_with_id($option_list, $selected);
1541 1541
 }
1542 1542
 
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
  * All Rights Reserved.
1550 1550
  * Contributor(s): ______________________________________..
1551 1551
  */
1552
-function get_select_options_with_id ($option_list, $selected_key) {
1552
+function get_select_options_with_id($option_list, $selected_key) {
1553 1553
 	return get_select_options_with_id_separate_key($option_list, $option_list, $selected_key);
1554 1554
 }
1555 1555
 
@@ -1564,14 +1564,14 @@  discard block
 block discarded – undo
1564 1564
  * All Rights Reserved.
1565 1565
  * Contributor(s): ______________________________________..
1566 1566
  */
1567
-function get_select_options_with_id_separate_key ($label_list, $key_list, $selected_key, $massupdate=false) {
1567
+function get_select_options_with_id_separate_key($label_list, $key_list, $selected_key, $massupdate = false) {
1568 1568
 	global $app_strings;
1569 1569
 	$select_options = "";
1570 1570
 
1571 1571
 	//for setting null selection values to human readable --None--
1572 1572
 	$pattern = "/'0?'></";
1573 1573
 	$replacement = "''>".$app_strings['LBL_NONE']."<";
1574
-    if($massupdate){
1574
+    if ($massupdate) {
1575 1575
         $replacement .= "/OPTION>\n<OPTION value='__SugarMassUpdateClearField__'><"; // Giving the user the option to unset a drop down list. I.e. none means that it won't get updated
1576 1576
     }
1577 1577
 
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
                 $option_key == ''
1589 1589
                 && (($selected_key == '' && !$massupdate) || $selected_key == '__SugarMassUpdateClearField__')
1590 1590
             )
1591
-            || (is_array($selected_key) &&  in_array($option_key, $selected_key))
1591
+            || (is_array($selected_key) && in_array($option_key, $selected_key))
1592 1592
         ) {
1593 1593
 			$selected_string = 'selected ';
1594 1594
 		}
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
  * All Rights Reserved.
1623 1623
  * Contributor(s): ______________________________________..
1624 1624
  */
1625
-function get_clear_form_js () {
1625
+function get_clear_form_js() {
1626 1626
 	$the_script = <<<EOQ
1627 1627
 <script type="text/javascript" language="JavaScript">
1628 1628
 function clear_form(form) {
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
  * All Rights Reserved.
1647 1647
  * Contributor(s): ______________________________________..
1648 1648
  */
1649
-function get_set_focus_js () {
1649
+function get_set_focus_js() {
1650 1650
 	//TODO Clint 5/20 - Make this function more generic so that it can take in the target form and field names as variables
1651 1651
 	$the_script = <<<EOQ
1652 1652
 <script type="text/javascript" language="JavaScript">
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
  */
1720 1720
 function parse_calendardate($local_format) {
1721 1721
 	preg_match('/\(?([^-]{1})[^-]*-([^-]{1})[^-]*-([^-]{1})[^-]*\)/', $local_format, $matches);
1722
-	$calendar_format = "%" . $matches[1] . "-%" . $matches[2] . "-%" . $matches[3];
1722
+	$calendar_format = "%".$matches[1]."-%".$matches[2]."-%".$matches[3];
1723 1723
 	return str_replace(array("y", "ᅣ1�7", "a", "j"), array("Y", "Y", "Y", "d"), $calendar_format);
1724 1724
 }
1725 1725
 
@@ -1727,20 +1727,20 @@  discard block
 block discarded – undo
1727 1727
 
1728 1728
 
1729 1729
 
1730
-function translate($string, $mod='', $selectedValue=''){
1730
+function translate($string, $mod = '', $selectedValue = '') {
1731 1731
 	//$test_start = microtime();
1732 1732
 	//static $mod_strings_results = array();
1733
-	if(!empty($mod)){
1733
+	if (!empty($mod)) {
1734 1734
 		global $current_language;
1735 1735
 		//Bug 31275
1736
-		if(isset($_REQUEST['login_language'])){
1737
-		    $current_language = ($_REQUEST['login_language'] == $current_language)? $current_language : $_REQUEST['login_language'];
1736
+		if (isset($_REQUEST['login_language'])) {
1737
+		    $current_language = ($_REQUEST['login_language'] == $current_language) ? $current_language : $_REQUEST['login_language'];
1738 1738
 		}
1739 1739
 		$mod_strings = return_module_language($current_language, $mod);
1740 1740
         if ($mod == "")
1741
-        echo "Language is <pre>" . $mod_strings . "</pre>";
1741
+        echo "Language is <pre>".$mod_strings."</pre>";
1742 1742
 
1743
-	}else{
1743
+	} else {
1744 1744
 		global $mod_strings;
1745 1745
 	}
1746 1746
 
@@ -1774,13 +1774,13 @@  discard block
 block discarded – undo
1774 1774
 
1775 1775
 
1776 1776
 
1777
-	if(empty($returnValue)){
1777
+	if (empty($returnValue)) {
1778 1778
 		return $string;
1779 1779
 	}
1780 1780
 
1781 1781
     // Bug 48996 - Custom enums with '0' value were not returning because of empty check
1782 1782
     // Added a numeric 0 checker to the conditional to allow 0 value indexed to pass
1783
-	if(is_array($returnValue) && (!empty($selectedValue) || (is_numeric($selectedValue) && $selectedValue == 0))  && isset($returnValue[$selectedValue]) ){
1783
+	if (is_array($returnValue) && (!empty($selectedValue) || (is_numeric($selectedValue) && $selectedValue == 0)) && isset($returnValue[$selectedValue])) {
1784 1784
 		return $returnValue[$selectedValue];
1785 1785
 	}
1786 1786
 
@@ -1792,25 +1792,25 @@  discard block
 block discarded – undo
1792 1792
         static $num_grp_sep;
1793 1793
         global $current_user, $sugar_config;
1794 1794
 
1795
-        if($dec_sep == null) {
1795
+        if ($dec_sep == null) {
1796 1796
             $user_dec_sep = $current_user->getPreference('dec_sep');
1797 1797
             $dec_sep = (empty($user_dec_sep) ? $sugar_config['default_decimal_seperator'] : $user_dec_sep);
1798 1798
         }
1799
-        if($num_grp_sep == null) {
1799
+        if ($num_grp_sep == null) {
1800 1800
             $user_num_grp_sep = $current_user->getPreference('num_grp_sep');
1801 1801
             $num_grp_sep = (empty($user_num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $user_num_grp_sep);
1802 1802
         }
1803 1803
 
1804
-        $num = preg_replace("'" . preg_quote($num_grp_sep) . "'", '', $num);
1805
-        $num = preg_replace("'" . preg_quote($dec_sep) . "'", '.', $num);
1804
+        $num = preg_replace("'".preg_quote($num_grp_sep)."'", '', $num);
1805
+        $num = preg_replace("'".preg_quote($dec_sep)."'", '.', $num);
1806 1806
         return $num;
1807 1807
 
1808 1808
 }
1809 1809
 
1810 1810
 function add_http($url) {
1811
-	if(!preg_match("@://@i", $url)) {
1811
+	if (!preg_match("@://@i", $url)) {
1812 1812
 		$scheme = "http";
1813
-		if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
1813
+		if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
1814 1814
 			$scheme = 'https';
1815 1815
 		}
1816 1816
 
@@ -1864,10 +1864,10 @@  discard block
 block discarded – undo
1864 1864
  * @param bool cleanImg Flag to allow <img> tags to survive - only used by InboundEmail for inline images.
1865 1865
  * @return array Array of matches, empty on clean string
1866 1866
  */
1867
-function clean_xss($str, $cleanImg=true) {
1867
+function clean_xss($str, $cleanImg = true) {
1868 1868
 	global $sugar_config;
1869 1869
 
1870
-	if(empty($sugar_config['email_xss']))
1870
+	if (empty($sugar_config['email_xss']))
1871 1871
 	$sugar_config['email_xss'] = getDefaultXssTags();
1872 1872
 
1873 1873
 	$xsstags = unserialize(base64_decode($sugar_config['email_xss']));
@@ -1877,32 +1877,32 @@  discard block
 block discarded – undo
1877 1877
 	$jsEvents .= "onmouseup|onmouseover|onmousedown|onmouseenter|onmouseleave|onmousemove|onload|onchange|";
1878 1878
 	$jsEvents .= "onreset|onselect|onsubmit|onkeydown|onkeypress|onkeyup|onabort|onerror|ondragdrop";
1879 1879
 
1880
-	$attribute_regex	= "#\b({$jsEvents})\s*=\s*(?|(?!['\"])\S+|['\"].+?['\"])#sim";
1881
-	$javascript_regex	= '@<[^/>][^>]+(expression\(|j\W*a\W*v\W*a|v\W*b\W*s\W*c\W*r|&#|/\*|\*/)[^>]*>@sim';
1882
-	$imgsrc_regex		= '#<[^>]+src[^=]*=([^>]*?http(s)?://[^>]*)>#sim';
1883
-	$css_url			= '#url\(.*\.\w+\)#';
1880
+	$attribute_regex = "#\b({$jsEvents})\s*=\s*(?|(?!['\"])\S+|['\"].+?['\"])#sim";
1881
+	$javascript_regex = '@<[^/>][^>]+(expression\(|j\W*a\W*v\W*a|v\W*b\W*s\W*c\W*r|&#|/\*|\*/)[^>]*>@sim';
1882
+	$imgsrc_regex = '#<[^>]+src[^=]*=([^>]*?http(s)?://[^>]*)>#sim';
1883
+	$css_url = '#url\(.*\.\w+\)#';
1884 1884
 
1885 1885
 	$tagsrex = '#<\/?(\w+)((?:\s+(?:\w|\w[\w-]*\w)(?:\s*=\s*(?:\".*?\"|\'.*?\'|[^\'\">\s]+))?)+\s*|\s*)\/?>#im';
1886 1886
 
1887 1887
 	$tagmatches = array();
1888 1888
 	$matches = array();
1889 1889
 	preg_match_all($tagsrex, $str, $tagmatches, PREG_PATTERN_ORDER);
1890
-    foreach($tagmatches[1] as $no => $tag) {
1891
-        if(in_array($tag, $xsstags)) {
1890
+    foreach ($tagmatches[1] as $no => $tag) {
1891
+        if (in_array($tag, $xsstags)) {
1892 1892
             // dangerous tag - take out whole
1893 1893
             $matches[] = $tagmatches[0][$no];
1894 1894
             continue;
1895 1895
         }
1896 1896
         $attrmatch = array();
1897 1897
         preg_match_all($attribute_regex, $tagmatches[2][$no], $attrmatch, PREG_PATTERN_ORDER);
1898
-        if(!empty($attrmatch[0])) {
1898
+        if (!empty($attrmatch[0])) {
1899 1899
             $matches = array_merge($matches, $attrmatch[0]);
1900 1900
         }
1901 1901
     }
1902 1902
 
1903 1903
 	$matches = array_merge($matches, xss_check_pattern($javascript_regex, $str));
1904 1904
 
1905
-	if($cleanImg) {
1905
+	if ($cleanImg) {
1906 1906
 		$matches = array_merge($matches,
1907 1907
 		xss_check_pattern($imgsrc_regex, $str)
1908 1908
 		);
@@ -1911,18 +1911,18 @@  discard block
 block discarded – undo
1911 1911
 	// cn: bug 13498 - custom white-list of allowed domains that vet remote images
1912 1912
 	preg_match_all($css_url, $str, $cssUrlMatches, PREG_PATTERN_ORDER);
1913 1913
 
1914
-	if(isset($sugar_config['security_trusted_domains']) && !empty($sugar_config['security_trusted_domains']) && is_array($sugar_config['security_trusted_domains'])) {
1915
-		if(is_array($cssUrlMatches) && count($cssUrlMatches) > 0) {
1914
+	if (isset($sugar_config['security_trusted_domains']) && !empty($sugar_config['security_trusted_domains']) && is_array($sugar_config['security_trusted_domains'])) {
1915
+		if (is_array($cssUrlMatches) && count($cssUrlMatches) > 0) {
1916 1916
 			// normalize whitelist
1917
-			foreach($sugar_config['security_trusted_domains'] as $k => $v) {
1917
+			foreach ($sugar_config['security_trusted_domains'] as $k => $v) {
1918 1918
 				$sugar_config['security_trusted_domains'][$k] = strtolower($v);
1919 1919
 			}
1920 1920
 
1921
-			foreach($cssUrlMatches[0] as $match) {
1921
+			foreach ($cssUrlMatches[0] as $match) {
1922 1922
 				$domain = strtolower(substr(strstr($match, "://"), 3));
1923 1923
 				$baseUrl = substr($domain, 0, strpos($domain, "/"));
1924 1924
 
1925
-				if(!in_array($baseUrl, $sugar_config['security_trusted_domains'])) {
1925
+				if (!in_array($baseUrl, $sugar_config['security_trusted_domains'])) {
1926 1926
 					$matches[] = $match;
1927 1927
 				}
1928 1928
 			}
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 		if (isset($GLOBALS['log']) && is_object($GLOBALS['log'])) {
1984 1984
 			$GLOBALS['log']->fatal("SECURITY[$filter]: bad data passed in; string: {$str}");
1985 1985
 		}
1986
-		if ( $dieOnBadData ) {
1986
+		if ($dieOnBadData) {
1987 1987
 			die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>");
1988 1988
 		}
1989 1989
 		return false;
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
 }
1995 1995
 
1996 1996
 function clean_special_arguments() {
1997
-	if(isset($_SERVER['PHP_SELF'])) {
1997
+	if (isset($_SERVER['PHP_SELF'])) {
1998 1998
 		if (!empty($_SERVER['PHP_SELF'])) clean_string($_SERVER['PHP_SELF'], 'SAFED_GET');
1999 1999
 	}
2000 2000
 	if (!empty($_REQUEST) && !empty($_REQUEST['login_theme'])) clean_string($_REQUEST['login_theme'], "STANDARD");
@@ -2024,12 +2024,12 @@  discard block
 block discarded – undo
2024 2024
  * cleans the given key in superglobals $_GET, $_POST, $_REQUEST
2025 2025
  */
2026 2026
 function clean_superglobals($key, $filter = 'STANDARD') {
2027
-	if(isset($_GET[$key])) clean_string($_GET[$key], $filter);
2028
-	if(isset($_POST[$key])) clean_string($_POST[$key], $filter);
2029
-	if(isset($_REQUEST[$key])) clean_string($_REQUEST[$key], $filter);
2027
+	if (isset($_GET[$key])) clean_string($_GET[$key], $filter);
2028
+	if (isset($_POST[$key])) clean_string($_POST[$key], $filter);
2029
+	if (isset($_REQUEST[$key])) clean_string($_REQUEST[$key], $filter);
2030 2030
 }
2031 2031
 
2032
-function set_superglobals($key, $val){
2032
+function set_superglobals($key, $val) {
2033 2033
 	$_GET[$key] = $val;
2034 2034
 	$_POST[$key] = $val;
2035 2035
 	$_REQUEST[$key] = $val;
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 	global $sugar_config;
2041 2041
     global $RAW_REQUEST;
2042 2042
 
2043
-    if(get_magic_quotes_gpc()) {
2043
+    if (get_magic_quotes_gpc()) {
2044 2044
         // magic quotes screw up data, we'd have to clean up
2045 2045
         $RAW_REQUEST = array_map("cleanup_slashes", $_REQUEST);
2046 2046
     } else {
@@ -2059,17 +2059,17 @@  discard block
 block discarded – undo
2059 2059
 	}
2060 2060
 
2061 2061
 	// PHP cannot stomp out superglobals reliably
2062
-	foreach($post as $k => $v) { $_POST[$k] = $v; }
2063
-	foreach($get  as $k => $v) { $_GET[$k] = $v; }
2064
-	foreach($req  as $k => $v) {
2062
+	foreach ($post as $k => $v) { $_POST[$k] = $v; }
2063
+	foreach ($get  as $k => $v) { $_GET[$k] = $v; }
2064
+	foreach ($req  as $k => $v) {
2065 2065
 		 $_REQUEST[$k] = $v;
2066 2066
 
2067 2067
 	    //ensure the keys are safe as well.  If mbstring encoding translation is on, the post keys don't
2068 2068
         //get translated, so scrub the data but don't die
2069
-	    if(ini_get('mbstring.encoding_translation')==='1'){
2070
-            securexsskey($k,false);
2071
-        }else{
2072
-		    securexsskey($k,true);
2069
+	    if (ini_get('mbstring.encoding_translation') === '1') {
2070
+            securexsskey($k, false);
2071
+        } else {
2072
+		    securexsskey($k, true);
2073 2073
         }
2074 2074
 
2075 2075
 	}
@@ -2088,8 +2088,8 @@  discard block
 block discarded – undo
2088 2088
 	if (isset($_REQUEST['offset'])) clean_string($_REQUEST['offset']);
2089 2089
 	if (isset($_REQUEST['stamp'])) clean_string($_REQUEST['stamp']);
2090 2090
 
2091
-	if(isset($_REQUEST['lvso'])){
2092
-			set_superglobals('lvso', (strtolower($_REQUEST['lvso']) === 'desc')?'desc':'asc');
2091
+	if (isset($_REQUEST['lvso'])) {
2092
+			set_superglobals('lvso', (strtolower($_REQUEST['lvso']) === 'desc') ? 'desc' : 'asc');
2093 2093
 	}
2094 2094
 	// Clean "offset" and "order_by" parameters in URL
2095 2095
 	foreach ($_REQUEST as $key => $val) {
@@ -2118,27 +2118,27 @@  discard block
 block discarded – undo
2118 2118
 }
2119 2119
 
2120 2120
 function securexss($value) {
2121
-	if(is_array($value)){
2121
+	if (is_array($value)) {
2122 2122
     	$new = array();
2123
-        foreach($value as $key=>$val){
2123
+        foreach ($value as $key=>$val) {
2124 2124
        		$new[$key] = securexss($val);
2125 2125
         }
2126 2126
         return $new;
2127 2127
     }
2128
-	static $xss_cleanup=  array("&quot;" => "&#38;", '"' =>'&quot;', "'" =>  '&#039;' , '<' =>'&lt;' , '>'=>'&gt;');
2128
+	static $xss_cleanup = array("&quot;" => "&#38;", '"' =>'&quot;', "'" =>  '&#039;', '<' =>'&lt;', '>'=>'&gt;');
2129 2129
 	$value = preg_replace(array('/javascript:/i', '/\0/'), array('java script:', ''), $value);
2130 2130
 	$value = preg_replace('/javascript:/i', 'java script:', $value);
2131 2131
 	return str_replace(array_keys($xss_cleanup), array_values($xss_cleanup), $value);
2132 2132
 }
2133 2133
 
2134
-function securexsskey($value, $die=true){
2134
+function securexsskey($value, $die = true) {
2135 2135
 	global $sugar_config;
2136 2136
 	$matches = array();
2137 2137
 	preg_match('/[\'"<>]/', $value, $matches);
2138
-	if(!empty($matches)){
2139
-		if($die){
2138
+	if (!empty($matches)) {
2139
+		if ($die) {
2140 2140
 			die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>");
2141
-		}else{
2141
+		} else {
2142 2142
 			unset($_REQUEST[$value]);
2143 2143
 			unset($_POST[$value]);
2144 2144
 			unset($_GET[$value]);
@@ -2146,15 +2146,15 @@  discard block
 block discarded – undo
2146 2146
 	}
2147 2147
 }
2148 2148
 
2149
-function preprocess_param($value){
2150
-	if(is_string($value)){
2151
-		if(get_magic_quotes_gpc() == 1){
2149
+function preprocess_param($value) {
2150
+	if (is_string($value)) {
2151
+		if (get_magic_quotes_gpc() == 1) {
2152 2152
 			$value = stripslashes($value);
2153 2153
 		}
2154 2154
 
2155 2155
 		$value = securexss($value);
2156 2156
 	}
2157
-	else if (is_array($value)){
2157
+	else if (is_array($value)) {
2158 2158
 	    foreach ($value as $key => $element) {
2159 2159
 	        $value[$key] = preprocess_param($element);
2160 2160
 	    }
@@ -2165,40 +2165,40 @@  discard block
 block discarded – undo
2165 2165
 
2166 2166
 function cleanup_slashes($value)
2167 2167
 {
2168
-    if(is_string($value)) return stripslashes($value);
2168
+    if (is_string($value)) return stripslashes($value);
2169 2169
     return $value;
2170 2170
 }
2171 2171
 
2172 2172
 
2173
-function set_register_value($category, $name, $value){
2173
+function set_register_value($category, $name, $value) {
2174 2174
     return sugar_cache_put("{$category}:{$name}", $value);
2175 2175
 }
2176 2176
 
2177
-function get_register_value($category,$name){
2177
+function get_register_value($category, $name) {
2178 2178
     return sugar_cache_retrieve("{$category}:{$name}");
2179 2179
 }
2180 2180
 
2181
-function clear_register_value($category,$name){
2181
+function clear_register_value($category, $name) {
2182 2182
     return sugar_cache_clear("{$category}:{$name}");
2183 2183
 }
2184 2184
 // this function cleans id's when being imported
2185 2185
 function convert_id($string)
2186 2186
 {
2187
-	return preg_replace_callback( '|[^A-Za-z0-9\-]|',
2187
+	return preg_replace_callback('|[^A-Za-z0-9\-]|',
2188 2188
 	create_function(
2189 2189
 	// single quotes are essential here,
2190 2190
 	// or alternative escape all $ as \$
2191 2191
 	'$matches',
2192 2192
 	'return ord($matches[0]);'
2193
-         ) ,$string);
2193
+         ), $string);
2194 2194
 }
2195 2195
 
2196 2196
 /**
2197 2197
  * @deprecated use SugarTheme::getImage()
2198 2198
  */
2199
-function get_image($image,$other_attributes,$width="",$height="",$ext='.gif',$alt="")
2199
+function get_image($image, $other_attributes, $width = "", $height = "", $ext = '.gif', $alt = "")
2200 2200
 {
2201
-    return SugarThemeRegistry::current()->getImage(basename($image), $other_attributes, empty($width) ? null : $width, empty($height) ? null : $height, $ext, $alt );
2201
+    return SugarThemeRegistry::current()->getImage(basename($image), $other_attributes, empty($width) ? null : $width, empty($height) ? null : $height, $ext, $alt);
2202 2202
 }
2203 2203
 /**
2204 2204
  * @deprecated use SugarTheme::getImageURL()
@@ -2208,54 +2208,54 @@  discard block
 block discarded – undo
2208 2208
     return SugarThemeRegistry::current()->getImageURL($image_name);
2209 2209
 }
2210 2210
 
2211
-function getWebPath($relative_path){
2211
+function getWebPath($relative_path) {
2212 2212
 	//if it has  a :// then it isn't a relative path
2213
-	if(substr_count($relative_path, '://') > 0) return $relative_path;
2214
-	if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2213
+	if (substr_count($relative_path, '://') > 0) return $relative_path;
2214
+	if (defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2215 2215
 	return $relative_path;
2216 2216
 }
2217 2217
 
2218
-function getVersionedPath($path, $additional_attrs='')
2218
+function getVersionedPath($path, $additional_attrs = '')
2219 2219
 {
2220
-	if(empty($GLOBALS['sugar_config']['js_custom_version'])) $GLOBALS['sugar_config']['js_custom_version'] = 1;
2221
-	$js_version_key = isset($GLOBALS['js_version_key'])?$GLOBALS['js_version_key']:'';
2222
-	if(inDeveloperMode()) {
2220
+	if (empty($GLOBALS['sugar_config']['js_custom_version'])) $GLOBALS['sugar_config']['js_custom_version'] = 1;
2221
+	$js_version_key = isset($GLOBALS['js_version_key']) ? $GLOBALS['js_version_key'] : '';
2222
+	if (inDeveloperMode()) {
2223 2223
 	    static $rand;
2224
-	    if(empty($rand)) $rand = mt_rand();
2224
+	    if (empty($rand)) $rand = mt_rand();
2225 2225
 	    $dev = $rand;
2226 2226
 	} else {
2227 2227
 	    $dev = '';
2228 2228
 	}
2229
-	if(is_array($additional_attrs)) {
2230
-	    $additional_attrs = join("|",$additional_attrs);
2229
+	if (is_array($additional_attrs)) {
2230
+	    $additional_attrs = join("|", $additional_attrs);
2231 2231
 	}
2232 2232
 	// cutting 2 last chars here because since md5 is 32 chars, it's always ==
2233 2233
 	$str = substr(base64_encode(md5("$js_version_key|{$GLOBALS['sugar_config']['js_custom_version']}|$dev|$additional_attrs", true)), 0, -2);
2234 2234
 	// remove / - it confuses some parsers
2235 2235
 	$str = strtr($str, '/+', '-_');
2236
-	if(empty($path)) return $str;
2236
+	if (empty($path)) return $str;
2237 2237
 
2238
-	return $path . "?v=$str";
2238
+	return $path."?v=$str";
2239 2239
 }
2240 2240
 
2241
-function getVersionedScript($path, $additional_attrs='')
2241
+function getVersionedScript($path, $additional_attrs = '')
2242 2242
 {
2243 2243
     return '<script type="text/javascript" src="'.getVersionedPath($path, $additional_attrs).'"></script>';
2244 2244
 }
2245 2245
 
2246
-function getJSPath($relative_path, $additional_attrs='')
2246
+function getJSPath($relative_path, $additional_attrs = '')
2247 2247
 {
2248
-	if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2249
-	return getVersionedPath($relative_path).(!empty($additional_attrs)?"&$additional_attrs":"");
2248
+	if (defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2249
+	return getVersionedPath($relative_path).(!empty($additional_attrs) ? "&$additional_attrs" : "");
2250 2250
 }
2251 2251
 
2252
-function getSWFPath($relative_path, $additional_params=''){
2252
+function getSWFPath($relative_path, $additional_params = '') {
2253 2253
 	$path = $relative_path;
2254
-	if (!empty($additional_params)){
2255
-		$path .= '?' . $additional_params;
2254
+	if (!empty($additional_params)) {
2255
+		$path .= '?'.$additional_params;
2256 2256
 	}
2257
-	if (defined('TEMPLATE_URL')){
2258
-		$path = TEMPLATE_URL . '/' . $path;
2257
+	if (defined('TEMPLATE_URL')) {
2258
+		$path = TEMPLATE_URL.'/'.$path;
2259 2259
 	}
2260 2260
 	return $path;
2261 2261
 }
@@ -2266,25 +2266,25 @@  discard block
 block discarded – undo
2266 2266
 
2267 2267
 function getSQLDate($date_str)
2268 2268
 {
2269
-	if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/',$date_str,$match))
2269
+	if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/', $date_str, $match))
2270 2270
 	{
2271
-		if ( strlen($match[2]) == 1)
2271
+		if (strlen($match[2]) == 1)
2272 2272
 		{
2273 2273
 			$match[2] = "0".$match[2];
2274 2274
 		}
2275
-		if ( strlen($match[1]) == 1)
2275
+		if (strlen($match[1]) == 1)
2276 2276
 		{
2277 2277
 			$match[1] = "0".$match[1];
2278 2278
 		}
2279 2279
 		return "{$match[3]}-{$match[1]}-{$match[2]}";
2280 2280
 	}
2281
-	else if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/',$date_str,$match))
2281
+	else if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/', $date_str, $match))
2282 2282
 	{
2283
-		if ( strlen($match[2]) == 1)
2283
+		if (strlen($match[2]) == 1)
2284 2284
 		{
2285 2285
 			$match[2] = "0".$match[2];
2286 2286
 		}
2287
-		if ( strlen($match[1]) == 1)
2287
+		if (strlen($match[1]) == 1)
2288 2288
 		{
2289 2289
 			$match[1] = "0".$match[1];
2290 2290
 		}
@@ -2296,15 +2296,15 @@  discard block
 block discarded – undo
2296 2296
 	}
2297 2297
 }
2298 2298
 
2299
-function clone_history(&$db, $from_id,$to_id, $to_type)
2299
+function clone_history(&$db, $from_id, $to_id, $to_type)
2300 2300
 {
2301 2301
 	global $timedate;
2302
-	$old_note_id=null;
2303
-	$old_filename=null;
2302
+	$old_note_id = null;
2303
+	$old_filename = null;
2304 2304
 	require_once('include/upload_file.php');
2305 2305
 	$tables = array('calls'=>'Call', 'meetings'=>'Meeting', 'notes'=>'Note', 'tasks'=>'Task');
2306 2306
 
2307
-	$location=array('Email'=>"modules/Emails/Email.php",
2307
+	$location = array('Email'=>"modules/Emails/Email.php",
2308 2308
 	'Call'=>"modules/Calls/Call.php",
2309 2309
 	'Meeting'=>"modules/Meetings/Meeting.php",
2310 2310
 	'Note'=>"modules/Notes/Note.php",
@@ -2312,7 +2312,7 @@  discard block
 block discarded – undo
2312 2312
 	);
2313 2313
 
2314 2314
 
2315
-	foreach($tables as $table=>$bean_class)
2315
+	foreach ($tables as $table=>$bean_class)
2316 2316
 	{
2317 2317
 
2318 2318
 		if (!class_exists($bean_class))
@@ -2320,48 +2320,48 @@  discard block
 block discarded – undo
2320 2320
 			require_once($location[$bean_class]);
2321 2321
 		}
2322 2322
 
2323
-		$bProcessingNotes=false;
2324
-		if ($table=='notes')
2323
+		$bProcessingNotes = false;
2324
+		if ($table == 'notes')
2325 2325
 		{
2326
-			$bProcessingNotes=true;
2326
+			$bProcessingNotes = true;
2327 2327
 		}
2328 2328
 		$query = "SELECT id FROM $table WHERE parent_id='$from_id'";
2329 2329
 		$results = $db->query($query);
2330
-		while($row = $db->fetchByAssoc($results))
2330
+		while ($row = $db->fetchByAssoc($results))
2331 2331
 		{
2332 2332
 			//retrieve existing record.
2333
-			$bean= new $bean_class();
2333
+			$bean = new $bean_class();
2334 2334
 			$bean->retrieve($row['id']);
2335 2335
 			//process for new instance.
2336 2336
 			if ($bProcessingNotes)
2337 2337
 			{
2338
-				$old_note_id=$row['id'];
2339
-				$old_filename=$bean->filename;
2338
+				$old_note_id = $row['id'];
2339
+				$old_filename = $bean->filename;
2340 2340
 			}
2341
-			$bean->id=null;
2342
-			$bean->parent_id=$to_id;
2343
-			$bean->parent_type=$to_type;
2344
-			if ($to_type=='Contacts' and in_array('contact_id',$bean->column_fields))
2341
+			$bean->id = null;
2342
+			$bean->parent_id = $to_id;
2343
+			$bean->parent_type = $to_type;
2344
+			if ($to_type == 'Contacts' and in_array('contact_id', $bean->column_fields))
2345 2345
 			{
2346
-				$bean->contact_id=$to_id;
2346
+				$bean->contact_id = $to_id;
2347 2347
 			}
2348 2348
 			$bean->update_date_modified = false;
2349 2349
             $bean->update_modified_by = false;
2350
-            if(isset($bean->date_modified))
2350
+            if (isset($bean->date_modified))
2351 2351
                 $bean->date_modified = $timedate->to_db($bean->date_modified);
2352
-            if(isset($bean->date_entered))
2352
+            if (isset($bean->date_entered))
2353 2353
                 $bean->date_entered = $timedate->to_db($bean->date_entered);
2354 2354
 			//save
2355
-			$new_id=$bean->save();
2355
+			$new_id = $bean->save();
2356 2356
 
2357 2357
 			//duplicate the file now. for notes.
2358 2358
 			if ($bProcessingNotes && !empty($old_filename))
2359 2359
 			{
2360
-				UploadFile::duplicate_file($old_note_id,$new_id,$old_filename);
2360
+				UploadFile::duplicate_file($old_note_id, $new_id, $old_filename);
2361 2361
 			}
2362 2362
 			//reset the values needed for attachment duplication.
2363
-			$old_note_id=null;
2364
-			$old_filename=null;
2363
+			$old_note_id = null;
2364
+			$old_filename = null;
2365 2365
 		}
2366 2366
 	}
2367 2367
 }
@@ -2369,11 +2369,11 @@  discard block
 block discarded – undo
2369 2369
 function values_to_keys($array)
2370 2370
 {
2371 2371
 	$new_array = array();
2372
-	if(!is_array($array))
2372
+	if (!is_array($array))
2373 2373
 	{
2374 2374
 		return $new_array;
2375 2375
 	}
2376
-	foreach($array as $arr){
2376
+	foreach ($array as $arr) {
2377 2377
 		$new_array[$arr] = $arr;
2378 2378
 	}
2379 2379
 	return $new_array;
@@ -2381,7 +2381,7 @@  discard block
 block discarded – undo
2381 2381
 
2382 2382
 function clone_relationship(&$db, $tables = array(), $from_column, $from_id, $to_id)
2383 2383
 {
2384
-	foreach($tables as $table)
2384
+	foreach ($tables as $table)
2385 2385
 	{
2386 2386
 
2387 2387
 		if ($table == 'emails_beans') {
@@ -2390,27 +2390,27 @@  discard block
 block discarded – undo
2390 2390
 			$query = "SELECT * FROM $table WHERE $from_column='$from_id'";
2391 2391
 		}
2392 2392
 		$results = $db->query($query);
2393
-		while($row = $db->fetchByAssoc($results))
2393
+		while ($row = $db->fetchByAssoc($results))
2394 2394
 		{
2395 2395
 			$query = "INSERT INTO $table ";
2396 2396
 			$names = '';
2397 2397
 			$values = '';
2398 2398
 			$row[$from_column] = $to_id;
2399 2399
 			$row['id'] = create_guid();
2400
-			if ($table=='emails_beans') {
2401
-				$row['bean_module'] =='Contacts';
2400
+			if ($table == 'emails_beans') {
2401
+				$row['bean_module'] == 'Contacts';
2402 2402
 			}
2403 2403
 
2404
-			foreach($row as $name=>$value)
2404
+			foreach ($row as $name=>$value)
2405 2405
 			{
2406 2406
 
2407
-				if(empty($names))
2407
+				if (empty($names))
2408 2408
 				{
2409 2409
 					$names .= $name;
2410 2410
 					$values .= "'$value'";
2411 2411
 				} else
2412 2412
 				{
2413
-					$names .= ', '. $name;
2413
+					$names .= ', '.$name;
2414 2414
 					$values .= ", '$value'";
2415 2415
 				}
2416 2416
 			}
@@ -2423,9 +2423,9 @@  discard block
 block discarded – undo
2423 2423
 function get_unlinked_email_query($type, $bean) {
2424 2424
     global $current_user;
2425 2425
 
2426
-    $return_array['select']='SELECT emails.id ';
2427
-    $return_array['from']='FROM emails ';
2428
-    $return_array['where']="";
2426
+    $return_array['select'] = 'SELECT emails.id ';
2427
+    $return_array['from'] = 'FROM emails ';
2428
+    $return_array['where'] = "";
2429 2429
 	$return_array['join'] = " JOIN (select DISTINCT email_id from emails_email_addr_rel eear
2430 2430
 
2431 2431
 	join email_addr_bean_rel eabr on eabr.bean_id ='$bean->id' and eabr.bean_module = '$bean->module_dir' and
@@ -2439,17 +2439,17 @@  discard block
 block discarded – undo
2439 2439
 		return $return_array;
2440 2440
 	}
2441 2441
 
2442
-	return $return_array['select'] . $return_array['from'] . $return_array['where'] . $return_array['join'] ;
2442
+	return $return_array['select'].$return_array['from'].$return_array['where'].$return_array['join'];
2443 2443
 } // fn
2444 2444
 
2445 2445
 function get_emails_by_assign_or_link($params)
2446 2446
 {
2447 2447
     $relation = $params['link'];
2448 2448
 	$bean = $GLOBALS['app']->controller->bean;
2449
-    if(empty($bean->$relation)) {
2449
+    if (empty($bean->$relation)) {
2450 2450
         $bean->load_relationship($relation);
2451 2451
     }
2452
-    if(empty($bean->$relation)) {
2452
+    if (empty($bean->$relation)) {
2453 2453
         $GLOBALS['log']->error("Bad relation '$relation' for bean '{$bean->object_name}' id '{$bean->id}'");
2454 2454
         return array();
2455 2455
     }
@@ -2459,7 +2459,7 @@  discard block
 block discarded – undo
2459 2459
     	'join_table_link_alias' => 'linkt',
2460 2460
     ));
2461 2461
     $rel_join = str_replace("{$bean->table_name}.id", "'{$bean->id}'", $rel_join);
2462
-    $return_array['select']='SELECT DISTINCT emails.id ';
2462
+    $return_array['select'] = 'SELECT DISTINCT emails.id ';
2463 2463
     $return_array['from'] = "FROM emails ";
2464 2464
 
2465 2465
     $return_array['join'] = array();
@@ -2531,15 +2531,15 @@  discard block
 block discarded – undo
2531 2531
         ";
2532 2532
     }
2533 2533
 
2534
-    $return_array['join'] = " INNER JOIN (" . implode(" UNION ", $return_array['join']). ") email_ids ON emails.id=email_ids.email_id ";
2534
+    $return_array['join'] = " INNER JOIN (".implode(" UNION ", $return_array['join']).") email_ids ON emails.id=email_ids.email_id ";
2535 2535
 
2536
-    $return_array['where']=" WHERE emails.deleted=0 ";
2536
+    $return_array['where'] = " WHERE emails.deleted=0 ";
2537 2537
 
2538 2538
     	//$return_array['join'] = '';
2539 2539
         $return_array['join_tables'][0] = '';
2540 2540
 
2541
-        if($bean->object_name == "Case" && !empty($bean->case_number)) {
2542
-            $where = str_replace("%1", $bean->case_number, 	$bean->getEmailSubjectMacro());
2541
+        if ($bean->object_name == "Case" && !empty($bean->case_number)) {
2542
+            $where = str_replace("%1", $bean->case_number, $bean->getEmailSubjectMacro());
2543 2543
     	    $return_array["where"] .= "\n AND (email_ids.source = 'direct' OR emails.name LIKE '%$where%')";
2544 2544
         }
2545 2545
 
@@ -2556,16 +2556,16 @@  discard block
 block discarded – undo
2556 2556
 	return empty($value) && $value != '0';
2557 2557
 }
2558 2558
 
2559
-function get_bean_select_array($add_blank=true, $bean_name, $display_columns, $where='', $order_by='', $blank_is_none=false)
2559
+function get_bean_select_array($add_blank = true, $bean_name, $display_columns, $where = '', $order_by = '', $blank_is_none = false)
2560 2560
 {
2561 2561
 	global $beanFiles;
2562 2562
 	require_once($beanFiles[$bean_name]);
2563 2563
 	$focus = new $bean_name();
2564 2564
 	$user_array = array();
2565 2565
 
2566
-    $key = ($bean_name == 'EmailTemplate') ?  $bean_name : $bean_name . $display_columns. $where . $order_by;
2567
-	$user_array = get_register_value('select_array', $key );
2568
-	if(!$user_array)
2566
+    $key = ($bean_name == 'EmailTemplate') ? $bean_name : $bean_name.$display_columns.$where.$order_by;
2567
+	$user_array = get_register_value('select_array', $key);
2568
+	if (!$user_array)
2569 2569
 	{
2570 2570
 
2571 2571
 		$db = DBManagerFactory::getInstance();
@@ -2573,16 +2573,16 @@  discard block
 block discarded – undo
2573 2573
 		$temp_result = Array();
2574 2574
 		$query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} ";
2575 2575
 		$query .= "where ";
2576
-		if ( $where != '')
2576
+		if ($where != '')
2577 2577
 		{
2578 2578
 			$query .= $where." AND ";
2579 2579
 		}
2580 2580
 
2581
-		$query .=  " {$focus->table_name}.deleted=0";
2581
+		$query .= " {$focus->table_name}.deleted=0";
2582 2582
 
2583 2583
         /* BEGIN - SECURITY GROUPS */
2584 2584
         global $current_user, $sugar_config;
2585
-        if($focus->module_dir == 'Users' && !is_admin($current_user)
2585
+        if ($focus->module_dir == 'Users' && !is_admin($current_user)
2586 2586
                 && isset($sugar_config['securitysuite_filter_user_list'])
2587 2587
                 && $sugar_config['securitysuite_filter_user_list'] == true
2588 2588
         ) {
@@ -2590,20 +2590,20 @@  discard block
 block discarded – undo
2590 2590
             $group_where = SecurityGroup::getGroupUsersWhere($current_user->id);
2591 2591
             $query .= " AND (".$group_where.") ";
2592 2592
         } else
2593
-        if($focus->bean_implements('ACL') && ACLController::requireSecurityGroup($focus->module_dir, 'list') )
2593
+        if ($focus->bean_implements('ACL') && ACLController::requireSecurityGroup($focus->module_dir, 'list'))
2594 2594
         {
2595 2595
             require_once('modules/SecurityGroups/SecurityGroup.php');
2596 2596
             $owner_where = $focus->getOwnerWhere($current_user->id);
2597
-            $group_where = SecurityGroup::getGroupWhere($focus->table_name,$focus->module_dir,$current_user->id);
2598
-            if(!empty($owner_where)){
2599
-                $query .= " AND (".  $owner_where." or ".$group_where.") ";
2597
+            $group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id);
2598
+            if (!empty($owner_where)) {
2599
+                $query .= " AND (".$owner_where." or ".$group_where.") ";
2600 2600
             } else {
2601
-                $query .= ' AND '.  $group_where;
2601
+                $query .= ' AND '.$group_where;
2602 2602
             }
2603 2603
         }
2604 2604
         /* END - SECURITY GROUPS */
2605 2605
 
2606
-		if ( $order_by != '')
2606
+		if ($order_by != '')
2607 2607
 		{
2608 2608
 			$query .= " order by {$focus->table_name}.{$order_by}";
2609 2609
 		}
@@ -2611,9 +2611,9 @@  discard block
 block discarded – undo
2611 2611
 		$GLOBALS['log']->debug("get_user_array query: $query");
2612 2612
 		$result = $db->query($query, true, "Error filling in user array: ");
2613 2613
 
2614
-		if ($add_blank==true){
2614
+		if ($add_blank == true) {
2615 2615
 			// Add in a blank row
2616
-			if($blank_is_none == true) { // set 'blank row' to "--None--"
2616
+			if ($blank_is_none == true) { // set 'blank row' to "--None--"
2617 2617
 				global $app_strings;
2618 2618
 				$temp_result[''] = $app_strings['LBL_NONE'];
2619 2619
 			} else {
@@ -2622,13 +2622,13 @@  discard block
 block discarded – undo
2622 2622
 		}
2623 2623
 
2624 2624
 		// Get the id and the name.
2625
-		while($row = $db->fetchByAssoc($result))
2625
+		while ($row = $db->fetchByAssoc($result))
2626 2626
 		{
2627 2627
 			$temp_result[$row['id']] = $row['display'];
2628 2628
 		}
2629 2629
 
2630 2630
 		$user_array = $temp_result;
2631
-		set_register_value('select_array', $key ,$temp_result);
2631
+		set_register_value('select_array', $key, $temp_result);
2632 2632
 	}
2633 2633
 
2634 2634
 	return $user_array;
@@ -2646,21 +2646,21 @@  discard block
 block discarded – undo
2646 2646
 	global $modListHeader;
2647 2647
 	$returnArray = array();
2648 2648
 
2649
-	foreach($listArray as $optionName => $optionVal)
2649
+	foreach ($listArray as $optionName => $optionVal)
2650 2650
 	{
2651
-		if(array_key_exists($optionName, $modListHeader))
2651
+		if (array_key_exists($optionName, $modListHeader))
2652 2652
 		{
2653 2653
 			$returnArray[$optionName] = $optionVal;
2654 2654
 		}
2655 2655
 
2656 2656
 		// special case for projects
2657
-		if(array_key_exists('Project', $modListHeader))
2657
+		if (array_key_exists('Project', $modListHeader))
2658 2658
 		{
2659 2659
 			$returnArray['ProjectTask'] = $listArray['ProjectTask'];
2660 2660
 		}
2661 2661
 	}
2662
-	$acldenied = ACLController::disabledModuleList($listArray,false);
2663
-	foreach($acldenied as $denied){
2662
+	$acldenied = ACLController::disabledModuleList($listArray, false);
2663
+	foreach ($acldenied as $denied) {
2664 2664
 		unset($returnArray[$denied]);
2665 2665
 	}
2666 2666
 	asort($returnArray);
@@ -2668,21 +2668,21 @@  discard block
 block discarded – undo
2668 2668
 	return $returnArray;
2669 2669
 }
2670 2670
 
2671
-function display_notice($msg = false){
2671
+function display_notice($msg = false) {
2672 2672
 	global $error_notice;
2673 2673
 	//no error notice - lets just display the error to the user
2674
-	if(!isset($error_notice)){
2675
-		echo '<br>'.$msg . '<br>';
2676
-	}else{
2677
-		$error_notice .= $msg . '<br>';
2674
+	if (!isset($error_notice)) {
2675
+		echo '<br>'.$msg.'<br>';
2676
+	} else {
2677
+		$error_notice .= $msg.'<br>';
2678 2678
 	}
2679 2679
 }
2680 2680
 
2681 2681
 /* checks if it is a number that at least has the plus at the beginning.
2682 2682
  */
2683
-function skype_formatted($number){
2683
+function skype_formatted($number) {
2684 2684
 	//kbrill - BUG #15375
2685
-	if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
2685
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == "Popup") {
2686 2686
 		return false;
2687 2687
 	} else {
2688 2688
 		return substr($number, 0, 1) == '+' || substr($number, 0, 2) == '00' || substr($number, 0, 3) == '011';
@@ -2691,7 +2691,7 @@  discard block
 block discarded – undo
2691 2691
 }
2692 2692
 
2693 2693
 function format_skype($number) {
2694
-    return preg_replace('/[^\+0-9]/','',$number);
2694
+    return preg_replace('/[^\+0-9]/', '', $number);
2695 2695
 }
2696 2696
 
2697 2697
 function insert_charset_header() {
@@ -2701,23 +2701,23 @@  discard block
 block discarded – undo
2701 2701
 function getCurrentURL()
2702 2702
 {
2703 2703
 	$href = "http:";
2704
-	if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
2704
+	if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
2705 2705
 	{
2706 2706
 		$href = 'https:';
2707 2707
 	}
2708 2708
 
2709
-	$href.= "//".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
2709
+	$href .= "//".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
2710 2710
 	return $href;
2711 2711
 }
2712 2712
 
2713 2713
 function javascript_escape($str) {
2714 2714
 	$new_str = '';
2715 2715
 
2716
-	for($i = 0; $i < strlen($str); $i++) {
2716
+	for ($i = 0; $i < strlen($str); $i++) {
2717 2717
 
2718
-		if(ord(substr($str, $i, 1))==10){
2718
+		if (ord(substr($str, $i, 1)) == 10) {
2719 2719
 			$new_str .= '\n';
2720
-		}elseif(ord(substr($str, $i, 1))==13){
2720
+		}elseif (ord(substr($str, $i, 1)) == 13) {
2721 2721
 			$new_str .= '\r';
2722 2722
 		}
2723 2723
 		else {
@@ -2730,10 +2730,10 @@  discard block
 block discarded – undo
2730 2730
 	return $new_str;
2731 2731
 }
2732 2732
 
2733
-function js_escape($str, $keep=true){
2733
+function js_escape($str, $keep = true) {
2734 2734
 	$str = html_entity_decode(str_replace("\\", "", $str), ENT_QUOTES);
2735 2735
 
2736
-	if($keep){
2736
+	if ($keep) {
2737 2737
 		$str = javascript_escape($str);
2738 2738
 	}
2739 2739
 	else {
@@ -2750,11 +2750,11 @@  discard block
 block discarded – undo
2750 2750
 	$regex = "#<[^>]+br.+?>#i";
2751 2751
 	preg_match_all($regex, $str, $matches);
2752 2752
 
2753
-	foreach($matches[0] as $match) {
2753
+	foreach ($matches[0] as $match) {
2754 2754
 		$str = str_replace($match, "<br>", $str);
2755 2755
 	}
2756 2756
 
2757
-	$brs = array('<br>','<br/>', '<br />');
2757
+	$brs = array('<br>', '<br/>', '<br />');
2758 2758
 	$str = str_replace("\r\n", "\n", $str); // make from windows-returns, *nix-returns
2759 2759
 	$str = str_replace("\n\r", "\n", $str); // make from windows-returns, *nix-returns
2760 2760
 	$str = str_replace("\r", "\n", $str); // make from windows-returns, *nix-returns
@@ -2781,20 +2781,20 @@  discard block
 block discarded – undo
2781 2781
  * @param $die boolean end script flow
2782 2782
  * @param $displayStackTrace also show stack trace
2783 2783
  */
2784
-function _ppl($mixed, $die=false, $displayStackTrace=false, $loglevel="fatal") {
2785
-	if(!isset($GLOBALS['log']) || empty($GLOBALS['log'])) {
2784
+function _ppl($mixed, $die = false, $displayStackTrace = false, $loglevel = "fatal") {
2785
+	if (!isset($GLOBALS['log']) || empty($GLOBALS['log'])) {
2786 2786
 
2787 2787
 		$GLOBALS['log'] = LoggerManager :: getLogger('SugarCRM');
2788 2788
 	}
2789 2789
 
2790 2790
 
2791
-	$mix	= print_r($mixed, true); // send print_r() output to $mix
2792
-	$stack	= debug_backtrace();
2791
+	$mix = print_r($mixed, true); // send print_r() output to $mix
2792
+	$stack = debug_backtrace();
2793 2793
 
2794 2794
 	$GLOBALS['log']->$loglevel('------------------------------ _ppLogger() output start -----------------------------');
2795 2795
 	$GLOBALS['log']->$loglevel($mix);
2796
-	if($displayStackTrace) {
2797
-		foreach($stack as $position) {
2796
+	if ($displayStackTrace) {
2797
+		foreach ($stack as $position) {
2798 2798
 			$GLOBALS['log']->$loglevel($position['file']."({$position['line']})");
2799 2799
 		}
2800 2800
 	}
@@ -2802,7 +2802,7 @@  discard block
 block discarded – undo
2802 2802
 	$GLOBALS['log']->$loglevel('------------------------------ _ppLogger() output end -----------------------------');
2803 2803
 	$GLOBALS['log']->$loglevel('------------------------------ _ppLogger() file: '.$stack[0]['file'].' line#: '.$stack[0]['line'].'-----------------------------');
2804 2804
 
2805
-	if($die) {
2805
+	if ($die) {
2806 2806
 		die();
2807 2807
 	}
2808 2808
 }
@@ -2812,7 +2812,7 @@  discard block
 block discarded – undo
2812 2812
  * The ppf stands for Pre[formatted] Print Focus [object]
2813 2813
  * @param object bean The focus bean
2814 2814
  */
2815
-function _ppf($bean, $die=false) {
2815
+function _ppf($bean, $die = false) {
2816 2816
 }
2817 2817
 
2818 2818
 
@@ -2831,7 +2831,7 @@  discard block
 block discarded – undo
2831 2831
  * This function is only intended to be used for SugarCRM internal development.
2832 2832
  * The pp stands for Pre Print.
2833 2833
  */
2834
-function _pstack_trace($mixed=NULL)
2834
+function _pstack_trace($mixed = NULL)
2835 2835
 {
2836 2836
 }
2837 2837
 
@@ -2840,7 +2840,7 @@  discard block
 block discarded – undo
2840 2840
  * This function is only intended to be used for SugarCRM internal development.
2841 2841
  * The pp stands for Pre Print Trace.
2842 2842
  */
2843
-function _ppt($mixed, $textOnly=false)
2843
+function _ppt($mixed, $textOnly = false)
2844 2844
 {
2845 2845
 }
2846 2846
 
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
 
2878 2878
 	// only the supported versions,
2879 2879
 	// should be mutually exclusive with $invalid_php_versions
2880
-	$supported_php_versions = array (
2880
+	$supported_php_versions = array(
2881 2881
     	'5.3.0'
2882 2882
 	);
2883 2883
 
@@ -2891,21 +2891,21 @@  discard block
 block discarded – undo
2891 2891
 	$retval = 0;
2892 2892
 
2893 2893
 	// versions below $min_considered_php_version are invalid
2894
-	if(1 == version_compare($sys_php_version, $min_considered_php_version, '<')) {
2894
+	if (1 == version_compare($sys_php_version, $min_considered_php_version, '<')) {
2895 2895
 		$retval = -1;
2896 2896
 	}
2897 2897
 
2898 2898
 	// supported version check overrides default unsupported
2899
-	foreach($supported_php_versions as $ver) {
2900
-		if(1 == version_compare($sys_php_version, $ver, 'eq') || strpos($sys_php_version,$ver) !== false) {
2899
+	foreach ($supported_php_versions as $ver) {
2900
+		if (1 == version_compare($sys_php_version, $ver, 'eq') || strpos($sys_php_version, $ver) !== false) {
2901 2901
 			$retval = 1;
2902 2902
 			break;
2903 2903
 		}
2904 2904
 	}
2905 2905
 
2906 2906
 	// invalid version check overrides default unsupported
2907
-	foreach($invalid_php_versions as $ver) {
2908
-		if(1 == version_compare($sys_php_version, $ver, 'eq') && strpos($sys_php_version,$ver) !== false) {
2907
+	foreach ($invalid_php_versions as $ver) {
2908
+		if (1 == version_compare($sys_php_version, $ver, 'eq') && strpos($sys_php_version, $ver) !== false) {
2909 2909
 			$retval = -1;
2910 2910
 			break;
2911 2911
 		}
@@ -2913,7 +2913,7 @@  discard block
 block discarded – undo
2913 2913
 
2914 2914
     //allow a redhat distro to install, regardless of version.  We are assuming the redhat naming convention is followed
2915 2915
     //and the php version contains 'rh' characters
2916
-    if(strpos($sys_php_version, 'rh') !== false) {
2916
+    if (strpos($sys_php_version, 'rh') !== false) {
2917 2917
         $retval = 1;
2918 2918
     }
2919 2919
 
@@ -2931,7 +2931,7 @@  discard block
 block discarded – undo
2931 2931
 
2932 2932
 	$server_software = $_SERVER["SERVER_SOFTWARE"];
2933 2933
 	$iis_version = '';
2934
-	if(strpos($server_software,'Microsoft-IIS') !== false && preg_match_all("/^.*\/(\d+\.?\d*)$/",  $server_software, $out))
2934
+	if (strpos($server_software, 'Microsoft-IIS') !== false && preg_match_all("/^.*\/(\d+\.?\d*)$/", $server_software, $out))
2935 2935
 	    $iis_version = $out[1][0];
2936 2936
 
2937 2937
     $sys_iis_version = empty($sys_iis_version) ? $iis_version : $sys_iis_version;
@@ -2943,7 +2943,7 @@  discard block
 block discarded – undo
2943 2943
 
2944 2944
     // only the supported versions,
2945 2945
     // should be mutually exclusive with $invalid_iis_versions
2946
-    $supported_iis_versions = array ('6.0', '7.0',);
2946
+    $supported_iis_versions = array('6.0', '7.0',);
2947 2947
     $unsupported_iis_versions = array();
2948 2948
     $invalid_iis_versions = array('5.0',);
2949 2949
 
@@ -2951,29 +2951,29 @@  discard block
 block discarded – undo
2951 2951
     $retval = 0;
2952 2952
 
2953 2953
     // versions below $min_considered_iis_version are invalid
2954
-    if(1 == version_compare($sys_iis_version, $min_considered_iis_version, '<')) {
2954
+    if (1 == version_compare($sys_iis_version, $min_considered_iis_version, '<')) {
2955 2955
         $retval = -1;
2956 2956
     }
2957 2957
 
2958 2958
     // supported version check overrides default unsupported
2959
-    foreach($supported_iis_versions as $ver) {
2960
-        if(1 == version_compare($sys_iis_version, $ver, 'eq') || strpos($sys_iis_version,$ver) !== false) {
2959
+    foreach ($supported_iis_versions as $ver) {
2960
+        if (1 == version_compare($sys_iis_version, $ver, 'eq') || strpos($sys_iis_version, $ver) !== false) {
2961 2961
             $retval = 1;
2962 2962
             break;
2963 2963
         }
2964 2964
     }
2965 2965
 
2966 2966
     // unsupported version check overrides default unsupported
2967
-    foreach($unsupported_iis_versions as $ver) {
2968
-        if(1 == version_compare($sys_iis_version, $ver, 'eq') && strpos($sys_iis_version,$ver) !== false) {
2967
+    foreach ($unsupported_iis_versions as $ver) {
2968
+        if (1 == version_compare($sys_iis_version, $ver, 'eq') && strpos($sys_iis_version, $ver) !== false) {
2969 2969
             $retval = 0;
2970 2970
             break;
2971 2971
         }
2972 2972
     }
2973 2973
 
2974 2974
     // invalid version check overrides default unsupported
2975
-    foreach($invalid_iis_versions as $ver) {
2976
-        if(1 == version_compare($sys_iis_version, $ver, 'eq') && strpos($sys_iis_version,$ver) !== false) {
2975
+    foreach ($invalid_iis_versions as $ver) {
2976
+        if (1 == version_compare($sys_iis_version, $ver, 'eq') && strpos($sys_iis_version, $ver) !== false) {
2977 2977
             $retval = -1;
2978 2978
             break;
2979 2979
         }
@@ -2982,18 +2982,18 @@  discard block
 block discarded – undo
2982 2982
     return $retval;
2983 2983
 }
2984 2984
 
2985
-function pre_login_check(){
2985
+function pre_login_check() {
2986 2986
 	global $action, $login_error;
2987
-	if(!empty($action)&& $action == 'Login'){
2987
+	if (!empty($action) && $action == 'Login') {
2988 2988
 
2989
-		if(!empty($login_error)){
2989
+		if (!empty($login_error)) {
2990 2990
 			$login_error = htmlentities($login_error);
2991
-			$login_error = str_replace(array("&lt;pre&gt;","&lt;/pre&gt;","\r\n", "\n"), "<br>", $login_error);
2991
+			$login_error = str_replace(array("&lt;pre&gt;", "&lt;/pre&gt;", "\r\n", "\n"), "<br>", $login_error);
2992 2992
 			$_SESSION['login_error'] = $login_error;
2993 2993
 			echo '<script>
2994 2994
 						function set_focus() {}
2995 2995
 						if(document.getElementById("post_error")) {
2996
-							document.getElementById("post_error").innerHTML="'. $login_error. '";
2996
+							document.getElementById("post_error").innerHTML="'. $login_error.'";
2997 2997
 							document.getElementById("cant_login").value=1;
2998 2998
 							document.getElementById("login_button").disabled = true;
2999 2999
 							document.getElementById("user_name").disabled = true;
@@ -3008,10 +3008,10 @@  discard block
 block discarded – undo
3008 3008
 
3009 3009
 function sugar_cleanup($exit = false) {
3010 3010
 	static $called = false;
3011
-	if($called)return;
3011
+	if ($called)return;
3012 3012
 	$called = true;
3013
-	set_include_path(realpath(dirname(__FILE__) . '/..') . PATH_SEPARATOR . get_include_path());
3014
-	chdir(realpath(dirname(__FILE__) . '/..'));
3013
+	set_include_path(realpath(dirname(__FILE__).'/..').PATH_SEPARATOR.get_include_path());
3014
+	chdir(realpath(dirname(__FILE__).'/..'));
3015 3015
 	global $sugar_config;
3016 3016
 	require_once('include/utils/LogicHook.php');
3017 3017
 	LogicHook::initialize();
@@ -3027,20 +3027,20 @@  discard block
 block discarded – undo
3027 3027
 	}
3028 3028
 	Tracker::logPage();
3029 3029
 	// Now write the cached tracker_queries
3030
-	if(!empty($GLOBALS['savePreferencesToDB']) && $GLOBALS['savePreferencesToDB']) {
3031
-	    if ( isset($GLOBALS['current_user']) && $GLOBALS['current_user'] instanceOf User )
3030
+	if (!empty($GLOBALS['savePreferencesToDB']) && $GLOBALS['savePreferencesToDB']) {
3031
+	    if (isset($GLOBALS['current_user']) && $GLOBALS['current_user'] instanceOf User)
3032 3032
 	        $GLOBALS['current_user']->savePreferencesToDB();
3033 3033
 	}
3034 3034
 
3035 3035
 	//check to see if this is not an `ajax call AND the user preference error flag is set
3036
-	if(
3036
+	if (
3037 3037
 		(isset($_SESSION['USER_PREFRENCE_ERRORS']) && $_SESSION['USER_PREFRENCE_ERRORS'])
3038
-		&& ($_REQUEST['action']!='modulelistmenu' && $_REQUEST['action']!='DynamicAction')
3039
-		&& ($_REQUEST['action']!='favorites' && $_REQUEST['action']!='DynamicAction')
3040
-		&& (empty($_REQUEST['to_pdf']) || !$_REQUEST['to_pdf'] )
3041
-		&& (empty($_REQUEST['sugar_body_only']) || !$_REQUEST['sugar_body_only'] )
3038
+		&& ($_REQUEST['action'] != 'modulelistmenu' && $_REQUEST['action'] != 'DynamicAction')
3039
+		&& ($_REQUEST['action'] != 'favorites' && $_REQUEST['action'] != 'DynamicAction')
3040
+		&& (empty($_REQUEST['to_pdf']) || !$_REQUEST['to_pdf'])
3041
+		&& (empty($_REQUEST['sugar_body_only']) || !$_REQUEST['sugar_body_only'])
3042 3042
 
3043
-	){
3043
+	) {
3044 3044
 		global $app_strings;
3045 3045
 		//this is not an ajax call and the user preference error flag is set, so reset the flag and print js to flash message
3046 3046
 		$err_mess = $app_strings['ERROR_USER_PREFS'];
@@ -3053,10 +3053,10 @@  discard block
 block discarded – undo
3053 3053
 	}
3054 3054
 
3055 3055
 	pre_login_check();
3056
-	if(class_exists('DBManagerFactory')) {
3056
+	if (class_exists('DBManagerFactory')) {
3057 3057
 		$db = DBManagerFactory::getInstance();
3058 3058
 		$db->disconnect();
3059
-		if($exit) {
3059
+		if ($exit) {
3060 3060
 			exit;
3061 3061
 		}
3062 3062
 	}
@@ -3070,27 +3070,27 @@  discard block
 block discarded – undo
3070 3070
  if not, it will add it. If the file isn't built yet, it will create the file
3071 3071
 
3072 3072
  */
3073
-function check_logic_hook_file($module_name, $event, $action_array){
3073
+function check_logic_hook_file($module_name, $event, $action_array) {
3074 3074
 	require_once('include/utils/logic_utils.php');
3075 3075
 	$add_logic = false;
3076 3076
 
3077
-	if(file_exists("custom/modules/$module_name/logic_hooks.php")){
3077
+	if (file_exists("custom/modules/$module_name/logic_hooks.php")) {
3078 3078
 
3079 3079
 		$hook_array = get_hook_array($module_name);
3080 3080
 
3081
-		if(check_existing_element($hook_array, $event, $action_array)==true){
3081
+		if (check_existing_element($hook_array, $event, $action_array) == true) {
3082 3082
 			//the hook at hand is present, so do nothing
3083 3083
 		} else {
3084 3084
 			$add_logic = true;
3085 3085
 
3086 3086
             $logic_count = 0;
3087
-            if(!empty($hook_array[$event]))
3087
+            if (!empty($hook_array[$event]))
3088 3088
             {
3089 3089
 			    $logic_count = count($hook_array[$event]);
3090 3090
             }
3091 3091
 
3092
-			if($action_array[0]==""){
3093
-				$action_array[0] = $logic_count  + 1;
3092
+			if ($action_array[0] == "") {
3093
+				$action_array[0] = $logic_count + 1;
3094 3094
 			}
3095 3095
 			$hook_array[$event][] = $action_array;
3096 3096
 
@@ -3098,14 +3098,14 @@  discard block
 block discarded – undo
3098 3098
 		//end if the file exists already
3099 3099
 	} else {
3100 3100
 		$add_logic = true;
3101
-		if($action_array[0]==""){
3101
+		if ($action_array[0] == "") {
3102 3102
 			$action_array[0] = 1;
3103 3103
 		}
3104 3104
 		$hook_array = array();
3105 3105
 		$hook_array[$event][] = $action_array;
3106 3106
 		//end if else file exists already
3107 3107
 	}
3108
-	if($add_logic == true){
3108
+	if ($add_logic == true) {
3109 3109
 
3110 3110
 		//reorder array by element[0]
3111 3111
 		//$hook_array = reorder_array($hook_array, $event);
@@ -3124,19 +3124,19 @@  discard block
 block discarded – undo
3124 3124
     require_once('include/utils/logic_utils.php');
3125 3125
 	$add_logic = false;
3126 3126
 
3127
-	if(file_exists("custom/modules/".$module_name."/logic_hooks.php")){
3127
+	if (file_exists("custom/modules/".$module_name."/logic_hooks.php")) {
3128 3128
         // The file exists, let's make sure the hook is there
3129 3129
 		$hook_array = get_hook_array($module_name);
3130 3130
 
3131
-		if(check_existing_element($hook_array, $event, $action_array)==true){
3131
+		if (check_existing_element($hook_array, $event, $action_array) == true) {
3132 3132
             // The hook is there, time to take it out.
3133 3133
 
3134
-            foreach ( $hook_array[$event] as $i => $hook ) {
3134
+            foreach ($hook_array[$event] as $i => $hook) {
3135 3135
                 // We don't do a full comparison below just in case the filename changes
3136
-                if ( $hook[0] == $action_array[0]
3136
+                if ($hook[0] == $action_array[0]
3137 3137
                      && $hook[1] == $action_array[1]
3138 3138
                      && $hook[3] == $action_array[3]
3139
-                     && $hook[4] == $action_array[4] ) {
3139
+                     && $hook[4] == $action_array[4]) {
3140 3140
                     unset($hook_array[$event][$i]);
3141 3141
                 }
3142 3142
             }
@@ -3148,53 +3148,53 @@  discard block
 block discarded – undo
3148 3148
     }
3149 3149
 }
3150 3150
 
3151
-function display_stack_trace($textOnly=false){
3151
+function display_stack_trace($textOnly = false) {
3152 3152
 
3153
-	$stack  = debug_backtrace();
3153
+	$stack = debug_backtrace();
3154 3154
 
3155
-	echo "\n\n display_stack_trace caller, file: " . $stack[0]['file']. ' line#: ' .$stack[0]['line'];
3155
+	echo "\n\n display_stack_trace caller, file: ".$stack[0]['file'].' line#: '.$stack[0]['line'];
3156 3156
 
3157
-	if(!$textOnly)
3157
+	if (!$textOnly)
3158 3158
 	echo '<br>';
3159 3159
 
3160 3160
 	$first = true;
3161 3161
 	$out = '';
3162 3162
 
3163
-	foreach($stack as $item) {
3163
+	foreach ($stack as $item) {
3164 3164
 		$file  = '';
3165 3165
 		$class = '';
3166 3166
 		$line  = '';
3167
-		$function  = '';
3167
+		$function = '';
3168 3168
 
3169
-		if(isset($item['file']))
3169
+		if (isset($item['file']))
3170 3170
 		$file = $item['file'];
3171
-		if(isset($item['class']))
3171
+		if (isset($item['class']))
3172 3172
 		$class = $item['class'];
3173
-		if(isset($item['line']))
3173
+		if (isset($item['line']))
3174 3174
 		$line = $item['line'];
3175
-		if(isset($item['function']))
3175
+		if (isset($item['function']))
3176 3176
 		$function = $item['function'];
3177 3177
 
3178
-		if(!$first) {
3179
-			if(!$textOnly) {
3178
+		if (!$first) {
3179
+			if (!$textOnly) {
3180 3180
 				$out .= '<font color="black"><b>';
3181 3181
 			}
3182 3182
 
3183 3183
 			$out .= $file;
3184 3184
 
3185
-			if(!$textOnly) {
3185
+			if (!$textOnly) {
3186 3186
 				$out .= '</b></font><font color="blue">';
3187 3187
 			}
3188 3188
 
3189 3189
 			$out .= "[L:{$line}]";
3190 3190
 
3191
-			if(!$textOnly) {
3191
+			if (!$textOnly) {
3192 3192
 				$out .= '</font><font color="red">';
3193 3193
 			}
3194 3194
 
3195 3195
 			$out .= "({$class}:{$function})";
3196 3196
 
3197
-			if(!$textOnly) {
3197
+			if (!$textOnly) {
3198 3198
 				$out .= '</font><br>';
3199 3199
 			} else {
3200 3200
 				$out .= "\n";
@@ -3207,14 +3207,14 @@  discard block
 block discarded – undo
3207 3207
 	echo $out;
3208 3208
 }
3209 3209
 
3210
-function StackTraceErrorHandler($errno, $errstr, $errfile,$errline, $errcontext) {
3211
-	$error_msg = " $errstr occurred in <b>$errfile</b> on line $errline [" . date("Y-m-d H:i:s") . ']';
3210
+function StackTraceErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
3211
+	$error_msg = " $errstr occurred in <b>$errfile</b> on line $errline [".date("Y-m-d H:i:s").']';
3212 3212
 	$halt_script = true;
3213
-	switch($errno){
3213
+	switch ($errno) {
3214 3214
 		case 2048: return; //depricated we have lots of these ignore them
3215 3215
 		case E_USER_NOTICE:
3216 3216
 		case E_NOTICE:
3217
-		    if ( error_reporting() & E_NOTICE ) {
3217
+		    if (error_reporting() & E_NOTICE) {
3218 3218
 		        $halt_script = false;
3219 3219
 		        $type = 'Notice';
3220 3220
 		    }
@@ -3249,10 +3249,10 @@  discard block
 block discarded – undo
3249 3249
 			$type = "Unknown Error ($errno)";
3250 3250
 			break;
3251 3251
 	}
3252
-	$error_msg = '<b>'.$type.'</b>:' . $error_msg;
3252
+	$error_msg = '<b>'.$type.'</b>:'.$error_msg;
3253 3253
 	echo $error_msg;
3254 3254
 	display_stack_trace();
3255
-	if($halt_script){
3255
+	if ($halt_script) {
3256 3256
 		exit -1;
3257 3257
 	}
3258 3258
 
@@ -3261,16 +3261,16 @@  discard block
 block discarded – undo
3261 3261
 }
3262 3262
 
3263 3263
 
3264
-if(isset($sugar_config['stack_trace_errors']) && $sugar_config['stack_trace_errors']){
3264
+if (isset($sugar_config['stack_trace_errors']) && $sugar_config['stack_trace_errors']) {
3265 3265
 
3266 3266
 	set_error_handler('StackTraceErrorHandler');
3267 3267
 }
3268
-function get_sub_cookies($name){
3268
+function get_sub_cookies($name) {
3269 3269
 	$cookies = array();
3270
-	if(isset($_COOKIE[$name])){
3270
+	if (isset($_COOKIE[$name])) {
3271 3271
 		$subs = explode('#', $_COOKIE[$name]);
3272
-		foreach($subs as $cookie){
3273
-			if(!empty($cookie)){
3272
+		foreach ($subs as $cookie) {
3273
+			if (!empty($cookie)) {
3274 3274
 				$cookie = explode('=', $cookie);
3275 3275
 
3276 3276
 				$cookies[$cookie[0]] = $cookie[1];
@@ -3282,16 +3282,16 @@  discard block
 block discarded – undo
3282 3282
 }
3283 3283
 
3284 3284
 
3285
-function mark_delete_components($sub_object_array, $run_second_level=false, $sub_sub_array=""){
3285
+function mark_delete_components($sub_object_array, $run_second_level = false, $sub_sub_array = "") {
3286 3286
 
3287
-	if(!empty($sub_object_array)){
3287
+	if (!empty($sub_object_array)) {
3288 3288
 
3289
-		foreach($sub_object_array as $sub_object){
3289
+		foreach ($sub_object_array as $sub_object) {
3290 3290
 
3291 3291
 			//run_second level is set to true if you need to remove sub-sub components
3292
-			if($run_second_level==true){
3292
+			if ($run_second_level == true) {
3293 3293
 
3294
-				mark_delete_components($sub_object->get_linked_beans($sub_sub_array['rel_field'],$sub_sub_array['rel_module']));
3294
+				mark_delete_components($sub_object->get_linked_beans($sub_sub_array['rel_field'], $sub_sub_array['rel_module']));
3295 3295
 
3296 3296
 				//end if run_second_level is true
3297 3297
 			}
@@ -3310,9 +3310,9 @@  discard block
 block discarded – undo
3310 3310
 function return_bytes($val)
3311 3311
 {
3312 3312
 	$val = trim($val);
3313
-	$last = strtolower($val{strlen($val)-1});
3313
+	$last = strtolower($val{strlen($val) - 1});
3314 3314
 
3315
-	switch($last)
3315
+	switch ($last)
3316 3316
 	{
3317 3317
 		// The 'G' modifier is available since PHP 5.1.0
3318 3318
 		case 'g':
@@ -3353,27 +3353,27 @@  discard block
 block discarded – undo
3353 3353
  * @return bool true if writable
3354 3354
  */
3355 3355
 function is_writable_windows($file) {
3356
-	if($file{strlen($file)-1}=='/') {
3356
+	if ($file{strlen($file) - 1} == '/') {
3357 3357
 		return is_writable_windows($file.uniqid(mt_rand()).'.tmp');
3358 3358
 	}
3359 3359
 
3360 3360
 	// the assumption here is that Windows has an inherited permissions scheme
3361 3361
 	// any file that is a descendant of an unwritable directory will inherit
3362 3362
 	// that property and will trigger a failure below.
3363
-	if(is_dir($file)) {
3363
+	if (is_dir($file)) {
3364 3364
 		return true;
3365 3365
 	}
3366 3366
 
3367 3367
 	$file = str_replace("/", '\\', $file);
3368 3368
 
3369
-	if(file_exists($file)) {
3369
+	if (file_exists($file)) {
3370 3370
 		if (!($f = @sugar_fopen($file, 'r+')))
3371 3371
 		return false;
3372 3372
 		fclose($f);
3373 3373
 		return true;
3374 3374
 	}
3375 3375
 
3376
-	if(!($f = @sugar_fopen($file, 'w')))
3376
+	if (!($f = @sugar_fopen($file, 'w')))
3377 3377
 	return false;
3378 3378
 	fclose($f);
3379 3379
 	unlink($file);
@@ -3389,16 +3389,16 @@  discard block
 block discarded – undo
3389 3389
     return TimeDate::guessTimezone($userOffset);
3390 3390
 }
3391 3391
 
3392
-function convert_module_to_singular($module_array){
3392
+function convert_module_to_singular($module_array) {
3393 3393
 	global $beanList;
3394 3394
 
3395
-	foreach($module_array as $key => $value){
3396
-		if(!empty($beanList[$value])) $module_array[$key] = $beanList[$value];
3395
+	foreach ($module_array as $key => $value) {
3396
+		if (!empty($beanList[$value])) $module_array[$key] = $beanList[$value];
3397 3397
 
3398
-		if($value=="Cases") {
3398
+		if ($value == "Cases") {
3399 3399
 			$module_array[$key] = "Case";
3400 3400
 		}
3401
-		if($key=="projecttask"){
3401
+		if ($key == "projecttask") {
3402 3402
 			$module_array['ProjectTask'] = "Project Task";
3403 3403
 			unset($module_array[$key]);
3404 3404
 		}
@@ -3413,12 +3413,12 @@  discard block
 block discarded – undo
3413 3413
  * Given the bean_name which may be plural or singular return the singular
3414 3414
  * bean_name. This is important when you need to include files.
3415 3415
  */
3416
-function get_singular_bean_name($bean_name){
3416
+function get_singular_bean_name($bean_name) {
3417 3417
 	global $beanFiles, $beanList;
3418
-	if(array_key_exists($bean_name, $beanList)){
3418
+	if (array_key_exists($bean_name, $beanList)) {
3419 3419
 		return $beanList[$bean_name];
3420 3420
 	}
3421
-	else{
3421
+	else {
3422 3422
 		return $bean_name;
3423 3423
 	}
3424 3424
 }
@@ -3457,13 +3457,13 @@  discard block
 block discarded – undo
3457 3457
     return $singular;
3458 3458
 }
3459 3459
 
3460
-function get_label($label_tag, $temp_module_strings){
3460
+function get_label($label_tag, $temp_module_strings) {
3461 3461
 	global $app_strings;
3462
-	if(!empty($temp_module_strings[$label_tag])){
3462
+	if (!empty($temp_module_strings[$label_tag])) {
3463 3463
 
3464 3464
 		$label_name = $temp_module_strings[$label_tag];
3465 3465
 	} else {
3466
-		if(!empty($app_strings[$label_tag])){
3466
+		if (!empty($app_strings[$label_tag])) {
3467 3467
 			$label_name = $app_strings[$label_tag];
3468 3468
 		} else {
3469 3469
 			$label_name = $label_tag;
@@ -3475,16 +3475,16 @@  discard block
 block discarded – undo
3475 3475
 }
3476 3476
 
3477 3477
 
3478
-function search_filter_rel_info(& $focus, $tar_rel_module, $relationship_name){
3478
+function search_filter_rel_info(& $focus, $tar_rel_module, $relationship_name) {
3479 3479
 
3480 3480
 	$rel_list = array();
3481 3481
 
3482
-	foreach($focus->relationship_fields as $rel_key => $rel_value){
3483
-		if($rel_value == $relationship_name){
3482
+	foreach ($focus->relationship_fields as $rel_key => $rel_value) {
3483
+		if ($rel_value == $relationship_name) {
3484 3484
 			$temp_bean = get_module_info($tar_rel_module);
3485 3485
 	//		echo $focus->$rel_key;
3486 3486
 			$temp_bean->retrieve($focus->$rel_key);
3487
-			if($temp_bean->id!=""){
3487
+			if ($temp_bean->id != "") {
3488 3488
 
3489 3489
 				$rel_list[] = $temp_bean;
3490 3490
 				return $rel_list;
@@ -3492,9 +3492,9 @@  discard block
 block discarded – undo
3492 3492
 		}
3493 3493
 	}
3494 3494
 
3495
-	foreach($focus->field_defs as $field_name => $field_def){
3495
+	foreach ($focus->field_defs as $field_name => $field_def) {
3496 3496
 		//Check if the relationship_name matches a "relate" field
3497
-		if(!empty($field_def['type']) && $field_def['type'] == 'relate'
3497
+		if (!empty($field_def['type']) && $field_def['type'] == 'relate'
3498 3498
 		&& !empty($field_def['id_name']) && !empty($focus->field_defs[$field_def['id_name']])
3499 3499
 		&& !empty($focus->field_defs[$field_def['id_name']]['relationship'])
3500 3500
 		&& $focus->field_defs[$field_def['id_name']]['relationship'] == $relationship_name)
@@ -3502,17 +3502,17 @@  discard block
 block discarded – undo
3502 3502
 			$temp_bean = get_module_info($tar_rel_module);
3503 3503
 		//	echo $focus->$field_def['id_name'];
3504 3504
 			$temp_bean->retrieve($focus->$field_def['id_name']);
3505
-			if($temp_bean->id!=""){
3505
+			if ($temp_bean->id != "") {
3506 3506
 
3507 3507
 				$rel_list[] = $temp_bean;
3508 3508
 				return $rel_list;
3509 3509
 			}
3510 3510
 		//Check if the relationship_name matches a "link" in a relate field
3511
-		} else if(!empty($rel_value['link']) && !empty($rel_value['id_name']) && $rel_value['link'] == $relationship_name){
3511
+		} else if (!empty($rel_value['link']) && !empty($rel_value['id_name']) && $rel_value['link'] == $relationship_name) {
3512 3512
 			$temp_bean = get_module_info($tar_rel_module);
3513 3513
 		//	echo $focus->$rel_value['id_name'];
3514 3514
 			$temp_bean->retrieve($focus->$rel_value['id_name']);
3515
-			if($temp_bean->id!=""){
3515
+			if ($temp_bean->id != "") {
3516 3516
 
3517 3517
 				$rel_list[] = $temp_bean;
3518 3518
 				return $rel_list;
@@ -3521,10 +3521,10 @@  discard block
 block discarded – undo
3521 3521
 	}
3522 3522
 
3523 3523
 	// special case for unlisted parent-type relationships
3524
-	if( !empty($focus->parent_type) && $focus->parent_type == $tar_rel_module && !empty($focus->parent_id)) {
3524
+	if (!empty($focus->parent_type) && $focus->parent_type == $tar_rel_module && !empty($focus->parent_id)) {
3525 3525
 		$temp_bean = get_module_info($tar_rel_module);
3526 3526
 		$temp_bean->retrieve($focus->parent_id);
3527
-		if($temp_bean->id!=""){
3527
+		if ($temp_bean->id != "") {
3528 3528
 			$rel_list[] = $temp_bean;
3529 3529
 			return $rel_list;
3530 3530
 		}
@@ -3535,24 +3535,24 @@  discard block
 block discarded – undo
3535 3535
 	//end function search_filter_rel_info
3536 3536
 }
3537 3537
 
3538
-function get_module_info($module_name){
3538
+function get_module_info($module_name) {
3539 3539
 	global $beanList;
3540 3540
 	global $dictionary;
3541 3541
 
3542 3542
 	//Get dictionary and focus data for module
3543 3543
 	$vardef_name = $beanList[$module_name];
3544 3544
 
3545
-	if($vardef_name=="aCase"){
3545
+	if ($vardef_name == "aCase") {
3546 3546
 		$class_name = "Case";
3547 3547
 	} else {
3548 3548
 		$class_name = $vardef_name;
3549 3549
 	}
3550 3550
 
3551
-	if(!file_exists('modules/'. $module_name . '/'.$class_name.'.php')){
3551
+	if (!file_exists('modules/'.$module_name.'/'.$class_name.'.php')) {
3552 3552
 		return;
3553 3553
 	}
3554 3554
 
3555
-	include_once('modules/'. $module_name . '/'.$class_name.'.php');
3555
+	include_once('modules/'.$module_name.'/'.$class_name.'.php');
3556 3556
 
3557 3557
 	$module_bean = new $vardef_name();
3558 3558
 	return $module_bean;
@@ -3564,11 +3564,11 @@  discard block
 block discarded – undo
3564 3564
  *
3565 3565
  * @param string $moduleName
3566 3566
  */
3567
-function get_valid_bean_name($module_name){
3567
+function get_valid_bean_name($module_name) {
3568 3568
 	global $beanList;
3569 3569
 
3570 3570
 	$vardef_name = $beanList[$module_name];
3571
-	if($vardef_name=="aCase"){
3571
+	if ($vardef_name == "aCase") {
3572 3572
 		$bean_name = "Case";
3573 3573
 	} else {
3574 3574
 		$bean_name = $vardef_name;
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 
3579 3579
 
3580 3580
 
3581
-function  checkAuthUserStatus(){
3581
+function  checkAuthUserStatus() {
3582 3582
 
3583 3583
 	//authUserStatus();
3584 3584
 }
@@ -3592,7 +3592,7 @@  discard block
 block discarded – undo
3592 3592
  * @author	original by "code at adspeed dot com" Fron php.net
3593 3593
  * @author	customized for Sugar by Chris N.
3594 3594
  */
3595
-function getPhpInfo($level=-1) {
3595
+function getPhpInfo($level = -1) {
3596 3596
 	/**	Name (constant)		Value	Description
3597 3597
 		INFO_GENERAL		1		The configuration line, php.ini location, build date, Web Server, System and more.
3598 3598
 		INFO_CREDITS		2		PHP Credits. See also phpcredits().
@@ -3608,36 +3608,36 @@  discard block
 block discarded – undo
3608 3608
 	$phpinfo = ob_get_contents();
3609 3609
 	ob_end_clean();
3610 3610
 
3611
-	$phpinfo	= strip_tags($phpinfo,'<h1><h2><th><td>');
3612
-	$phpinfo	= preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$phpinfo);
3613
-	$phpinfo	= preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$phpinfo);
3611
+	$phpinfo	= strip_tags($phpinfo, '<h1><h2><th><td>');
3612
+	$phpinfo	= preg_replace('/<th[^>]*>([^<]+)<\/th>/', "<info>\\1</info>", $phpinfo);
3613
+	$phpinfo	= preg_replace('/<td[^>]*>([^<]+)<\/td>/', "<info>\\1</info>", $phpinfo);
3614 3614
 	$parsedInfo	= preg_split('/(<h.?>[^<]+<\/h.>)/', $phpinfo, -1, PREG_SPLIT_DELIM_CAPTURE);
3615
-	$match		= '';
3615
+	$match = '';
3616 3616
 	$version	= '';
3617 3617
 	$returnInfo	= array();
3618 3618
 
3619
-	if(preg_match('/<h1 class\=\"p\">PHP Version ([^<]+)<\/h1>/', $phpinfo, $version)) {
3619
+	if (preg_match('/<h1 class\=\"p\">PHP Version ([^<]+)<\/h1>/', $phpinfo, $version)) {
3620 3620
 		$returnInfo['PHP Version'] = $version[1];
3621 3621
 	}
3622 3622
 
3623 3623
 
3624
-	for ($i=1; $i<count($parsedInfo); $i++) {
3624
+	for ($i = 1; $i < count($parsedInfo); $i++) {
3625 3625
 		if (preg_match('/<h.>([^<]+)<\/h.>/', $parsedInfo[$i], $match)) {
3626 3626
 			$vName = trim($match[1]);
3627
-			$parsedInfo2 = explode("\n",$parsedInfo[$i+1]);
3627
+			$parsedInfo2 = explode("\n", $parsedInfo[$i + 1]);
3628 3628
 
3629 3629
 			foreach ($parsedInfo2 AS $vOne) {
3630
-				$vPat	= '<info>([^<]+)<\/info>';
3630
+				$vPat = '<info>([^<]+)<\/info>';
3631 3631
 				$vPat3	= "/$vPat\s*$vPat\s*$vPat/";
3632 3632
 				$vPat2	= "/$vPat\s*$vPat/";
3633 3633
 
3634
-				if (preg_match($vPat3,$vOne,$match)) { // 3cols
3635
-					$returnInfo[$vName][trim($match[1])] = array(trim($match[2]),trim($match[3]));
3636
-				} elseif (preg_match($vPat2,$vOne,$match)) { // 2cols
3634
+				if (preg_match($vPat3, $vOne, $match)) { // 3cols
3635
+					$returnInfo[$vName][trim($match[1])] = array(trim($match[2]), trim($match[3]));
3636
+				} elseif (preg_match($vPat2, $vOne, $match)) { // 2cols
3637 3637
 					$returnInfo[$vName][trim($match[1])] = trim($match[2]);
3638 3638
 				}
3639 3639
 			}
3640
-		} elseif(true) {
3640
+		} elseif (true) {
3641 3641
 
3642 3642
 		}
3643 3643
 	}
@@ -3652,7 +3652,7 @@  discard block
 block discarded – undo
3652 3652
  * @param	$args args to replace
3653 3653
  * @return	$result a formatted string
3654 3654
  */
3655
-function string_format($format, $args){
3655
+function string_format($format, $args) {
3656 3656
 	$result = $format;
3657 3657
 
3658 3658
     /** Bug47277 fix.
@@ -3670,7 +3670,7 @@  discard block
 block discarded – undo
3670 3670
     }
3671 3671
     /* End of fix */
3672 3672
 
3673
-	for($i = 0; $i < count($args); $i++){
3673
+	for ($i = 0; $i < count($args); $i++) {
3674 3674
 		$result = str_replace('{'.$i.'}', $args[$i], $result);
3675 3675
 	}
3676 3676
 	return $result;
@@ -3686,19 +3686,19 @@  discard block
 block discarded – undo
3686 3686
  * @param	$system_id from system
3687 3687
  * @return	$result a formatted string
3688 3688
  */
3689
-function format_number_display($num, $system_id){
3689
+function format_number_display($num, $system_id) {
3690 3690
 	global $sugar_config;
3691
-	if(isset($num) && !empty($num)){
3692
-		$num=unformat_number($num);
3693
-		if(isset($system_id) && $system_id == 1){
3691
+	if (isset($num) && !empty($num)) {
3692
+		$num = unformat_number($num);
3693
+		if (isset($system_id) && $system_id == 1) {
3694 3694
 			return sprintf("%d", $num);
3695 3695
 		}
3696
-		else{
3696
+		else {
3697 3697
 			return sprintf("%d-%d", $num, $system_id);
3698 3698
 		}
3699 3699
 	}
3700 3700
 }
3701
-function checkLoginUserStatus(){
3701
+function checkLoginUserStatus() {
3702 3702
 }
3703 3703
 
3704 3704
 /**
@@ -3712,11 +3712,11 @@  discard block
 block discarded – undo
3712 3712
 	$resulturl = $url;
3713 3713
 
3714 3714
 	// if no port, don't change the url
3715
-	if($port != '')
3715
+	if ($port != '')
3716 3716
 	{
3717 3717
 		$split = explode("/", $url);
3718 3718
 		//check if it starts with http, in case they didn't include that in url
3719
-		if(str_begin($url, 'http'))
3719
+		if (str_begin($url, 'http'))
3720 3720
 		{
3721 3721
 			//third index ($split[2]) will be the host
3722 3722
 			$split[2] .= ":".$port;
@@ -3739,7 +3739,7 @@  discard block
 block discarded – undo
3739 3739
  */
3740 3740
 function getJSONobj() {
3741 3741
 	static $json = null;
3742
-	if(!isset($json)) {
3742
+	if (!isset($json)) {
3743 3743
 		require_once('include/JSON.php');
3744 3744
 		$json = new JSON(JSON_LOOSE_TYPE);
3745 3745
 	}
@@ -3771,7 +3771,7 @@  discard block
 block discarded – undo
3771 3771
 	// http://us3.php.net/manual/en/ref.pcre.php#ini.pcre.backtrack-limit
3772 3772
 	// starting with 5.2.0, backtrack_limit breaks JSON decoding
3773 3773
 	$backtrack_limit = ini_get('pcre.backtrack_limit');
3774
-	if(!empty($backtrack_limit)) {
3774
+	if (!empty($backtrack_limit)) {
3775 3775
 		ini_set('pcre.backtrack_limit', '-1');
3776 3776
 	}
3777 3777
 }
@@ -3788,19 +3788,19 @@  discard block
 block discarded – undo
3788 3788
  */
3789 3789
 function sugarLangArrayMerge($gimp, $dom)
3790 3790
 {
3791
-	if(is_array($gimp) && is_array($dom))
3791
+	if (is_array($gimp) && is_array($dom))
3792 3792
     {
3793
-		foreach($dom as $domKey => $domVal)
3793
+		foreach ($dom as $domKey => $domVal)
3794 3794
         {
3795
-			if(isset($gimp[$domKey]))
3795
+			if (isset($gimp[$domKey]))
3796 3796
             {
3797
-				if(is_array($domVal))
3797
+				if (is_array($domVal))
3798 3798
                 {
3799 3799
 					$tempArr = array();
3800
-                    foreach ( $domVal as $domArrKey => $domArrVal )
3800
+                    foreach ($domVal as $domArrKey => $domArrVal)
3801 3801
                         $tempArr[$domArrKey] = $domArrVal;
3802
-                    foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal )
3803
-                        if ( !isset($tempArr[$gimpArrKey]) )
3802
+                    foreach ($gimp[$domKey] as $gimpArrKey => $gimpArrVal)
3803
+                        if (!isset($tempArr[$gimpArrKey]))
3804 3804
                             $tempArr[$gimpArrKey] = $gimpArrVal;
3805 3805
                     $gimp[$domKey] = $tempArr;
3806 3806
 				}
@@ -3816,7 +3816,7 @@  discard block
 block discarded – undo
3816 3816
 		}
3817 3817
 	}
3818 3818
     // if the passed value for gimp isn't an array, then return the $dom
3819
-    elseif(is_array($dom))
3819
+    elseif (is_array($dom))
3820 3820
     {
3821 3821
         return $dom;
3822 3822
     }
@@ -3838,15 +3838,15 @@  discard block
 block discarded – undo
3838 3838
  * @return array beaten gimp
3839 3839
  */
3840 3840
 function sugarArrayMerge($gimp, $dom) {
3841
-	if(is_array($gimp) && is_array($dom)) {
3842
-		foreach($dom as $domKey => $domVal) {
3843
-			if(array_key_exists($domKey, $gimp)) {
3844
-				if(is_array($domVal)) {
3841
+	if (is_array($gimp) && is_array($dom)) {
3842
+		foreach ($dom as $domKey => $domVal) {
3843
+			if (array_key_exists($domKey, $gimp)) {
3844
+				if (is_array($domVal)) {
3845 3845
 					$tempArr = array();
3846
-                    foreach ( $domVal as $domArrKey => $domArrVal )
3846
+                    foreach ($domVal as $domArrKey => $domArrVal)
3847 3847
                         $tempArr[$domArrKey] = $domArrVal;
3848
-                    foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal )
3849
-                        if ( !array_key_exists($gimpArrKey, $tempArr) )
3848
+                    foreach ($gimp[$domKey] as $gimpArrKey => $gimpArrVal)
3849
+                        if (!array_key_exists($gimpArrKey, $tempArr))
3850 3850
                             $tempArr[$gimpArrKey] = $gimpArrVal;
3851 3851
                     $gimp[$domKey] = $tempArr;
3852 3852
 				} else {
@@ -3858,7 +3858,7 @@  discard block
 block discarded – undo
3858 3858
 		}
3859 3859
 	}
3860 3860
     // if the passed value for gimp isn't an array, then return the $dom
3861
-    elseif(is_array($dom))
3861
+    elseif (is_array($dom))
3862 3862
         return $dom;
3863 3863
 
3864 3864
 	return $gimp;
@@ -3872,10 +3872,10 @@  discard block
 block discarded – undo
3872 3872
  * @return array beaten gimp
3873 3873
  */
3874 3874
 function sugarArrayMergeRecursive($gimp, $dom) {
3875
-	if(is_array($gimp) && is_array($dom)) {
3876
-		foreach($dom as $domKey => $domVal) {
3877
-			if(array_key_exists($domKey, $gimp)) {
3878
-				if(is_array($domVal) && is_array($gimp[$domKey])) {
3875
+	if (is_array($gimp) && is_array($dom)) {
3876
+		foreach ($dom as $domKey => $domVal) {
3877
+			if (array_key_exists($domKey, $gimp)) {
3878
+				if (is_array($domVal) && is_array($gimp[$domKey])) {
3879 3879
 					$gimp[$domKey] = sugarArrayMergeRecursive($gimp[$domKey], $domVal);
3880 3880
 				} else {
3881 3881
 					$gimp[$domKey] = $domVal;
@@ -3886,7 +3886,7 @@  discard block
 block discarded – undo
3886 3886
 		}
3887 3887
 	}
3888 3888
     // if the passed value for gimp isn't an array, then return the $dom
3889
-    elseif(is_array($dom))
3889
+    elseif (is_array($dom))
3890 3890
         return $dom;
3891 3891
 
3892 3892
 	return $gimp;
@@ -3897,7 +3897,7 @@  discard block
 block discarded – undo
3897 3897
  * @return bool True if NOT found or WRONG version
3898 3898
  */
3899 3899
 function returnPhpJsonStatus() {
3900
-	if(function_exists('json_encode')) {
3900
+	if (function_exists('json_encode')) {
3901 3901
 		$phpInfo = getPhpInfo(8);
3902 3902
         return version_compare($phpInfo['json']['json version'], '1.1.1', '<');
3903 3903
 	}
@@ -3924,16 +3924,16 @@  discard block
 block discarded – undo
3924 3924
 
3925 3925
 	global $sugar_config;
3926 3926
 
3927
-	if(!isset($max_tracker_item_length)) {
3928
-		if(isset($sugar_config['tracker_max_display_length'])) {
3927
+	if (!isset($max_tracker_item_length)) {
3928
+		if (isset($sugar_config['tracker_max_display_length'])) {
3929 3929
 	      $max_tracker_item_length = (is_int($sugar_config['tracker_max_display_length']) && $sugar_config['tracker_max_display_length'] > 0 && $sugar_config['tracker_max_display_length'] < 50) ? $sugar_config['tracker_max_display_length'] : 15;
3930 3930
 		} else {
3931 3931
 	      $max_tracker_item_length = 15;
3932 3932
 		}
3933 3933
 	}
3934 3934
 
3935
-	if($strlen > $max_tracker_item_length) {
3936
-		$chopped = function_exists('mb_substr') ? mb_substr($name, 0, $max_tracker_item_length-3, "UTF-8") : substr($name, 0, $max_tracker_item_length-3);
3935
+	if ($strlen > $max_tracker_item_length) {
3936
+		$chopped = function_exists('mb_substr') ? mb_substr($name, 0, $max_tracker_item_length - 3, "UTF-8") : substr($name, 0, $max_tracker_item_length - 3);
3937 3937
 		$chopped .= "...";
3938 3938
 	} else {
3939 3939
 		$chopped = $name;
@@ -3941,51 +3941,51 @@  discard block
 block discarded – undo
3941 3941
 
3942 3942
 	return $chopped;
3943 3943
 }
3944
-function generate_search_where ($field_list=array(),$values=array(),&$bean,$add_custom_fields=false,$module='') {
3945
-	$where_clauses= array();
3946
-	$like_char='%';
3947
-	$table_name=$bean->object_name;
3944
+function generate_search_where($field_list = array(), $values = array(), &$bean, $add_custom_fields = false, $module = '') {
3945
+	$where_clauses = array();
3946
+	$like_char = '%';
3947
+	$table_name = $bean->object_name;
3948 3948
 	foreach ($field_list[$module] as $field=>$parms) {
3949
-		if(isset($values[$field]) && $values[$field] != "") {
3950
-			$operator='like';
3949
+		if (isset($values[$field]) && $values[$field] != "") {
3950
+			$operator = 'like';
3951 3951
 			if (!empty($parms['operator'])) {
3952
-				$operator=$parms['operator'];
3952
+				$operator = $parms['operator'];
3953 3953
 			}
3954 3954
 			if (is_array($values[$field])) {
3955
-				$operator='in';
3956
-				$field_value='';
3955
+				$operator = 'in';
3956
+				$field_value = '';
3957 3957
 				foreach ($values[$field] as $key => $val) {
3958 3958
 					if ($val != ' ' and $val != '') {
3959 3959
 						if (!empty($field_value)) {
3960
-							$field_value.=',';
3960
+							$field_value .= ',';
3961 3961
 						}
3962 3962
 						$field_value .= "'".$GLOBALS['db']->quote($val)."'";
3963 3963
 					}
3964 3964
 				}
3965 3965
 			} else {
3966
-				$field_value=$GLOBALS['db']->quote($values[$field]);
3966
+				$field_value = $GLOBALS['db']->quote($values[$field]);
3967 3967
 			}
3968 3968
 			//set db_fields array.
3969
-			if (!isset($parms['db_field']) )  {
3969
+			if (!isset($parms['db_field'])) {
3970 3970
 				$parms['db_field'] = array($field);
3971 3971
 			}
3972 3972
 			if (isset($parms['my_items']) and $parms['my_items'] == true) {
3973 3973
 				global $current_user;
3974 3974
 				$field_value = $GLOBALS['db']->quote($current_user->id);
3975
-				$operator='=';
3975
+				$operator = '=';
3976 3976
 			}
3977 3977
 
3978
-			$where='';
3979
-			$itr=0;
3978
+			$where = '';
3979
+			$itr = 0;
3980 3980
 			if ($field_value != '') {
3981 3981
 
3982 3982
 				foreach ($parms['db_field'] as $db_field) {
3983
-					if (strstr($db_field,'.')===false) {
3984
-						$db_field=$bean->table_name.".".$db_field;
3983
+					if (strstr($db_field, '.') === false) {
3984
+						$db_field = $bean->table_name.".".$db_field;
3985 3985
 					}
3986
-					if ($GLOBALS['db']->supports('case_sensitive') &&  isset($parms['query_type']) && $parms['query_type']=='case_insensitive') {
3987
-						$db_field='upper('.$db_field.")";
3988
-						$field_value=strtoupper($field_value);
3986
+					if ($GLOBALS['db']->supports('case_sensitive') && isset($parms['query_type']) && $parms['query_type'] == 'case_insensitive') {
3987
+						$db_field = 'upper('.$db_field.")";
3988
+						$field_value = strtoupper($field_value);
3989 3989
 					}
3990 3990
 
3991 3991
 					$itr++;
@@ -3994,19 +3994,19 @@  discard block
 block discarded – undo
3994 3994
 					}
3995 3995
 					switch (strtolower($operator)) {
3996 3996
 						case 'like' :
3997
-							$where .=  $db_field . " like '".$field_value.$like_char."'";
3997
+							$where .= $db_field." like '".$field_value.$like_char."'";
3998 3998
 							break;
3999 3999
 						case 'in':
4000
-							$where .=  $db_field . " in (".$field_value.')';
4000
+							$where .= $db_field." in (".$field_value.')';
4001 4001
 							break;
4002 4002
 						case '=':
4003
-							$where .=  $db_field . " = '".$field_value ."'";
4003
+							$where .= $db_field." = '".$field_value."'";
4004 4004
 							break;
4005 4005
 					}
4006 4006
 				}
4007 4007
 			}
4008 4008
 			if (!empty($where)) {
4009
-				if ($itr>1) {
4009
+				if ($itr > 1) {
4010 4010
 					array_push($where_clauses, '( '.$where.' )');
4011 4011
 				} else {
4012 4012
 					array_push($where_clauses, $where);
@@ -4034,13 +4034,13 @@  discard block
 block discarded – undo
4034 4034
  */
4035 4035
 function rebuildConfigFile($sugar_config, $sugar_version) {
4036 4036
 	// add defaults to missing values of in-memory sugar_config
4037
-	$sugar_config = sugarArrayMerge(get_sugar_config_defaults(), $sugar_config );
4037
+	$sugar_config = sugarArrayMerge(get_sugar_config_defaults(), $sugar_config);
4038 4038
 	// need to override version with default no matter what
4039 4039
 	$sugar_config['sugar_version'] = $sugar_version;
4040 4040
 
4041
-	ksort( $sugar_config );
4041
+	ksort($sugar_config);
4042 4042
 
4043
-	if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
4043
+	if (write_array_to_file("sugar_config", $sugar_config, "config.php")) {
4044 4044
 		return true;
4045 4045
 	}
4046 4046
 	else {
@@ -4073,40 +4073,40 @@  discard block
 block discarded – undo
4073 4073
  */
4074 4074
 function getJavascriptSiteURL() {
4075 4075
 	global $sugar_config;
4076
-	if(!empty($_SERVER['HTTP_REFERER'])) {
4076
+	if (!empty($_SERVER['HTTP_REFERER'])) {
4077 4077
 		$url = parse_url($_SERVER['HTTP_REFERER']);
4078 4078
 		$replacement_url = $url['scheme']."://".$url['host'];
4079
-		if(!empty($url['port']))
4079
+		if (!empty($url['port']))
4080 4080
 		$replacement_url .= ':'.$url['port'];
4081
-		$site_url = preg_replace('/^http[s]?\:\/\/[^\/]+/',$replacement_url,$sugar_config['site_url']);
4081
+		$site_url = preg_replace('/^http[s]?\:\/\/[^\/]+/', $replacement_url, $sugar_config['site_url']);
4082 4082
 	} else {
4083
-		$site_url = preg_replace('/^http(s)?\:\/\/[^\/]+/',"http$1://".$_SERVER['HTTP_HOST'],$sugar_config['site_url']);
4084
-		if(!empty($_SERVER['SERVER_PORT']) &&$_SERVER['SERVER_PORT'] == '443') {
4085
-			$site_url = preg_replace('/^http\:/','https:',$site_url);
4083
+		$site_url = preg_replace('/^http(s)?\:\/\/[^\/]+/', "http$1://".$_SERVER['HTTP_HOST'], $sugar_config['site_url']);
4084
+		if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') {
4085
+			$site_url = preg_replace('/^http\:/', 'https:', $site_url);
4086 4086
 		}
4087 4087
 	}
4088
-	$GLOBALS['log']->debug("getJavascriptSiteURL(), site_url=".  $site_url);
4088
+	$GLOBALS['log']->debug("getJavascriptSiteURL(), site_url=".$site_url);
4089 4089
 	return $site_url;
4090 4090
 }
4091 4091
 
4092 4092
 // works nicely with array_map() -- can be used to wrap single quotes around each element in an array
4093 4093
 function add_squotes($str) {
4094
-	return "'" . $str . "'";
4094
+	return "'".$str."'";
4095 4095
 }
4096 4096
 
4097 4097
 
4098 4098
 // recursive function to count the number of levels within an array
4099
-function array_depth($array, $depth_count=-1, $depth_array=array()){
4099
+function array_depth($array, $depth_count = -1, $depth_array = array()) {
4100 4100
 	$depth_count++;
4101
-	if (is_array($array)){
4102
-		foreach ($array as $key => $value){
4101
+	if (is_array($array)) {
4102
+		foreach ($array as $key => $value) {
4103 4103
 			$depth_array[] = array_depth($value, $depth_count);
4104 4104
 		}
4105 4105
 	}
4106
-	else{
4106
+	else {
4107 4107
 		return $depth_count;
4108 4108
 	}
4109
-	foreach ($depth_array as $value){
4109
+	foreach ($depth_array as $value) {
4110 4110
 		$depth_count = $value > $depth_count ? $value : $depth_count;
4111 4111
 	}
4112 4112
 	return $depth_count;
@@ -4125,7 +4125,7 @@  discard block
 block discarded – undo
4125 4125
 	$group->last_name	= $name;
4126 4126
 	$group->is_group	= 1;
4127 4127
 	$group->deleted		= 0;
4128
-	$group->status		= 'Active'; // cn: bug 6711
4128
+	$group->status = 'Active'; // cn: bug 6711
4129 4129
 	$group->setPreference('timezone', TimeDate::userTimezone());
4130 4130
 	$group->save();
4131 4131
 
@@ -4143,19 +4143,19 @@  discard block
 block discarded – undo
4143 4143
 {
4144 4144
 
4145 4145
 	$iconName = "icon_{$iconFileName}.gif";
4146
-    $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4146
+    $iconFound = SugarThemeRegistry::current()->getImageURL($iconName, false);
4147 4147
 
4148 4148
     //First try un-ucfirst-ing the icon name
4149
-    if ( empty($iconFound) )
4150
-		$iconName = "icon_" . strtolower(substr($iconFileName,0,1)).substr($iconFileName,1) . ".gif";
4151
-        $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4149
+    if (empty($iconFound))
4150
+		$iconName = "icon_".strtolower(substr($iconFileName, 0, 1)).substr($iconFileName, 1).".gif";
4151
+        $iconFound = SugarThemeRegistry::current()->getImageURL($iconName, false);
4152 4152
 
4153 4153
 	//Next try removing the icon prefix
4154
-    if ( empty($iconFound) )
4154
+    if (empty($iconFound))
4155 4155
 		$iconName = "{$iconFileName}.gif";
4156
-		$iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4156
+		$iconFound = SugarThemeRegistry::current()->getImageURL($iconName, false);
4157 4157
 
4158
-	if ( empty($iconFound) )
4158
+	if (empty($iconFound))
4159 4159
 		$iconName = '';
4160 4160
 
4161 4161
   	return $iconName;
@@ -4171,12 +4171,12 @@  discard block
 block discarded – undo
4171 4171
  * @return string $string <img> tag with corresponding image
4172 4172
  */
4173 4173
 
4174
-function getStudioIcon($iconFileName='', $altFileName='', $width='48', $height='48', $align='baseline', $alt='' )
4174
+function getStudioIcon($iconFileName = '', $altFileName = '', $width = '48', $height = '48', $align = 'baseline', $alt = '')
4175 4175
 {
4176 4176
 	global $app_strings, $theme;
4177 4177
 
4178 4178
     $iconName = _getIcon($iconFileName);
4179
- 	if(empty($iconName)){
4179
+ 	if (empty($iconName)) {
4180 4180
  	    $iconName = _getIcon($altFileName);
4181 4181
  	    if (empty($iconName))
4182 4182
  	    {
@@ -4197,14 +4197,14 @@  discard block
 block discarded – undo
4197 4197
  * @return string $string <img> tag with corresponding image
4198 4198
  */
4199 4199
 
4200
-function get_dashlets_dialog_icon($module='', $width='32', $height='32', $align='absmiddle',$alt=''){
4200
+function get_dashlets_dialog_icon($module = '', $width = '32', $height = '32', $align = 'absmiddle', $alt = '') {
4201 4201
 	global $app_strings, $theme;
4202
- 	$iconName = _getIcon($module . "_32");
4202
+ 	$iconName = _getIcon($module."_32");
4203 4203
  	if (empty($iconName))
4204 4204
  	{
4205 4205
  		$iconName = _getIcon($module);
4206 4206
  	}
4207
- 	if(empty($iconName)){
4207
+ 	if (empty($iconName)) {
4208 4208
  		return $app_strings['LBL_NO_IMAGE'];
4209 4209
  	}
4210 4210
 	return SugarThemeRegistry::current()->getImage($iconName, "align=\"$align\" border=\"0\"", $width, $height);
@@ -4232,9 +4232,9 @@  discard block
 block discarded – undo
4232 4232
 function code2utf($num)
4233 4233
 {
4234 4234
     if ($num < 128) return chr($num);
4235
-    if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
4236
-    if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4237
-    if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4235
+    if ($num < 2048) return chr(($num >> 6) + 192).chr(($num & 63) + 128);
4236
+    if ($num < 65536) return chr(($num >> 12) + 224).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128);
4237
+    if ($num < 2097152) return chr(($num >> 18) + 240).chr((($num >> 12) & 63) + 128).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128);
4238 4238
     return '';
4239 4239
 }
4240 4240
 
@@ -4287,7 +4287,7 @@  discard block
 block discarded – undo
4287 4287
  */
4288 4288
 function chartColors()
4289 4289
 {
4290
-	if (SugarThemeRegistry::current()->getCSSURL('sugarColors.xml')=='')
4290
+	if (SugarThemeRegistry::current()->getCSSURL('sugarColors.xml') == '')
4291 4291
 	return SugarThemeRegistry::current()->getImageURL('sugarColors.xml');
4292 4292
     return SugarThemeRegistry::current()->getCSSURL('sugarColors.xml');
4293 4293
 }
@@ -4316,10 +4316,10 @@  discard block
 block discarded – undo
4316 4316
     $path = trim($path);
4317 4317
 
4318 4318
     // try to match absolute paths like \\server\share, /directory or c:\
4319
-    if ( ( substr($path,0,2) == '\\\\' )
4320
-            || ( $path[0] == '/' )
4321
-            || preg_match('/^[A-z]:/i',$path)
4322
-            || $currentServer )
4319
+    if ((substr($path, 0, 2) == '\\\\')
4320
+            || ($path[0] == '/')
4321
+            || preg_match('/^[A-z]:/i', $path)
4322
+            || $currentServer)
4323 4323
         return $path;
4324 4324
 
4325 4325
     return getcwd().'/'.$path;
@@ -4348,12 +4348,12 @@  discard block
 block discarded – undo
4348 4348
     $ua = empty($_SERVER['HTTP_USER_AGENT']) ? "undefined" : strtolower($_SERVER['HTTP_USER_AGENT']);
4349 4349
 
4350 4350
     // first check if we have forced use of the touch enhanced interface
4351
-    if ( isset($_COOKIE['touchscreen']) && $_COOKIE['touchscreen'] == '1' ) {
4351
+    if (isset($_COOKIE['touchscreen']) && $_COOKIE['touchscreen'] == '1') {
4352 4352
         return true;
4353 4353
     }
4354 4354
 
4355 4355
     // next check if we should use the touch interface with our device
4356
-    if ( strpos($ua, 'ipad') !== false ) {
4356
+    if (strpos($ua, 'ipad') !== false) {
4357 4357
         return true;
4358 4358
     }
4359 4359
 
@@ -4367,30 +4367,30 @@  discard block
 block discarded – undo
4367 4367
  */
4368 4368
 function get_alt_hot_key() {
4369 4369
 	$ua = '';
4370
-    if ( isset($_SERVER['HTTP_USER_AGENT']) )
4370
+    if (isset($_SERVER['HTTP_USER_AGENT']))
4371 4371
         $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
4372 4372
 	$isMac = strpos($ua, 'mac') !== false;
4373 4373
 	$isLinux = strpos($ua, 'linux') !== false;
4374 4374
 
4375
-	if(!$isMac && !$isLinux && strpos($ua, 'mozilla') !== false) {
4376
-	   if(preg_match('/firefox\/(\d)?\./', $ua, $matches)) {
4375
+	if (!$isMac && !$isLinux && strpos($ua, 'mozilla') !== false) {
4376
+	   if (preg_match('/firefox\/(\d)?\./', $ua, $matches)) {
4377 4377
 	   	  return $matches[1] < 2 ? 'Alt+' : 'Alt+Shift+';
4378 4378
 	   }
4379 4379
 	}
4380 4380
 	return $isMac ? 'Ctrl+' : 'Alt+';
4381 4381
 }
4382 4382
 
4383
-function can_start_session(){
4384
-	if(!empty($_GET['PHPSESSID'])) {
4383
+function can_start_session() {
4384
+	if (!empty($_GET['PHPSESSID'])) {
4385 4385
 	   return true;
4386 4386
 	}
4387 4387
 	$session_id = session_id();
4388 4388
 	return empty($session_id) ? true : false;
4389 4389
 }
4390 4390
 
4391
-function load_link_class($properties){
4391
+function load_link_class($properties) {
4392 4392
 	$class = 'Link2';
4393
-	if(!empty($properties['link_class']) && !empty($properties['link_file'])){
4393
+	if (!empty($properties['link_class']) && !empty($properties['link_file'])) {
4394 4394
     	require_once($properties['link_file']);
4395 4395
     	$class = $properties['link_class'];
4396 4396
     }
@@ -4410,9 +4410,9 @@  discard block
 block discarded – undo
4410 4410
  */
4411 4411
 function filterInboundEmailPopSelection($protocol)
4412 4412
 {
4413
-    if ( !isset($GLOBALS['sugar_config']['allow_pop_inbound']) || ! $GLOBALS['sugar_config']['allow_pop_inbound'] )
4413
+    if (!isset($GLOBALS['sugar_config']['allow_pop_inbound']) || !$GLOBALS['sugar_config']['allow_pop_inbound'])
4414 4414
     {
4415
-        if( isset($protocol['pop3']) )
4415
+        if (isset($protocol['pop3']))
4416 4416
 			unset($protocol['pop3']);
4417 4417
     }
4418 4418
     else
@@ -4427,10 +4427,10 @@  discard block
 block discarded – undo
4427 4427
  * The varchar in MySQL, Orcale, and nvarchar in FreeTDS, we can store $length mutilbyte charaters in it. we need mb_substr to keep more info.
4428 4428
 * @returns the substred strings.
4429 4429
  */
4430
-function sugar_substr($string, $length, $charset='UTF-8')
4430
+function sugar_substr($string, $length, $charset = 'UTF-8')
4431 4431
 {
4432
-    if(mb_strlen($string,$charset) > $length) {
4433
-        $string = trim(mb_substr(trim($string),0,$length,$charset));
4432
+    if (mb_strlen($string, $charset) > $length) {
4433
+        $string = trim(mb_substr(trim($string), 0, $length, $charset));
4434 4434
     }
4435 4435
     return $string;
4436 4436
 }
@@ -4439,8 +4439,8 @@  discard block
 block discarded – undo
4439 4439
  * The function is used because on FastCGI enviroment, the ucfirst(Chinese Characters) will produce bad charcters.
4440 4440
  * This will work even without setting the mbstring.*encoding
4441 4441
  */
4442
-function sugar_ucfirst($string, $charset='UTF-8') {
4443
-    return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset) . mb_substr($string, 1, mb_strlen($string), $charset);
4442
+function sugar_ucfirst($string, $charset = 'UTF-8') {
4443
+    return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_substr($string, 1, mb_strlen($string), $charset);
4444 4444
 }
4445 4445
 
4446 4446
 
@@ -4452,8 +4452,8 @@  discard block
 block discarded – undo
4452 4452
 	{
4453 4453
 	   return $string;
4454 4454
 	}
4455
-	if (substr($string, 0 ,1) == "^" && substr($string, -1) == "^") {
4456
-          $string = substr(substr($string, 1), 0, strlen($string) -2);
4455
+	if (substr($string, 0, 1) == "^" && substr($string, -1) == "^") {
4456
+          $string = substr(substr($string, 1), 0, strlen($string) - 2);
4457 4457
 	}
4458 4458
 
4459 4459
 	return explode('^,^', $string);
@@ -4466,7 +4466,7 @@  discard block
 block discarded – undo
4466 4466
     if (empty($arr))
4467 4467
         return "";
4468 4468
 
4469
-	$string = "^" . implode('^,^', $arr) . "^";
4469
+	$string = "^".implode('^,^', $arr)."^";
4470 4470
 
4471 4471
     return $string;
4472 4472
 }
@@ -4481,19 +4481,19 @@  discard block
 block discarded – undo
4481 4481
  * @return $ret_array['where']: corrected where clause
4482 4482
  * @return $ret_array['join']: extra join condition
4483 4483
  */
4484
-function create_export_query_relate_link_patch($module, $searchFields, $where){
4485
-	if(file_exists('modules/'.$module.'/SearchForm.html')){
4484
+function create_export_query_relate_link_patch($module, $searchFields, $where) {
4485
+	if (file_exists('modules/'.$module.'/SearchForm.html')) {
4486 4486
 		$ret_array['where'] = $where;
4487 4487
 		return $ret_array;
4488 4488
 	}
4489 4489
 	$seed = loadBean($module);
4490
-    foreach($seed->field_defs as $name=>$field)
4490
+    foreach ($seed->field_defs as $name=>$field)
4491 4491
 	{
4492 4492
 
4493
-		if( $field['type'] == 'relate' && isset($field['link']) && !empty($searchFields[$name]['value']) ){
4493
+		if ($field['type'] == 'relate' && isset($field['link']) && !empty($searchFields[$name]['value'])) {
4494 4494
 			$seed->load_relationship($field['link']);
4495 4495
 			$params = array();
4496
-			if(empty($join_type))
4496
+			if (empty($join_type))
4497 4497
 			{
4498 4498
 				$params['join_type'] = ' LEFT JOIN ';
4499 4499
 			}
@@ -4501,16 +4501,16 @@  discard block
 block discarded – undo
4501 4501
 			{
4502 4502
 				$params['join_type'] = $join_type;
4503 4503
 			}
4504
-			if(isset($data['join_name']))
4504
+			if (isset($data['join_name']))
4505 4505
 			{
4506 4506
 				$params['join_table_alias'] = $field['join_name'];
4507 4507
 			}
4508 4508
 			else
4509 4509
 			{
4510
-				$params['join_table_alias']	= 'join_'.$field['name'];
4510
+				$params['join_table_alias'] = 'join_'.$field['name'];
4511 4511
 
4512 4512
 			}
4513
-			if(isset($data['join_link_name']))
4513
+			if (isset($data['join_link_name']))
4514 4514
 			{
4515 4515
 				$params['join_table_link_alias'] = $field['join_link_name'];
4516 4516
 			}
@@ -4520,11 +4520,11 @@  discard block
 block discarded – undo
4520 4520
 			}
4521 4521
 			$join = $seed->$field['link']->getJoin($params, true);
4522 4522
 			$join_table_alias = 'join_'.$field['name'];
4523
-			if(isset($field['db_concat_fields'])){
4523
+			if (isset($field['db_concat_fields'])) {
4524 4524
 				$db_field = db_concat($join_table_alias, $field['db_concat_fields']);
4525 4525
 				$where = preg_replace('/'.$field['name'].'/', $db_field, $where);
4526
-			}else{
4527
-				$where = preg_replace('/(^|[\s(])' . $field['name'] . '/', '${1}' . $join_table_alias . '.'.$field['rname'], $where);
4526
+			} else {
4527
+				$where = preg_replace('/(^|[\s(])'.$field['name'].'/', '${1}'.$join_table_alias.'.'.$field['rname'], $where);
4528 4528
 			}
4529 4529
 		}
4530 4530
 	}
@@ -4537,11 +4537,11 @@  discard block
 block discarded – undo
4537 4537
   * @Depends on QuickRepairAndRebuild.php
4538 4538
   * @Relate bug 30642  ,23177
4539 4539
   */
4540
-function clearAllJsAndJsLangFilesWithoutOutput(){
4541
-		global $current_language , $mod_strings;
4540
+function clearAllJsAndJsLangFilesWithoutOutput() {
4541
+		global $current_language, $mod_strings;
4542 4542
 		$MBmodStrings = $mod_strings;
4543
-        $mod_strings = return_module_language ( $current_language, 'Administration' ) ;
4544
-        include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
4543
+        $mod_strings = return_module_language($current_language, 'Administration');
4544
+        include_once ('modules/Administration/QuickRepairAndRebuild.php');
4545 4545
         $repair = new RepairAndClear();
4546 4546
         $repair->module_list = array();
4547 4547
 		$repair->show_output = false;
@@ -4553,13 +4553,13 @@  discard block
 block discarded – undo
4553 4553
 /**
4554 4554
  * This function will allow you to get a variable value from query string
4555 4555
  */
4556
-function getVariableFromQueryString($variable, $string){
4556
+function getVariableFromQueryString($variable, $string) {
4557 4557
 	$matches = array();
4558 4558
 	$number = preg_match("/{$variable}=([a-zA-Z0-9_-]+)[&]?/", $string, $matches);
4559
-	if($number){
4559
+	if ($number) {
4560 4560
 		return $matches[1];
4561 4561
 	}
4562
-	else{
4562
+	else {
4563 4563
 		return false;
4564 4564
 	}
4565 4565
 }
@@ -4573,8 +4573,8 @@  discard block
 block discarded – undo
4573 4573
  */
4574 4574
 function should_hide_iframes() {
4575 4575
    //Remove the MySites module
4576
-   if(file_exists('modules/iFrames/iFrame.php')) {
4577
-        if(!class_exists("iFrame")) {
4576
+   if (file_exists('modules/iFrames/iFrame.php')) {
4577
+        if (!class_exists("iFrame")) {
4578 4578
                 require_once('modules/iFrames/iFrame.php');
4579 4579
         }
4580 4580
         return false;
@@ -4588,10 +4588,10 @@  discard block
 block discarded – undo
4588 4588
  * @param string $version
4589 4589
  * @return string RC, BETA, GA
4590 4590
  */
4591
-function getVersionStatus($version){
4592
-	if(preg_match('/^[\d\.]+?([a-zA-Z]+?)[\d]*?$/si', $version, $matches)) {
4591
+function getVersionStatus($version) {
4592
+	if (preg_match('/^[\d\.]+?([a-zA-Z]+?)[\d]*?$/si', $version, $matches)) {
4593 4593
 		return strtoupper($matches[1]);
4594
-	}else{
4594
+	} else {
4595 4595
 		return 'GA';
4596 4596
 	}
4597 4597
 }
@@ -4603,12 +4603,12 @@  discard block
 block discarded – undo
4603 4603
  * @param string $version
4604 4604
  * @return version
4605 4605
  */
4606
-function getMajorMinorVersion($version){
4607
-	if(preg_match('/^([\d\.]+).*$/si', $version, $matches2)){
4606
+function getMajorMinorVersion($version) {
4607
+	if (preg_match('/^([\d\.]+).*$/si', $version, $matches2)) {
4608 4608
 		$version = $matches2[1];
4609 4609
 		$arr = explode('.', $version);
4610
-		if(count($arr) > 2){
4611
-			if($arr[2] == '0'){
4610
+		if (count($arr) > 2) {
4611
+			if ($arr[2] == '0') {
4612 4612
 				$version = substr($version, 0, 3);
4613 4613
 			}
4614 4614
 		}
@@ -4636,10 +4636,10 @@  discard block
 block discarded – undo
4636 4636
 {
4637 4637
 	$lines = explode("<br>", trim($string));
4638 4638
 	$urls = array();
4639
-	foreach($lines as $line){
4639
+	foreach ($lines as $line) {
4640 4640
     	$regex = '/http?\:\/\/[^\" ]+/i';
4641 4641
     	preg_match_all($regex, $line, $matches);
4642
-    	foreach($matches[0] as $match){
4642
+    	foreach ($matches[0] as $match) {
4643 4643
     		$urls[] = $match;
4644 4644
     	}
4645 4645
 	}
@@ -4654,20 +4654,20 @@  discard block
 block discarded – undo
4654 4654
  */
4655 4655
 function verify_image_file($path, $jpeg = false)
4656 4656
 {
4657
-	if(function_exists('imagepng') && function_exists('imagejpeg') && function_exists('imagecreatefromstring')) {
4657
+	if (function_exists('imagepng') && function_exists('imagejpeg') && function_exists('imagecreatefromstring')) {
4658 4658
         $img = imagecreatefromstring(file_get_contents($path));
4659
-    	if(!$img) {
4659
+    	if (!$img) {
4660 4660
     	    return false;
4661 4661
     	}
4662 4662
     	$img_size = getimagesize($path);
4663 4663
 		$filetype = $img_size['mime'];
4664 4664
 		//if filetype is jpeg or if we are only allowing jpegs, create jpg image
4665
-        if($filetype == "image/jpeg" || $jpeg) {
4665
+        if ($filetype == "image/jpeg" || $jpeg) {
4666 4666
             ob_start();
4667 4667
             imagejpeg($img);
4668 4668
             $image = ob_get_clean();
4669 4669
             // not writing directly because imagejpeg does not work with streams
4670
-            if(file_put_contents($path, $image)) {
4670
+            if (file_put_contents($path, $image)) {
4671 4671
                 return true;
4672 4672
             }
4673 4673
         } elseif ($filetype == "image/png") {
@@ -4677,7 +4677,7 @@  discard block
 block discarded – undo
4677 4677
         	ob_start();
4678 4678
             imagepng($img);
4679 4679
             $image = ob_get_clean();
4680
-    	    if(file_put_contents($path, $image)) {
4680
+    	    if (file_put_contents($path, $image)) {
4681 4681
                 return true;
4682 4682
     	    }
4683 4683
         } else {
@@ -4686,15 +4686,15 @@  discard block
 block discarded – undo
4686 4686
 	} else {
4687 4687
 	    // check image manually
4688 4688
         $fp = fopen($path, "rb");
4689
-        if(!$fp) return false;
4689
+        if (!$fp) return false;
4690 4690
         $data = '';
4691 4691
         // read the whole file in chunks
4692
-        while(!feof($fp)) {
4693
-            $data .= fread($fp,8192);
4692
+        while (!feof($fp)) {
4693
+            $data .= fread($fp, 8192);
4694 4694
         }
4695 4695
 
4696 4696
 	    fclose($fp);
4697
-	    if(preg_match("/<(\?php|html|!doctype|script|body|head|plaintext|table|img |pre(>| )|frameset|iframe|object|link|base|style|font|applet|meta|center|form|isindex)/i",
4697
+	    if (preg_match("/<(\?php|html|!doctype|script|body|head|plaintext|table|img |pre(>| )|frameset|iframe|object|link|base|style|font|applet|meta|center|form|isindex)/i",
4698 4698
 	         $data, $m)) {
4699 4699
 	        $GLOBALS['log']->fatal("Found {$m[0]} in $path, not allowing upload");
4700 4700
 	        return false;
@@ -4713,18 +4713,18 @@  discard block
 block discarded – undo
4713 4713
 function verify_uploaded_image($path, $jpeg_only = false)
4714 4714
 {
4715 4715
     $supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg');
4716
-    if(!$jpeg_only) {
4716
+    if (!$jpeg_only) {
4717 4717
         $supportedExtensions['png'] = 'image/png';
4718 4718
     }
4719 4719
 
4720
-    if(!file_exists($path) || !is_file($path)) {
4720
+    if (!file_exists($path) || !is_file($path)) {
4721 4721
 	    return false;
4722 4722
 	}
4723 4723
 
4724 4724
 	$img_size = getimagesize($path);
4725 4725
 	$filetype = $img_size['mime'];
4726 4726
 	$ext = end(explode(".", $path));
4727
-	if(substr_count('..', $path) > 0 || ($ext !== $path && !isset($supportedExtensions[strtolower($ext)])) ||
4727
+	if (substr_count('..', $path) > 0 || ($ext !== $path && !isset($supportedExtensions[strtolower($ext)])) ||
4728 4728
 	    !in_array($filetype, array_values($supportedExtensions))) {
4729 4729
 	        return false;
4730 4730
 	}
@@ -4735,7 +4735,7 @@  discard block
 block discarded – undo
4735 4735
 {
4736 4736
     global $sugar_web_service_order_by;
4737 4737
     //If the order_by field is not valid, return 0;
4738
-    if (empty($sugar_web_service_order_by) || !isset($a->$sugar_web_service_order_by) || !isset($b->$sugar_web_service_order_by)){
4738
+    if (empty($sugar_web_service_order_by) || !isset($a->$sugar_web_service_order_by) || !isset($b->$sugar_web_service_order_by)) {
4739 4739
         return 0;
4740 4740
     }
4741 4741
     if (is_object($a->$sugar_web_service_order_by) || is_object($b->$sugar_web_service_order_by)
@@ -4778,13 +4778,13 @@  discard block
 block discarded – undo
4778 4778
     // add wildcard at the beginning of the search string
4779 4779
     if (isset($GLOBALS['sugar_config']['search_wildcard_infront']) &&
4780 4780
         $GLOBALS['sugar_config']['search_wildcard_infront'] == true) {
4781
-        if (substr($str,0,1) <> $wildcard)
4781
+        if (substr($str, 0, 1) <> $wildcard)
4782 4782
           $str = $wildcard.$str;
4783 4783
     }
4784 4784
 
4785 4785
     // add wildcard at the end of search string (default)
4786 4786
     if ($appendWildcard) {
4787
-        if(substr($str,-1) <> $wildcard) {
4787
+        if (substr($str, -1) <> $wildcard) {
4788 4788
             $str .= $wildcard;
4789 4789
         }
4790 4790
     }
@@ -4793,12 +4793,12 @@  discard block
 block discarded – undo
4793 4793
 }
4794 4794
 
4795 4795
 //check to see if custom utils exists
4796
-if(file_exists('custom/include/custom_utils.php')){
4796
+if (file_exists('custom/include/custom_utils.php')) {
4797 4797
 	include_once('custom/include/custom_utils.php');
4798 4798
 }
4799 4799
 
4800 4800
 //check to see if custom utils exists in Extension framework
4801
-if(file_exists('custom/application/Ext/Utils/custom_utils.ext.php')) {
4801
+if (file_exists('custom/application/Ext/Utils/custom_utils.ext.php')) {
4802 4802
     include_once('custom/application/Ext/Utils/custom_utils.ext.php');
4803 4803
 }
4804 4804
 /**
@@ -4852,8 +4852,8 @@  discard block
 block discarded – undo
4852 4852
 function utf8_recursive_encode($data)
4853 4853
 {
4854 4854
     $result = array();
4855
-    foreach($data as $key=>$val) {
4856
-        if(is_array($val)) {
4855
+    foreach ($data as $key=>$val) {
4856
+        if (is_array($val)) {
4857 4857
            $result[$key] = utf8_recursive_encode($val);
4858 4858
         } else {
4859 4859
            $result[$key] = utf8_encode($val);
@@ -4917,12 +4917,12 @@  discard block
 block discarded – undo
4917 4917
         $sendUrl = $sugar_config['custom_help_url'];
4918 4918
     } else {
4919 4919
         if (!empty($sugar_config['custom_help_base_url'])) {
4920
-            $baseUrl= $sugar_config['custom_help_base_url'];
4920
+            $baseUrl = $sugar_config['custom_help_base_url'];
4921 4921
         } else {
4922 4922
             $baseUrl = "http://www.sugarcrm.com/crm/product_doc.php";
4923 4923
         }
4924
-        $sendUrl = $baseUrl . "?edition={$send_edition}&version={$send_version}&lang={$send_lang}&module={$send_module}&help_action={$send_action}&status={$dev_status}&key={$send_key}";
4925
-        if(!empty($send_anchor)) {
4924
+        $sendUrl = $baseUrl."?edition={$send_edition}&version={$send_version}&lang={$send_lang}&module={$send_module}&help_action={$send_action}&status={$dev_status}&key={$send_key}";
4925
+        if (!empty($send_anchor)) {
4926 4926
             $sendUrl .= "&anchor=".$send_anchor;
4927 4927
         }
4928 4928
     }
@@ -4937,13 +4937,13 @@  discard block
 block discarded – undo
4937 4937
  *
4938 4938
  * @param string $etag ETag to use for this content.
4939 4939
  */
4940
-function generateETagHeader($etag){
4940
+function generateETagHeader($etag) {
4941 4941
 	header("cache-control:");
4942 4942
 	header('Expires: ');
4943
-	header("ETag: " . $etag);
4943
+	header("ETag: ".$etag);
4944 4944
 	header("Pragma:");
4945
-	if(isset($_SERVER["HTTP_IF_NONE_MATCH"])){
4946
-		if($etag == $_SERVER["HTTP_IF_NONE_MATCH"]){
4945
+	if (isset($_SERVER["HTTP_IF_NONE_MATCH"])) {
4946
+		if ($etag == $_SERVER["HTTP_IF_NONE_MATCH"]) {
4947 4947
 			ob_clean();
4948 4948
 			header("Status: 304 Not Modified");
4949 4949
 			header("HTTP/1.0 304 Not Modified");
@@ -4988,12 +4988,12 @@  discard block
 block discarded – undo
4988 4988
  */
4989 4989
 function clean_sensitive_data($defs, $data)
4990 4990
 {
4991
-    foreach($defs as $field => $def) {
4992
-        if(!empty($def['sensitive'])) {
4993
-            if(is_array($data)) {
4991
+    foreach ($defs as $field => $def) {
4992
+        if (!empty($def['sensitive'])) {
4993
+            if (is_array($data)) {
4994 4994
                 $data[$field] = '';
4995 4995
             }
4996
-            if($data instanceof SugarBean) {
4996
+            if ($data instanceof SugarBean) {
4997 4997
                 $data->$field = '';
4998 4998
             }
4999 4999
         }
@@ -5027,7 +5027,7 @@  discard block
 block discarded – undo
5027 5027
         // Add the relationship name for easier recognition
5028 5028
         foreach ($select_array as $key => $value)
5029 5029
         {
5030
-            $select_array[$key] .= ' (' . $key . ')';
5030
+            $select_array[$key] .= ' ('.$key.')';
5031 5031
         }
5032 5032
     }
5033 5033
     asort($select_array);
@@ -5056,7 +5056,7 @@  discard block
 block discarded – undo
5056 5056
  */
5057 5057
 function assignConcatenatedValue(SugarBean $bean, $fieldDef, $value)
5058 5058
 {
5059
-    $valueParts = explode(' ',$value);
5059
+    $valueParts = explode(' ', $value);
5060 5060
     $valueParts = array_filter($valueParts);
5061 5061
     $fieldNum   = count($fieldDef['db_concat_fields']);
5062 5062
 
@@ -5076,56 +5076,56 @@  discard block
 block discarded – undo
5076 5076
 
5077 5077
         if (!empty($valueParts))
5078 5078
         {
5079
-            $bean->$fieldName .= ' ' . implode(' ', $valueParts);
5079
+            $bean->$fieldName .= ' '.implode(' ', $valueParts);
5080 5080
         }
5081 5081
     }
5082 5082
 }
5083 5083
 
5084
-define("DEFAULT_UTIL_SUITE_ENCODING","UTF-8");
5084
+define("DEFAULT_UTIL_SUITE_ENCODING", "UTF-8");
5085 5085
 
5086 5086
 function suite_strlen($input, $encoding = DEFAULT_UTIL_SUITE_ENCODING)
5087 5087
 {
5088
-	if(function_exists('mb_strlen'))
5089
-		return mb_strlen($input,$encoding);
5088
+	if (function_exists('mb_strlen'))
5089
+		return mb_strlen($input, $encoding);
5090 5090
 	else
5091 5091
 		return strlen($input);
5092 5092
 }
5093 5093
 
5094
-function suite_substr($input, $start, $length = null,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5094
+function suite_substr($input, $start, $length = null, $encoding = DEFAULT_UTIL_SUITE_ENCODING)
5095 5095
 {
5096
-	if(function_exists('mb_substr'))
5097
-		return mb_substr($input,$start,$length,$encoding);
5096
+	if (function_exists('mb_substr'))
5097
+		return mb_substr($input, $start, $length, $encoding);
5098 5098
 	else
5099
-		return substr($input,$start,$length);
5099
+		return substr($input, $start, $length);
5100 5100
 }
5101 5101
 
5102
-function suite_strtoupper($input,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5102
+function suite_strtoupper($input, $encoding = DEFAULT_UTIL_SUITE_ENCODING)
5103 5103
 {
5104
-	if(function_exists('mb_strtoupper'))
5105
-		return mb_strtoupper($input,$encoding);
5104
+	if (function_exists('mb_strtoupper'))
5105
+		return mb_strtoupper($input, $encoding);
5106 5106
 	else
5107 5107
 		return strtoupper($input);
5108 5108
 }
5109
-function suite_strtolower($input,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5109
+function suite_strtolower($input, $encoding = DEFAULT_UTIL_SUITE_ENCODING)
5110 5110
 {
5111
-	if(function_exists('mb_strtolower'))
5112
-		return mb_strtolower($input,$encoding);
5111
+	if (function_exists('mb_strtolower'))
5112
+		return mb_strtolower($input, $encoding);
5113 5113
 	else
5114 5114
 		return strtolower($input);
5115 5115
 }
5116 5116
 
5117
-function suite_strpos($haystack,$needle,$offset=0,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5117
+function suite_strpos($haystack, $needle, $offset = 0, $encoding = DEFAULT_UTIL_SUITE_ENCODING)
5118 5118
 {
5119
-	if(function_exists('mb_strpos'))
5120
-		return mb_strpos($haystack,$needle,$offset,$encoding);
5119
+	if (function_exists('mb_strpos'))
5120
+		return mb_strpos($haystack, $needle, $offset, $encoding);
5121 5121
 	else
5122
-		return strpos($haystack,$needle,$offset);
5122
+		return strpos($haystack, $needle, $offset);
5123 5123
 }
5124 5124
 
5125
-function suite_strrpos($haystack,$needle,$offset=0,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5125
+function suite_strrpos($haystack, $needle, $offset = 0, $encoding = DEFAULT_UTIL_SUITE_ENCODING)
5126 5126
 {
5127
-	if(function_exists('mb_strrpos'))
5128
-		return mb_strrpos($haystack,$needle,$offset,$encoding);
5127
+	if (function_exists('mb_strrpos'))
5128
+		return mb_strrpos($haystack, $needle, $offset, $encoding);
5129 5129
 	else
5130
-		return strrpos($haystack,$needle,$offset);
5130
+		return strrpos($haystack, $needle, $offset);
5131 5131
 }
5132 5132
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +343 added lines, -225 removed lines patch added patch discarded remove patch
@@ -448,11 +448,9 @@  discard block
 block discarded – undo
448 448
 
449 449
 	if(file_exists("custom/include/language/{$language}.notify_template.html")){
450 450
 		$file = "custom/include/language/{$language}.notify_template.html";
451
-	}
452
-	else if(file_exists("include/language/{$language}.notify_template.html")){
451
+	} else if(file_exists("include/language/{$language}.notify_template.html")){
453 452
 		$file = "include/language/{$language}.notify_template.html";
454
-	}
455
-	else if(file_exists("custom/include/language/en_us.notify_template.html")){
453
+	} else if(file_exists("custom/include/language/en_us.notify_template.html")){
456 454
 		$file = "custom/include/language/en_us.notify_template.html";
457 455
 	}
458 456
 
@@ -470,8 +468,7 @@  discard block
 block discarded – undo
470 468
 	foreach( $default as $key => $value ){
471 469
 		if( !array_key_exists($key, $override) ){
472 470
 			$override[$key] = $value;
473
-		}
474
-		else if( is_array( $key ) ){
471
+		} else if( is_array( $key ) ){
475 472
 			$override[$key] = sugar_config_union( $value, $override[$key] );
476 473
 		}
477 474
 	}
@@ -484,8 +481,7 @@  discard block
 block discarded – undo
484 481
 	if( is_file($file) || is_dir($file) ){
485 482
 		if( !is_writable($file) ){
486 483
 			$ret_val = true;
487
-		}
488
-		else {
484
+		} else {
489 485
 			$original_fileperms = fileperms($file);
490 486
 
491 487
 			// take away writable permissions
@@ -591,8 +587,9 @@  discard block
 block discarded – undo
591 587
 function get_user_name($id) {
592 588
 	global $db;
593 589
 
594
-	if(empty($db))
595
-	$db = DBManagerFactory::getInstance();
590
+	if(empty($db)) {
591
+		$db = DBManagerFactory::getInstance();
592
+	}
596 593
 
597 594
 	$q = "SELECT user_name FROM users WHERE id='{$id}'";
598 595
 	$r = $db->query($q);
@@ -637,8 +634,7 @@  discard block
 block discarded – undo
637 634
 		// Including deleted users for now.
638 635
 		if (empty($status)) {
639 636
 			$query = "SELECT id, first_name, last_name, user_name from users WHERE 1=1".$portal_filter;
640
-		}
641
-		else {
637
+		} else {
642 638
 			$query = "SELECT id, first_name, last_name, user_name from users WHERE status='$status'".$portal_filter;
643 639
 		}
644 640
         /* BEGIN - SECURITY GROUPS */
@@ -677,7 +673,7 @@  discard block
 block discarded – undo
677 673
                 //its possible for first name to be skipped, check for this
678 674
                 if($firstNamePos===false){
679 675
                     $order_by_string =  'last_name ASC';
680
-                }else{
676
+                } else{
681 677
                     $order_by_string =  ($lastNamePos < $firstNamePos) ? "last_name, first_name ASC" : "first_name, last_name ASC";
682 678
                 }
683 679
             }
@@ -1100,18 +1096,20 @@  discard block
 block discarded – undo
1100 1096
 	$loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language,$refresh);
1101 1097
 
1102 1098
 	// cn: bug 6048 - merge en_us with requested language
1103
-	if($language != $sugar_config['default_language'])
1104
-        $loaded_mod_strings = sugarLangArrayMerge(
1099
+	if($language != $sugar_config['default_language']) {
1100
+	        $loaded_mod_strings = sugarLangArrayMerge(
1105 1101
             LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'],$refresh),
1106 1102
                 $loaded_mod_strings
1107 1103
             );
1104
+	}
1108 1105
 
1109 1106
     // Load in en_us strings by default
1110
-    if($language != 'en_us' && $sugar_config['default_language'] != 'en_us')
1111
-        $loaded_mod_strings = sugarLangArrayMerge(
1107
+    if($language != 'en_us' && $sugar_config['default_language'] != 'en_us') {
1108
+            $loaded_mod_strings = sugarLangArrayMerge(
1112 1109
             LanguageManager::loadModuleLanguage($module, 'en_us', $refresh),
1113 1110
                 $loaded_mod_strings
1114 1111
             );
1112
+    }
1115 1113
 
1116 1114
 	// If we are in debug mode for translating, turn on the prefix now!
1117 1115
 	if($sugar_config['translation_string_prefix']) {
@@ -1123,9 +1121,9 @@  discard block
 block discarded – undo
1123 1121
 	$return_value = $loaded_mod_strings;
1124 1122
 	if(!isset($mod_strings)){
1125 1123
 		$mod_strings = $return_value;
1124
+	} else {
1125
+			$mod_strings = $temp_mod_strings;
1126 1126
 	}
1127
-	else
1128
-		$mod_strings = $temp_mod_strings;
1129 1127
 
1130 1128
     $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
1131 1129
     sugar_cache_put($cache_key, $return_value);
@@ -1164,8 +1162,9 @@  discard block
 block discarded – undo
1164 1162
 	// cn: bug 6048 - merge en_us with requested language
1165 1163
 	include("modules/$module/language/en_us.lang.php");
1166 1164
 	$en_mod_list_strings = array();
1167
-	if($language_used != $default_language)
1168
-	$en_mod_list_strings = $mod_list_strings;
1165
+	if($language_used != $default_language) {
1166
+		$en_mod_list_strings = $mod_list_strings;
1167
+	}
1169 1168
 
1170 1169
 	if(file_exists("modules/$module/language/$language.lang.php")) {
1171 1170
 		include("modules/$module/language/$language.lang.php");
@@ -1295,8 +1294,9 @@  discard block
 block discarded – undo
1295 1294
 	$where = "";
1296 1295
 	foreach($where_clauses as $clause)
1297 1296
 	{
1298
-		if($where != "")
1299
-		$where .= " and ";
1297
+		if($where != "") {
1298
+				$where .= " and ";
1299
+		}
1300 1300
 		$where .= $clause;
1301 1301
 	}
1302 1302
 
@@ -1374,8 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 	if($strlen < $length)
1375 1375
 	{
1376 1376
 		$string = str_pad($string,$length,"0");
1377
-	}
1378
-	else if($strlen > $length)
1377
+	} else if($strlen > $length)
1379 1378
 	{
1380 1379
 		$string = substr($string, 0, $length);
1381 1380
 	}
@@ -1575,7 +1574,9 @@  discard block
 block discarded – undo
1575 1574
         $replacement .= "/OPTION>\n<OPTION value='__SugarMassUpdateClearField__'><"; // Giving the user the option to unset a drop down list. I.e. none means that it won't get updated
1576 1575
     }
1577 1576
 
1578
-	if (empty($key_list)) $key_list = array();
1577
+	if (empty($key_list)) {
1578
+	    $key_list = array();
1579
+	}
1579 1580
 	//create the type dropdown domain and set the selected value if $opp value already exists
1580 1581
 	foreach ($key_list as $option_key=>$option_value) {
1581 1582
 
@@ -1737,24 +1738,26 @@  discard block
 block discarded – undo
1737 1738
 		    $current_language = ($_REQUEST['login_language'] == $current_language)? $current_language : $_REQUEST['login_language'];
1738 1739
 		}
1739 1740
 		$mod_strings = return_module_language($current_language, $mod);
1740
-        if ($mod == "")
1741
-        echo "Language is <pre>" . $mod_strings . "</pre>";
1741
+        if ($mod == "") {
1742
+                echo "Language is <pre>" . $mod_strings . "</pre>";
1743
+        }
1742 1744
 
1743
-	}else{
1745
+	} else{
1744 1746
 		global $mod_strings;
1745 1747
 	}
1746 1748
 
1747 1749
 	$returnValue = '';
1748 1750
 	global $app_strings, $app_list_strings;
1749 1751
 
1750
-    if (isset($mod_strings[$string]))
1751
-        $returnValue = $mod_strings[$string];
1752
-    else if (isset($app_strings[$string]))
1753
-        $returnValue = $app_strings[$string];
1754
-    else if (isset($app_list_strings[$string]))
1755
-        $returnValue = $app_list_strings[$string];
1756
-    else if (isset($app_list_strings['moduleList']) && isset($app_list_strings['moduleList'][$string]))
1757
-        $returnValue = $app_list_strings['moduleList'][$string];
1752
+    if (isset($mod_strings[$string])) {
1753
+            $returnValue = $mod_strings[$string];
1754
+    } else if (isset($app_strings[$string])) {
1755
+            $returnValue = $app_strings[$string];
1756
+    } else if (isset($app_list_strings[$string])) {
1757
+            $returnValue = $app_list_strings[$string];
1758
+    } else if (isset($app_list_strings['moduleList']) && isset($app_list_strings['moduleList'][$string])) {
1759
+            $returnValue = $app_list_strings['moduleList'][$string];
1760
+    }
1758 1761
 
1759 1762
 
1760 1763
 	//$test_end = microtime();
@@ -1867,8 +1870,9 @@  discard block
 block discarded – undo
1867 1870
 function clean_xss($str, $cleanImg=true) {
1868 1871
 	global $sugar_config;
1869 1872
 
1870
-	if(empty($sugar_config['email_xss']))
1871
-	$sugar_config['email_xss'] = getDefaultXssTags();
1873
+	if(empty($sugar_config['email_xss'])) {
1874
+		$sugar_config['email_xss'] = getDefaultXssTags();
1875
+	}
1872 1876
 
1873 1877
 	$xsstags = unserialize(base64_decode($sugar_config['email_xss']));
1874 1878
 
@@ -1987,32 +1991,65 @@  discard block
 block discarded – undo
1987 1991
 			die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>");
1988 1992
 		}
1989 1993
 		return false;
1990
-	}
1991
-	else {
1994
+	} else {
1992 1995
 		return $str;
1993 1996
 	}
1994 1997
 }
1995 1998
 
1996 1999
 function clean_special_arguments() {
1997 2000
 	if(isset($_SERVER['PHP_SELF'])) {
1998
-		if (!empty($_SERVER['PHP_SELF'])) clean_string($_SERVER['PHP_SELF'], 'SAFED_GET');
1999
-	}
2000
-	if (!empty($_REQUEST) && !empty($_REQUEST['login_theme'])) clean_string($_REQUEST['login_theme'], "STANDARD");
2001
-	if (!empty($_REQUEST) && !empty($_REQUEST['login_module'])) clean_string($_REQUEST['login_module'], "STANDARD");
2002
-	if (!empty($_REQUEST) && !empty($_REQUEST['login_action'])) clean_string($_REQUEST['login_action'], "STANDARD");
2003
-	if (!empty($_REQUEST) && !empty($_REQUEST['ck_login_theme_20'])) clean_string($_REQUEST['ck_login_theme_20'], "STANDARD");
2004
-	if (!empty($_SESSION) && !empty($_SESSION['authenticated_user_theme'])) clean_string($_SESSION['authenticated_user_theme'], "STANDARD");
2005
-	if (!empty($_REQUEST) && !empty($_REQUEST['module_name'])) clean_string($_REQUEST['module_name'], "STANDARD");
2006
-	if (!empty($_REQUEST) && !empty($_REQUEST['module'])) clean_string($_REQUEST['module'], "STANDARD");
2007
-	if (!empty($_POST) && !empty($_POST['parent_type'])) clean_string($_POST['parent_type'], "STANDARD");
2008
-	if (!empty($_REQUEST) && !empty($_REQUEST['mod_lang'])) clean_string($_REQUEST['mod_lang'], "STANDARD");
2009
-	if (!empty($_SESSION) && !empty($_SESSION['authenticated_user_language'])) clean_string($_SESSION['authenticated_user_language'], "STANDARD");
2010
-	if (!empty($_SESSION) && !empty($_SESSION['dyn_layout_file'])) clean_string($_SESSION['dyn_layout_file'], "PATH_NO_URL");
2011
-	if (!empty($_GET) && !empty($_GET['from'])) clean_string($_GET['from']);
2012
-	if (!empty($_GET) && !empty($_GET['gmto'])) clean_string($_GET['gmto'], "NUMBER");
2013
-	if (!empty($_GET) && !empty($_GET['case_number'])) clean_string($_GET['case_number'], "AUTO_INCREMENT");
2014
-	if (!empty($_GET) && !empty($_GET['bug_number'])) clean_string($_GET['bug_number'], "AUTO_INCREMENT");
2015
-	if (!empty($_GET) && !empty($_GET['quote_num'])) clean_string($_GET['quote_num'], "AUTO_INCREMENT");
2001
+		if (!empty($_SERVER['PHP_SELF'])) {
2002
+		    clean_string($_SERVER['PHP_SELF'], 'SAFED_GET');
2003
+		}
2004
+	}
2005
+	if (!empty($_REQUEST) && !empty($_REQUEST['login_theme'])) {
2006
+	    clean_string($_REQUEST['login_theme'], "STANDARD");
2007
+	}
2008
+	if (!empty($_REQUEST) && !empty($_REQUEST['login_module'])) {
2009
+	    clean_string($_REQUEST['login_module'], "STANDARD");
2010
+	}
2011
+	if (!empty($_REQUEST) && !empty($_REQUEST['login_action'])) {
2012
+	    clean_string($_REQUEST['login_action'], "STANDARD");
2013
+	}
2014
+	if (!empty($_REQUEST) && !empty($_REQUEST['ck_login_theme_20'])) {
2015
+	    clean_string($_REQUEST['ck_login_theme_20'], "STANDARD");
2016
+	}
2017
+	if (!empty($_SESSION) && !empty($_SESSION['authenticated_user_theme'])) {
2018
+	    clean_string($_SESSION['authenticated_user_theme'], "STANDARD");
2019
+	}
2020
+	if (!empty($_REQUEST) && !empty($_REQUEST['module_name'])) {
2021
+	    clean_string($_REQUEST['module_name'], "STANDARD");
2022
+	}
2023
+	if (!empty($_REQUEST) && !empty($_REQUEST['module'])) {
2024
+	    clean_string($_REQUEST['module'], "STANDARD");
2025
+	}
2026
+	if (!empty($_POST) && !empty($_POST['parent_type'])) {
2027
+	    clean_string($_POST['parent_type'], "STANDARD");
2028
+	}
2029
+	if (!empty($_REQUEST) && !empty($_REQUEST['mod_lang'])) {
2030
+	    clean_string($_REQUEST['mod_lang'], "STANDARD");
2031
+	}
2032
+	if (!empty($_SESSION) && !empty($_SESSION['authenticated_user_language'])) {
2033
+	    clean_string($_SESSION['authenticated_user_language'], "STANDARD");
2034
+	}
2035
+	if (!empty($_SESSION) && !empty($_SESSION['dyn_layout_file'])) {
2036
+	    clean_string($_SESSION['dyn_layout_file'], "PATH_NO_URL");
2037
+	}
2038
+	if (!empty($_GET) && !empty($_GET['from'])) {
2039
+	    clean_string($_GET['from']);
2040
+	}
2041
+	if (!empty($_GET) && !empty($_GET['gmto'])) {
2042
+	    clean_string($_GET['gmto'], "NUMBER");
2043
+	}
2044
+	if (!empty($_GET) && !empty($_GET['case_number'])) {
2045
+	    clean_string($_GET['case_number'], "AUTO_INCREMENT");
2046
+	}
2047
+	if (!empty($_GET) && !empty($_GET['bug_number'])) {
2048
+	    clean_string($_GET['bug_number'], "AUTO_INCREMENT");
2049
+	}
2050
+	if (!empty($_GET) && !empty($_GET['quote_num'])) {
2051
+	    clean_string($_GET['quote_num'], "AUTO_INCREMENT");
2052
+	}
2016 2053
 	clean_superglobals('stamp', 'ALPHANUM'); // for vcr controls
2017 2054
 	clean_superglobals('offset', 'ALPHANUM');
2018 2055
 	clean_superglobals('return_action');
@@ -2024,10 +2061,16 @@  discard block
 block discarded – undo
2024 2061
  * cleans the given key in superglobals $_GET, $_POST, $_REQUEST
2025 2062
  */
2026 2063
 function clean_superglobals($key, $filter = 'STANDARD') {
2027
-	if(isset($_GET[$key])) clean_string($_GET[$key], $filter);
2028
-	if(isset($_POST[$key])) clean_string($_POST[$key], $filter);
2029
-	if(isset($_REQUEST[$key])) clean_string($_REQUEST[$key], $filter);
2030
-}
2064
+	if(isset($_GET[$key])) {
2065
+	    clean_string($_GET[$key], $filter);
2066
+	}
2067
+	if(isset($_POST[$key])) {
2068
+	    clean_string($_POST[$key], $filter);
2069
+	}
2070
+	if(isset($_REQUEST[$key])) {
2071
+	    clean_string($_REQUEST[$key], $filter);
2072
+	}
2073
+	}
2031 2074
 
2032 2075
 function set_superglobals($key, $val){
2033 2076
 	$_GET[$key] = $val;
@@ -2068,25 +2111,51 @@  discard block
 block discarded – undo
2068 2111
         //get translated, so scrub the data but don't die
2069 2112
 	    if(ini_get('mbstring.encoding_translation')==='1'){
2070 2113
             securexsskey($k,false);
2071
-        }else{
2114
+        } else{
2072 2115
 		    securexsskey($k,true);
2073 2116
         }
2074 2117
 
2075 2118
 	}
2076 2119
 	// Any additional variables that need to be cleaned should be added here
2077
-	if (isset($_REQUEST['login_theme'])) clean_string($_REQUEST['login_theme']);
2078
-	if (isset($_REQUEST['login_module'])) clean_string($_REQUEST['login_module']);
2079
-	if (isset($_REQUEST['login_action'])) clean_string($_REQUEST['login_action']);
2080
-	if (isset($_REQUEST['login_language'])) clean_string($_REQUEST['login_language']);
2081
-	if (isset($_REQUEST['action'])) clean_string($_REQUEST['action']);
2082
-	if (isset($_REQUEST['module'])) clean_string($_REQUEST['module']);
2083
-	if (isset($_REQUEST['record'])) clean_string($_REQUEST['record'], 'STANDARDSPACE');
2084
-	if (isset($_SESSION['authenticated_user_theme'])) clean_string($_SESSION['authenticated_user_theme']);
2085
-	if (isset($_SESSION['authenticated_user_language'])) clean_string($_SESSION['authenticated_user_language']);
2086
-	if (isset($_REQUEST['language'])) clean_string($_REQUEST['language']);
2087
-	if (isset($sugar_config['default_theme'])) clean_string($sugar_config['default_theme']);
2088
-	if (isset($_REQUEST['offset'])) clean_string($_REQUEST['offset']);
2089
-	if (isset($_REQUEST['stamp'])) clean_string($_REQUEST['stamp']);
2120
+	if (isset($_REQUEST['login_theme'])) {
2121
+	    clean_string($_REQUEST['login_theme']);
2122
+	}
2123
+	if (isset($_REQUEST['login_module'])) {
2124
+	    clean_string($_REQUEST['login_module']);
2125
+	}
2126
+	if (isset($_REQUEST['login_action'])) {
2127
+	    clean_string($_REQUEST['login_action']);
2128
+	}
2129
+	if (isset($_REQUEST['login_language'])) {
2130
+	    clean_string($_REQUEST['login_language']);
2131
+	}
2132
+	if (isset($_REQUEST['action'])) {
2133
+	    clean_string($_REQUEST['action']);
2134
+	}
2135
+	if (isset($_REQUEST['module'])) {
2136
+	    clean_string($_REQUEST['module']);
2137
+	}
2138
+	if (isset($_REQUEST['record'])) {
2139
+	    clean_string($_REQUEST['record'], 'STANDARDSPACE');
2140
+	}
2141
+	if (isset($_SESSION['authenticated_user_theme'])) {
2142
+	    clean_string($_SESSION['authenticated_user_theme']);
2143
+	}
2144
+	if (isset($_SESSION['authenticated_user_language'])) {
2145
+	    clean_string($_SESSION['authenticated_user_language']);
2146
+	}
2147
+	if (isset($_REQUEST['language'])) {
2148
+	    clean_string($_REQUEST['language']);
2149
+	}
2150
+	if (isset($sugar_config['default_theme'])) {
2151
+	    clean_string($sugar_config['default_theme']);
2152
+	}
2153
+	if (isset($_REQUEST['offset'])) {
2154
+	    clean_string($_REQUEST['offset']);
2155
+	}
2156
+	if (isset($_REQUEST['stamp'])) {
2157
+	    clean_string($_REQUEST['stamp']);
2158
+	}
2090 2159
 
2091 2160
 	if(isset($_REQUEST['lvso'])){
2092 2161
 			set_superglobals('lvso', (strtolower($_REQUEST['lvso']) === 'desc')?'desc':'asc');
@@ -2096,8 +2165,7 @@  discard block
 block discarded – undo
2096 2165
 		if (str_end($key, "_offset")) {
2097 2166
 			clean_string($_REQUEST[$key], "ALPHANUM"); // keep this ALPHANUM for disable_count_query
2098 2167
 			set_superglobals($key, $_REQUEST[$key]);
2099
-		}
2100
-		elseif (str_end($key, "_ORDER_BY")) {
2168
+		} elseif (str_end($key, "_ORDER_BY")) {
2101 2169
 			clean_string($_REQUEST[$key], "SQL_COLUMN_LIST");
2102 2170
 			set_superglobals($key, $_REQUEST[$key]);
2103 2171
 		}
@@ -2138,7 +2206,7 @@  discard block
 block discarded – undo
2138 2206
 	if(!empty($matches)){
2139 2207
 		if($die){
2140 2208
 			die("Bad data passed in; <a href=\"{$sugar_config['site_url']}\">Return to Home</a>");
2141
-		}else{
2209
+		} else{
2142 2210
 			unset($_REQUEST[$value]);
2143 2211
 			unset($_POST[$value]);
2144 2212
 			unset($_GET[$value]);
@@ -2153,8 +2221,7 @@  discard block
 block discarded – undo
2153 2221
 		}
2154 2222
 
2155 2223
 		$value = securexss($value);
2156
-	}
2157
-	else if (is_array($value)){
2224
+	} else if (is_array($value)){
2158 2225
 	    foreach ($value as $key => $element) {
2159 2226
 	        $value[$key] = preprocess_param($element);
2160 2227
 	    }
@@ -2165,7 +2232,9 @@  discard block
 block discarded – undo
2165 2232
 
2166 2233
 function cleanup_slashes($value)
2167 2234
 {
2168
-    if(is_string($value)) return stripslashes($value);
2235
+    if(is_string($value)) {
2236
+        return stripslashes($value);
2237
+    }
2169 2238
     return $value;
2170 2239
 }
2171 2240
 
@@ -2210,18 +2279,26 @@  discard block
 block discarded – undo
2210 2279
 
2211 2280
 function getWebPath($relative_path){
2212 2281
 	//if it has  a :// then it isn't a relative path
2213
-	if(substr_count($relative_path, '://') > 0) return $relative_path;
2214
-	if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2282
+	if(substr_count($relative_path, '://') > 0) {
2283
+	    return $relative_path;
2284
+	}
2285
+	if(defined('TEMPLATE_URL')) {
2286
+	    $relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2287
+	}
2215 2288
 	return $relative_path;
2216 2289
 }
2217 2290
 
2218 2291
 function getVersionedPath($path, $additional_attrs='')
2219 2292
 {
2220
-	if(empty($GLOBALS['sugar_config']['js_custom_version'])) $GLOBALS['sugar_config']['js_custom_version'] = 1;
2293
+	if(empty($GLOBALS['sugar_config']['js_custom_version'])) {
2294
+	    $GLOBALS['sugar_config']['js_custom_version'] = 1;
2295
+	}
2221 2296
 	$js_version_key = isset($GLOBALS['js_version_key'])?$GLOBALS['js_version_key']:'';
2222 2297
 	if(inDeveloperMode()) {
2223 2298
 	    static $rand;
2224
-	    if(empty($rand)) $rand = mt_rand();
2299
+	    if(empty($rand)) {
2300
+	        $rand = mt_rand();
2301
+	    }
2225 2302
 	    $dev = $rand;
2226 2303
 	} else {
2227 2304
 	    $dev = '';
@@ -2233,7 +2310,9 @@  discard block
 block discarded – undo
2233 2310
 	$str = substr(base64_encode(md5("$js_version_key|{$GLOBALS['sugar_config']['js_custom_version']}|$dev|$additional_attrs", true)), 0, -2);
2234 2311
 	// remove / - it confuses some parsers
2235 2312
 	$str = strtr($str, '/+', '-_');
2236
-	if(empty($path)) return $str;
2313
+	if(empty($path)) {
2314
+	    return $str;
2315
+	}
2237 2316
 
2238 2317
 	return $path . "?v=$str";
2239 2318
 }
@@ -2245,7 +2324,9 @@  discard block
 block discarded – undo
2245 2324
 
2246 2325
 function getJSPath($relative_path, $additional_attrs='')
2247 2326
 {
2248
-	if(defined('TEMPLATE_URL'))$relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2327
+	if(defined('TEMPLATE_URL')) {
2328
+	    $relative_path = SugarTemplateUtilities::getWebPath($relative_path);
2329
+	}
2249 2330
 	return getVersionedPath($relative_path).(!empty($additional_attrs)?"&$additional_attrs":"");
2250 2331
 }
2251 2332
 
@@ -2277,8 +2358,7 @@  discard block
 block discarded – undo
2277 2358
 			$match[1] = "0".$match[1];
2278 2359
 		}
2279 2360
 		return "{$match[3]}-{$match[1]}-{$match[2]}";
2280
-	}
2281
-	else if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/',$date_str,$match))
2361
+	} else if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/',$date_str,$match))
2282 2362
 	{
2283 2363
 		if ( strlen($match[2]) == 1)
2284 2364
 		{
@@ -2289,8 +2369,7 @@  discard block
 block discarded – undo
2289 2369
 			$match[1] = "0".$match[1];
2290 2370
 		}
2291 2371
 		return "{$match[3]}-{$match[1]}-{$match[2]}";
2292
-	}
2293
-	else
2372
+	} else
2294 2373
 	{
2295 2374
 		return "";
2296 2375
 	}
@@ -2347,10 +2426,12 @@  discard block
 block discarded – undo
2347 2426
 			}
2348 2427
 			$bean->update_date_modified = false;
2349 2428
             $bean->update_modified_by = false;
2350
-            if(isset($bean->date_modified))
2351
-                $bean->date_modified = $timedate->to_db($bean->date_modified);
2352
-            if(isset($bean->date_entered))
2353
-                $bean->date_entered = $timedate->to_db($bean->date_entered);
2429
+            if(isset($bean->date_modified)) {
2430
+                            $bean->date_modified = $timedate->to_db($bean->date_modified);
2431
+            }
2432
+            if(isset($bean->date_entered)) {
2433
+                            $bean->date_entered = $timedate->to_db($bean->date_entered);
2434
+            }
2354 2435
 			//save
2355 2436
 			$new_id=$bean->save();
2356 2437
 
@@ -2673,7 +2754,7 @@  discard block
 block discarded – undo
2673 2754
 	//no error notice - lets just display the error to the user
2674 2755
 	if(!isset($error_notice)){
2675 2756
 		echo '<br>'.$msg . '<br>';
2676
-	}else{
2757
+	} else{
2677 2758
 		$error_notice .= $msg . '<br>';
2678 2759
 	}
2679 2760
 }
@@ -2717,10 +2798,9 @@  discard block
 block discarded – undo
2717 2798
 
2718 2799
 		if(ord(substr($str, $i, 1))==10){
2719 2800
 			$new_str .= '\n';
2720
-		}elseif(ord(substr($str, $i, 1))==13){
2801
+		} elseif(ord(substr($str, $i, 1))==13){
2721 2802
 			$new_str .= '\r';
2722
-		}
2723
-		else {
2803
+		} else {
2724 2804
 			$new_str .= $str{$i};
2725 2805
 		}
2726 2806
 	}
@@ -2735,8 +2815,7 @@  discard block
 block discarded – undo
2735 2815
 
2736 2816
 	if($keep){
2737 2817
 		$str = javascript_escape($str);
2738
-	}
2739
-	else {
2818
+	} else {
2740 2819
 		$str = str_replace("'", " ", $str);
2741 2820
 		$str = str_replace('"', " ", $str);
2742 2821
 	}
@@ -2931,8 +3010,9 @@  discard block
 block discarded – undo
2931 3010
 
2932 3011
 	$server_software = $_SERVER["SERVER_SOFTWARE"];
2933 3012
 	$iis_version = '';
2934
-	if(strpos($server_software,'Microsoft-IIS') !== false && preg_match_all("/^.*\/(\d+\.?\d*)$/",  $server_software, $out))
2935
-	    $iis_version = $out[1][0];
3013
+	if(strpos($server_software,'Microsoft-IIS') !== false && preg_match_all("/^.*\/(\d+\.?\d*)$/",  $server_software, $out)) {
3014
+		    $iis_version = $out[1][0];
3015
+	}
2936 3016
 
2937 3017
     $sys_iis_version = empty($sys_iis_version) ? $iis_version : $sys_iis_version;
2938 3018
 
@@ -3008,7 +3088,9 @@  discard block
 block discarded – undo
3008 3088
 
3009 3089
 function sugar_cleanup($exit = false) {
3010 3090
 	static $called = false;
3011
-	if($called)return;
3091
+	if($called) {
3092
+	    return;
3093
+	}
3012 3094
 	$called = true;
3013 3095
 	set_include_path(realpath(dirname(__FILE__) . '/..') . PATH_SEPARATOR . get_include_path());
3014 3096
 	chdir(realpath(dirname(__FILE__) . '/..'));
@@ -3019,7 +3101,11 @@  discard block
 block discarded – undo
3019 3101
 
3020 3102
 	//added this check to avoid errors during install.
3021 3103
 	if (empty($sugar_config['dbconfig'])) {
3022
-		if ($exit) exit; else return;
3104
+		if ($exit) {
3105
+		    exit;
3106
+		} else {
3107
+		    return;
3108
+		}
3023 3109
 	}
3024 3110
 
3025 3111
     if (!class_exists('Tracker', true)) {
@@ -3028,8 +3114,9 @@  discard block
 block discarded – undo
3028 3114
 	Tracker::logPage();
3029 3115
 	// Now write the cached tracker_queries
3030 3116
 	if(!empty($GLOBALS['savePreferencesToDB']) && $GLOBALS['savePreferencesToDB']) {
3031
-	    if ( isset($GLOBALS['current_user']) && $GLOBALS['current_user'] instanceOf User )
3032
-	        $GLOBALS['current_user']->savePreferencesToDB();
3117
+	    if ( isset($GLOBALS['current_user']) && $GLOBALS['current_user'] instanceOf User ) {
3118
+	    	        $GLOBALS['current_user']->savePreferencesToDB();
3119
+	    }
3033 3120
 	}
3034 3121
 
3035 3122
 	//check to see if this is not an `ajax call AND the user preference error flag is set
@@ -3154,8 +3241,9 @@  discard block
 block discarded – undo
3154 3241
 
3155 3242
 	echo "\n\n display_stack_trace caller, file: " . $stack[0]['file']. ' line#: ' .$stack[0]['line'];
3156 3243
 
3157
-	if(!$textOnly)
3158
-	echo '<br>';
3244
+	if(!$textOnly) {
3245
+		echo '<br>';
3246
+	}
3159 3247
 
3160 3248
 	$first = true;
3161 3249
 	$out = '';
@@ -3166,14 +3254,18 @@  discard block
 block discarded – undo
3166 3254
 		$line  = '';
3167 3255
 		$function  = '';
3168 3256
 
3169
-		if(isset($item['file']))
3170
-		$file = $item['file'];
3171
-		if(isset($item['class']))
3172
-		$class = $item['class'];
3173
-		if(isset($item['line']))
3174
-		$line = $item['line'];
3175
-		if(isset($item['function']))
3176
-		$function = $item['function'];
3257
+		if(isset($item['file'])) {
3258
+				$file = $item['file'];
3259
+		}
3260
+		if(isset($item['class'])) {
3261
+				$class = $item['class'];
3262
+		}
3263
+		if(isset($item['line'])) {
3264
+				$line = $item['line'];
3265
+		}
3266
+		if(isset($item['function'])) {
3267
+				$function = $item['function'];
3268
+		}
3177 3269
 
3178 3270
 		if(!$first) {
3179 3271
 			if(!$textOnly) {
@@ -3217,9 +3309,9 @@  discard block
 block discarded – undo
3217 3309
 		    if ( error_reporting() & E_NOTICE ) {
3218 3310
 		        $halt_script = false;
3219 3311
 		        $type = 'Notice';
3312
+		    } else {
3313
+		    		        return;
3220 3314
 		    }
3221
-		    else
3222
-		        return;
3223 3315
 			break;
3224 3316
 		case E_USER_WARNING:
3225 3317
 		case E_COMPILE_WARNING:
@@ -3367,14 +3459,16 @@  discard block
 block discarded – undo
3367 3459
 	$file = str_replace("/", '\\', $file);
3368 3460
 
3369 3461
 	if(file_exists($file)) {
3370
-		if (!($f = @sugar_fopen($file, 'r+')))
3371
-		return false;
3462
+		if (!($f = @sugar_fopen($file, 'r+'))) {
3463
+				return false;
3464
+		}
3372 3465
 		fclose($f);
3373 3466
 		return true;
3374 3467
 	}
3375 3468
 
3376
-	if(!($f = @sugar_fopen($file, 'w')))
3377
-	return false;
3469
+	if(!($f = @sugar_fopen($file, 'w'))) {
3470
+		return false;
3471
+	}
3378 3472
 	fclose($f);
3379 3473
 	unlink($file);
3380 3474
 	return true;
@@ -3393,7 +3487,9 @@  discard block
 block discarded – undo
3393 3487
 	global $beanList;
3394 3488
 
3395 3489
 	foreach($module_array as $key => $value){
3396
-		if(!empty($beanList[$value])) $module_array[$key] = $beanList[$value];
3490
+		if(!empty($beanList[$value])) {
3491
+		    $module_array[$key] = $beanList[$value];
3492
+		}
3397 3493
 
3398 3494
 		if($value=="Cases") {
3399 3495
 			$module_array[$key] = "Case";
@@ -3417,8 +3513,7 @@  discard block
 block discarded – undo
3417 3513
 	global $beanFiles, $beanList;
3418 3514
 	if(array_key_exists($bean_name, $beanList)){
3419 3515
 		return $beanList[$bean_name];
3420
-	}
3421
-	else{
3516
+	} else{
3422 3517
 		return $bean_name;
3423 3518
 	}
3424 3519
 }
@@ -3692,8 +3787,7 @@  discard block
 block discarded – undo
3692 3787
 		$num=unformat_number($num);
3693 3788
 		if(isset($system_id) && $system_id == 1){
3694 3789
 			return sprintf("%d", $num);
3695
-		}
3696
-		else{
3790
+		} else{
3697 3791
 			return sprintf("%d-%d", $num, $system_id);
3698 3792
 		}
3699 3793
 	}
@@ -3720,8 +3814,7 @@  discard block
 block discarded – undo
3720 3814
 		{
3721 3815
 			//third index ($split[2]) will be the host
3722 3816
 			$split[2] .= ":".$port;
3723
-		}
3724
-		else // otherwise assumed to start with host name
3817
+		} else // otherwise assumed to start with host name
3725 3818
 		{
3726 3819
 			//first index ($split[0]) will be the host
3727 3820
 			$split[0] .= ":".$port;
@@ -3797,19 +3890,19 @@  discard block
 block discarded – undo
3797 3890
 				if(is_array($domVal))
3798 3891
                 {
3799 3892
 					$tempArr = array();
3800
-                    foreach ( $domVal as $domArrKey => $domArrVal )
3801
-                        $tempArr[$domArrKey] = $domArrVal;
3802
-                    foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal )
3803
-                        if ( !isset($tempArr[$gimpArrKey]) )
3893
+                    foreach ( $domVal as $domArrKey => $domArrVal ) {
3894
+                                            $tempArr[$domArrKey] = $domArrVal;
3895
+                    }
3896
+                    foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal ) {
3897
+                                            if ( !isset($tempArr[$gimpArrKey]) )
3804 3898
                             $tempArr[$gimpArrKey] = $gimpArrVal;
3899
+                    }
3805 3900
                     $gimp[$domKey] = $tempArr;
3806
-				}
3807
-                else
3901
+				} else
3808 3902
                 {
3809 3903
 					$gimp[$domKey] = $domVal;
3810 3904
 				}
3811
-			}
3812
-            else
3905
+			} else
3813 3906
             {
3814 3907
 				$gimp[$domKey] = $domVal;
3815 3908
 			}
@@ -3843,11 +3936,13 @@  discard block
 block discarded – undo
3843 3936
 			if(array_key_exists($domKey, $gimp)) {
3844 3937
 				if(is_array($domVal)) {
3845 3938
 					$tempArr = array();
3846
-                    foreach ( $domVal as $domArrKey => $domArrVal )
3847
-                        $tempArr[$domArrKey] = $domArrVal;
3848
-                    foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal )
3849
-                        if ( !array_key_exists($gimpArrKey, $tempArr) )
3939
+                    foreach ( $domVal as $domArrKey => $domArrVal ) {
3940
+                                            $tempArr[$domArrKey] = $domArrVal;
3941
+                    }
3942
+                    foreach ( $gimp[$domKey] as $gimpArrKey => $gimpArrVal ) {
3943
+                                            if ( !array_key_exists($gimpArrKey, $tempArr) )
3850 3944
                             $tempArr[$gimpArrKey] = $gimpArrVal;
3945
+                    }
3851 3946
                     $gimp[$domKey] = $tempArr;
3852 3947
 				} else {
3853 3948
 					$gimp[$domKey] = $domVal;
@@ -3858,8 +3953,9 @@  discard block
 block discarded – undo
3858 3953
 		}
3859 3954
 	}
3860 3955
     // if the passed value for gimp isn't an array, then return the $dom
3861
-    elseif(is_array($dom))
3862
-        return $dom;
3956
+    elseif(is_array($dom)) {
3957
+            return $dom;
3958
+    }
3863 3959
 
3864 3960
 	return $gimp;
3865 3961
 }
@@ -3886,8 +3982,9 @@  discard block
 block discarded – undo
3886 3982
 		}
3887 3983
 	}
3888 3984
     // if the passed value for gimp isn't an array, then return the $dom
3889
-    elseif(is_array($dom))
3890
-        return $dom;
3985
+    elseif(is_array($dom)) {
3986
+            return $dom;
3987
+    }
3891 3988
 
3892 3989
 	return $gimp;
3893 3990
 }
@@ -4042,8 +4139,7 @@  discard block
 block discarded – undo
4042 4139
 
4043 4140
 	if( write_array_to_file( "sugar_config", $sugar_config, "config.php" ) ){
4044 4141
 		return true;
4045
-	}
4046
-	else {
4142
+	} else {
4047 4143
 		return false;
4048 4144
 	}
4049 4145
 }
@@ -4076,8 +4172,9 @@  discard block
 block discarded – undo
4076 4172
 	if(!empty($_SERVER['HTTP_REFERER'])) {
4077 4173
 		$url = parse_url($_SERVER['HTTP_REFERER']);
4078 4174
 		$replacement_url = $url['scheme']."://".$url['host'];
4079
-		if(!empty($url['port']))
4080
-		$replacement_url .= ':'.$url['port'];
4175
+		if(!empty($url['port'])) {
4176
+				$replacement_url .= ':'.$url['port'];
4177
+		}
4081 4178
 		$site_url = preg_replace('/^http[s]?\:\/\/[^\/]+/',$replacement_url,$sugar_config['site_url']);
4082 4179
 	} else {
4083 4180
 		$site_url = preg_replace('/^http(s)?\:\/\/[^\/]+/',"http$1://".$_SERVER['HTTP_HOST'],$sugar_config['site_url']);
@@ -4102,8 +4199,7 @@  discard block
 block discarded – undo
4102 4199
 		foreach ($array as $key => $value){
4103 4200
 			$depth_array[] = array_depth($value, $depth_count);
4104 4201
 		}
4105
-	}
4106
-	else{
4202
+	} else{
4107 4203
 		return $depth_count;
4108 4204
 	}
4109 4205
 	foreach ($depth_array as $value){
@@ -4146,17 +4242,20 @@  discard block
 block discarded – undo
4146 4242
     $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4147 4243
 
4148 4244
     //First try un-ucfirst-ing the icon name
4149
-    if ( empty($iconFound) )
4150
-		$iconName = "icon_" . strtolower(substr($iconFileName,0,1)).substr($iconFileName,1) . ".gif";
4245
+    if ( empty($iconFound) ) {
4246
+    		$iconName = "icon_" . strtolower(substr($iconFileName,0,1)).substr($iconFileName,1) . ".gif";
4247
+    }
4151 4248
         $iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4152 4249
 
4153 4250
 	//Next try removing the icon prefix
4154
-    if ( empty($iconFound) )
4155
-		$iconName = "{$iconFileName}.gif";
4251
+    if ( empty($iconFound) ) {
4252
+    		$iconName = "{$iconFileName}.gif";
4253
+    }
4156 4254
 		$iconFound = SugarThemeRegistry::current()->getImageURL($iconName,false);
4157 4255
 
4158
-	if ( empty($iconFound) )
4159
-		$iconName = '';
4256
+	if ( empty($iconFound) ) {
4257
+			$iconName = '';
4258
+	}
4160 4259
 
4161 4260
   	return $iconName;
4162 4261
 }
@@ -4222,8 +4321,9 @@  discard block
 block discarded – undo
4222 4321
     if (!isset($trans_tbl))
4223 4322
     {
4224 4323
         $trans_tbl = array();
4225
-        foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key)
4226
-            $trans_tbl[$key] = utf8_encode($val);
4324
+        foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key) {
4325
+                    $trans_tbl[$key] = utf8_encode($val);
4326
+        }
4227 4327
     }
4228 4328
     return strtr($string, $trans_tbl);
4229 4329
 }
@@ -4231,10 +4331,18 @@  discard block
 block discarded – undo
4231 4331
 // Returns the utf string corresponding to the unicode value
4232 4332
 function code2utf($num)
4233 4333
 {
4234
-    if ($num < 128) return chr($num);
4235
-    if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
4236
-    if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4237
-    if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4334
+    if ($num < 128) {
4335
+        return chr($num);
4336
+    }
4337
+    if ($num < 2048) {
4338
+        return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
4339
+    }
4340
+    if ($num < 65536) {
4341
+        return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4342
+    }
4343
+    if ($num < 2097152) {
4344
+        return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4345
+    }
4238 4346
     return '';
4239 4347
 }
4240 4348
 
@@ -4287,8 +4395,9 @@  discard block
 block discarded – undo
4287 4395
  */
4288 4396
 function chartColors()
4289 4397
 {
4290
-	if (SugarThemeRegistry::current()->getCSSURL('sugarColors.xml')=='')
4291
-	return SugarThemeRegistry::current()->getImageURL('sugarColors.xml');
4398
+	if (SugarThemeRegistry::current()->getCSSURL('sugarColors.xml')=='') {
4399
+		return SugarThemeRegistry::current()->getImageURL('sugarColors.xml');
4400
+	}
4292 4401
     return SugarThemeRegistry::current()->getCSSURL('sugarColors.xml');
4293 4402
 }
4294 4403
 /* End Chart Dashlet helper functions */
@@ -4319,8 +4428,9 @@  discard block
 block discarded – undo
4319 4428
     if ( ( substr($path,0,2) == '\\\\' )
4320 4429
             || ( $path[0] == '/' )
4321 4430
             || preg_match('/^[A-z]:/i',$path)
4322
-            || $currentServer )
4323
-        return $path;
4431
+            || $currentServer ) {
4432
+            return $path;
4433
+    }
4324 4434
 
4325 4435
     return getcwd().'/'.$path;
4326 4436
 }
@@ -4367,8 +4477,9 @@  discard block
 block discarded – undo
4367 4477
  */
4368 4478
 function get_alt_hot_key() {
4369 4479
 	$ua = '';
4370
-    if ( isset($_SERVER['HTTP_USER_AGENT']) )
4371
-        $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
4480
+    if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
4481
+            $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
4482
+    }
4372 4483
 	$isMac = strpos($ua, 'mac') !== false;
4373 4484
 	$isLinux = strpos($ua, 'linux') !== false;
4374 4485
 
@@ -4412,11 +4523,12 @@  discard block
 block discarded – undo
4412 4523
 {
4413 4524
     if ( !isset($GLOBALS['sugar_config']['allow_pop_inbound']) || ! $GLOBALS['sugar_config']['allow_pop_inbound'] )
4414 4525
     {
4415
-        if( isset($protocol['pop3']) )
4416
-			unset($protocol['pop3']);
4526
+        if( isset($protocol['pop3']) ) {
4527
+        			unset($protocol['pop3']);
4528
+        }
4529
+    } else {
4530
+            $protocol['pop3'] = 'POP3';
4417 4531
     }
4418
-    else
4419
-        $protocol['pop3'] = 'POP3';
4420 4532
 
4421 4533
     return $protocol;
4422 4534
 }
@@ -4460,11 +4572,13 @@  discard block
 block discarded – undo
4460 4572
 }
4461 4573
 
4462 4574
 function encodeMultienumValue($arr) {
4463
-    if (!is_array($arr))
4464
-        return $arr;
4575
+    if (!is_array($arr)) {
4576
+            return $arr;
4577
+    }
4465 4578
 
4466
-    if (empty($arr))
4467
-        return "";
4579
+    if (empty($arr)) {
4580
+            return "";
4581
+    }
4468 4582
 
4469 4583
 	$string = "^" . implode('^,^', $arr) . "^";
4470 4584
 
@@ -4496,16 +4610,14 @@  discard block
 block discarded – undo
4496 4610
 			if(empty($join_type))
4497 4611
 			{
4498 4612
 				$params['join_type'] = ' LEFT JOIN ';
4499
-			}
4500
-			else
4613
+			} else
4501 4614
 			{
4502 4615
 				$params['join_type'] = $join_type;
4503 4616
 			}
4504 4617
 			if(isset($data['join_name']))
4505 4618
 			{
4506 4619
 				$params['join_table_alias'] = $field['join_name'];
4507
-			}
4508
-			else
4620
+			} else
4509 4621
 			{
4510 4622
 				$params['join_table_alias']	= 'join_'.$field['name'];
4511 4623
 
@@ -4513,8 +4625,7 @@  discard block
 block discarded – undo
4513 4625
 			if(isset($data['join_link_name']))
4514 4626
 			{
4515 4627
 				$params['join_table_link_alias'] = $field['join_link_name'];
4516
-			}
4517
-			else
4628
+			} else
4518 4629
 			{
4519 4630
 				$params['join_table_link_alias'] = 'join_link_'.$field['name'];
4520 4631
 			}
@@ -4523,7 +4634,7 @@  discard block
 block discarded – undo
4523 4634
 			if(isset($field['db_concat_fields'])){
4524 4635
 				$db_field = db_concat($join_table_alias, $field['db_concat_fields']);
4525 4636
 				$where = preg_replace('/'.$field['name'].'/', $db_field, $where);
4526
-			}else{
4637
+			} else{
4527 4638
 				$where = preg_replace('/(^|[\s(])' . $field['name'] . '/', '${1}' . $join_table_alias . '.'.$field['rname'], $where);
4528 4639
 			}
4529 4640
 		}
@@ -4558,8 +4669,7 @@  discard block
 block discarded – undo
4558 4669
 	$number = preg_match("/{$variable}=([a-zA-Z0-9_-]+)[&]?/", $string, $matches);
4559 4670
 	if($number){
4560 4671
 		return $matches[1];
4561
-	}
4562
-	else{
4672
+	} else{
4563 4673
 		return false;
4564 4674
 	}
4565 4675
 }
@@ -4591,7 +4701,7 @@  discard block
 block discarded – undo
4591 4701
 function getVersionStatus($version){
4592 4702
 	if(preg_match('/^[\d\.]+?([a-zA-Z]+?)[\d]*?$/si', $version, $matches)) {
4593 4703
 		return strtoupper($matches[1]);
4594
-	}else{
4704
+	} else{
4595 4705
 		return 'GA';
4596 4706
 	}
4597 4707
 }
@@ -4686,7 +4796,9 @@  discard block
 block discarded – undo
4686 4796
 	} else {
4687 4797
 	    // check image manually
4688 4798
         $fp = fopen($path, "rb");
4689
-        if(!$fp) return false;
4799
+        if(!$fp) {
4800
+            return false;
4801
+        }
4690 4802
         $data = '';
4691 4803
         // read the whole file in chunks
4692 4804
         while(!feof($fp)) {
@@ -4778,8 +4890,9 @@  discard block
 block discarded – undo
4778 4890
     // add wildcard at the beginning of the search string
4779 4891
     if (isset($GLOBALS['sugar_config']['search_wildcard_infront']) &&
4780 4892
         $GLOBALS['sugar_config']['search_wildcard_infront'] == true) {
4781
-        if (substr($str,0,1) <> $wildcard)
4782
-          $str = $wildcard.$str;
4893
+        if (substr($str,0,1) <> $wildcard) {
4894
+                  $str = $wildcard.$str;
4895
+        }
4783 4896
     }
4784 4897
 
4785 4898
     // add wildcard at the end of search string (default)
@@ -4834,8 +4947,7 @@  discard block
 block discarded – undo
4834 4947
 {
4835 4948
     if (isset($GLOBALS['app_list_strings'][$optionName])) {
4836 4949
         return $GLOBALS['app_list_strings'][$optionName];
4837
-    }
4838
-    else {
4950
+    } else {
4839 4951
         return array();
4840 4952
     }
4841 4953
 }
@@ -5085,47 +5197,53 @@  discard block
 block discarded – undo
5085 5197
 
5086 5198
 function suite_strlen($input, $encoding = DEFAULT_UTIL_SUITE_ENCODING)
5087 5199
 {
5088
-	if(function_exists('mb_strlen'))
5089
-		return mb_strlen($input,$encoding);
5090
-	else
5091
-		return strlen($input);
5092
-}
5200
+	if(function_exists('mb_strlen')) {
5201
+			return mb_strlen($input,$encoding);
5202
+	} else {
5203
+			return strlen($input);
5204
+	}
5205
+	}
5093 5206
 
5094 5207
 function suite_substr($input, $start, $length = null,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5095 5208
 {
5096
-	if(function_exists('mb_substr'))
5097
-		return mb_substr($input,$start,$length,$encoding);
5098
-	else
5099
-		return substr($input,$start,$length);
5100
-}
5209
+	if(function_exists('mb_substr')) {
5210
+			return mb_substr($input,$start,$length,$encoding);
5211
+	} else {
5212
+			return substr($input,$start,$length);
5213
+	}
5214
+	}
5101 5215
 
5102 5216
 function suite_strtoupper($input,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5103 5217
 {
5104
-	if(function_exists('mb_strtoupper'))
5105
-		return mb_strtoupper($input,$encoding);
5106
-	else
5107
-		return strtoupper($input);
5108
-}
5218
+	if(function_exists('mb_strtoupper')) {
5219
+			return mb_strtoupper($input,$encoding);
5220
+	} else {
5221
+			return strtoupper($input);
5222
+	}
5223
+	}
5109 5224
 function suite_strtolower($input,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5110 5225
 {
5111
-	if(function_exists('mb_strtolower'))
5112
-		return mb_strtolower($input,$encoding);
5113
-	else
5114
-		return strtolower($input);
5115
-}
5226
+	if(function_exists('mb_strtolower')) {
5227
+			return mb_strtolower($input,$encoding);
5228
+	} else {
5229
+			return strtolower($input);
5230
+	}
5231
+	}
5116 5232
 
5117 5233
 function suite_strpos($haystack,$needle,$offset=0,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5118 5234
 {
5119
-	if(function_exists('mb_strpos'))
5120
-		return mb_strpos($haystack,$needle,$offset,$encoding);
5121
-	else
5122
-		return strpos($haystack,$needle,$offset);
5123
-}
5235
+	if(function_exists('mb_strpos')) {
5236
+			return mb_strpos($haystack,$needle,$offset,$encoding);
5237
+	} else {
5238
+			return strpos($haystack,$needle,$offset);
5239
+	}
5240
+	}
5124 5241
 
5125 5242
 function suite_strrpos($haystack,$needle,$offset=0,$encoding = DEFAULT_UTIL_SUITE_ENCODING)
5126 5243
 {
5127
-	if(function_exists('mb_strrpos'))
5128
-		return mb_strrpos($haystack,$needle,$offset,$encoding);
5129
-	else
5130
-		return strrpos($haystack,$needle,$offset);
5131
-}
5132 5244
\ No newline at end of file
5245
+	if(function_exists('mb_strrpos')) {
5246
+			return mb_strrpos($haystack,$needle,$offset,$encoding);
5247
+	} else {
5248
+			return strrpos($haystack,$needle,$offset);
5249
+	}
5250
+	}
5133 5251
\ No newline at end of file
Please login to merge, or discard this patch.
include/Popups/PopupSmarty.php 3 patches
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 define("NUM_COLS", 2);
46 46
 class PopupSmarty extends ListViewSmarty{
47 47
 
48
-	var $contextMenus = false;
49
-	var $export = false;
50
-	var $mailmerge = false;
51
-	var $mergeduplicates = false;
52
-	var $quickViewLinks = false;
53
-	var $multiSelect = false;
54
-	var $headerTpl;
48
+    var $contextMenus = false;
49
+    var $export = false;
50
+    var $mailmerge = false;
51
+    var $mergeduplicates = false;
52
+    var $quickViewLinks = false;
53
+    var $multiSelect = false;
54
+    var $headerTpl;
55 55
     var $footerTpl;
56 56
     var $th;
57 57
     var $tpl;
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
     var $module;
71 71
     var $massUpdateData = '';
72 72
 
73
-	function PopupSmarty($seed, $module){
74
-		parent::ListViewSmarty();
75
-		$this->th = new TemplateHandler();
76
-		$this->th->loadSmarty();
77
-		$this->seed = $seed;
78
-		$this->view = 'Popup';
79
-		$this->module = $module;
80
-		$this->searchForm = new SearchForm($this->seed, $this->module);
81
-		$this->th->deleteTemplate($module, $this->view);
73
+    function PopupSmarty($seed, $module){
74
+        parent::ListViewSmarty();
75
+        $this->th = new TemplateHandler();
76
+        $this->th->loadSmarty();
77
+        $this->seed = $seed;
78
+        $this->view = 'Popup';
79
+        $this->module = $module;
80
+        $this->searchForm = new SearchForm($this->seed, $this->module);
81
+        $this->th->deleteTemplate($module, $this->view);
82 82
         $this->headerTpl = 'include/Popups/tpls/header.tpl';
83 83
         $this->footerTpl = 'include/Popups/tpls/footer.tpl';
84 84
 
85
-	}
85
+    }
86 86
 
87 87
     /**
88 88
      * Assign several arrow image attributes to TemplateHandler smarty. Such as width, height, etc.
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $this->th->ss->assign('arrowAlt', translate('LBL_SORT'));
102 102
     }
103 103
 
104
-	/**
104
+    /**
105 105
      * Processes the request. Calls ListViewData process. Also assigns all lang strings, export links,
106 106
      * This is called from ListViewDisplay
107 107
      *
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
      * @param html_var string the corresponding html var in xtpl per row
111 111
      *
112 112
      */
113
-	function process($file, $data, $htmlVar) {
113
+    function process($file, $data, $htmlVar) {
114 114
 
115
-		global $odd_bg, $even_bg, $hilite_bg, $click_bg, $app_strings;
116
-		parent::process($file, $data, $htmlVar);
115
+        global $odd_bg, $even_bg, $hilite_bg, $click_bg, $app_strings;
116
+        parent::process($file, $data, $htmlVar);
117 117
 
118
-		$this->tpl = $file;
119
-		$this->data = $data;
118
+        $this->tpl = $file;
119
+        $this->data = $data;
120 120
 
121 121
         $totalWidth = 0;
122 122
         foreach($this->displayColumns as $name => $params) {
@@ -131,47 +131,47 @@  discard block
 block discarded – undo
131 131
             if(!empty($params['contextMenu']['objectType']))
132 132
                 $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true;
133 133
         }
134
-		$this->th->ss->assign('displayColumns', $this->displayColumns);
134
+        $this->th->ss->assign('displayColumns', $this->displayColumns);
135 135
 
136 136
 
137
-		$this->th->ss->assign('bgHilite', $hilite_bg);
138
-		$this->th->ss->assign('colCount', count($this->displayColumns) + 1);
139
-		$this->th->ss->assign('htmlVar', strtoupper($htmlVar));
140
-		$this->th->ss->assign('moduleString', $this->moduleString);
137
+        $this->th->ss->assign('bgHilite', $hilite_bg);
138
+        $this->th->ss->assign('colCount', count($this->displayColumns) + 1);
139
+        $this->th->ss->assign('htmlVar', strtoupper($htmlVar));
140
+        $this->th->ss->assign('moduleString', $this->moduleString);
141 141
         $this->th->ss->assign('editLinkString', $GLOBALS['app_strings']['LBL_EDIT_BUTTON']);
142 142
         $this->th->ss->assign('viewLinkString', $GLOBALS['app_strings']['LBL_VIEW_BUTTON']);
143 143
 
144 144
         //rrs
145 145
         $this->searchForm->parsedView = 'popup_query_form';
146 146
         $this->searchForm->displayType = 'popupView';
147
-		$this->th->ss->assign('searchForm', $this->searchForm->display(false));
147
+        $this->th->ss->assign('searchForm', $this->searchForm->display(false));
148 148
         //rrs
149 149
 
150
-		if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink());
151
-		$this->th->ss->assign('quickViewLinks', $this->quickViewLinks);
152
-		if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access
153
-		if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink());
150
+        if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink());
151
+        $this->th->ss->assign('quickViewLinks', $this->quickViewLinks);
152
+        if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access
153
+        if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink());
154 154
 
155 155
 
156
-		if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
157
-			$this->multiSelect = true;
158
-		}
159
-		// handle save checks and stuff
160
-		if($this->multiSelect) {
161
-			$this->th->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan());
162
-			$this->th->ss->assign('multiSelectData', $this->getMultiSelectData());
163
-			$this->th->ss->assign('MODE', "<input type='hidden' name='mode' value='MultiSelect'>");
156
+        if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
157
+            $this->multiSelect = true;
158
+        }
159
+        // handle save checks and stuff
160
+        if($this->multiSelect) {
161
+            $this->th->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan());
162
+            $this->th->ss->assign('multiSelectData', $this->getMultiSelectData());
163
+            $this->th->ss->assign('MODE', "<input type='hidden' name='mode' value='MultiSelect'>");
164 164
             $pageTotal = $this->data['pageData']['offsets']['next'] - $this->data['pageData']['offsets']['current'];
165 165
             if($this->data['pageData']['offsets']['next'] < 0){ // If we are on the last page, 'next' is -1, which means we have to have a custom calculation
166 166
                 $pageTotal = $this->data['pageData']['offsets']['total'] - $this->data['pageData']['offsets']['current'];
167 167
             }
168
-    		$this->th->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal));
169
-		}
168
+            $this->th->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal));
169
+        }
170 170
 
171
-		$this->processArrows($data['pageData']['ordering']);
172
-		$this->th->ss->assign('prerow', $this->multiSelect);
173
-		$this->th->ss->assign('rowColor', array('oddListRow', 'evenListRow'));
174
-		$this->th->ss->assign('bgColor', array($odd_bg, $even_bg));
171
+        $this->processArrows($data['pageData']['ordering']);
172
+        $this->th->ss->assign('prerow', $this->multiSelect);
173
+        $this->th->ss->assign('rowColor', array('oddListRow', 'evenListRow'));
174
+        $this->th->ss->assign('bgColor', array($odd_bg, $even_bg));
175 175
         $this->th->ss->assign('contextMenus', $this->contextMenus);
176 176
 
177 177
 
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 
192 192
             // arrow image attributes
193 193
             $this->processArrowVars();
194
-	}
194
+    }
195 195
 
196
-	/*
196
+    /*
197 197
 	 * Display the Smarty template.  Here we are using the TemplateHandler for caching per the module.
198 198
 	 */
199
-	function display($end = true) {
199
+    function display($end = true) {
200 200
         global $app_strings;
201 201
 
202 202
         if(!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) {
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
         $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js",  $GLOBALS['sugar_config']['js_lang_version']);
207 207
 
208 208
         $this->th->ss->assign('data', $this->data['data']);
209
-		$this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']);
210
-		$this->th->ss->assign('pageData', $this->data['pageData']);
209
+        $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']);
210
+        $this->th->ss->assign('pageData', $this->data['pageData']);
211 211
 
212 212
         $navStrings = array('next' => $GLOBALS['app_strings']['LNK_LIST_NEXT'],
213 213
                             'previous' => $GLOBALS['app_strings']['LNK_LIST_PREVIOUS'],
@@ -217,128 +217,128 @@  discard block
 block discarded – undo
217 217
         $this->th->ss->assign('navStrings', $navStrings);
218 218
 
219 219
 
220
-		$associated_row_data = array();
220
+        $associated_row_data = array();
221 221
 		
222
-		//C.L. - Bug 44324 - Override the NAME entry to not display salutation so that the data returned from the popup can be searched on correctly
223
-		$searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false;
222
+        //C.L. - Bug 44324 - Override the NAME entry to not display salutation so that the data returned from the popup can be searched on correctly
223
+        $searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false;
224 224
 		
225
-		global $locale;
226
-		foreach($this->data['data'] as $val)
227
-		{
228
-			$associated_row_data[$val['ID']] = $val;
229
-			if($searchNameOverride)
230
-			{
231
-			   $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']);
232
-			}
233
-		}
234
-		$is_show_fullname = showFullName() ? 1 : 0;
235
-		$json = getJSONobj();
236
-		$this->th->ss->assign('jsLang', $jsLang);
237
-		$this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2));
225
+        global $locale;
226
+        foreach($this->data['data'] as $val)
227
+        {
228
+            $associated_row_data[$val['ID']] = $val;
229
+            if($searchNameOverride)
230
+            {
231
+                $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']);
232
+            }
233
+        }
234
+        $is_show_fullname = showFullName() ? 1 : 0;
235
+        $json = getJSONobj();
236
+        $this->th->ss->assign('jsLang', $jsLang);
237
+        $this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2));
238 238
         $this->th->ss->assign('headerTpl', $this->headerTpl);
239 239
         $this->th->ss->assign('footerTpl', $this->footerTpl);
240 240
         $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data). '; var is_show_fullname = '.$is_show_fullname.';');
241
-		$this->th->ss->assign('module', $this->seed->module_dir);
242
-		$request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
243
-
244
-		$this->th->ss->assign('request_data', $request_data);
245
-		$this->th->ss->assign('fields', $this->fieldDefs);
246
-		$this->th->ss->assign('formData', $this->formData);
247
-		$this->th->ss->assign('APP', $GLOBALS['app_strings']);
248
-		$this->th->ss->assign('MOD', $GLOBALS['mod_strings']);
241
+        $this->th->ss->assign('module', $this->seed->module_dir);
242
+        $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
243
+
244
+        $this->th->ss->assign('request_data', $request_data);
245
+        $this->th->ss->assign('fields', $this->fieldDefs);
246
+        $this->th->ss->assign('formData', $this->formData);
247
+        $this->th->ss->assign('APP', $GLOBALS['app_strings']);
248
+        $this->th->ss->assign('MOD', $GLOBALS['mod_strings']);
249 249
         if (isset($this->_popupMeta['create']['createButton'])) 
250
-		{
251
-           $this->_popupMeta['create']['createButton'] = translate($this->_popupMeta['create']['createButton']);
250
+        {
251
+            $this->_popupMeta['create']['createButton'] = translate($this->_popupMeta['create']['createButton']);
252 252
         }
253
-		$this->th->ss->assign('popupMeta', $this->_popupMeta);
253
+        $this->th->ss->assign('popupMeta', $this->_popupMeta);
254 254
         $this->th->ss->assign('current_query', base64_encode(serialize($_REQUEST)));
255
-		$this->th->ss->assign('customFields', $this->customFieldDefs);
256
-		$this->th->ss->assign('numCols', NUM_COLS);
257
-		$this->th->ss->assign('massUpdateData', $this->massUpdateData);
258
-		$this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']);
255
+        $this->th->ss->assign('customFields', $this->customFieldDefs);
256
+        $this->th->ss->assign('numCols', NUM_COLS);
257
+        $this->th->ss->assign('massUpdateData', $this->massUpdateData);
258
+        $this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']);
259 259
         $this->th->ss->assign('should_process', $this->should_process);
260 260
 
261
-		if($this->_create){
262
-			$this->th->ss->assign('ADDFORM', $this->getQuickCreate());//$this->_getAddForm());
263
-			$this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader());
264
-			$this->th->ss->assign('object_name', $this->seed->object_name);
265
-		}
266
-		$this->th->ss->assign('LIST_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'], '', false));
267
-		$this->th->ss->assign('SEARCH_FORM_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_SEARCH_FORM_TITLE'], '', false));
268
-		$str = $this->th->displayTemplate($this->seed->module_dir, $this->view, $this->tpl);
269
-		return $str;
270
-	}
271
-
272
-	/*
261
+        if($this->_create){
262
+            $this->th->ss->assign('ADDFORM', $this->getQuickCreate());//$this->_getAddForm());
263
+            $this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader());
264
+            $this->th->ss->assign('object_name', $this->seed->object_name);
265
+        }
266
+        $this->th->ss->assign('LIST_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'], '', false));
267
+        $this->th->ss->assign('SEARCH_FORM_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_SEARCH_FORM_TITLE'], '', false));
268
+        $str = $this->th->displayTemplate($this->seed->module_dir, $this->view, $this->tpl);
269
+        return $str;
270
+    }
271
+
272
+    /*
273 273
 	 * Setup up the smarty template. we added an extra step here to add the order by from the popupdefs.
274 274
 	 */
275
-	function setup($seed, $file = null, $where = null, $params = Array(), $offset = 0, $limit = -1, $filter_fields = Array(), $id_field = 'id') {
276
-		$args = func_get_args();
277
-		return call_user_func_array(array($this, '_setup'), $args);
278
-	}
279
-	function _setup($file) {
280
-
281
-	    if(isset($this->_popupMeta)){
282
-			if(isset($this->_popupMeta['create']['formBase'])) {
283
-				require_once('modules/' . $this->seed->module_dir . '/' . $this->_popupMeta['create']['formBase']);
284
-				$this->_create = true;
285
-			}
286
-		}
287
-	    if(!empty($this->_popupMeta['create'])){
288
-			$formBase = new $this->_popupMeta['create']['formBaseClass']();
289
-			if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save')
290
-			{
291
-				//If it's a new record, set useRequired to false
292
-				$useRequired = empty($_REQUEST['id']) ? false : true;
293
-				$formBase->handleSave('', false, $useRequired);
294
-			}
295
-		}
296
-
297
-		$params = array();
298
-		if(!empty($this->_popupMeta['orderBy'])){
299
-			$params['orderBy'] = $this->_popupMeta['orderBy'];
300
-		}
301
-
302
-		if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
303
-			require('custom/modules/'.$this->module.'/metadata/metafiles.php');
304
-		}elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
305
-			require('modules/'.$this->module.'/metadata/metafiles.php');
306
-		}
307
-
308
-		if(!empty($metafiles[$this->module]['searchfields'])) {
309
-			require($metafiles[$this->module]['searchfields']);
310
-		} elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) {
311
-			require('modules/'.$this->module.'/metadata/SearchFields.php');
312
-	    }
275
+    function setup($seed, $file = null, $where = null, $params = Array(), $offset = 0, $limit = -1, $filter_fields = Array(), $id_field = 'id') {
276
+        $args = func_get_args();
277
+        return call_user_func_array(array($this, '_setup'), $args);
278
+    }
279
+    function _setup($file) {
280
+
281
+        if(isset($this->_popupMeta)){
282
+            if(isset($this->_popupMeta['create']['formBase'])) {
283
+                require_once('modules/' . $this->seed->module_dir . '/' . $this->_popupMeta['create']['formBase']);
284
+                $this->_create = true;
285
+            }
286
+        }
287
+        if(!empty($this->_popupMeta['create'])){
288
+            $formBase = new $this->_popupMeta['create']['formBaseClass']();
289
+            if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save')
290
+            {
291
+                //If it's a new record, set useRequired to false
292
+                $useRequired = empty($_REQUEST['id']) ? false : true;
293
+                $formBase->handleSave('', false, $useRequired);
294
+            }
295
+        }
296
+
297
+        $params = array();
298
+        if(!empty($this->_popupMeta['orderBy'])){
299
+            $params['orderBy'] = $this->_popupMeta['orderBy'];
300
+        }
301
+
302
+        if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
303
+            require('custom/modules/'.$this->module.'/metadata/metafiles.php');
304
+        }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
305
+            require('modules/'.$this->module.'/metadata/metafiles.php');
306
+        }
307
+
308
+        if(!empty($metafiles[$this->module]['searchfields'])) {
309
+            require($metafiles[$this->module]['searchfields']);
310
+        } elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) {
311
+            require('modules/'.$this->module.'/metadata/SearchFields.php');
312
+        }
313 313
         $this->searchdefs[$this->module]['templateMeta']['maxColumns'] = 2;
314 314
         $this->searchdefs[$this->module]['templateMeta']['widths']['label'] = 10;
315 315
         $this->searchdefs[$this->module]['templateMeta']['widths']['field'] = 30;
316 316
 
317 317
         $this->searchForm->view = 'PopupSearchForm';
318
-		$this->searchForm->setup($this->searchdefs, $searchFields, 'SearchFormGenericAdvanced.tpl', 'advanced_search', $this->listviewdefs);
319
-
320
-		$lv = new ListViewSmarty();
321
-		$displayColumns = array();
322
-		if(!empty($_REQUEST['displayColumns'])) {
323
-		    foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
324
-		        if(!empty($listViewDefs[$this->module][$col]))
325
-		            $displayColumns[$col] = $this->listviewdefs[$this->module][$col];
326
-		    }
327
-		}
328
-		else {
329
-		    foreach($this->listviewdefs[$this->module] as $col => $para) {
330
-		        if(!empty($para['default']) && $para['default'])
331
-		            $displayColumns[$col] = $para;
332
-		    }
333
-		}
334
-		$params['massupdate'] = true;
335
-		if(!empty($_REQUEST['orderBy'])) {
336
-		    $params['orderBy'] = $_REQUEST['orderBy'];
337
-		    $params['overrideOrder'] = true;
338
-		    if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
339
-		}
340
-
341
-		$lv->displayColumns = $displayColumns;
318
+        $this->searchForm->setup($this->searchdefs, $searchFields, 'SearchFormGenericAdvanced.tpl', 'advanced_search', $this->listviewdefs);
319
+
320
+        $lv = new ListViewSmarty();
321
+        $displayColumns = array();
322
+        if(!empty($_REQUEST['displayColumns'])) {
323
+            foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
324
+                if(!empty($listViewDefs[$this->module][$col]))
325
+                    $displayColumns[$col] = $this->listviewdefs[$this->module][$col];
326
+            }
327
+        }
328
+        else {
329
+            foreach($this->listviewdefs[$this->module] as $col => $para) {
330
+                if(!empty($para['default']) && $para['default'])
331
+                    $displayColumns[$col] = $para;
332
+            }
333
+        }
334
+        $params['massupdate'] = true;
335
+        if(!empty($_REQUEST['orderBy'])) {
336
+            $params['orderBy'] = $_REQUEST['orderBy'];
337
+            $params['overrideOrder'] = true;
338
+            if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
339
+        }
340
+
341
+        $lv->displayColumns = $displayColumns;
342 342
         $this->searchForm->lv = $lv;
343 343
         $this->searchForm->displaySavedSearch = false;
344 344
 
@@ -351,25 +351,25 @@  discard block
 block discarded – undo
351 351
         $this->should_process = true;
352 352
 
353 353
         if(isset($params['export'])) {
354
-          $this->export = $params['export'];
354
+            $this->export = $params['export'];
355 355
         }
356 356
         if(!empty($params['multiSelectPopup'])) {
357
-		  $this->multi_select_popup = $params['multiSelectPopup'];
357
+            $this->multi_select_popup = $params['multiSelectPopup'];
358 358
         }
359
-		if(!empty($params['massupdate']) && $params['massupdate'] != false) {
360
-			$this->show_mass_update_form = true;
361
-			$this->mass = new MassUpdate();
362
-			$this->mass->setSugarBean($this->seed);
363
-			if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) {
359
+        if(!empty($params['massupdate']) && $params['massupdate'] != false) {
360
+            $this->show_mass_update_form = true;
361
+            $this->mass = new MassUpdate();
362
+            $this->mass->setSugarBean($this->seed);
363
+            if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) {
364 364
                 $this->mass->handleMassUpdate();
365 365
             }
366
-		}
366
+        }
367 367
 
368 368
         // create filter fields based off of display columns
369 369
         if(empty($this->filter_fields) || $this->mergeDisplayColumns) {
370 370
             foreach($this->displayColumns as $columnName => $def) {
371
-               $this->filter_fields[strtolower($columnName)] = true;
372
-               if(!empty($def['related_fields'])) {
371
+                $this->filter_fields[strtolower($columnName)] = true;
372
+                if(!empty($def['related_fields'])) {
373 373
                     foreach($def['related_fields'] as $field) {
374 374
                         //id column is added by query construction function. This addition creates duplicates
375 375
                         //and causes issues in oracle. #10165
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
                     }
380 380
                 }
381 381
                 if (!empty($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'])) {
382
-	                foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){
383
-	                    if(!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)])
384
-	                    {
385
-	                        $this->filter_fields[strtolower($field)] = true;
386
-	                    }
387
-	                }
382
+                    foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){
383
+                        if(!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)])
384
+                        {
385
+                            $this->filter_fields[strtolower($field)] = true;
386
+                        }
387
+                    }
388 388
                 }
389 389
             }
390 390
             foreach ($this->searchColumns as $columnName => $def )
@@ -418,119 +418,119 @@  discard block
 block discarded – undo
418 418
         }
419 419
 
420 420
 
421
-		if (!empty($_REQUEST['query']) || (!empty($GLOBALS['sugar_config']['save_query']) && $GLOBALS['sugar_config']['save_query'] != 'populate_only')) {
422
-			$data = $this->lvd->getListViewData($this->seed, $searchWhere, 0, -1, $this->filter_fields, $params, 'id');
423
-		} else {
424
-			$this->should_process = false;
425
-			$data = array(
426
-				'data'=>array(),
427
-			    'pageData'=>array(
428
-			    	'bean'=>array('moduleDir'=>$this->seed->module_dir),
429
-					'ordering'=>'',
430
-					'offsets'=>array('total'=>0,'next'=>0,'current'=>0),
431
-				),
432
-			);
433
-		}
421
+        if (!empty($_REQUEST['query']) || (!empty($GLOBALS['sugar_config']['save_query']) && $GLOBALS['sugar_config']['save_query'] != 'populate_only')) {
422
+            $data = $this->lvd->getListViewData($this->seed, $searchWhere, 0, -1, $this->filter_fields, $params, 'id');
423
+        } else {
424
+            $this->should_process = false;
425
+            $data = array(
426
+                'data'=>array(),
427
+                'pageData'=>array(
428
+                    'bean'=>array('moduleDir'=>$this->seed->module_dir),
429
+                    'ordering'=>'',
430
+                    'offsets'=>array('total'=>0,'next'=>0,'current'=>0),
431
+                ),
432
+            );
433
+        }
434 434
 
435 435
         $this->fillDisplayColumnsWithVardefs();
436 436
 
437
-		$this->process($file, $data, $this->seed->object_name);
438
-	}
437
+        $this->process($file, $data, $this->seed->object_name);
438
+    }
439 439
 
440
-	/*
440
+    /*
441 441
 	 * Return the where clause as per the REQUEST.
442 442
 	 */
443
-	function _get_where_clause()
444
-	{
445
-		$where = '';
446
-		$where_clauses = $this->searchForm->generateSearchWhere(true, $this->seed->module_dir);
447
-
448
-		// Bug 43452 - FG - Changed the way generated Where array is imploded into the string.
449
-		//                  Now it's imploding in the same way view.list.php do.
450
-		if (count($where_clauses) > 0 ) {
451
-		    $where = '( ' . implode(' and ', $where_clauses) . ' )';
443
+    function _get_where_clause()
444
+    {
445
+        $where = '';
446
+        $where_clauses = $this->searchForm->generateSearchWhere(true, $this->seed->module_dir);
447
+
448
+        // Bug 43452 - FG - Changed the way generated Where array is imploded into the string.
449
+        //                  Now it's imploding in the same way view.list.php do.
450
+        if (count($where_clauses) > 0 ) {
451
+            $where = '( ' . implode(' and ', $where_clauses) . ' )';
452 452
         }
453 453
 
454 454
         // Need to include the default whereStatement
455
-		if(!empty($this->_popupMeta['whereStatement'])){
455
+        if(!empty($this->_popupMeta['whereStatement'])){
456 456
             if(!empty($where))$where .= ' AND ';
457 457
             $where .= $this->_popupMeta['whereStatement'];
458
-		}
458
+        }
459 459
 
460
-		return $where;
461
-	}
460
+        return $where;
461
+    }
462 462
 
463
-	/*
463
+    /*
464 464
 	 * Generate the data for the search form on the header of the Popup.
465 465
 	 */
466
-		function _build_field_defs(){
467
-		$this->formData = array();
468
-		$this->customFieldDefs = array();
469
-		foreach($this->searchdefs[$this->module]['layout']['advanced_search'] as $data){
470
-			if(is_array($data)){
471
-
472
-				$this->formData[] = array('field' => $data);
473
-				$value = '';
474
-				$this->customFieldDefs[$data['name']]= $data;
475
-				if(!empty($_REQUEST[$data['name']]))
476
-	            	$value = $_REQUEST[$data['name']];
477
-	            $this->customFieldDefs[$data['name']]['value'] = $value;
478
-			}else
479
-				$this->formData[] = array('field' => array('name'=>$data));
480
-		}
481
-		$this->fieldDefs = array();
482
-		if($this->seed){
483
-			$this->seed->fill_in_additional_detail_fields();
484
-
485
-	        foreach($this->seed->toArray() as $name => $value) {
486
-	            $this->fieldDefs[$name] = $this->seed->field_defs[$name];
487
-	            //if we have a relate type then reset to name so that we end up with a textbox
488
-	            //rather than a select button
489
-	            $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name'];
490
-	            if($this->fieldDefs[$name]['type'] == 'relate')
491
-	            	$this->fieldDefs[$name]['type'] = 'name';
492
-	            if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) {
493
-	                $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums
494
-	            }
495
-	            if(!empty($_REQUEST[$name]))
496
-	            	$value = $_REQUEST[$name];
497
-	            $this->fieldDefs[$name]['value'] = $value;
498
-	        }
499
-		}
500
-	}
501
-
502
-	function _getAddForm(){
503
-		$addform = '';
466
+        function _build_field_defs(){
467
+        $this->formData = array();
468
+        $this->customFieldDefs = array();
469
+        foreach($this->searchdefs[$this->module]['layout']['advanced_search'] as $data){
470
+            if(is_array($data)){
471
+
472
+                $this->formData[] = array('field' => $data);
473
+                $value = '';
474
+                $this->customFieldDefs[$data['name']]= $data;
475
+                if(!empty($_REQUEST[$data['name']]))
476
+                    $value = $_REQUEST[$data['name']];
477
+                $this->customFieldDefs[$data['name']]['value'] = $value;
478
+            }else
479
+                $this->formData[] = array('field' => array('name'=>$data));
480
+        }
481
+        $this->fieldDefs = array();
482
+        if($this->seed){
483
+            $this->seed->fill_in_additional_detail_fields();
484
+
485
+            foreach($this->seed->toArray() as $name => $value) {
486
+                $this->fieldDefs[$name] = $this->seed->field_defs[$name];
487
+                //if we have a relate type then reset to name so that we end up with a textbox
488
+                //rather than a select button
489
+                $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name'];
490
+                if($this->fieldDefs[$name]['type'] == 'relate')
491
+                    $this->fieldDefs[$name]['type'] = 'name';
492
+                if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) {
493
+                    $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums
494
+                }
495
+                if(!empty($_REQUEST[$name]))
496
+                    $value = $_REQUEST[$name];
497
+                $this->fieldDefs[$name]['value'] = $value;
498
+            }
499
+        }
500
+    }
501
+
502
+    function _getAddForm(){
503
+        $addform = '';
504 504
         if(!$this->seed->ACLAccess('save')){
505 505
             return;
506 506
         }
507
-		if(!empty($this->_popupMeta['create'])){
508
-			$formBase = new $this->_popupMeta['create']['formBaseClass']();
507
+        if(!empty($this->_popupMeta['create'])){
508
+            $formBase = new $this->_popupMeta['create']['formBaseClass']();
509 509
 
510 510
 
511 511
 
512
-				// TODO: cleanup the construction of $addform
513
-				$prefix = empty($this->_popupMeta['create']['getFormBodyParams'][0]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][0];
514
-				$mod = empty($this->_popupMeta['create']['getFormBodyParams'][1]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][1];
515
-				$formBody = empty($this->_popupMeta['create']['getFormBodyParams'][2]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][2];
512
+                // TODO: cleanup the construction of $addform
513
+                $prefix = empty($this->_popupMeta['create']['getFormBodyParams'][0]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][0];
514
+                $mod = empty($this->_popupMeta['create']['getFormBodyParams'][1]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][1];
515
+                $formBody = empty($this->_popupMeta['create']['getFormBodyParams'][2]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][2];
516 516
 
517
-				$getFormMethod = (empty($this->_popupMeta['create']['getFormMethod']) ? 'getFormBody' : $this->_popupMeta['create']['getFormMethod']);
518
-				$formbody = $formBase->$getFormMethod($prefix, $mod, $formBody);
517
+                $getFormMethod = (empty($this->_popupMeta['create']['getFormMethod']) ? 'getFormBody' : $this->_popupMeta['create']['getFormMethod']);
518
+                $formbody = $formBase->$getFormMethod($prefix, $mod, $formBody);
519 519
 
520
-				$addform = '<table><tr><td nowrap="nowrap" valign="top">'
521
-					. str_replace('<br>', '</td><td nowrap="nowrap" valign="top">&nbsp;', $formbody)
522
-					. '</td></tr></table>'
523
-					. '<input type="hidden" name="action" value="Popup" />';
520
+                $addform = '<table><tr><td nowrap="nowrap" valign="top">'
521
+                    . str_replace('<br>', '</td><td nowrap="nowrap" valign="top">&nbsp;', $formbody)
522
+                    . '</td></tr></table>'
523
+                    . '<input type="hidden" name="action" value="Popup" />';
524 524
 
525
-			return $addform;
526
-		}
527
-	}
525
+            return $addform;
526
+        }
527
+    }
528 528
 
529
-	function _getAddFormHeader(){
530
-		$lbl_save_button_title = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_TITLE'];
531
-		$lbl_save_button_key = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_KEY'];
532
-		$lbl_save_button_label = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'];
533
-		$module_dir = $this->seed->module_dir;
529
+    function _getAddFormHeader(){
530
+        $lbl_save_button_title = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_TITLE'];
531
+        $lbl_save_button_key = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_KEY'];
532
+        $lbl_save_button_label = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'];
533
+        $module_dir = $this->seed->module_dir;
534 534
 $formSave = <<<EOQ
535 535
 			<input type="hidden" name="create" value="true">
536 536
 			<input type="hidden" name="popup" value="true">
@@ -538,21 +538,21 @@  discard block
 block discarded – undo
538 538
 			<input type="hidden" name="return_module" value="$module_dir">
539 539
 			<input type="hidden" name="return_action" value="Popup">
540 540
 EOQ;
541
-		// if metadata contains custom inputs for the quickcreate
542
-		if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) {
543
-			foreach($this->_popupMeta['customInput'] as $key => $value)
544
-				$formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n';
545
-		}
546
-
547
-
548
-		$addformheader = get_form_header(translate($this->_popupMeta['create']['createButton']), $formSave, false);
549
-		return $addformheader;
550
-	}
551
-
552
-	function getQuickCreate(){
553
-		require_once("include/EditView/PopupQuickCreate.php");
554
-		$qc = new PopupQuickCreate($this->module);
555
-		return $qc->process($this->module);
556
-	}
541
+        // if metadata contains custom inputs for the quickcreate
542
+        if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) {
543
+            foreach($this->_popupMeta['customInput'] as $key => $value)
544
+                $formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n';
545
+        }
546
+
547
+
548
+        $addformheader = get_form_header(translate($this->_popupMeta['create']['createButton']), $formSave, false);
549
+        return $addformheader;
550
+    }
551
+
552
+    function getQuickCreate(){
553
+        require_once("include/EditView/PopupQuickCreate.php");
554
+        $qc = new PopupQuickCreate($this->module);
555
+        return $qc->process($this->module);
556
+    }
557 557
 }
558 558
 ?>
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 require_once('include/TemplateHandler/TemplateHandler.php');
44 44
 require_once('include/SearchForm/SearchForm2.php');
45 45
 define("NUM_COLS", 2);
46
-class PopupSmarty extends ListViewSmarty{
46
+class PopupSmarty extends ListViewSmarty {
47 47
 
48 48
 	var $contextMenus = false;
49 49
 	var $export = false;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     var $module;
71 71
     var $massUpdateData = '';
72 72
 
73
-	function PopupSmarty($seed, $module){
73
+	function PopupSmarty($seed, $module) {
74 74
 		parent::ListViewSmarty();
75 75
 		$this->th = new TemplateHandler();
76 76
 		$this->th->loadSmarty();
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
      */
92 92
     function processArrowVars()
93 93
     {
94
-        $pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif',false));
94
+        $pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif', false));
95 95
 
96
-        list($width,$height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']);
96
+        list($width, $height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']);
97 97
 
98 98
         $this->th->ss->assign('arrowExt', $pathParts['extension']);
99 99
         $this->th->ss->assign('arrowWidth', $width);
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 		$this->data = $data;
120 120
 
121 121
         $totalWidth = 0;
122
-        foreach($this->displayColumns as $name => $params) {
122
+        foreach ($this->displayColumns as $name => $params) {
123 123
             $totalWidth += $params['width'];
124 124
         }
125 125
         $adjustment = $totalWidth / 100;
126 126
 
127 127
         $contextMenuObjectsTypes = array();
128
-        foreach($this->displayColumns as $name => $params) {
128
+        foreach ($this->displayColumns as $name => $params) {
129 129
             $this->displayColumns[$name]['width'] = round($this->displayColumns[$name]['width'] / $adjustment, 2);
130 130
             // figure out which contextMenu objectsTypes are required
131
-            if(!empty($params['contextMenu']['objectType']))
131
+            if (!empty($params['contextMenu']['objectType']))
132 132
                 $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true;
133 133
         }
134 134
 		$this->th->ss->assign('displayColumns', $this->displayColumns);
@@ -147,22 +147,22 @@  discard block
 block discarded – undo
147 147
 		$this->th->ss->assign('searchForm', $this->searchForm->display(false));
148 148
         //rrs
149 149
 
150
-		if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink());
150
+		if ($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink());
151 151
 		$this->th->ss->assign('quickViewLinks', $this->quickViewLinks);
152
-		if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access
153
-		if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink());
152
+		if ($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access
153
+		if ($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink());
154 154
 
155 155
 
156 156
 		if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
157 157
 			$this->multiSelect = true;
158 158
 		}
159 159
 		// handle save checks and stuff
160
-		if($this->multiSelect) {
160
+		if ($this->multiSelect) {
161 161
 			$this->th->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan());
162 162
 			$this->th->ss->assign('multiSelectData', $this->getMultiSelectData());
163 163
 			$this->th->ss->assign('MODE', "<input type='hidden' name='mode' value='MultiSelect'>");
164 164
             $pageTotal = $this->data['pageData']['offsets']['next'] - $this->data['pageData']['offsets']['current'];
165
-            if($this->data['pageData']['offsets']['next'] < 0){ // If we are on the last page, 'next' is -1, which means we have to have a custom calculation
165
+            if ($this->data['pageData']['offsets']['next'] < 0) { // If we are on the last page, 'next' is -1, which means we have to have a custom calculation
166 166
                 $pageTotal = $this->data['pageData']['offsets']['total'] - $this->data['pageData']['offsets']['current'];
167 167
             }
168 168
     		$this->th->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal));
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
         $this->th->ss->assign('contextMenus', $this->contextMenus);
176 176
 
177 177
 
178
-        if($this->contextMenus && !empty($contextMenuObjectsTypes)) {
178
+        if ($this->contextMenus && !empty($contextMenuObjectsTypes)) {
179 179
             $script = '';
180 180
             $cm = new contextMenu();
181
-            foreach($contextMenuObjectsTypes as $type => $value) {
181
+            foreach ($contextMenuObjectsTypes as $type => $value) {
182 182
                 $cm->loadFromFile($type);
183 183
                 $script .= $cm->getScript();
184 184
                 $cm->menuItems = array(); // clear menuItems out
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	function display($end = true) {
200 200
         global $app_strings;
201 201
 
202
-        if(!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) {
202
+        if (!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) {
203 203
             require_once('include/language/jsLanguage.php');
204 204
             jsLanguage::createAppStringsCache($GLOBALS['current_language']);
205 205
         }
206
-        $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js",  $GLOBALS['sugar_config']['js_lang_version']);
206
+        $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']);
207 207
 
208 208
         $this->th->ss->assign('data', $this->data['data']);
209 209
 		$this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']);
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
 		$searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false;
224 224
 		
225 225
 		global $locale;
226
-		foreach($this->data['data'] as $val)
226
+		foreach ($this->data['data'] as $val)
227 227
 		{
228 228
 			$associated_row_data[$val['ID']] = $val;
229
-			if($searchNameOverride)
229
+			if ($searchNameOverride)
230 230
 			{
231 231
 			   $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']);
232 232
 			}
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		$this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2));
238 238
         $this->th->ss->assign('headerTpl', $this->headerTpl);
239 239
         $this->th->ss->assign('footerTpl', $this->footerTpl);
240
-        $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data). '; var is_show_fullname = '.$is_show_fullname.';');
240
+        $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data).'; var is_show_fullname = '.$is_show_fullname.';');
241 241
 		$this->th->ss->assign('module', $this->seed->module_dir);
242 242
 		$request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
243 243
 
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 		$this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']);
259 259
         $this->th->ss->assign('should_process', $this->should_process);
260 260
 
261
-		if($this->_create){
262
-			$this->th->ss->assign('ADDFORM', $this->getQuickCreate());//$this->_getAddForm());
261
+		if ($this->_create) {
262
+			$this->th->ss->assign('ADDFORM', $this->getQuickCreate()); //$this->_getAddForm());
263 263
 			$this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader());
264 264
 			$this->th->ss->assign('object_name', $this->seed->object_name);
265 265
 		}
@@ -278,15 +278,15 @@  discard block
 block discarded – undo
278 278
 	}
279 279
 	function _setup($file) {
280 280
 
281
-	    if(isset($this->_popupMeta)){
282
-			if(isset($this->_popupMeta['create']['formBase'])) {
283
-				require_once('modules/' . $this->seed->module_dir . '/' . $this->_popupMeta['create']['formBase']);
281
+	    if (isset($this->_popupMeta)) {
282
+			if (isset($this->_popupMeta['create']['formBase'])) {
283
+				require_once('modules/'.$this->seed->module_dir.'/'.$this->_popupMeta['create']['formBase']);
284 284
 				$this->_create = true;
285 285
 			}
286 286
 		}
287
-	    if(!empty($this->_popupMeta['create'])){
287
+	    if (!empty($this->_popupMeta['create'])) {
288 288
 			$formBase = new $this->_popupMeta['create']['formBaseClass']();
289
-			if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save')
289
+			if (isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save')
290 290
 			{
291 291
 				//If it's a new record, set useRequired to false
292 292
 				$useRequired = empty($_REQUEST['id']) ? false : true;
@@ -295,19 +295,19 @@  discard block
 block discarded – undo
295 295
 		}
296 296
 
297 297
 		$params = array();
298
-		if(!empty($this->_popupMeta['orderBy'])){
298
+		if (!empty($this->_popupMeta['orderBy'])) {
299 299
 			$params['orderBy'] = $this->_popupMeta['orderBy'];
300 300
 		}
301 301
 
302
-		if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
302
+		if (file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')) {
303 303
 			require('custom/modules/'.$this->module.'/metadata/metafiles.php');
304
-		}elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
304
+		}elseif (file_exists('modules/'.$this->module.'/metadata/metafiles.php')) {
305 305
 			require('modules/'.$this->module.'/metadata/metafiles.php');
306 306
 		}
307 307
 
308
-		if(!empty($metafiles[$this->module]['searchfields'])) {
308
+		if (!empty($metafiles[$this->module]['searchfields'])) {
309 309
 			require($metafiles[$this->module]['searchfields']);
310
-		} elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) {
310
+		} elseif (file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) {
311 311
 			require('modules/'.$this->module.'/metadata/SearchFields.php');
312 312
 	    }
313 313
         $this->searchdefs[$this->module]['templateMeta']['maxColumns'] = 2;
@@ -319,23 +319,23 @@  discard block
 block discarded – undo
319 319
 
320 320
 		$lv = new ListViewSmarty();
321 321
 		$displayColumns = array();
322
-		if(!empty($_REQUEST['displayColumns'])) {
323
-		    foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
324
-		        if(!empty($listViewDefs[$this->module][$col]))
322
+		if (!empty($_REQUEST['displayColumns'])) {
323
+		    foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) {
324
+		        if (!empty($listViewDefs[$this->module][$col]))
325 325
 		            $displayColumns[$col] = $this->listviewdefs[$this->module][$col];
326 326
 		    }
327 327
 		}
328 328
 		else {
329
-		    foreach($this->listviewdefs[$this->module] as $col => $para) {
330
-		        if(!empty($para['default']) && $para['default'])
329
+		    foreach ($this->listviewdefs[$this->module] as $col => $para) {
330
+		        if (!empty($para['default']) && $para['default'])
331 331
 		            $displayColumns[$col] = $para;
332 332
 		    }
333 333
 		}
334 334
 		$params['massupdate'] = true;
335
-		if(!empty($_REQUEST['orderBy'])) {
335
+		if (!empty($_REQUEST['orderBy'])) {
336 336
 		    $params['orderBy'] = $_REQUEST['orderBy'];
337 337
 		    $params['overrideOrder'] = true;
338
-		    if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
338
+		    if (!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
339 339
 		}
340 340
 
341 341
 		$lv->displayColumns = $displayColumns;
@@ -350,27 +350,27 @@  discard block
 block discarded – undo
350 350
 
351 351
         $this->should_process = true;
352 352
 
353
-        if(isset($params['export'])) {
353
+        if (isset($params['export'])) {
354 354
           $this->export = $params['export'];
355 355
         }
356
-        if(!empty($params['multiSelectPopup'])) {
356
+        if (!empty($params['multiSelectPopup'])) {
357 357
 		  $this->multi_select_popup = $params['multiSelectPopup'];
358 358
         }
359
-		if(!empty($params['massupdate']) && $params['massupdate'] != false) {
359
+		if (!empty($params['massupdate']) && $params['massupdate'] != false) {
360 360
 			$this->show_mass_update_form = true;
361 361
 			$this->mass = new MassUpdate();
362 362
 			$this->mass->setSugarBean($this->seed);
363
-			if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) {
363
+			if (!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) {
364 364
                 $this->mass->handleMassUpdate();
365 365
             }
366 366
 		}
367 367
 
368 368
         // create filter fields based off of display columns
369
-        if(empty($this->filter_fields) || $this->mergeDisplayColumns) {
370
-            foreach($this->displayColumns as $columnName => $def) {
369
+        if (empty($this->filter_fields) || $this->mergeDisplayColumns) {
370
+            foreach ($this->displayColumns as $columnName => $def) {
371 371
                $this->filter_fields[strtolower($columnName)] = true;
372
-               if(!empty($def['related_fields'])) {
373
-                    foreach($def['related_fields'] as $field) {
372
+               if (!empty($def['related_fields'])) {
373
+                    foreach ($def['related_fields'] as $field) {
374 374
                         //id column is added by query construction function. This addition creates duplicates
375 375
                         //and causes issues in oracle. #10165
376 376
                         if ($field != 'id') {
@@ -379,15 +379,15 @@  discard block
 block discarded – undo
379 379
                     }
380 380
                 }
381 381
                 if (!empty($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'])) {
382
-	                foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){
383
-	                    if(!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)])
382
+	                foreach ($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field) {
383
+	                    if (!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)])
384 384
 	                    {
385 385
 	                        $this->filter_fields[strtolower($field)] = true;
386 386
 	                    }
387 387
 	                }
388 388
                 }
389 389
             }
390
-            foreach ($this->searchColumns as $columnName => $def )
390
+            foreach ($this->searchColumns as $columnName => $def)
391 391
             {
392 392
                 $this->filter_fields[strtolower($columnName)] = true;
393 393
             }
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
          * By default bean's create_new_list_query function loads fields displayed on the page or used in the search
404 404
          * add fields used to populate forms from _viewdefs :: field_to_name_array to retrive from db
405 405
          */
406
-        if ( isset($_REQUEST['field_to_name']) && $_REQUEST['field_to_name'] )
406
+        if (isset($_REQUEST['field_to_name']) && $_REQUEST['field_to_name'])
407 407
         {
408 408
             $_REQUEST['field_to_name'] = is_array($_REQUEST['field_to_name']) ? $_REQUEST['field_to_name'] : array($_REQUEST['field_to_name']);
409
-            foreach ( $_REQUEST['field_to_name'] as $add_field )
409
+            foreach ($_REQUEST['field_to_name'] as $add_field)
410 410
             {
411 411
                 $add_field = strtolower($add_field);
412
-                if ( $add_field != 'id' && !isset($this->filter_fields[$add_field]) && isset($this->seed->field_defs[$add_field]) )
412
+                if ($add_field != 'id' && !isset($this->filter_fields[$add_field]) && isset($this->seed->field_defs[$add_field]))
413 413
                 {
414 414
                     $this->filter_fields[$add_field] = true;
415 415
                 }
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 			    'pageData'=>array(
428 428
 			    	'bean'=>array('moduleDir'=>$this->seed->module_dir),
429 429
 					'ordering'=>'',
430
-					'offsets'=>array('total'=>0,'next'=>0,'current'=>0),
430
+					'offsets'=>array('total'=>0, 'next'=>0, 'current'=>0),
431 431
 				),
432 432
 			);
433 433
 		}
@@ -447,13 +447,13 @@  discard block
 block discarded – undo
447 447
 
448 448
 		// Bug 43452 - FG - Changed the way generated Where array is imploded into the string.
449 449
 		//                  Now it's imploding in the same way view.list.php do.
450
-		if (count($where_clauses) > 0 ) {
451
-		    $where = '( ' . implode(' and ', $where_clauses) . ' )';
450
+		if (count($where_clauses) > 0) {
451
+		    $where = '( '.implode(' and ', $where_clauses).' )';
452 452
         }
453 453
 
454 454
         // Need to include the default whereStatement
455
-		if(!empty($this->_popupMeta['whereStatement'])){
456
-            if(!empty($where))$where .= ' AND ';
455
+		if (!empty($this->_popupMeta['whereStatement'])) {
456
+            if (!empty($where))$where .= ' AND ';
457 457
             $where .= $this->_popupMeta['whereStatement'];
458 458
 		}
459 459
 
@@ -463,48 +463,48 @@  discard block
 block discarded – undo
463 463
 	/*
464 464
 	 * Generate the data for the search form on the header of the Popup.
465 465
 	 */
466
-		function _build_field_defs(){
466
+		function _build_field_defs() {
467 467
 		$this->formData = array();
468 468
 		$this->customFieldDefs = array();
469
-		foreach($this->searchdefs[$this->module]['layout']['advanced_search'] as $data){
470
-			if(is_array($data)){
469
+		foreach ($this->searchdefs[$this->module]['layout']['advanced_search'] as $data) {
470
+			if (is_array($data)) {
471 471
 
472 472
 				$this->formData[] = array('field' => $data);
473 473
 				$value = '';
474
-				$this->customFieldDefs[$data['name']]= $data;
475
-				if(!empty($_REQUEST[$data['name']]))
474
+				$this->customFieldDefs[$data['name']] = $data;
475
+				if (!empty($_REQUEST[$data['name']]))
476 476
 	            	$value = $_REQUEST[$data['name']];
477 477
 	            $this->customFieldDefs[$data['name']]['value'] = $value;
478
-			}else
478
+			} else
479 479
 				$this->formData[] = array('field' => array('name'=>$data));
480 480
 		}
481 481
 		$this->fieldDefs = array();
482
-		if($this->seed){
482
+		if ($this->seed) {
483 483
 			$this->seed->fill_in_additional_detail_fields();
484 484
 
485
-	        foreach($this->seed->toArray() as $name => $value) {
485
+	        foreach ($this->seed->toArray() as $name => $value) {
486 486
 	            $this->fieldDefs[$name] = $this->seed->field_defs[$name];
487 487
 	            //if we have a relate type then reset to name so that we end up with a textbox
488 488
 	            //rather than a select button
489 489
 	            $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name'];
490
-	            if($this->fieldDefs[$name]['type'] == 'relate')
490
+	            if ($this->fieldDefs[$name]['type'] == 'relate')
491 491
 	            	$this->fieldDefs[$name]['type'] = 'name';
492
-	            if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) {
492
+	            if (isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) {
493 493
 	                $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums
494 494
 	            }
495
-	            if(!empty($_REQUEST[$name]))
495
+	            if (!empty($_REQUEST[$name]))
496 496
 	            	$value = $_REQUEST[$name];
497 497
 	            $this->fieldDefs[$name]['value'] = $value;
498 498
 	        }
499 499
 		}
500 500
 	}
501 501
 
502
-	function _getAddForm(){
502
+	function _getAddForm() {
503 503
 		$addform = '';
504
-        if(!$this->seed->ACLAccess('save')){
504
+        if (!$this->seed->ACLAccess('save')) {
505 505
             return;
506 506
         }
507
-		if(!empty($this->_popupMeta['create'])){
507
+		if (!empty($this->_popupMeta['create'])) {
508 508
 			$formBase = new $this->_popupMeta['create']['formBaseClass']();
509 509
 
510 510
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 		}
527 527
 	}
528 528
 
529
-	function _getAddFormHeader(){
529
+	function _getAddFormHeader() {
530 530
 		$lbl_save_button_title = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_TITLE'];
531 531
 		$lbl_save_button_key = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_KEY'];
532 532
 		$lbl_save_button_label = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'];
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
 			<input type="hidden" name="return_action" value="Popup">
540 540
 EOQ;
541 541
 		// if metadata contains custom inputs for the quickcreate
542
-		if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) {
543
-			foreach($this->_popupMeta['customInput'] as $key => $value)
544
-				$formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n';
542
+		if (!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) {
543
+			foreach ($this->_popupMeta['customInput'] as $key => $value)
544
+				$formSave .= '<input type="hidden" name="'.$key.'" value="'.$value.'">\n';
545 545
 		}
546 546
 
547 547
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 		return $addformheader;
550 550
 	}
551 551
 
552
-	function getQuickCreate(){
552
+	function getQuickCreate() {
553 553
 		require_once("include/EditView/PopupQuickCreate.php");
554 554
 		$qc = new PopupQuickCreate($this->module);
555 555
 		return $qc->process($this->module);
Please login to merge, or discard this patch.
Braces   +45 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.
@@ -128,8 +130,9 @@  discard block
 block discarded – undo
128 130
         foreach($this->displayColumns as $name => $params) {
129 131
             $this->displayColumns[$name]['width'] = round($this->displayColumns[$name]['width'] / $adjustment, 2);
130 132
             // figure out which contextMenu objectsTypes are required
131
-            if(!empty($params['contextMenu']['objectType']))
132
-                $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true;
133
+            if(!empty($params['contextMenu']['objectType'])) {
134
+                            $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true;
135
+            }
133 136
         }
134 137
 		$this->th->ss->assign('displayColumns', $this->displayColumns);
135 138
 
@@ -147,10 +150,17 @@  discard block
 block discarded – undo
147 150
 		$this->th->ss->assign('searchForm', $this->searchForm->display(false));
148 151
         //rrs
149 152
 
150
-		if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink());
153
+		if($this->export) {
154
+		    $this->th->ss->assign('exportLink', $this->buildExportLink());
155
+		}
151 156
 		$this->th->ss->assign('quickViewLinks', $this->quickViewLinks);
152
-		if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access
153
-		if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink());
157
+		if($this->mailMerge) {
158
+		    $this->th->ss->assign('mergeLink', $this->buildMergeLink());
159
+		}
160
+		// still check for mailmerge access
161
+		if($this->mergeduplicates) {
162
+		    $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink());
163
+		}
154 164
 
155 165
 
156 166
 		if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
@@ -301,7 +311,7 @@  discard block
 block discarded – undo
301 311
 
302 312
 		if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
303 313
 			require('custom/modules/'.$this->module.'/metadata/metafiles.php');
304
-		}elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
314
+		} elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
305 315
 			require('modules/'.$this->module.'/metadata/metafiles.php');
306 316
 		}
307 317
 
@@ -321,21 +331,24 @@  discard block
 block discarded – undo
321 331
 		$displayColumns = array();
322 332
 		if(!empty($_REQUEST['displayColumns'])) {
323 333
 		    foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
324
-		        if(!empty($listViewDefs[$this->module][$col]))
325
-		            $displayColumns[$col] = $this->listviewdefs[$this->module][$col];
334
+		        if(!empty($listViewDefs[$this->module][$col])) {
335
+		        		            $displayColumns[$col] = $this->listviewdefs[$this->module][$col];
336
+		        }
326 337
 		    }
327
-		}
328
-		else {
338
+		} else {
329 339
 		    foreach($this->listviewdefs[$this->module] as $col => $para) {
330
-		        if(!empty($para['default']) && $para['default'])
331
-		            $displayColumns[$col] = $para;
340
+		        if(!empty($para['default']) && $para['default']) {
341
+		        		            $displayColumns[$col] = $para;
342
+		        }
332 343
 		    }
333 344
 		}
334 345
 		$params['massupdate'] = true;
335 346
 		if(!empty($_REQUEST['orderBy'])) {
336 347
 		    $params['orderBy'] = $_REQUEST['orderBy'];
337 348
 		    $params['overrideOrder'] = true;
338
-		    if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
349
+		    if(!empty($_REQUEST['sortOrder'])) {
350
+		        $params['sortOrder'] = $_REQUEST['sortOrder'];
351
+		    }
339 352
 		}
340 353
 
341 354
 		$lv->displayColumns = $displayColumns;
@@ -453,7 +466,9 @@  discard block
 block discarded – undo
453 466
 
454 467
         // Need to include the default whereStatement
455 468
 		if(!empty($this->_popupMeta['whereStatement'])){
456
-            if(!empty($where))$where .= ' AND ';
469
+            if(!empty($where)) {
470
+                $where .= ' AND ';
471
+            }
457 472
             $where .= $this->_popupMeta['whereStatement'];
458 473
 		}
459 474
 
@@ -472,11 +487,13 @@  discard block
 block discarded – undo
472 487
 				$this->formData[] = array('field' => $data);
473 488
 				$value = '';
474 489
 				$this->customFieldDefs[$data['name']]= $data;
475
-				if(!empty($_REQUEST[$data['name']]))
476
-	            	$value = $_REQUEST[$data['name']];
490
+				if(!empty($_REQUEST[$data['name']])) {
491
+					            	$value = $_REQUEST[$data['name']];
492
+				}
477 493
 	            $this->customFieldDefs[$data['name']]['value'] = $value;
478
-			}else
479
-				$this->formData[] = array('field' => array('name'=>$data));
494
+			} else {
495
+							$this->formData[] = array('field' => array('name'=>$data));
496
+			}
480 497
 		}
481 498
 		$this->fieldDefs = array();
482 499
 		if($this->seed){
@@ -487,13 +504,15 @@  discard block
 block discarded – undo
487 504
 	            //if we have a relate type then reset to name so that we end up with a textbox
488 505
 	            //rather than a select button
489 506
 	            $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name'];
490
-	            if($this->fieldDefs[$name]['type'] == 'relate')
491
-	            	$this->fieldDefs[$name]['type'] = 'name';
507
+	            if($this->fieldDefs[$name]['type'] == 'relate') {
508
+	            	            	$this->fieldDefs[$name]['type'] = 'name';
509
+	            }
492 510
 	            if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) {
493 511
 	                $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums
494 512
 	            }
495
-	            if(!empty($_REQUEST[$name]))
496
-	            	$value = $_REQUEST[$name];
513
+	            if(!empty($_REQUEST[$name])) {
514
+	            	            	$value = $_REQUEST[$name];
515
+	            }
497 516
 	            $this->fieldDefs[$name]['value'] = $value;
498 517
 	        }
499 518
 		}
@@ -540,8 +559,9 @@  discard block
 block discarded – undo
540 559
 EOQ;
541 560
 		// if metadata contains custom inputs for the quickcreate
542 561
 		if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) {
543
-			foreach($this->_popupMeta['customInput'] as $key => $value)
544
-				$formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n';
562
+			foreach($this->_popupMeta['customInput'] as $key => $value) {
563
+							$formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n';
564
+			}
545 565
 		}
546 566
 
547 567
 
Please login to merge, or discard this patch.
include/language/jsLanguage.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 EOQ;
63 63
         
64 64
         $cacheDir = create_cache_directory('jsLanguage/');
65
-        if($fh = @sugar_fopen($cacheDir . $lang . '.js', "w")){
65
+        if ($fh = @sugar_fopen($cacheDir.$lang.'.js', "w")) {
66 66
             fputs($fh, $str);
67 67
             fclose($fh);
68 68
         }
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
         // cn: bug 8242 - non-US langpack chokes
75 75
         $mod_strings = return_module_language($lang, $moduleDir);
76 76
         $mod_strings_encoded = $json->encode($mod_strings);
77
-        $str = "SUGAR.language.setLanguage('" . $moduleDir . "', " . $mod_strings_encoded . ");";
77
+        $str = "SUGAR.language.setLanguage('".$moduleDir."', ".$mod_strings_encoded.");";
78 78
         
79
-        $cacheDir = create_cache_directory('jsLanguage/' . $moduleDir . '/');
79
+        $cacheDir = create_cache_directory('jsLanguage/'.$moduleDir.'/');
80 80
         
81
-        if($fh = @fopen($cacheDir . $lang . '.js', "w")){
81
+        if ($fh = @fopen($cacheDir.$lang.'.js', "w")) {
82 82
             fputs($fh, $str);
83 83
             fclose($fh);
84 84
         }
85 85
 
86
-        if($return) {
86
+        if ($return) {
87 87
             return $str;
88 88
         }
89 89
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 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.
Please login to merge, or discard this patch.