Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created
modules/Project/Dashlets/MyProjectDashlet/MyProjectDashlet.php 2 patches
Spacing   +4 added lines, -4 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 is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004 - 2008 SugarCRM Inc.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
         parent::__construct($id, $def);
50 50
 
51
-        if(empty($def['title'])) $this->title = translate('LBL_LIST_MY_PROJECT', 'Project');
51
+        if (empty($def['title'])) $this->title = translate('LBL_LIST_MY_PROJECT', 'Project');
52 52
 
53 53
         $this->searchFields = $dashletData['MyProjectDashlet']['searchFields'];
54 54
         $this->columns = $dashletData['MyProjectDashlet']['columns'];
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     /**
59 59
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
60 60
      */
61
-    function MyProjectDashlet($id, $def = null){
61
+    function MyProjectDashlet($id, $def = null) {
62 62
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
63
-        if(isset($GLOBALS['log'])) {
63
+        if (isset($GLOBALS['log'])) {
64 64
             $GLOBALS['log']->deprecated($deprecatedMessage);
65 65
         }
66 66
         else {
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 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 is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004 - 2008 SugarCRM Inc.
@@ -48,7 +50,9 @@  discard block
 block discarded – undo
48 50
 
49 51
         parent::__construct($id, $def);
50 52
 
51
-        if(empty($def['title'])) $this->title = translate('LBL_LIST_MY_PROJECT', 'Project');
53
+        if(empty($def['title'])) {
54
+            $this->title = translate('LBL_LIST_MY_PROJECT', 'Project');
55
+        }
52 56
 
53 57
         $this->searchFields = $dashletData['MyProjectDashlet']['searchFields'];
54 58
         $this->columns = $dashletData['MyProjectDashlet']['columns'];
@@ -62,8 +66,7 @@  discard block
 block discarded – undo
62 66
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
63 67
         if(isset($GLOBALS['log'])) {
64 68
             $GLOBALS['log']->deprecated($deprecatedMessage);
65
-        }
66
-        else {
69
+        } else {
67 70
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
68 71
         }
69 72
         self::__construct($id, $def);
Please login to merge, or discard this patch.
modules/SavedSearch/UpgradeSavedSearch.php 3 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -40,108 +40,108 @@
 block discarded – undo
40 40
 
41 41
 class UpgradeSavedSearch {
42 42
 
43
-	function __construct() {
43
+    function __construct() {
44 44
 
45
-		$result = $GLOBALS['db']->query("SELECT id FROM saved_search");
46
-		while($row = $GLOBALS['db']->fetchByAssoc($result)) {
47
-		      $focus = new SavedSearch();
48
-			  $focus->retrieve($row['id']);
49
-			  $contents = unserialize(base64_decode($focus->contents));
50
-              $has_team_name_saved = isset($contents['team_name_advanced']) || isset($contents['team_name_basic']) ? true : false;
51
-			  //If $contents['searchFormTab'] is set then this is coming from a 4.x saved search
52
-			  if(isset($contents['searchFormTab']) && $contents['searchFormTab'] == 'saved_views') {
53
-			  	 $new_contents = array();
54
-			  	 $module = $contents['search_module'];
55
-			  	 $advanced = !empty($contents['advanced']);
56
-			  	 $field_map = array();
45
+        $result = $GLOBALS['db']->query("SELECT id FROM saved_search");
46
+        while($row = $GLOBALS['db']->fetchByAssoc($result)) {
47
+                $focus = new SavedSearch();
48
+                $focus->retrieve($row['id']);
49
+                $contents = unserialize(base64_decode($focus->contents));
50
+                $has_team_name_saved = isset($contents['team_name_advanced']) || isset($contents['team_name_basic']) ? true : false;
51
+                //If $contents['searchFormTab'] is set then this is coming from a 4.x saved search
52
+                if(isset($contents['searchFormTab']) && $contents['searchFormTab'] == 'saved_views') {
53
+                    $new_contents = array();
54
+                    $module = $contents['search_module'];
55
+                    $advanced = !empty($contents['advanced']);
56
+                    $field_map = array();
57 57
 
58
-			  	 if(file_exists("custom/modules/{$module}/metadata/searchdefs.php")) {
59
-			  	 	require("custom/modules/{$module}/metadata/searchdefs.php");
60
-			  	 	$field_map = $advanced ? $searchdefs[$module]['layout']['advanced_search'] : $searchdefs[$module]['layout']['basic_search'];
61
-			     }else if(file_exists("modules/{$module}/metadata/SearchFields.php")) {
62
-			  	 	require("modules/{$module}/metadata/SearchFields.php");
63
-			  	 	$field_map = $searchFields[$module];
64
-			  	 } else {
58
+                    if(file_exists("custom/modules/{$module}/metadata/searchdefs.php")) {
59
+                        require("custom/modules/{$module}/metadata/searchdefs.php");
60
+                        $field_map = $advanced ? $searchdefs[$module]['layout']['advanced_search'] : $searchdefs[$module]['layout']['basic_search'];
61
+                    }else if(file_exists("modules/{$module}/metadata/SearchFields.php")) {
62
+                        require("modules/{$module}/metadata/SearchFields.php");
63
+                        $field_map = $searchFields[$module];
64
+                    } else {
65 65
 
66
-				  	$bean = loadBean($module);
67
-				  	$field_map = $bean->field_name_map;
68
-			  	 }
66
+                        $bean = loadBean($module);
67
+                        $field_map = $bean->field_name_map;
68
+                    }
69 69
 
70
-			  	 //Special case for team_id field (from 4.5.x)
71
-			  	 if(isset($contents['team_id'])) {
72
-			  	    $contents['team_name'] = $contents['team_id'];
73
-			  	    unset($contents['team_id']);
74
-			  	 }
70
+                    //Special case for team_id field (from 4.5.x)
71
+                    if(isset($contents['team_id'])) {
72
+                        $contents['team_name'] = $contents['team_id'];
73
+                        unset($contents['team_id']);
74
+                    }
75 75
 
76
-			  	 foreach($contents as $key=>$value) {
77
-			  	 	 if(isset($field_map[$key])) {
78
-			  	 	 	$new_key = $key . ($advanced ? '_advanced' : '_basic');
79
-			  	 	    if(preg_match('/^team_name_(advanced|basic)$/', $new_key)) {
76
+                    foreach($contents as $key=>$value) {
77
+                        if(isset($field_map[$key])) {
78
+                            $new_key = $key . ($advanced ? '_advanced' : '_basic');
79
+                            if(preg_match('/^team_name_(advanced|basic)$/', $new_key)) {
80 80
 
81
-			  	 	       if(!is_array($value)) {
82
-			  	 	       	  $temp_value = array();
83
-			  	 	       	  $teap_value[] = $value;
84
-			  	 	       	  $value = $temp_value;
85
-			  	 	       }
81
+                                if(!is_array($value)) {
82
+                                    $temp_value = array();
83
+                                    $teap_value[] = $value;
84
+                                    $value = $temp_value;
85
+                                }
86 86
 
87
-			  	 	       $team_results = $GLOBALS['db']->query("SELECT id, name FROM teams where id in ('" . implode("','", $value) . "')");
88
-			  	 	       if(!empty($team_results)) {
89
-			  	 	       	  $count = 0;
90
-			  	 	       	  while($team_row = $GLOBALS['db']->fetchByAssoc($team_results)) {
91
-			  	 	       	 	 	$team_key = $new_key . '_collection_' . $count;
92
-				  	 	       	 	$new_contents[$team_key] = $team_row['name'];
93
-				  	 	       	 	$new_contents['id_' . $team_key] = $team_row['id'];
94
-				  	 	       	 	$count++;
95
-			  	 	       	  } //while
96
-			  	 	       } //if
87
+                                $team_results = $GLOBALS['db']->query("SELECT id, name FROM teams where id in ('" . implode("','", $value) . "')");
88
+                                if(!empty($team_results)) {
89
+                                    $count = 0;
90
+                                    while($team_row = $GLOBALS['db']->fetchByAssoc($team_results)) {
91
+                                            $team_key = $new_key . '_collection_' . $count;
92
+                                            $new_contents[$team_key] = $team_row['name'];
93
+                                            $new_contents['id_' . $team_key] = $team_row['id'];
94
+                                            $count++;
95
+                                    } //while
96
+                                } //if
97 97
 
98 98
 
99
-			  	 	       //Unset the original key
100
-			  	 	       unset($new_contents[$key]);
99
+                                //Unset the original key
100
+                                unset($new_contents[$key]);
101 101
 
102
-			  	 	       //Add the any switch
103
-			  	 	       $new_contents[$new_key . '_type'] = 'any';
104
-			  	 	 	} else {
105
-			  	 	 	   $new_contents[$new_key] = $value;
106
-			  	 	 	}
107
-			  	 	 } else {
108
-			  	 	 	$new_contents[$key] = $value;
109
-			  	 	 }
110
-			  	 }
111
-			  	 $new_contents['searchFormTab'] = $advanced ? 'advanced_search' : 'basic_search';
112
-			  	 $content = base64_encode(serialize($new_contents));
113
-			  	 $GLOBALS['db']->query("UPDATE saved_search SET contents = '{$content}' WHERE id = '{$row['id']}'");
114
-			} else if($has_team_name_saved) {
115
-			     //Otherwise, if the boolean has_team_name_saved is set to true, we also need to parse (coming from 5.x)
116
-			  	 if(isset($contents['team_name_advanced'])) {
117
-			  	 	$team_results = $GLOBALS['db']->query("SELECT name FROM teams where id = '{$contents['team_name_advanced']}'");
118
-			  	 	if(!empty($team_results)) {
119
-			  	 		$team_row = $GLOBALS['db']->fetchByAssoc($team_results);
120
-				  	 	$contents['team_name_advanced_collection_0'] = $team_row['name'];
121
-				  	 	$contents['id_team_name_advanced_collection_0'] = $contents['team_name_advanced'];
122
-				  	 	$contents['team_name_advanced_type'] = 'any';
123
-				  	 	unset($contents['team_name_advanced']);
124
-					  	$content = base64_encode(serialize($contents));
125
-					  	$GLOBALS['db']->query("UPDATE saved_search SET contents = '{$content}' WHERE id = '{$row['id']}'");
126
-			  	 	}
127
-			  	 }
128
-			}
129
-		} //while
130
-	}
102
+                                //Add the any switch
103
+                                $new_contents[$new_key . '_type'] = 'any';
104
+                            } else {
105
+                                $new_contents[$new_key] = $value;
106
+                            }
107
+                        } else {
108
+                            $new_contents[$key] = $value;
109
+                        }
110
+                    }
111
+                    $new_contents['searchFormTab'] = $advanced ? 'advanced_search' : 'basic_search';
112
+                    $content = base64_encode(serialize($new_contents));
113
+                    $GLOBALS['db']->query("UPDATE saved_search SET contents = '{$content}' WHERE id = '{$row['id']}'");
114
+            } else if($has_team_name_saved) {
115
+                    //Otherwise, if the boolean has_team_name_saved is set to true, we also need to parse (coming from 5.x)
116
+                    if(isset($contents['team_name_advanced'])) {
117
+                        $team_results = $GLOBALS['db']->query("SELECT name FROM teams where id = '{$contents['team_name_advanced']}'");
118
+                        if(!empty($team_results)) {
119
+                            $team_row = $GLOBALS['db']->fetchByAssoc($team_results);
120
+                            $contents['team_name_advanced_collection_0'] = $team_row['name'];
121
+                            $contents['id_team_name_advanced_collection_0'] = $contents['team_name_advanced'];
122
+                            $contents['team_name_advanced_type'] = 'any';
123
+                            unset($contents['team_name_advanced']);
124
+                            $content = base64_encode(serialize($contents));
125
+                            $GLOBALS['db']->query("UPDATE saved_search SET contents = '{$content}' WHERE id = '{$row['id']}'");
126
+                        }
127
+                    }
128
+            }
129
+        } //while
130
+    }
131 131
 
132
-	/**
133
-	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
134
-	 */
135
-	public function UpgradeSavedSearch(){
136
-		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
137
-		if(isset($GLOBALS['log'])) {
138
-			$GLOBALS['log']->deprecated($deprecatedMessage);
139
-		}
140
-		else {
141
-			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
142
-		}
143
-		self::__construct();
144
-	}
132
+    /**
133
+     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
134
+     */
135
+    public function UpgradeSavedSearch(){
136
+        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
137
+        if(isset($GLOBALS['log'])) {
138
+            $GLOBALS['log']->deprecated($deprecatedMessage);
139
+        }
140
+        else {
141
+            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
142
+        }
143
+        self::__construct();
144
+    }
145 145
 
146 146
 }
147 147
 ?>
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 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,22 +43,22 @@  discard block
 block discarded – undo
43 43
 	function __construct() {
44 44
 
45 45
 		$result = $GLOBALS['db']->query("SELECT id FROM saved_search");
46
-		while($row = $GLOBALS['db']->fetchByAssoc($result)) {
46
+		while ($row = $GLOBALS['db']->fetchByAssoc($result)) {
47 47
 		      $focus = new SavedSearch();
48 48
 			  $focus->retrieve($row['id']);
49 49
 			  $contents = unserialize(base64_decode($focus->contents));
50 50
               $has_team_name_saved = isset($contents['team_name_advanced']) || isset($contents['team_name_basic']) ? true : false;
51 51
 			  //If $contents['searchFormTab'] is set then this is coming from a 4.x saved search
52
-			  if(isset($contents['searchFormTab']) && $contents['searchFormTab'] == 'saved_views') {
52
+			  if (isset($contents['searchFormTab']) && $contents['searchFormTab'] == 'saved_views') {
53 53
 			  	 $new_contents = array();
54 54
 			  	 $module = $contents['search_module'];
55 55
 			  	 $advanced = !empty($contents['advanced']);
56 56
 			  	 $field_map = array();
57 57
 
58
-			  	 if(file_exists("custom/modules/{$module}/metadata/searchdefs.php")) {
58
+			  	 if (file_exists("custom/modules/{$module}/metadata/searchdefs.php")) {
59 59
 			  	 	require("custom/modules/{$module}/metadata/searchdefs.php");
60 60
 			  	 	$field_map = $advanced ? $searchdefs[$module]['layout']['advanced_search'] : $searchdefs[$module]['layout']['basic_search'];
61
-			     }else if(file_exists("modules/{$module}/metadata/SearchFields.php")) {
61
+			     } else if (file_exists("modules/{$module}/metadata/SearchFields.php")) {
62 62
 			  	 	require("modules/{$module}/metadata/SearchFields.php");
63 63
 			  	 	$field_map = $searchFields[$module];
64 64
 			  	 } else {
@@ -68,29 +68,29 @@  discard block
 block discarded – undo
68 68
 			  	 }
69 69
 
70 70
 			  	 //Special case for team_id field (from 4.5.x)
71
-			  	 if(isset($contents['team_id'])) {
71
+			  	 if (isset($contents['team_id'])) {
72 72
 			  	    $contents['team_name'] = $contents['team_id'];
73 73
 			  	    unset($contents['team_id']);
74 74
 			  	 }
75 75
 
76
-			  	 foreach($contents as $key=>$value) {
77
-			  	 	 if(isset($field_map[$key])) {
78
-			  	 	 	$new_key = $key . ($advanced ? '_advanced' : '_basic');
79
-			  	 	    if(preg_match('/^team_name_(advanced|basic)$/', $new_key)) {
76
+			  	 foreach ($contents as $key=>$value) {
77
+			  	 	 if (isset($field_map[$key])) {
78
+			  	 	 	$new_key = $key.($advanced ? '_advanced' : '_basic');
79
+			  	 	    if (preg_match('/^team_name_(advanced|basic)$/', $new_key)) {
80 80
 
81
-			  	 	       if(!is_array($value)) {
81
+			  	 	       if (!is_array($value)) {
82 82
 			  	 	       	  $temp_value = array();
83 83
 			  	 	       	  $teap_value[] = $value;
84 84
 			  	 	       	  $value = $temp_value;
85 85
 			  	 	       }
86 86
 
87
-			  	 	       $team_results = $GLOBALS['db']->query("SELECT id, name FROM teams where id in ('" . implode("','", $value) . "')");
88
-			  	 	       if(!empty($team_results)) {
87
+			  	 	       $team_results = $GLOBALS['db']->query("SELECT id, name FROM teams where id in ('".implode("','", $value)."')");
88
+			  	 	       if (!empty($team_results)) {
89 89
 			  	 	       	  $count = 0;
90
-			  	 	       	  while($team_row = $GLOBALS['db']->fetchByAssoc($team_results)) {
91
-			  	 	       	 	 	$team_key = $new_key . '_collection_' . $count;
90
+			  	 	       	  while ($team_row = $GLOBALS['db']->fetchByAssoc($team_results)) {
91
+			  	 	       	 	 	$team_key = $new_key.'_collection_'.$count;
92 92
 				  	 	       	 	$new_contents[$team_key] = $team_row['name'];
93
-				  	 	       	 	$new_contents['id_' . $team_key] = $team_row['id'];
93
+				  	 	       	 	$new_contents['id_'.$team_key] = $team_row['id'];
94 94
 				  	 	       	 	$count++;
95 95
 			  	 	       	  } //while
96 96
 			  	 	       } //if
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 			  	 	       unset($new_contents[$key]);
101 101
 
102 102
 			  	 	       //Add the any switch
103
-			  	 	       $new_contents[$new_key . '_type'] = 'any';
103
+			  	 	       $new_contents[$new_key.'_type'] = 'any';
104 104
 			  	 	 	} else {
105 105
 			  	 	 	   $new_contents[$new_key] = $value;
106 106
 			  	 	 	}
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 			  	 $new_contents['searchFormTab'] = $advanced ? 'advanced_search' : 'basic_search';
112 112
 			  	 $content = base64_encode(serialize($new_contents));
113 113
 			  	 $GLOBALS['db']->query("UPDATE saved_search SET contents = '{$content}' WHERE id = '{$row['id']}'");
114
-			} else if($has_team_name_saved) {
114
+			} else if ($has_team_name_saved) {
115 115
 			     //Otherwise, if the boolean has_team_name_saved is set to true, we also need to parse (coming from 5.x)
116
-			  	 if(isset($contents['team_name_advanced'])) {
116
+			  	 if (isset($contents['team_name_advanced'])) {
117 117
 			  	 	$team_results = $GLOBALS['db']->query("SELECT name FROM teams where id = '{$contents['team_name_advanced']}'");
118
-			  	 	if(!empty($team_results)) {
118
+			  	 	if (!empty($team_results)) {
119 119
 			  	 		$team_row = $GLOBALS['db']->fetchByAssoc($team_results);
120 120
 				  	 	$contents['team_name_advanced_collection_0'] = $team_row['name'];
121 121
 				  	 	$contents['id_team_name_advanced_collection_0'] = $contents['team_name_advanced'];
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 	/**
133 133
 	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
134 134
 	 */
135
-	public function UpgradeSavedSearch(){
135
+	public function UpgradeSavedSearch() {
136 136
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
137
-		if(isset($GLOBALS['log'])) {
137
+		if (isset($GLOBALS['log'])) {
138 138
 			$GLOBALS['log']->deprecated($deprecatedMessage);
139 139
 		}
140 140
 		else {
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 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.
@@ -58,7 +60,7 @@  discard block
 block discarded – undo
58 60
 			  	 if(file_exists("custom/modules/{$module}/metadata/searchdefs.php")) {
59 61
 			  	 	require("custom/modules/{$module}/metadata/searchdefs.php");
60 62
 			  	 	$field_map = $advanced ? $searchdefs[$module]['layout']['advanced_search'] : $searchdefs[$module]['layout']['basic_search'];
61
-			     }else if(file_exists("modules/{$module}/metadata/SearchFields.php")) {
63
+			     } else if(file_exists("modules/{$module}/metadata/SearchFields.php")) {
62 64
 			  	 	require("modules/{$module}/metadata/SearchFields.php");
63 65
 			  	 	$field_map = $searchFields[$module];
64 66
 			  	 } else {
@@ -136,8 +138,7 @@  discard block
 block discarded – undo
136 138
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
137 139
 		if(isset($GLOBALS['log'])) {
138 140
 			$GLOBALS['log']->deprecated($deprecatedMessage);
139
-		}
140
-		else {
141
+		} else {
141 142
 			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
142 143
 		}
143 144
 		self::__construct();
Please login to merge, or discard this patch.
modules/SavedSearch/SavedSearch.php 3 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -49,81 +49,81 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 class SavedSearch extends SugarBean {
52
-	var $db;
52
+    var $db;
53 53
     var $field_name_map;
54 54
 
55
-	// Stored fields
56
-	var $id;
57
-	var $date_entered;
58
-	var $date_modified;
59
-	var $assigned_user_id;
60
-	var $assigned_user_name;
61
-	var $modified_by_name;
62
-	var $name;
63
-	var $description;
64
-	var $content;
65
-	var $search_module;
66
-
67
-	var $object_name = 'SavedSearch';
68
-	var $table_name = 'saved_search';
69
-
70
-	var $module_dir = 'SavedSearch';
71
-	var $field_defs = array();
72
-	var $field_defs_map = array();
55
+    // Stored fields
56
+    var $id;
57
+    var $date_entered;
58
+    var $date_modified;
59
+    var $assigned_user_id;
60
+    var $assigned_user_name;
61
+    var $modified_by_name;
62
+    var $name;
63
+    var $description;
64
+    var $content;
65
+    var $search_module;
66
+
67
+    var $object_name = 'SavedSearch';
68
+    var $table_name = 'saved_search';
69
+
70
+    var $module_dir = 'SavedSearch';
71
+    var $field_defs = array();
72
+    var $field_defs_map = array();
73 73
 
74 74
     var $columns;
75 75
 
76 76
     public function __construct($columns = array(), $orderBy = null, $sortOrder = 'DESC') {
77
-		parent::__construct();
77
+        parent::__construct();
78 78
         $this->columns = $columns;
79 79
         $this->orderBy = $orderBy;
80 80
         $this->sortOrder = $sortOrder;
81
-		$this->setupCustomFields('SavedSearch');
82
-		foreach ($this->field_defs as $field) {
83
-			$this->field_name_map[$field['name']] = $field;
84
-		}
85
-
86
-	}
87
-
88
-	/**
89
-	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
90
-	 */
91
-	public function SavedSearch($columns = array(), $orderBy = null, $sortOrder = 'DESC'){
92
-		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
93
-		if(isset($GLOBALS['log'])) {
94
-			$GLOBALS['log']->deprecated($deprecatedMessage);
95
-		}
96
-		else {
97
-			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
98
-		}
99
-		self::__construct($columns, $orderBy, $sortOrder);
100
-	}
101
-
102
-	// Saved Search Form
103
-	function getForm($module, $inline = true) {
104
-	    global $db, $current_user, $currentModule, $current_language, $app_strings;
81
+        $this->setupCustomFields('SavedSearch');
82
+        foreach ($this->field_defs as $field) {
83
+            $this->field_name_map[$field['name']] = $field;
84
+        }
85
+
86
+    }
87
+
88
+    /**
89
+     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
90
+     */
91
+    public function SavedSearch($columns = array(), $orderBy = null, $sortOrder = 'DESC'){
92
+        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
93
+        if(isset($GLOBALS['log'])) {
94
+            $GLOBALS['log']->deprecated($deprecatedMessage);
95
+        }
96
+        else {
97
+            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
98
+        }
99
+        self::__construct($columns, $orderBy, $sortOrder);
100
+    }
101
+
102
+    // Saved Search Form
103
+    function getForm($module, $inline = true) {
104
+        global $db, $current_user, $currentModule, $current_language, $app_strings;
105 105
         $json = getJSONobj();
106 106
 
107
-		$saved_search_mod_strings = return_module_language($current_language, 'SavedSearch');
107
+        $saved_search_mod_strings = return_module_language($current_language, 'SavedSearch');
108 108
 
109
-		$query = 'SELECT id, name FROM saved_search
109
+        $query = 'SELECT id, name FROM saved_search
110 110
 				  WHERE
111 111
 					deleted = \'0\' AND
112 112
 				  	assigned_user_id = \'' . $current_user->id . '\' AND
113 113
 					search_module =  \'' . $module . '\'
114 114
 				  ORDER BY name';
115
-	    $result = $db->query($query, true, "Error filling in saved search list: ");
116
-
117
-		$savedSearchArray['_none'] = $app_strings['LBL_NONE'];
118
-	    while ($row = $db->fetchByAssoc($result, -1, FALSE)) {
119
-	        $savedSearchArray[$row['id']] = htmlspecialchars($row['name'], ENT_QUOTES);
120
-	    }
121
-		$sugarSmarty = new Sugar_Smarty();
122
-		$sugarSmarty->assign('SEARCH_MODULE', $module);
123
-		$sugarSmarty->assign('MOD', $saved_search_mod_strings);
124
-		$sugarSmarty->assign('DELETE', $app_strings['LBL_DELETE_BUTTON_LABEL']);
115
+        $result = $db->query($query, true, "Error filling in saved search list: ");
116
+
117
+        $savedSearchArray['_none'] = $app_strings['LBL_NONE'];
118
+        while ($row = $db->fetchByAssoc($result, -1, FALSE)) {
119
+            $savedSearchArray[$row['id']] = htmlspecialchars($row['name'], ENT_QUOTES);
120
+        }
121
+        $sugarSmarty = new Sugar_Smarty();
122
+        $sugarSmarty->assign('SEARCH_MODULE', $module);
123
+        $sugarSmarty->assign('MOD', $saved_search_mod_strings);
124
+        $sugarSmarty->assign('DELETE', $app_strings['LBL_DELETE_BUTTON_LABEL']);
125 125
         $sugarSmarty->assign('UPDATE', $app_strings['LBL_UPDATE']);
126
-		$sugarSmarty->assign('SAVE', $app_strings['LBL_SAVE_BUTTON_LABEL']);
126
+        $sugarSmarty->assign('SAVE', $app_strings['LBL_SAVE_BUTTON_LABEL']);
127 127
 
128 128
         // Column Chooser
129 129
         $chooser = new TemplateGroupChooser();
@@ -139,23 +139,23 @@  discard block
 block discarded – undo
139 139
         }
140 140
 
141 141
         if((!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') || (isset($this->contents['displayColumns']) && $this->contents['displayColumns'] != 'undefined')) {
142
-             // columns to display
143
-             if(!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') $temp_displayColumns = $_REQUEST['displayColumns'];
144
-             else $temp_displayColumns = $this->contents['displayColumns'];
145
-             foreach(explode('|', $temp_displayColumns) as $num => $name) {
146
-             		if (!isset($this->columns[$name])) {
147
-						// Ignore any column that is not on the list.
148
-             			continue;
149
-             		}
142
+                // columns to display
143
+                if(!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') $temp_displayColumns = $_REQUEST['displayColumns'];
144
+                else $temp_displayColumns = $this->contents['displayColumns'];
145
+                foreach(explode('|', $temp_displayColumns) as $num => $name) {
146
+                        if (!isset($this->columns[$name])) {
147
+                        // Ignore any column that is not on the list.
148
+                            continue;
149
+                        }
150 150
                     $chooser->args['values_array'][0][$name] = trim(translate($this->columns[$name]['label'], $module), ':');
151
-             }
152
-             // columns not displayed
153
-             foreach(array_diff(array_keys($this->columns), array_values(explode('|', $temp_displayColumns))) as $num => $name) {
151
+                }
152
+                // columns not displayed
153
+                foreach(array_diff(array_keys($this->columns), array_values(explode('|', $temp_displayColumns))) as $num => $name) {
154 154
                     $chooser->args['values_array'][1][$name] = trim(translate($this->columns[$name]['label'], $module), ':');
155
-             }
155
+                }
156 156
         }
157 157
         else {
158
-             foreach($this->columns as $name => $val) {
158
+                foreach($this->columns as $name => $val) {
159 159
                 if(!empty($val['default']) && $val['default'])
160 160
                     $chooser->args['values_array'][0][$name] = trim(translate($val['label'], $module), ':');
161 161
                 else
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         $json = getJSONobj();
188 188
 
189 189
         return $sugarSmarty->fetch('modules/SavedSearch/SavedSearchForm.tpl');
190
-	}
190
+    }
191 191
 
192 192
     function getSelect($module) {
193 193
 
@@ -242,135 +242,135 @@  discard block
 block discarded – undo
242 242
 }
243 243
 
244 244
     function returnSavedSearchContents($id) {
245
-		global $db, $current_user, $currentModule;
246
-		$query = 'SELECT id, name, contents, search_module FROM saved_search
245
+        global $db, $current_user, $currentModule;
246
+        $query = 'SELECT id, name, contents, search_module FROM saved_search
247 247
 				  WHERE
248 248
 				  	id = \'' . $id . '\'';
249
-	    $result = $db->query($query, true, "Error filling in saved search list: ");
249
+        $result = $db->query($query, true, "Error filling in saved search list: ");
250 250
 
251
-	    $header = 'Location: index.php?action=index&module=';
252
-	    $contents = '';
253
-	    $saved_search_name = '';
254
-	    while ($row = $db->fetchByAssoc($result, false)) {
255
-	        $header .= $row['search_module'];
251
+        $header = 'Location: index.php?action=index&module=';
252
+        $contents = '';
253
+        $saved_search_name = '';
254
+        while ($row = $db->fetchByAssoc($result, false)) {
255
+            $header .= $row['search_module'];
256 256
             if(empty($_SESSION['LastSavedView'])) $_SESSION['LastSavedView'] = array();
257 257
             $_SESSION['LastSavedView'][$row['search_module']] = $row['id'];
258
-	        $contents = unserialize(base64_decode($row['contents']));
259
-	        $saved_search_id = $row['id'];
258
+            $contents = unserialize(base64_decode($row['contents']));
259
+            $saved_search_id = $row['id'];
260 260
             $saved_search_name = $row['name'];
261
-	    }
261
+        }
262 262
 
263
-	    return $contents;
264
-	}
263
+        return $contents;
264
+    }
265 265
 
266
-	function handleDelete($id) {
267
-		$this->mark_deleted($id);
268
-		header("Location: index.php?action=index&module={$_REQUEST['search_module']}&advanced={$_REQUEST['advanced']}&query=true&clear_query=true");
269
-	}
266
+    function handleDelete($id) {
267
+        $this->mark_deleted($id);
268
+        header("Location: index.php?action=index&module={$_REQUEST['search_module']}&advanced={$_REQUEST['advanced']}&query=true&clear_query=true");
269
+    }
270 270
 
271
-	function handleSave($prefix, $redirect = true, $useRequired = false, $id = null, $searchModuleBean) {
271
+    function handleSave($prefix, $redirect = true, $useRequired = false, $id = null, $searchModuleBean) {
272 272
 
273
-		global $current_user, $timedate;
273
+        global $current_user, $timedate;
274 274
 
275
-		$focus = new SavedSearch();
276
-		if($id) $focus->retrieve($id);
275
+        $focus = new SavedSearch();
276
+        if($id) $focus->retrieve($id);
277 277
 
278
-		if($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
279
-			return null;
280
-		}
278
+        if($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
279
+            return null;
280
+        }
281 281
 
282
-		$ignored_inputs = array('PHPSESSID', 'module', 'action', 'saved_search_name', 'saved_search_select', 'advanced', 'Calls_divs', 'ACLRoles_divs');
282
+        $ignored_inputs = array('PHPSESSID', 'module', 'action', 'saved_search_name', 'saved_search_select', 'advanced', 'Calls_divs', 'ACLRoles_divs');
283 283
 
284 284
         $contents = $_REQUEST;
285
-		if($id == null) $focus->name = $contents['saved_search_name'];
286
-		$focus->search_module = $contents['search_module'];
287
-
288
-		foreach($contents as $input=>$value)
289
-		{
290
-			if(in_array($input, $ignored_inputs))
291
-			{
292
-				unset($contents[$input]);
293
-				continue;
294
-			}
295
-
296
-			//Filter date fields to ensure it is saved to DB format, but also avoid empty values
297
-			if(!empty($value) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $input, $match))
298
-			{
299
-			   $field = $match[2];
300
-			   if(isset($searchModuleBean->field_defs[$field]['type']) && empty($searchModuleBean->field_defs[$field]['disable_num_format']))
301
-			   {
302
-			   	  $type = $searchModuleBean->field_defs[$field]['type'];
303
-
304
-			   	  //Avoid macro values for the date types
305
-			   	  if(($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && !preg_match('/^\[.*?\]$/', $value))
306
-			   	  {
307
-			   	  	 $db_format = $timedate->to_db_date($value, false);
308
-			   	  	 $contents[$input] = $db_format;
309
-			   	  } else if ($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') {
310
-
311
-			   	  	if(preg_match('/[^\d]/', $value)) {
312
-				   	  	 require_once('modules/Currencies/Currency.php');
313
-				   	  	 $contents[$input] = unformat_number($value);
314
-				   	  	 //Flag this value as having been unformatted
315
-				   	  	 $contents[$input . '_unformatted_number'] = true;
316
-				   	  	 //If the type is of currency and there was a currency symbol (non-digit), save the symbol
317
-				   	  	 if($type == 'currency' && preg_match('/^([^\d])/', $value, $match))
318
-				   	  	 {
319
-				   	  	 	$contents[$input . '_currency_symbol'] = $match[1];
320
-				   	  	 }
321
-			   	  	} else {
322
-			   	  		 //unset any flags
323
-			   	  		 if(isset($contents[$input . '_unformatted_number']))
324
-			   	  		 {
325
-			   	  		 	unset($contents[$input . '_unformatted_number']);
326
-			   	  		 }
327
-
328
-			   	  		 if(isset($contents[$input . '_currency_symbol']))
329
-			   	  		 {
330
-			   	  		 	unset($contents[$input . '_currency_symbol']);
331
-			   	  		 }
332
-			   	  	}
333
-			   	  }
334
-			   }
335
-			}
336
-
337
-		}
338
-
339
-		$contents['advanced'] = true;
340
-
341
-		$focus->contents = base64_encode(serialize($contents));
342
-
343
-		$focus->assigned_user_id = $current_user->id;
344
-		$focus->new_schema = true;
345
-
346
-		$saved_search_id = $focus->save();
347
-
348
-		$GLOBALS['log']->debug("Saved record with id of " . $focus->id);
349
-		$orderBy = empty($contents['orderBy'])? 'name' : $contents['orderBy'];
285
+        if($id == null) $focus->name = $contents['saved_search_name'];
286
+        $focus->search_module = $contents['search_module'];
287
+
288
+        foreach($contents as $input=>$value)
289
+        {
290
+            if(in_array($input, $ignored_inputs))
291
+            {
292
+                unset($contents[$input]);
293
+                continue;
294
+            }
295
+
296
+            //Filter date fields to ensure it is saved to DB format, but also avoid empty values
297
+            if(!empty($value) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $input, $match))
298
+            {
299
+                $field = $match[2];
300
+                if(isset($searchModuleBean->field_defs[$field]['type']) && empty($searchModuleBean->field_defs[$field]['disable_num_format']))
301
+                {
302
+                        $type = $searchModuleBean->field_defs[$field]['type'];
303
+
304
+                        //Avoid macro values for the date types
305
+                        if(($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && !preg_match('/^\[.*?\]$/', $value))
306
+                        {
307
+                            $db_format = $timedate->to_db_date($value, false);
308
+                            $contents[$input] = $db_format;
309
+                        } else if ($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') {
310
+
311
+                            if(preg_match('/[^\d]/', $value)) {
312
+                                require_once('modules/Currencies/Currency.php');
313
+                                $contents[$input] = unformat_number($value);
314
+                                //Flag this value as having been unformatted
315
+                                $contents[$input . '_unformatted_number'] = true;
316
+                                //If the type is of currency and there was a currency symbol (non-digit), save the symbol
317
+                                if($type == 'currency' && preg_match('/^([^\d])/', $value, $match))
318
+                                {
319
+                                    $contents[$input . '_currency_symbol'] = $match[1];
320
+                                }
321
+                            } else {
322
+                                //unset any flags
323
+                                if(isset($contents[$input . '_unformatted_number']))
324
+                                {
325
+                                    unset($contents[$input . '_unformatted_number']);
326
+                                }
327
+
328
+                                if(isset($contents[$input . '_currency_symbol']))
329
+                                {
330
+                                    unset($contents[$input . '_currency_symbol']);
331
+                                }
332
+                            }
333
+                        }
334
+                }
335
+            }
336
+
337
+        }
338
+
339
+        $contents['advanced'] = true;
340
+
341
+        $focus->contents = base64_encode(serialize($contents));
342
+
343
+        $focus->assigned_user_id = $current_user->id;
344
+        $focus->new_schema = true;
345
+
346
+        $saved_search_id = $focus->save();
347
+
348
+        $GLOBALS['log']->debug("Saved record with id of " . $focus->id);
349
+        $orderBy = empty($contents['orderBy'])? 'name' : $contents['orderBy'];
350 350
         $search_query = "&orderBy=" . $orderBy . "&sortOrder=".$contents['sortOrder'] . "&query=" . $_REQUEST['query'] . "&searchFormTab=" . $_REQUEST['searchFormTab'].'&showSSDIV=' . $contents['showSSDIV'];
351 351
 
352 352
         if($redirect)
353 353
         {
354
-        	$this->handleRedirect($focus->search_module, $search_query, $saved_search_id, 'true');
354
+            $this->handleRedirect($focus->search_module, $search_query, $saved_search_id, 'true');
355 355
         }
356 356
     }
357 357
 
358
-	function handleRedirect($return_module, $search_query, $saved_search_id, $advanced = 'false') {
358
+    function handleRedirect($return_module, $search_query, $saved_search_id, $advanced = 'false') {
359 359
         $_SESSION['LastSavedView'][$return_module] = $saved_search_id;
360 360
         $return_action = 'index';
361 361
         $ajaxLoad = empty($_REQUEST['ajax_load']) ? "" : "&ajax_load=" . $_REQUEST['ajax_load'];
362 362
         //Reduce the params to avoid the problems caused by URL max length in IE ( the reduced params can be get from saved search according to saved_search_id).
363 363
         header("Location: index.php?action=$return_action&module=$return_module&saved_search_select={$saved_search_id}{$search_query}&advanced={$advanced}$ajaxLoad");
364 364
         die();
365
-	}
365
+    }
366 366
 
367
-	function fill_in_additional_list_fields() {
368
-		global $app_list_strings;
369
-		// Fill in the assigned_user_name
370
-		$this->search_module = $app_list_strings['moduleList'][$this->contents['search_module']];
371
-		$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
367
+    function fill_in_additional_list_fields() {
368
+        global $app_list_strings;
369
+        // Fill in the assigned_user_name
370
+        $this->search_module = $app_list_strings['moduleList'][$this->contents['search_module']];
371
+        $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
372 372
 
373
-	}
373
+    }
374 374
 
375 375
 
376 376
     function retrieveSavedSearch($id) {
@@ -380,36 +380,36 @@  discard block
 block discarded – undo
380 380
 
381 381
     function populateRequest(){
382 382
 
383
-    	global $timedate;
383
+        global $timedate;
384 384
 
385 385
         if(isset($this->contents['search_module']))
386 386
         {
387
-           $searchModuleBean = loadBean($this->contents['search_module']);
387
+            $searchModuleBean = loadBean($this->contents['search_module']);
388 388
         }
389 389
 
390 390
         foreach($this->contents as $key=>$val){
391 391
             if($key != 'advanced' && $key != 'module' && !strpos($key, '_ORDER_BY') && $key != 'lvso') {
392
-            	if(isset($searchModuleBean) && !empty($val) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $key, $match))
393
-            	{
394
-            	   $field = $match[2];
395
-				   if(isset($searchModuleBean->field_defs[$field]['type'])  && empty($searchModuleBean->field_defs[$field]['disable_num_format']))
396
-				   {
397
-				   	  $type = $searchModuleBean->field_defs[$field]['type'];
398
-
399
-				   	  //Avoid macro values for the date types
400
-				   	  if(($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && preg_match('/^\d{4}-\d{2}-\d{2}$/', $val) && !preg_match('/^\[.*?\]$/', $val))
401
-				   	  {
402
-				   	  	 $val = $timedate->to_display_date($val, false);
403
-				   	  }  else if (($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') && isset($this->contents[$key . '_unformatted_number']) && preg_match('/^\d+$/', $val)) {
404
-				   	  	 require_once('modules/Currencies/Currency.php');
405
-				   	  	 $val = format_number($val);
406
-				   	  	 if($type == 'currency' && isset($this->contents[$key . '_currency_symbol']))
407
-				   	  	 {
408
-				   	  	 	$val = $this->contents[$key . '_currency_symbol'] . $val;
409
-				   	  	 }
410
-				   	  }
411
-				   }
412
-            	}
392
+                if(isset($searchModuleBean) && !empty($val) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $key, $match))
393
+                {
394
+                    $field = $match[2];
395
+                    if(isset($searchModuleBean->field_defs[$field]['type'])  && empty($searchModuleBean->field_defs[$field]['disable_num_format']))
396
+                    {
397
+                            $type = $searchModuleBean->field_defs[$field]['type'];
398
+
399
+                            //Avoid macro values for the date types
400
+                            if(($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && preg_match('/^\d{4}-\d{2}-\d{2}$/', $val) && !preg_match('/^\[.*?\]$/', $val))
401
+                            {
402
+                                $val = $timedate->to_display_date($val, false);
403
+                            }  else if (($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') && isset($this->contents[$key . '_unformatted_number']) && preg_match('/^\d+$/', $val)) {
404
+                                require_once('modules/Currencies/Currency.php');
405
+                                $val = format_number($val);
406
+                                if($type == 'currency' && isset($this->contents[$key . '_currency_symbol']))
407
+                                {
408
+                                    $val = $this->contents[$key . '_currency_symbol'] . $val;
409
+                                }
410
+                            }
411
+                    }
412
+                }
413 413
 
414 414
                 $_REQUEST[$key] = $val;
415 415
                 $_GET[$key] = $val;
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 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.
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 	/**
89 89
 	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
90 90
 	 */
91
-	public function SavedSearch($columns = array(), $orderBy = null, $sortOrder = 'DESC'){
91
+	public function SavedSearch($columns = array(), $orderBy = null, $sortOrder = 'DESC') {
92 92
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
93
-		if(isset($GLOBALS['log'])) {
93
+		if (isset($GLOBALS['log'])) {
94 94
 			$GLOBALS['log']->deprecated($deprecatedMessage);
95 95
 		}
96 96
 		else {
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 		$query = 'SELECT id, name FROM saved_search
110 110
 				  WHERE
111 111
 					deleted = \'0\' AND
112
-				  	assigned_user_id = \'' . $current_user->id . '\' AND
113
-					search_module =  \'' . $module . '\'
112
+				  	assigned_user_id = \'' . $current_user->id.'\' AND
113
+					search_module =  \'' . $module.'\'
114 114
 				  ORDER BY name';
115 115
 	    $result = $db->query($query, true, "Error filling in saved search list: ");
116 116
 
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
         $chooser->args['values_array'][0] = array();
135 135
         $chooser->args['values_array'][1] = array();
136 136
 
137
-        if(isset($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
137
+        if (isset($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select'] != '_none') {
138 138
             $this->retrieveSavedSearch($_REQUEST['saved_search_select']);
139 139
         }
140 140
 
141
-        if((!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') || (isset($this->contents['displayColumns']) && $this->contents['displayColumns'] != 'undefined')) {
141
+        if ((!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') || (isset($this->contents['displayColumns']) && $this->contents['displayColumns'] != 'undefined')) {
142 142
              // columns to display
143
-             if(!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') $temp_displayColumns = $_REQUEST['displayColumns'];
143
+             if (!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') $temp_displayColumns = $_REQUEST['displayColumns'];
144 144
              else $temp_displayColumns = $this->contents['displayColumns'];
145
-             foreach(explode('|', $temp_displayColumns) as $num => $name) {
145
+             foreach (explode('|', $temp_displayColumns) as $num => $name) {
146 146
              		if (!isset($this->columns[$name])) {
147 147
 						// Ignore any column that is not on the list.
148 148
              			continue;
@@ -150,33 +150,33 @@  discard block
 block discarded – undo
150 150
                     $chooser->args['values_array'][0][$name] = trim(translate($this->columns[$name]['label'], $module), ':');
151 151
              }
152 152
              // columns not displayed
153
-             foreach(array_diff(array_keys($this->columns), array_values(explode('|', $temp_displayColumns))) as $num => $name) {
153
+             foreach (array_diff(array_keys($this->columns), array_values(explode('|', $temp_displayColumns))) as $num => $name) {
154 154
                     $chooser->args['values_array'][1][$name] = trim(translate($this->columns[$name]['label'], $module), ':');
155 155
              }
156 156
         }
157 157
         else {
158
-             foreach($this->columns as $name => $val) {
159
-                if(!empty($val['default']) && $val['default'])
158
+             foreach ($this->columns as $name => $val) {
159
+                if (!empty($val['default']) && $val['default'])
160 160
                     $chooser->args['values_array'][0][$name] = trim(translate($val['label'], $module), ':');
161 161
                 else
162 162
                     $chooser->args['values_array'][1][$name] = trim(translate($val['label'], $module), ':');
163 163
             }
164 164
         }
165 165
 
166
-        if(!empty($_REQUEST['sortOrder'])) $this->sortOrder = $_REQUEST['sortOrder'];
167
-        if(!empty($_REQUEST['orderBy'])) $this->orderBy = $_REQUEST['orderBy'];
166
+        if (!empty($_REQUEST['sortOrder'])) $this->sortOrder = $_REQUEST['sortOrder'];
167
+        if (!empty($_REQUEST['orderBy'])) $this->orderBy = $_REQUEST['orderBy'];
168 168
 
169 169
         $chooser->args['left_name'] = 'display_tabs';
170 170
         $chooser->args['right_name'] = 'hide_tabs';
171 171
         $chooser->args['alt_tip'] = $app_strings['LBL_SORT'];
172 172
 
173
-        $chooser->args['left_label'] =  $app_strings['LBL_DISPLAY_COLUMNS'];
174
-        $chooser->args['right_label'] =  $app_strings['LBL_HIDE_COLUMNS'];
175
-        $chooser->args['title'] =  '';
173
+        $chooser->args['left_label'] = $app_strings['LBL_DISPLAY_COLUMNS'];
174
+        $chooser->args['right_label'] = $app_strings['LBL_HIDE_COLUMNS'];
175
+        $chooser->args['title'] = '';
176 176
         $sugarSmarty->assign('columnChooser', $chooser->display());
177 177
 
178 178
         $sugarSmarty->assign('selectedOrderBy', $this->orderBy);
179
-        if(empty($this->sortOrder)) $this->sortOrder = 'ASC';
179
+        if (empty($this->sortOrder)) $this->sortOrder = 'ASC';
180 180
         $sugarSmarty->assign('selectedSortOrder', $this->sortOrder);
181 181
 
182 182
         $lastSavedView = (empty($_SESSION['LastSavedView'][$module]) ? '' : $_SESSION['LastSavedView'][$module]);
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
         $query = 'SELECT id, name FROM saved_search
199 199
                   WHERE
200 200
                     deleted = \'0\' AND
201
-                    assigned_user_id = \'' . $current_user->id . '\' AND
202
-                    search_module =  \'' . $module . '\'
201
+                    assigned_user_id = \'' . $current_user->id.'\' AND
202
+                    search_module =  \'' . $module.'\'
203 203
                   ORDER BY name';
204 204
         $result = $db->query($query, true, "Error filling in saved search list: ");
205 205
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         $sugarSmarty->assign('SEARCH_MODULE', $module);
213 213
         $sugarSmarty->assign('MOD', $saved_search_mod_strings);
214 214
 
215
-        if(!empty($_SESSION['LastSavedView'][$module]) && (($_REQUEST['action'] == 'ListView') || ($_REQUEST['action'] == 'index')))
215
+        if (!empty($_SESSION['LastSavedView'][$module]) && (($_REQUEST['action'] == 'ListView') || ($_REQUEST['action'] == 'index')))
216 216
             $selectedSearch = $_SESSION['LastSavedView'][$module];
217 217
         else
218 218
             $selectedSearch = '';
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
         return $sugarSmarty->fetch('modules/SavedSearch/SavedSearchSelects.tpl');
223 223
     }
224 224
 
225
-    function returnSavedSearch($id, $searchFormTab = 'advanced_search', $showDiv='no') {
225
+    function returnSavedSearch($id, $searchFormTab = 'advanced_search', $showDiv = 'no') {
226 226
         global $db, $current_user, $currentModule;
227 227
         $this->retrieveSavedSearch($id);
228 228
 
@@ -230,22 +230,22 @@  discard block
 block discarded – undo
230 230
 
231 231
         $saved_search_name = '';
232 232
         $header .= $this->contents['search_module'];
233
-        if(empty($_SESSION['LastSavedView'])) $_SESSION['LastSavedView'] = array();
233
+        if (empty($_SESSION['LastSavedView'])) $_SESSION['LastSavedView'] = array();
234 234
         $_SESSION['LastSavedView'][$this->contents['search_module']] = $id;
235 235
         $saved_search_id = $id;
236 236
         $saved_search_name = $this->name;
237 237
         $search_form_tab = $this->contents['searchFormTab'];
238 238
         $query = $this->contents['query'];
239
-        $orderBy = empty($this->contents['orderBy'])? 'name' : $this->contents['orderBy'];
239
+        $orderBy = empty($this->contents['orderBy']) ? 'name' : $this->contents['orderBy'];
240 240
         //Reduce the params to avoid the problems caused by URL max length in IE.
241
-        header($header . '&saved_search_select=' . $saved_search_id . '&saved_search_select_name=' . $saved_search_name . '&orderBy=' . $orderBy . '&sortOrder=' . $this->contents['sortOrder'] . '&query=' . $query . '&searchFormTab='. $search_form_tab .'&showSSDIV=' . $showDiv);
241
+        header($header.'&saved_search_select='.$saved_search_id.'&saved_search_select_name='.$saved_search_name.'&orderBy='.$orderBy.'&sortOrder='.$this->contents['sortOrder'].'&query='.$query.'&searchFormTab='.$search_form_tab.'&showSSDIV='.$showDiv);
242 242
 }
243 243
 
244 244
     function returnSavedSearchContents($id) {
245 245
 		global $db, $current_user, $currentModule;
246 246
 		$query = 'SELECT id, name, contents, search_module FROM saved_search
247 247
 				  WHERE
248
-				  	id = \'' . $id . '\'';
248
+				  	id = \'' . $id.'\'';
249 249
 	    $result = $db->query($query, true, "Error filling in saved search list: ");
250 250
 
251 251
 	    $header = 'Location: index.php?action=index&module=';
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	    $saved_search_name = '';
254 254
 	    while ($row = $db->fetchByAssoc($result, false)) {
255 255
 	        $header .= $row['search_module'];
256
-            if(empty($_SESSION['LastSavedView'])) $_SESSION['LastSavedView'] = array();
256
+            if (empty($_SESSION['LastSavedView'])) $_SESSION['LastSavedView'] = array();
257 257
             $_SESSION['LastSavedView'][$row['search_module']] = $row['id'];
258 258
 	        $contents = unserialize(base64_decode($row['contents']));
259 259
 	        $saved_search_id = $row['id'];
@@ -273,61 +273,61 @@  discard block
 block discarded – undo
273 273
 		global $current_user, $timedate;
274 274
 
275 275
 		$focus = new SavedSearch();
276
-		if($id) $focus->retrieve($id);
276
+		if ($id) $focus->retrieve($id);
277 277
 
278
-		if($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
278
+		if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
279 279
 			return null;
280 280
 		}
281 281
 
282 282
 		$ignored_inputs = array('PHPSESSID', 'module', 'action', 'saved_search_name', 'saved_search_select', 'advanced', 'Calls_divs', 'ACLRoles_divs');
283 283
 
284 284
         $contents = $_REQUEST;
285
-		if($id == null) $focus->name = $contents['saved_search_name'];
285
+		if ($id == null) $focus->name = $contents['saved_search_name'];
286 286
 		$focus->search_module = $contents['search_module'];
287 287
 
288
-		foreach($contents as $input=>$value)
288
+		foreach ($contents as $input=>$value)
289 289
 		{
290
-			if(in_array($input, $ignored_inputs))
290
+			if (in_array($input, $ignored_inputs))
291 291
 			{
292 292
 				unset($contents[$input]);
293 293
 				continue;
294 294
 			}
295 295
 
296 296
 			//Filter date fields to ensure it is saved to DB format, but also avoid empty values
297
-			if(!empty($value) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $input, $match))
297
+			if (!empty($value) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $input, $match))
298 298
 			{
299 299
 			   $field = $match[2];
300
-			   if(isset($searchModuleBean->field_defs[$field]['type']) && empty($searchModuleBean->field_defs[$field]['disable_num_format']))
300
+			   if (isset($searchModuleBean->field_defs[$field]['type']) && empty($searchModuleBean->field_defs[$field]['disable_num_format']))
301 301
 			   {
302 302
 			   	  $type = $searchModuleBean->field_defs[$field]['type'];
303 303
 
304 304
 			   	  //Avoid macro values for the date types
305
-			   	  if(($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && !preg_match('/^\[.*?\]$/', $value))
305
+			   	  if (($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && !preg_match('/^\[.*?\]$/', $value))
306 306
 			   	  {
307 307
 			   	  	 $db_format = $timedate->to_db_date($value, false);
308 308
 			   	  	 $contents[$input] = $db_format;
309 309
 			   	  } else if ($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') {
310 310
 
311
-			   	  	if(preg_match('/[^\d]/', $value)) {
311
+			   	  	if (preg_match('/[^\d]/', $value)) {
312 312
 				   	  	 require_once('modules/Currencies/Currency.php');
313 313
 				   	  	 $contents[$input] = unformat_number($value);
314 314
 				   	  	 //Flag this value as having been unformatted
315
-				   	  	 $contents[$input . '_unformatted_number'] = true;
315
+				   	  	 $contents[$input.'_unformatted_number'] = true;
316 316
 				   	  	 //If the type is of currency and there was a currency symbol (non-digit), save the symbol
317
-				   	  	 if($type == 'currency' && preg_match('/^([^\d])/', $value, $match))
317
+				   	  	 if ($type == 'currency' && preg_match('/^([^\d])/', $value, $match))
318 318
 				   	  	 {
319
-				   	  	 	$contents[$input . '_currency_symbol'] = $match[1];
319
+				   	  	 	$contents[$input.'_currency_symbol'] = $match[1];
320 320
 				   	  	 }
321 321
 			   	  	} else {
322 322
 			   	  		 //unset any flags
323
-			   	  		 if(isset($contents[$input . '_unformatted_number']))
323
+			   	  		 if (isset($contents[$input.'_unformatted_number']))
324 324
 			   	  		 {
325
-			   	  		 	unset($contents[$input . '_unformatted_number']);
325
+			   	  		 	unset($contents[$input.'_unformatted_number']);
326 326
 			   	  		 }
327 327
 
328
-			   	  		 if(isset($contents[$input . '_currency_symbol']))
328
+			   	  		 if (isset($contents[$input.'_currency_symbol']))
329 329
 			   	  		 {
330
-			   	  		 	unset($contents[$input . '_currency_symbol']);
330
+			   	  		 	unset($contents[$input.'_currency_symbol']);
331 331
 			   	  		 }
332 332
 			   	  	}
333 333
 			   	  }
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 
346 346
 		$saved_search_id = $focus->save();
347 347
 
348
-		$GLOBALS['log']->debug("Saved record with id of " . $focus->id);
349
-		$orderBy = empty($contents['orderBy'])? 'name' : $contents['orderBy'];
350
-        $search_query = "&orderBy=" . $orderBy . "&sortOrder=".$contents['sortOrder'] . "&query=" . $_REQUEST['query'] . "&searchFormTab=" . $_REQUEST['searchFormTab'].'&showSSDIV=' . $contents['showSSDIV'];
348
+		$GLOBALS['log']->debug("Saved record with id of ".$focus->id);
349
+		$orderBy = empty($contents['orderBy']) ? 'name' : $contents['orderBy'];
350
+        $search_query = "&orderBy=".$orderBy."&sortOrder=".$contents['sortOrder']."&query=".$_REQUEST['query']."&searchFormTab=".$_REQUEST['searchFormTab'].'&showSSDIV='.$contents['showSSDIV'];
351 351
 
352
-        if($redirect)
352
+        if ($redirect)
353 353
         {
354 354
         	$this->handleRedirect($focus->search_module, $search_query, $saved_search_id, 'true');
355 355
         }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	function handleRedirect($return_module, $search_query, $saved_search_id, $advanced = 'false') {
359 359
         $_SESSION['LastSavedView'][$return_module] = $saved_search_id;
360 360
         $return_action = 'index';
361
-        $ajaxLoad = empty($_REQUEST['ajax_load']) ? "" : "&ajax_load=" . $_REQUEST['ajax_load'];
361
+        $ajaxLoad = empty($_REQUEST['ajax_load']) ? "" : "&ajax_load=".$_REQUEST['ajax_load'];
362 362
         //Reduce the params to avoid the problems caused by URL max length in IE ( the reduced params can be get from saved search according to saved_search_id).
363 363
         header("Location: index.php?action=$return_action&module=$return_module&saved_search_select={$saved_search_id}{$search_query}&advanced={$advanced}$ajaxLoad");
364 364
         die();
@@ -378,34 +378,34 @@  discard block
 block discarded – undo
378 378
         $this->contents = unserialize(base64_decode($this->contents));
379 379
     }
380 380
 
381
-    function populateRequest(){
381
+    function populateRequest() {
382 382
 
383 383
     	global $timedate;
384 384
 
385
-        if(isset($this->contents['search_module']))
385
+        if (isset($this->contents['search_module']))
386 386
         {
387 387
            $searchModuleBean = loadBean($this->contents['search_module']);
388 388
         }
389 389
 
390
-        foreach($this->contents as $key=>$val){
391
-            if($key != 'advanced' && $key != 'module' && !strpos($key, '_ORDER_BY') && $key != 'lvso') {
392
-            	if(isset($searchModuleBean) && !empty($val) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $key, $match))
390
+        foreach ($this->contents as $key=>$val) {
391
+            if ($key != 'advanced' && $key != 'module' && !strpos($key, '_ORDER_BY') && $key != 'lvso') {
392
+            	if (isset($searchModuleBean) && !empty($val) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $key, $match))
393 393
             	{
394 394
             	   $field = $match[2];
395
-				   if(isset($searchModuleBean->field_defs[$field]['type'])  && empty($searchModuleBean->field_defs[$field]['disable_num_format']))
395
+				   if (isset($searchModuleBean->field_defs[$field]['type']) && empty($searchModuleBean->field_defs[$field]['disable_num_format']))
396 396
 				   {
397 397
 				   	  $type = $searchModuleBean->field_defs[$field]['type'];
398 398
 
399 399
 				   	  //Avoid macro values for the date types
400
-				   	  if(($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && preg_match('/^\d{4}-\d{2}-\d{2}$/', $val) && !preg_match('/^\[.*?\]$/', $val))
400
+				   	  if (($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && preg_match('/^\d{4}-\d{2}-\d{2}$/', $val) && !preg_match('/^\[.*?\]$/', $val))
401 401
 				   	  {
402 402
 				   	  	 $val = $timedate->to_display_date($val, false);
403
-				   	  }  else if (($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') && isset($this->contents[$key . '_unformatted_number']) && preg_match('/^\d+$/', $val)) {
403
+				   	  } else if (($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') && isset($this->contents[$key.'_unformatted_number']) && preg_match('/^\d+$/', $val)) {
404 404
 				   	  	 require_once('modules/Currencies/Currency.php');
405 405
 				   	  	 $val = format_number($val);
406
-				   	  	 if($type == 'currency' && isset($this->contents[$key . '_currency_symbol']))
406
+				   	  	 if ($type == 'currency' && isset($this->contents[$key.'_currency_symbol']))
407 407
 				   	  	 {
408
-				   	  	 	$val = $this->contents[$key . '_currency_symbol'] . $val;
408
+				   	  	 	$val = $this->contents[$key.'_currency_symbol'].$val;
409 409
 				   	  	 }
410 410
 				   	  }
411 411
 				   }
Please login to merge, or discard this patch.
Braces   +42 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -92,8 +94,7 @@  discard block
 block discarded – undo
92 94
 		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
93 95
 		if(isset($GLOBALS['log'])) {
94 96
 			$GLOBALS['log']->deprecated($deprecatedMessage);
95
-		}
96
-		else {
97
+		} else {
97 98
 			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
98 99
 		}
99 100
 		self::__construct($columns, $orderBy, $sortOrder);
@@ -140,8 +141,11 @@  discard block
 block discarded – undo
140 141
 
141 142
         if((!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') || (isset($this->contents['displayColumns']) && $this->contents['displayColumns'] != 'undefined')) {
142 143
              // columns to display
143
-             if(!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') $temp_displayColumns = $_REQUEST['displayColumns'];
144
-             else $temp_displayColumns = $this->contents['displayColumns'];
144
+             if(!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') {
145
+                 $temp_displayColumns = $_REQUEST['displayColumns'];
146
+             } else {
147
+                 $temp_displayColumns = $this->contents['displayColumns'];
148
+             }
145 149
              foreach(explode('|', $temp_displayColumns) as $num => $name) {
146 150
              		if (!isset($this->columns[$name])) {
147 151
 						// Ignore any column that is not on the list.
@@ -153,18 +157,22 @@  discard block
 block discarded – undo
153 157
              foreach(array_diff(array_keys($this->columns), array_values(explode('|', $temp_displayColumns))) as $num => $name) {
154 158
                     $chooser->args['values_array'][1][$name] = trim(translate($this->columns[$name]['label'], $module), ':');
155 159
              }
156
-        }
157
-        else {
160
+        } else {
158 161
              foreach($this->columns as $name => $val) {
159
-                if(!empty($val['default']) && $val['default'])
160
-                    $chooser->args['values_array'][0][$name] = trim(translate($val['label'], $module), ':');
161
-                else
162
-                    $chooser->args['values_array'][1][$name] = trim(translate($val['label'], $module), ':');
162
+                if(!empty($val['default']) && $val['default']) {
163
+                                    $chooser->args['values_array'][0][$name] = trim(translate($val['label'], $module), ':');
164
+                } else {
165
+                                    $chooser->args['values_array'][1][$name] = trim(translate($val['label'], $module), ':');
166
+                }
163 167
             }
164 168
         }
165 169
 
166
-        if(!empty($_REQUEST['sortOrder'])) $this->sortOrder = $_REQUEST['sortOrder'];
167
-        if(!empty($_REQUEST['orderBy'])) $this->orderBy = $_REQUEST['orderBy'];
170
+        if(!empty($_REQUEST['sortOrder'])) {
171
+            $this->sortOrder = $_REQUEST['sortOrder'];
172
+        }
173
+        if(!empty($_REQUEST['orderBy'])) {
174
+            $this->orderBy = $_REQUEST['orderBy'];
175
+        }
168 176
 
169 177
         $chooser->args['left_name'] = 'display_tabs';
170 178
         $chooser->args['right_name'] = 'hide_tabs';
@@ -176,7 +184,9 @@  discard block
 block discarded – undo
176 184
         $sugarSmarty->assign('columnChooser', $chooser->display());
177 185
 
178 186
         $sugarSmarty->assign('selectedOrderBy', $this->orderBy);
179
-        if(empty($this->sortOrder)) $this->sortOrder = 'ASC';
187
+        if(empty($this->sortOrder)) {
188
+            $this->sortOrder = 'ASC';
189
+        }
180 190
         $sugarSmarty->assign('selectedSortOrder', $this->sortOrder);
181 191
 
182 192
         $lastSavedView = (empty($_SESSION['LastSavedView'][$module]) ? '' : $_SESSION['LastSavedView'][$module]);
@@ -212,10 +222,11 @@  discard block
 block discarded – undo
212 222
         $sugarSmarty->assign('SEARCH_MODULE', $module);
213 223
         $sugarSmarty->assign('MOD', $saved_search_mod_strings);
214 224
 
215
-        if(!empty($_SESSION['LastSavedView'][$module]) && (($_REQUEST['action'] == 'ListView') || ($_REQUEST['action'] == 'index')))
216
-            $selectedSearch = $_SESSION['LastSavedView'][$module];
217
-        else
218
-            $selectedSearch = '';
225
+        if(!empty($_SESSION['LastSavedView'][$module]) && (($_REQUEST['action'] == 'ListView') || ($_REQUEST['action'] == 'index'))) {
226
+                    $selectedSearch = $_SESSION['LastSavedView'][$module];
227
+        } else {
228
+                    $selectedSearch = '';
229
+        }
219 230
 
220 231
         $sugarSmarty->assign('SAVED_SEARCHES_OPTIONS', get_select_options_with_id($savedSearchArray, $selectedSearch));
221 232
 
@@ -230,7 +241,9 @@  discard block
 block discarded – undo
230 241
 
231 242
         $saved_search_name = '';
232 243
         $header .= $this->contents['search_module'];
233
-        if(empty($_SESSION['LastSavedView'])) $_SESSION['LastSavedView'] = array();
244
+        if(empty($_SESSION['LastSavedView'])) {
245
+            $_SESSION['LastSavedView'] = array();
246
+        }
234 247
         $_SESSION['LastSavedView'][$this->contents['search_module']] = $id;
235 248
         $saved_search_id = $id;
236 249
         $saved_search_name = $this->name;
@@ -253,7 +266,9 @@  discard block
 block discarded – undo
253 266
 	    $saved_search_name = '';
254 267
 	    while ($row = $db->fetchByAssoc($result, false)) {
255 268
 	        $header .= $row['search_module'];
256
-            if(empty($_SESSION['LastSavedView'])) $_SESSION['LastSavedView'] = array();
269
+            if(empty($_SESSION['LastSavedView'])) {
270
+                $_SESSION['LastSavedView'] = array();
271
+            }
257 272
             $_SESSION['LastSavedView'][$row['search_module']] = $row['id'];
258 273
 	        $contents = unserialize(base64_decode($row['contents']));
259 274
 	        $saved_search_id = $row['id'];
@@ -273,7 +288,9 @@  discard block
 block discarded – undo
273 288
 		global $current_user, $timedate;
274 289
 
275 290
 		$focus = new SavedSearch();
276
-		if($id) $focus->retrieve($id);
291
+		if($id) {
292
+		    $focus->retrieve($id);
293
+		}
277 294
 
278 295
 		if($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
279 296
 			return null;
@@ -282,7 +299,9 @@  discard block
 block discarded – undo
282 299
 		$ignored_inputs = array('PHPSESSID', 'module', 'action', 'saved_search_name', 'saved_search_select', 'advanced', 'Calls_divs', 'ACLRoles_divs');
283 300
 
284 301
         $contents = $_REQUEST;
285
-		if($id == null) $focus->name = $contents['saved_search_name'];
302
+		if($id == null) {
303
+		    $focus->name = $contents['saved_search_name'];
304
+		}
286 305
 		$focus->search_module = $contents['search_module'];
287 306
 
288 307
 		foreach($contents as $input=>$value)
@@ -400,7 +419,7 @@  discard block
 block discarded – undo
400 419
 				   	  if(($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && preg_match('/^\d{4}-\d{2}-\d{2}$/', $val) && !preg_match('/^\[.*?\]$/', $val))
401 420
 				   	  {
402 421
 				   	  	 $val = $timedate->to_display_date($val, false);
403
-				   	  }  else if (($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') && isset($this->contents[$key . '_unformatted_number']) && preg_match('/^\d+$/', $val)) {
422
+				   	  } else if (($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') && isset($this->contents[$key . '_unformatted_number']) && preg_match('/^\d+$/', $val)) {
404 423
 				   	  	 require_once('modules/Currencies/Currency.php');
405 424
 				   	  	 $val = format_number($val);
406 425
 				   	  	 if($type == 'currency' && isset($this->contents[$key . '_currency_symbol']))
Please login to merge, or discard this patch.
modules/AOD_IndexEvent/AOD_IndexEvent_sugar.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	var $table_name = 'aod_indexevent';
52 52
 	var $tracker_visibility = false;
53 53
 	var $importable = false;
54
-	var $disable_row_level_security = true ; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO
54
+	var $disable_row_level_security = true; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO
55 55
 		var $id;
56 56
 		var $name;
57 57
 		var $date_entered;
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 		var $error;
71 71
 		var $success;
72 72
 
73
-    public function __construct(){
73
+    public function __construct() {
74 74
 		parent::__construct();
75 75
 	}
76 76
 
77 77
     /**
78 78
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
79 79
      */
80
-    public function AOD_IndexEvent_sugar(){
80
+    public function AOD_IndexEvent_sugar() {
81 81
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
82
-        if(isset($GLOBALS['log'])) {
82
+        if (isset($GLOBALS['log'])) {
83 83
             $GLOBALS['log']->deprecated($deprecatedMessage);
84 84
         }
85 85
         else {
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
     }
90 90
 
91 91
 
92
-	function bean_implements($interface){
93
-		switch($interface){
92
+	function bean_implements($interface) {
93
+		switch ($interface) {
94 94
 			case 'ACL': return true;
95 95
 		}
96 96
 		return false;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/AOD_IndexEvent/AOD_IndexEvent.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@
 block discarded – undo
40 40
 require_once('modules/AM_TaskTemplates/AM_TaskTemplates_sugar.php');
41 41
 class AM_TaskTemplates extends AM_TaskTemplates_sugar {
42 42
 
43
-	public function __construct(){
44
-		parent::__construct();
45
-	}
43
+    public function __construct(){
44
+        parent::__construct();
45
+    }
46 46
 
47 47
     /**
48 48
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,16 +43,16 @@
 block discarded – undo
43 43
 require_once('modules/AOD_IndexEvent/AOD_IndexEvent_sugar.php');
44 44
 class AOD_IndexEvent extends AOD_IndexEvent_sugar {
45 45
 
46
-	public function __construct(){
46
+	public function __construct() {
47 47
 		parent::__construct();
48 48
 	}
49 49
 
50 50
     /**
51 51
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
52 52
      */
53
-    public function AOD_IndexEvent(){
53
+    public function AOD_IndexEvent() {
54 54
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
55
-        if(isset($GLOBALS['log'])) {
55
+        if (isset($GLOBALS['log'])) {
56 56
             $GLOBALS['log']->deprecated($deprecatedMessage);
57 57
         }
58 58
         else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/EmailTemplates/views/view.classic.php 2 patches
Spacing   +4 added lines, -4 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
 /*********************************************************************************
5 5
  * SugarCRM is a customer relationship management program developed by
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 class EmailTemplatesViewClassic extends ViewClassic {
49 49
 
50
- 	function __construct(){
50
+ 	function __construct() {
51 51
 
52 52
 		/* BEGIN - SECURITY GROUPS - The whole file is custom but the purpose is the following code */
53 53
         //turn on normal display of subpanels
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
     /**
61 61
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
62 62
      */
63
-    function EmailTemplatesViewClassic(){
63
+    function EmailTemplatesViewClassic() {
64 64
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
65
-        if(isset($GLOBALS['log'])) {
65
+        if (isset($GLOBALS['log'])) {
66 66
             $GLOBALS['log']->deprecated($deprecatedMessage);
67 67
         }
68 68
         else {
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.
modules/AOS_Line_Item_Groups/AOS_Line_Item_Groups_sugar.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,18 +38,18 @@  discard block
 block discarded – undo
38 38
 	var $table_name = 'aos_line_item_groups';
39 39
 	var $tracker_visibility = false;
40 40
 	var $importable = true;
41
-	var $disable_row_level_security = true ;
41
+	var $disable_row_level_security = true;
42 42
 
43
-	function __construct(){
43
+	function __construct() {
44 44
 		parent::__construct();
45 45
 	}
46 46
 
47 47
     /**
48 48
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
49 49
      */
50
-    function AOS_Line_Item_Groups_sugar(){
50
+    function AOS_Line_Item_Groups_sugar() {
51 51
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
52
-        if(isset($GLOBALS['log'])) {
52
+        if (isset($GLOBALS['log'])) {
53 53
             $GLOBALS['log']->deprecated($deprecatedMessage);
54 54
         }
55 55
         else {
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
     }
60 60
 
61 61
 
62
-	function bean_implements($interface){
63
-		switch($interface){
62
+	function bean_implements($interface) {
63
+		switch ($interface) {
64 64
 			case 'ACL': return false;
65 65
 		}
66 66
 		return false;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/AOS_Line_Item_Groups/AOS_Line_Item_Groups.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
     /**
52 52
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
53 53
      */
54
-    function AOS_Line_Item_Groups(){
54
+    function AOS_Line_Item_Groups() {
55 55
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
56
-        if(isset($GLOBALS['log'])) {
56
+        if (isset($GLOBALS['log'])) {
57 57
             $GLOBALS['log']->deprecated($deprecatedMessage);
58 58
         }
59 59
         else {
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
     {
68 68
 
69 69
         $groups = array();
70
-        $group_count = isset($post_data[$key . 'group_number']) ? count($post_data[$key . 'group_number']) : 0;
70
+        $group_count = isset($post_data[$key.'group_number']) ? count($post_data[$key.'group_number']) : 0;
71 71
         $j = 0;
72 72
         for ($i = 0; $i < $group_count; ++$i) {
73 73
 
74
-            if ($post_data[$key . 'deleted'][$i] == 1) {
75
-                $this->mark_deleted($post_data[$key . 'id'][$i]);
74
+            if ($post_data[$key.'deleted'][$i] == 1) {
75
+                $this->mark_deleted($post_data[$key.'id'][$i]);
76 76
             } else {
77 77
                 $product_quote_group = new AOS_Line_Item_Groups();
78 78
                 foreach ($this->field_defs as $field_def) {
79 79
                     $field_name = $field_def['name'];
80
-                    if (isset($post_data[$key . $field_name][$i])) {
81
-                        $product_quote_group->$field_name = $post_data[$key . $field_name][$i];
80
+                    if (isset($post_data[$key.$field_name][$i])) {
81
+                        $product_quote_group->$field_name = $post_data[$key.$field_name][$i];
82 82
                     }
83 83
                 }
84 84
                 $product_quote_group->number = ++$j;
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
                 $product_quote_group->parent_id = $parent->id;
88 88
                 $product_quote_group->parent_type = $parent->object_name;
89 89
                 $product_quote_group->save();
90
-                $post_data[$key . 'id'][$i] = $product_quote_group->id;
90
+                $post_data[$key.'id'][$i] = $product_quote_group->id;
91 91
 
92
-                if (isset($post_data[$key . 'group_number'][$i])) {
93
-                    $groups[$post_data[$key . 'group_number'][$i]] = $product_quote_group->id;
92
+                if (isset($post_data[$key.'group_number'][$i])) {
93
+                    $groups[$post_data[$key.'group_number'][$i]] = $product_quote_group->id;
94 94
                 }
95 95
 
96 96
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/AOK_KnowledgeBase/views/view.detail.php 2 patches
Spacing   +7 added lines, -7 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.
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 require_once('include/MVC/View/views/view.detail.php');
42 42
 
43 43
 class AOK_KnowledgeBaseViewDetail extends ViewDetail {
44
-    function __construct(){
44
+    function __construct() {
45 45
         parent::__construct();
46 46
     }
47 47
 
48 48
     /**
49 49
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
50 50
      */
51
-    function AOK_KnowledgeBaseViewDetail(){
51
+    function AOK_KnowledgeBaseViewDetail() {
52 52
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
53
-        if(isset($GLOBALS['log'])) {
53
+        if (isset($GLOBALS['log'])) {
54 54
             $GLOBALS['log']->deprecated($deprecatedMessage);
55 55
         }
56 56
         else {
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
 
63
-    function display(){
63
+    function display() {
64 64
         $this->setDecodeHTML();
65 65
         parent::display();
66 66
     }
67 67
 
68
-    function setDecodeHTML(){
69
-        $this->bean->description = html_entity_decode(str_replace('&nbsp;',' ',$this->bean->description));
68
+    function setDecodeHTML() {
69
+        $this->bean->description = html_entity_decode(str_replace('&nbsp;', ' ', $this->bean->description));
70 70
     }
71 71
 }
72 72
 ?>
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.