Completed
Push — master ( 58f496...a833c2 )
by Adam
18:52
created
include/utils/sugar_file_utils.php 3 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -54,44 +54,44 @@  discard block
 block discarded – undo
54 54
  * @return boolean - Returns true on success false on failure
55 55
  */
56 56
 function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') {
57
-	$mode = get_mode('dir_mode', $mode);
58
-
59
-	if ( sugar_is_dir($pathname,$mode) )
60
-	    return true;
61
-
62
-	$result = false;
63
-	if(empty($mode))
64
-		$mode = 0777;
65
-	if(empty($context)) {
66
-		$result = @mkdir($pathname, $mode, $recursive);
67
-	} else {
68
-		$result = @mkdir($pathname, $mode, $recursive, $context);
69
-	}
70
-
71
-	if($result){
72
-		if(!sugar_chmod($pathname, $mode)){
73
-			return false;
74
-		}
75
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
76
-			if(!sugar_chown($pathname)){
77
-				return false;
78
-			}
79
-		}
80
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
81
-   			if(!sugar_chgrp($pathname)) {
82
-   				return false;
83
-   			}
84
-		}
85
-	}
86
-	else {
87
-		$errorMessage = "Cannot create directory $pathname cannot be touched";
88
-		if(is_null($GLOBALS['log'])) {
89
-			throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
90
-		}
91
-		$GLOBALS['log']->error($errorMessage);
92
-	}
93
-
94
-	return $result;
57
+    $mode = get_mode('dir_mode', $mode);
58
+
59
+    if ( sugar_is_dir($pathname,$mode) )
60
+        return true;
61
+
62
+    $result = false;
63
+    if(empty($mode))
64
+        $mode = 0777;
65
+    if(empty($context)) {
66
+        $result = @mkdir($pathname, $mode, $recursive);
67
+    } else {
68
+        $result = @mkdir($pathname, $mode, $recursive, $context);
69
+    }
70
+
71
+    if($result){
72
+        if(!sugar_chmod($pathname, $mode)){
73
+            return false;
74
+        }
75
+        if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
76
+            if(!sugar_chown($pathname)){
77
+                return false;
78
+            }
79
+        }
80
+        if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
81
+                if(!sugar_chgrp($pathname)) {
82
+                    return false;
83
+                }
84
+        }
85
+    }
86
+    else {
87
+        $errorMessage = "Cannot create directory $pathname cannot be touched";
88
+        if(is_null($GLOBALS['log'])) {
89
+            throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
90
+        }
91
+        $GLOBALS['log']->error($errorMessage);
92
+    }
93
+
94
+    return $result;
95 95
 }
96 96
 
97 97
 /**
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
  * @return boolean - Returns a file pointer on success, false otherwise
110 110
  */
111 111
 function sugar_fopen($filename, $mode, $use_include_path=false, $context=null){
112
-	//check to see if the file exists, if not then use touch to create it.
113
-	if(!file_exists($filename)){
114
-		sugar_touch($filename);
115
-	}
112
+    //check to see if the file exists, if not then use touch to create it.
113
+    if(!file_exists($filename)){
114
+        sugar_touch($filename);
115
+    }
116 116
 
117
-	if(empty($context)) {
117
+    if(empty($context)) {
118 118
 
119
-		return fopen($filename, $mode, $use_include_path);
120
-	} else {
121
-		return fopen($filename, $mode, $use_include_path, $context);
122
-	}
119
+        return fopen($filename, $mode, $use_include_path);
120
+    } else {
121
+        return fopen($filename, $mode, $use_include_path, $context);
122
+    }
123 123
 }
124 124
 
125 125
 /**
@@ -137,23 +137,23 @@  discard block
 block discarded – undo
137 137
  * @return int - Returns the number of bytes written to the file, false otherwise.
138 138
  */
139 139
 function sugar_file_put_contents($filename, $data, $flags=null, $context=null){
140
-	//check to see if the file exists, if not then use touch to create it.
141
-	if(!file_exists($filename)){
142
-		sugar_touch($filename);
143
-	}
144
-
145
-	if ( !is_writable($filename) ) {
146
-	    $GLOBALS['log']->error("File $filename cannot be written to");
147
-	    return false;
148
-	}
149
-
150
-	if(empty($flags)) {
151
-		return file_put_contents($filename, $data);
152
-	} elseif(empty($context)) {
153
-		return file_put_contents($filename, $data, $flags);
154
-	} else{
155
-		return file_put_contents($filename, $data, $flags, $context);
156
-	}
140
+    //check to see if the file exists, if not then use touch to create it.
141
+    if(!file_exists($filename)){
142
+        sugar_touch($filename);
143
+    }
144
+
145
+    if ( !is_writable($filename) ) {
146
+        $GLOBALS['log']->error("File $filename cannot be written to");
147
+        return false;
148
+    }
149
+
150
+    if(empty($flags)) {
151
+        return file_put_contents($filename, $data);
152
+    } elseif(empty($context)) {
153
+        return file_put_contents($filename, $data, $flags);
154
+    } else{
155
+        return file_put_contents($filename, $data, $flags, $context);
156
+    }
157 157
 }
158 158
 
159 159
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
     if(file_exists($filename))
200 200
     {
201
-       return sugar_chmod($filename, 0755);
201
+        return sugar_chmod($filename, 0755);
202 202
     }
203 203
 
204 204
     return false;
@@ -215,21 +215,21 @@  discard block
 block discarded – undo
215 215
  * @return string|boolean - Returns a file data on success, false otherwise
216 216
  */
217 217
 function sugar_file_get_contents($filename, $use_include_path=false, $context=null){
218
-	//check to see if the file exists, if not then use touch to create it.
219
-	if(!file_exists($filename)){
220
-		sugar_touch($filename);
221
-	}
222
-
223
-	if ( !is_readable($filename) ) {
224
-	    $GLOBALS['log']->error("File $filename cannot be read");
225
-	    return false;
226
-	}
227
-
228
-	if(empty($context)) {
229
-		return file_get_contents($filename, $use_include_path);
230
-	} else {
231
-		return file_get_contents($filename, $use_include_path, $context);
232
-	}
218
+    //check to see if the file exists, if not then use touch to create it.
219
+    if(!file_exists($filename)){
220
+        sugar_touch($filename);
221
+    }
222
+
223
+    if ( !is_readable($filename) ) {
224
+        $GLOBALS['log']->error("File $filename cannot be read");
225
+        return false;
226
+    }
227
+
228
+    if(empty($context)) {
229
+        return file_get_contents($filename, $use_include_path);
230
+    } else {
231
+        return file_get_contents($filename, $use_include_path, $context);
232
+    }
233 233
 }
234 234
 
235 235
 /**
@@ -248,31 +248,31 @@  discard block
 block discarded – undo
248 248
  */
249 249
 function sugar_touch($filename, $time=null, $atime=null) {
250 250
 
251
-   $result = false;
252
-
253
-   if(!empty($atime) && !empty($time)) {
254
-   	  $result = @touch($filename, $time, $atime);
255
-   } else if(!empty($time)) {
256
-   	  $result = @touch($filename, $time);
257
-   } else {
258
-   	  $result = @touch($filename);
259
-   }
260
-
261
-   if(!$result) {
262
-       $GLOBALS['log']->error("File $filename cannot be touched");
263
-       return $result;
264
-   }
265
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){
266
-		sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
267
-	}
268
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
269
-		sugar_chown($filename);
270
-	}
271
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
272
-		sugar_chgrp($filename);
273
-	}
274
-
275
-   return true;
251
+    $result = false;
252
+
253
+    if(!empty($atime) && !empty($time)) {
254
+            $result = @touch($filename, $time, $atime);
255
+    } else if(!empty($time)) {
256
+            $result = @touch($filename, $time);
257
+    } else {
258
+            $result = @touch($filename);
259
+    }
260
+
261
+    if(!$result) {
262
+        $GLOBALS['log']->error("File $filename cannot be touched");
263
+        return $result;
264
+    }
265
+    if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){
266
+        sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
267
+    }
268
+    if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
269
+        sugar_chown($filename);
270
+    }
271
+    if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
272
+        sugar_chgrp($filename);
273
+    }
274
+
275
+    return true;
276 276
 }
277 277
 
278 278
 /**
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
 function sugar_chmod($filename, $mode=null) {
288 288
     if ( !is_int($mode) )
289 289
         $mode = (int) $mode;
290
-	if(!is_windows()){
291
-		if(!isset($mode)){
292
-			$mode = get_mode('file_mode', $mode);
293
-		}
290
+    if(!is_windows()){
291
+        if(!isset($mode)){
292
+            $mode = get_mode('file_mode', $mode);
293
+        }
294 294
         if(isset($mode) && $mode > 0){
295
-		   return @chmod($filename, $mode);
296
-		}else{
297
-	    	return false;
298
-		}
299
-	}
300
-	return true;
295
+            return @chmod($filename, $mode);
296
+        }else{
297
+            return false;
298
+        }
299
+    }
300
+    return true;
301 301
 }
302 302
 
303 303
 /**
@@ -310,19 +310,19 @@  discard block
 block discarded – undo
310 310
  * @return boolean - Returns TRUE on success or FALSE on failure.
311 311
  */
312 312
 function sugar_chown($filename, $user='') {
313
-	if(!is_windows()){
314
-		if(strlen($user)){
315
-			return chown($filename, $user);
316
-		}else{
317
-			if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
318
-				$user = $GLOBALS['sugar_config']['default_permissions']['user'];
319
-				return chown($filename, $user);
320
-			}else{
321
-				return false;
322
-			}
323
-		}
324
-	}
325
-	return true;
313
+    if(!is_windows()){
314
+        if(strlen($user)){
315
+            return chown($filename, $user);
316
+        }else{
317
+            if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
318
+                $user = $GLOBALS['sugar_config']['default_permissions']['user'];
319
+                return chown($filename, $user);
320
+            }else{
321
+                return false;
322
+            }
323
+        }
324
+    }
325
+    return true;
326 326
 }
327 327
 
328 328
 /**
@@ -335,19 +335,19 @@  discard block
 block discarded – undo
335 335
  * @return boolean - Returns TRUE on success or FALSE on failure.
336 336
  */
337 337
 function sugar_chgrp($filename, $group='') {
338
-	if(!is_windows()){
339
-		if(!empty($group)){
340
-			return chgrp($filename, $group);
341
-		}else{
342
-			if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
343
-				$group = $GLOBALS['sugar_config']['default_permissions']['group'];
344
-				return chgrp($filename, $group);
345
-			}else{
346
-				return false;
347
-			}
348
-		}
349
-	}
350
-	return true;
338
+    if(!is_windows()){
339
+        if(!empty($group)){
340
+            return chgrp($filename, $group);
341
+        }else{
342
+            if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
343
+                $group = $GLOBALS['sugar_config']['default_permissions']['group'];
344
+                return chgrp($filename, $group);
345
+            }else{
346
+                return false;
347
+            }
348
+        }
349
+    }
350
+    return true;
351 351
 }
352 352
 
353 353
 /**
@@ -361,26 +361,26 @@  discard block
 block discarded – undo
361 361
  * @return int - the mode either found in the config file or passed in via the input parameter
362 362
  */
363 363
 function get_mode($key = 'dir_mode', $mode=null) {
364
-	if ( !is_int($mode) )
364
+    if ( !is_int($mode) )
365 365
         $mode = (int) $mode;
366 366
     if(!class_exists('SugarConfig', true)) {
367
-		require 'include/SugarObjects/SugarConfig.php';
368
-	}
369
-	if(!is_windows()){
370
-		$conf_inst=SugarConfig::getInstance();
371
-		$mode = $conf_inst->get('default_permissions.'.$key, $mode);
372
-	}
373
-	return $mode;
367
+        require 'include/SugarObjects/SugarConfig.php';
368
+    }
369
+    if(!is_windows()){
370
+        $conf_inst=SugarConfig::getInstance();
371
+        $mode = $conf_inst->get('default_permissions.'.$key, $mode);
372
+    }
373
+    return $mode;
374 374
 }
375 375
 
376 376
 function sugar_is_dir($path, $mode='r'){
377
-		if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
378
-		return is_dir($path);
377
+        if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
378
+        return is_dir($path);
379 379
 }
380 380
 
381 381
 function sugar_is_file($path, $mode='r'){
382
-		if(defined('TEMPLATE_URL'))return is_file($path, $mode);
383
-		return is_file($path);
382
+        if(defined('TEMPLATE_URL'))return is_file($path, $mode);
383
+        return is_file($path);
384 384
 }
385 385
 
386 386
 /**
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 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.
@@ -53,39 +53,39 @@  discard block
 block discarded – undo
53 53
  * @param $context
54 54
  * @return boolean - Returns true on success false on failure
55 55
  */
56
-function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') {
56
+function sugar_mkdir($pathname, $mode = null, $recursive = false, $context = '') {
57 57
 	$mode = get_mode('dir_mode', $mode);
58 58
 
59
-	if ( sugar_is_dir($pathname,$mode) )
59
+	if (sugar_is_dir($pathname, $mode))
60 60
 	    return true;
61 61
 
62 62
 	$result = false;
63
-	if(empty($mode))
63
+	if (empty($mode))
64 64
 		$mode = 0777;
65
-	if(empty($context)) {
65
+	if (empty($context)) {
66 66
 		$result = @mkdir($pathname, $mode, $recursive);
67 67
 	} else {
68 68
 		$result = @mkdir($pathname, $mode, $recursive, $context);
69 69
 	}
70 70
 
71
-	if($result){
72
-		if(!sugar_chmod($pathname, $mode)){
71
+	if ($result) {
72
+		if (!sugar_chmod($pathname, $mode)) {
73 73
 			return false;
74 74
 		}
75
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
76
-			if(!sugar_chown($pathname)){
75
+		if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
76
+			if (!sugar_chown($pathname)) {
77 77
 				return false;
78 78
 			}
79 79
 		}
80
-		if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
81
-   			if(!sugar_chgrp($pathname)) {
80
+		if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
81
+   			if (!sugar_chgrp($pathname)) {
82 82
    				return false;
83 83
    			}
84 84
 		}
85 85
 	}
86 86
 	else {
87 87
 		$errorMessage = "Cannot create directory $pathname cannot be touched";
88
-		if(is_null($GLOBALS['log'])) {
88
+		if (is_null($GLOBALS['log'])) {
89 89
 			throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
90 90
 		}
91 91
 		$GLOBALS['log']->error($errorMessage);
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
  * @param $context
109 109
  * @return boolean - Returns a file pointer on success, false otherwise
110 110
  */
111
-function sugar_fopen($filename, $mode, $use_include_path=false, $context=null){
111
+function sugar_fopen($filename, $mode, $use_include_path = false, $context = null) {
112 112
 	//check to see if the file exists, if not then use touch to create it.
113
-	if(!file_exists($filename)){
113
+	if (!file_exists($filename)) {
114 114
 		sugar_touch($filename);
115 115
 	}
116 116
 
117
-	if(empty($context)) {
117
+	if (empty($context)) {
118 118
 
119 119
 		return fopen($filename, $mode, $use_include_path);
120 120
 	} else {
@@ -136,22 +136,22 @@  discard block
 block discarded – undo
136 136
  * @param $context
137 137
  * @return int - Returns the number of bytes written to the file, false otherwise.
138 138
  */
139
-function sugar_file_put_contents($filename, $data, $flags=null, $context=null){
139
+function sugar_file_put_contents($filename, $data, $flags = null, $context = null) {
140 140
 	//check to see if the file exists, if not then use touch to create it.
141
-	if(!file_exists($filename)){
141
+	if (!file_exists($filename)) {
142 142
 		sugar_touch($filename);
143 143
 	}
144 144
 
145
-	if ( !is_writable($filename) ) {
145
+	if (!is_writable($filename)) {
146 146
 	    $GLOBALS['log']->error("File $filename cannot be written to");
147 147
 	    return false;
148 148
 	}
149 149
 
150
-	if(empty($flags)) {
150
+	if (empty($flags)) {
151 151
 		return file_put_contents($filename, $data);
152
-	} elseif(empty($context)) {
152
+	} elseif (empty($context)) {
153 153
 		return file_put_contents($filename, $data, $flags);
154
-	} else{
154
+	} else {
155 155
 		return file_put_contents($filename, $data, $flags, $context);
156 156
 	}
157 157
 }
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
  * @param context $context Context to pass into fopen operation
170 170
  * @return boolean - Returns true if $filename was created, false otherwise.
171 171
  */
172
-function sugar_file_put_contents_atomic($filename, $data, $mode='wb', $use_include_path=false, $context=null){
172
+function sugar_file_put_contents_atomic($filename, $data, $mode = 'wb', $use_include_path = false, $context = null) {
173 173
 
174 174
     $dir = dirname($filename);
175 175
     $temp = tempnam($dir, 'temp');
176 176
 
177 177
     if (!($f = @fopen($temp, $mode))) {
178
-        $temp =  $dir . DIRECTORY_SEPARATOR . uniqid('temp');
178
+        $temp = $dir.DIRECTORY_SEPARATOR.uniqid('temp');
179 179
         if (!($f = @fopen($temp, $mode))) {
180 180
             trigger_error("sugar_file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING);
181 181
             return false;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         }
197 197
     }
198 198
 
199
-    if(file_exists($filename))
199
+    if (file_exists($filename))
200 200
     {
201 201
        return sugar_chmod($filename, 0755);
202 202
     }
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
  * @param $context
215 215
  * @return string|boolean - Returns a file data on success, false otherwise
216 216
  */
217
-function sugar_file_get_contents($filename, $use_include_path=false, $context=null){
217
+function sugar_file_get_contents($filename, $use_include_path = false, $context = null) {
218 218
 	//check to see if the file exists, if not then use touch to create it.
219
-	if(!file_exists($filename)){
219
+	if (!file_exists($filename)) {
220 220
 		sugar_touch($filename);
221 221
 	}
222 222
 
223
-	if ( !is_readable($filename) ) {
223
+	if (!is_readable($filename)) {
224 224
 	    $GLOBALS['log']->error("File $filename cannot be read");
225 225
 	    return false;
226 226
 	}
227 227
 
228
-	if(empty($context)) {
228
+	if (empty($context)) {
229 229
 		return file_get_contents($filename, $use_include_path);
230 230
 	} else {
231 231
 		return file_get_contents($filename, $use_include_path, $context);
@@ -246,29 +246,29 @@  discard block
 block discarded – undo
246 246
  * @return boolean - Returns TRUE on success or FALSE on failure.
247 247
  *
248 248
  */
249
-function sugar_touch($filename, $time=null, $atime=null) {
249
+function sugar_touch($filename, $time = null, $atime = null) {
250 250
 
251 251
    $result = false;
252 252
 
253
-   if(!empty($atime) && !empty($time)) {
253
+   if (!empty($atime) && !empty($time)) {
254 254
    	  $result = @touch($filename, $time, $atime);
255
-   } else if(!empty($time)) {
255
+   } else if (!empty($time)) {
256 256
    	  $result = @touch($filename, $time);
257 257
    } else {
258 258
    	  $result = @touch($filename);
259 259
    }
260 260
 
261
-   if(!$result) {
261
+   if (!$result) {
262 262
        $GLOBALS['log']->error("File $filename cannot be touched");
263 263
        return $result;
264 264
    }
265
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){
265
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])) {
266 266
 		sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
267 267
 	}
268
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){
268
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
269 269
 		sugar_chown($filename);
270 270
 	}
271
-	if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
271
+	if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
272 272
 		sugar_chgrp($filename);
273 273
 	}
274 274
 
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
  * @param  int $mode The integer value of the permissions mode to set the created directory to
285 285
  * @return boolean   Returns TRUE on success or FALSE on failure.
286 286
  */
287
-function sugar_chmod($filename, $mode=null) {
288
-    if ( !is_int($mode) )
289
-        $mode = (int) $mode;
290
-	if(!is_windows()){
291
-		if(!isset($mode)){
287
+function sugar_chmod($filename, $mode = null) {
288
+    if (!is_int($mode))
289
+        $mode = (int)$mode;
290
+	if (!is_windows()) {
291
+		if (!isset($mode)) {
292 292
 			$mode = get_mode('file_mode', $mode);
293 293
 		}
294
-        if(isset($mode) && $mode > 0){
294
+        if (isset($mode) && $mode > 0) {
295 295
 		   return @chmod($filename, $mode);
296
-		}else{
296
+		} else {
297 297
 	    	return false;
298 298
 		}
299 299
 	}
@@ -309,15 +309,15 @@  discard block
 block discarded – undo
309 309
  * @param user - A user name or number
310 310
  * @return boolean - Returns TRUE on success or FALSE on failure.
311 311
  */
312
-function sugar_chown($filename, $user='') {
313
-	if(!is_windows()){
314
-		if(strlen($user)){
312
+function sugar_chown($filename, $user = '') {
313
+	if (!is_windows()) {
314
+		if (strlen($user)) {
315 315
 			return chown($filename, $user);
316
-		}else{
317
-			if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
316
+		} else {
317
+			if (strlen($GLOBALS['sugar_config']['default_permissions']['user'])) {
318 318
 				$user = $GLOBALS['sugar_config']['default_permissions']['user'];
319 319
 				return chown($filename, $user);
320
-			}else{
320
+			} else {
321 321
 				return false;
322 322
 			}
323 323
 		}
@@ -334,15 +334,15 @@  discard block
 block discarded – undo
334 334
  * @param group - A group name or number
335 335
  * @return boolean - Returns TRUE on success or FALSE on failure.
336 336
  */
337
-function sugar_chgrp($filename, $group='') {
338
-	if(!is_windows()){
339
-		if(!empty($group)){
337
+function sugar_chgrp($filename, $group = '') {
338
+	if (!is_windows()) {
339
+		if (!empty($group)) {
340 340
 			return chgrp($filename, $group);
341
-		}else{
342
-			if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
341
+		} else {
342
+			if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
343 343
 				$group = $GLOBALS['sugar_config']['default_permissions']['group'];
344 344
 				return chgrp($filename, $group);
345
-			}else{
345
+			} else {
346 346
 				return false;
347 347
 			}
348 348
 		}
@@ -360,26 +360,26 @@  discard block
 block discarded – undo
360 360
  * defined in the config file.
361 361
  * @return int - the mode either found in the config file or passed in via the input parameter
362 362
  */
363
-function get_mode($key = 'dir_mode', $mode=null) {
364
-	if ( !is_int($mode) )
365
-        $mode = (int) $mode;
366
-    if(!class_exists('SugarConfig', true)) {
363
+function get_mode($key = 'dir_mode', $mode = null) {
364
+	if (!is_int($mode))
365
+        $mode = (int)$mode;
366
+    if (!class_exists('SugarConfig', true)) {
367 367
 		require 'include/SugarObjects/SugarConfig.php';
368 368
 	}
369
-	if(!is_windows()){
370
-		$conf_inst=SugarConfig::getInstance();
369
+	if (!is_windows()) {
370
+		$conf_inst = SugarConfig::getInstance();
371 371
 		$mode = $conf_inst->get('default_permissions.'.$key, $mode);
372 372
 	}
373 373
 	return $mode;
374 374
 }
375 375
 
376
-function sugar_is_dir($path, $mode='r'){
377
-		if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
376
+function sugar_is_dir($path, $mode = 'r') {
377
+		if (defined('TEMPLATE_URL'))return is_dir($path, $mode);
378 378
 		return is_dir($path);
379 379
 }
380 380
 
381
-function sugar_is_file($path, $mode='r'){
382
-		if(defined('TEMPLATE_URL'))return is_file($path, $mode);
381
+function sugar_is_file($path, $mode = 'r') {
382
+		if (defined('TEMPLATE_URL'))return is_file($path, $mode);
383 383
 		return is_file($path);
384 384
 }
385 385
 
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 function sugar_cached($file)
392 392
 {
393 393
     static $cdir = null;
394
-    if(empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) {
394
+    if (empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) {
395 395
         $cdir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
396 396
     }
397
-    if(empty($cdir)) {
397
+    if (empty($cdir)) {
398 398
         $cdir = "cache";
399 399
     }
400 400
     return "$cdir/$file";
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 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.
@@ -56,12 +58,14 @@  discard block
 block discarded – undo
56 58
 function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') {
57 59
 	$mode = get_mode('dir_mode', $mode);
58 60
 
59
-	if ( sugar_is_dir($pathname,$mode) )
60
-	    return true;
61
+	if ( sugar_is_dir($pathname,$mode) ) {
62
+		    return true;
63
+	}
61 64
 
62 65
 	$result = false;
63
-	if(empty($mode))
64
-		$mode = 0777;
66
+	if(empty($mode)) {
67
+			$mode = 0777;
68
+	}
65 69
 	if(empty($context)) {
66 70
 		$result = @mkdir($pathname, $mode, $recursive);
67 71
 	} else {
@@ -82,8 +86,7 @@  discard block
 block discarded – undo
82 86
    				return false;
83 87
    			}
84 88
 		}
85
-	}
86
-	else {
89
+	} else {
87 90
 		$errorMessage = "Cannot create directory $pathname cannot be touched";
88 91
 		if(is_null($GLOBALS['log'])) {
89 92
 			throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\"");
@@ -285,15 +288,16 @@  discard block
 block discarded – undo
285 288
  * @return boolean   Returns TRUE on success or FALSE on failure.
286 289
  */
287 290
 function sugar_chmod($filename, $mode=null) {
288
-    if ( !is_int($mode) )
289
-        $mode = (int) $mode;
291
+    if ( !is_int($mode) ) {
292
+            $mode = (int) $mode;
293
+    }
290 294
 	if(!is_windows()){
291 295
 		if(!isset($mode)){
292 296
 			$mode = get_mode('file_mode', $mode);
293 297
 		}
294 298
         if(isset($mode) && $mode > 0){
295 299
 		   return @chmod($filename, $mode);
296
-		}else{
300
+		} else{
297 301
 	    	return false;
298 302
 		}
299 303
 	}
@@ -313,11 +317,11 @@  discard block
 block discarded – undo
313 317
 	if(!is_windows()){
314 318
 		if(strlen($user)){
315 319
 			return chown($filename, $user);
316
-		}else{
320
+		} else{
317 321
 			if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){
318 322
 				$user = $GLOBALS['sugar_config']['default_permissions']['user'];
319 323
 				return chown($filename, $user);
320
-			}else{
324
+			} else{
321 325
 				return false;
322 326
 			}
323 327
 		}
@@ -338,11 +342,11 @@  discard block
 block discarded – undo
338 342
 	if(!is_windows()){
339 343
 		if(!empty($group)){
340 344
 			return chgrp($filename, $group);
341
-		}else{
345
+		} else{
342 346
 			if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){
343 347
 				$group = $GLOBALS['sugar_config']['default_permissions']['group'];
344 348
 				return chgrp($filename, $group);
345
-			}else{
349
+			} else{
346 350
 				return false;
347 351
 			}
348 352
 		}
@@ -361,8 +365,9 @@  discard block
 block discarded – undo
361 365
  * @return int - the mode either found in the config file or passed in via the input parameter
362 366
  */
363 367
 function get_mode($key = 'dir_mode', $mode=null) {
364
-	if ( !is_int($mode) )
365
-        $mode = (int) $mode;
368
+	if ( !is_int($mode) ) {
369
+	        $mode = (int) $mode;
370
+	}
366 371
     if(!class_exists('SugarConfig', true)) {
367 372
 		require 'include/SugarObjects/SugarConfig.php';
368 373
 	}
@@ -374,12 +379,16 @@  discard block
 block discarded – undo
374 379
 }
375 380
 
376 381
 function sugar_is_dir($path, $mode='r'){
377
-		if(defined('TEMPLATE_URL'))return is_dir($path, $mode);
382
+		if(defined('TEMPLATE_URL')) {
383
+		    return is_dir($path, $mode);
384
+		}
378 385
 		return is_dir($path);
379 386
 }
380 387
 
381 388
 function sugar_is_file($path, $mode='r'){
382
-		if(defined('TEMPLATE_URL'))return is_file($path, $mode);
389
+		if(defined('TEMPLATE_URL')) {
390
+		    return is_file($path, $mode);
391
+		}
383 392
 		return is_file($path);
384 393
 }
385 394
 
Please login to merge, or discard this patch.
include/TemplateHandler/TemplateHandler.php 3 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     var $templateDir = 'modules/';
51 51
     var $ss;
52 52
     function TemplateHandler() {
53
-      $this->cacheDir = sugar_cached('');
53
+        $this->cacheDir = sugar_cached('');
54 54
     }
55 55
 
56 56
     function loadSmarty(){
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
      *
67 67
      */
68 68
     static function clearAll() {
69
-    	global $beanList;
70
-		foreach($beanList as $module_dir =>$object_name){
69
+        global $beanList;
70
+        foreach($beanList as $module_dir =>$object_name){
71 71
                 TemplateHandler::clearCache($module_dir);
72
-		}
72
+        }
73 73
     }
74 74
 
75 75
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                     foreach($panel as $row) {
133 133
                             foreach($row as $entry) {
134 134
                                     if(empty($entry)) {
135
-                                       continue;
135
+                                        continue;
136 136
                                     }
137 137
 
138 138
                                     if(is_array($entry) &&
@@ -140,35 +140,35 @@  discard block
 block discarded – undo
140 140
                                        isset($entry['displayParams']) &&
141 141
                                        isset($entry['displayParams']['required']) &&
142 142
                                        $entry['displayParams']['required']) {
143
-                                       $panelFields[$entry['name']] = $entry;
143
+                                        $panelFields[$entry['name']] = $entry;
144 144
                                     }
145 145
 
146 146
                                     if(is_array($entry)) {
147
-                                      $defs2[$entry['name']] = $entry;
147
+                                        $defs2[$entry['name']] = $entry;
148 148
                                     } else {
149
-                                      $defs2[$entry] = array('name' => $entry);
149
+                                        $defs2[$entry] = array('name' => $entry);
150 150
                                     }
151 151
                             } //foreach
152 152
                     } //foreach
153 153
             } //foreach
154 154
 
155 155
             foreach($panelFields as $field=>$value) {
156
-                      $nameList = array();
157
-                      if(!is_array($value['displayParams']['required'])) {
158
-                         $nameList[] = $field;
159
-                      } else {
160
-                         foreach($value['displayParams']['required'] as $groupedField) {
161
-                                 $nameList[] = $groupedField;
162
-                         }
163
-                      }
164
-
165
-                      foreach($nameList as $x) {
166
-                         if(isset($defs[$x]) &&
156
+                        $nameList = array();
157
+                        if(!is_array($value['displayParams']['required'])) {
158
+                            $nameList[] = $field;
159
+                        } else {
160
+                            foreach($value['displayParams']['required'] as $groupedField) {
161
+                                    $nameList[] = $groupedField;
162
+                            }
163
+                        }
164
+
165
+                        foreach($nameList as $x) {
166
+                            if(isset($defs[$x]) &&
167 167
                             isset($defs[$x]['type']) &&
168 168
                             !isset($defs[$x]['required'])) {
169 169
                             $defs[$x]['required'] = true;
170
-                         }
171
-                      }
170
+                            }
171
+                        }
172 172
             } //foreach
173 173
 
174 174
             //Create a base class with field_name_map property
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
             //5) not already been added to Array
196 196
             foreach($sugarbean->field_name_map as $name=>$def) {
197 197
 
198
-               if($def['type']=='relate' &&
198
+                if($def['type']=='relate' &&
199 199
                   isset($defs2[$name]) &&
200 200
                   (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) &&
201 201
                   isset($def['id_name']) &&
202 202
                   !in_array($name, $validatedFields)) {
203 203
 
204
-                  if(isset($mod_strings[$def['vname']])
204
+                    if(isset($mod_strings[$def['vname']])
205 205
                         || isset($app_strings[$def['vname']])
206 206
                         || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
207
-                     $vname = $def['vname'];
208
-                  }
209
-                  else{
210
-                     $vname = "undefined";
211
-                  }
212
-                  $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
213
-                  $validatedFields[] = $name;
214
-               }
207
+                        $vname = $def['vname'];
208
+                    }
209
+                    else{
210
+                        $vname = "undefined";
211
+                    }
212
+                    $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
213
+                    $validatedFields[] = $name;
214
+                }
215 215
             } //foreach
216 216
 
217 217
             $contents .= "{literal}\n";
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
         }
276 276
         $file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl';
277 277
         if(file_exists($file)) {
278
-           return $this->ss->fetch($file);
278
+            return $this->ss->fetch($file);
279 279
         } else {
280
-           global $app_strings;
281
-           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
282
-           return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
280
+            global $app_strings;
281
+            $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
282
+            return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
283 283
         }
284 284
     }
285 285
 
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
         }
330 330
         $qsd->setFormName($view);
331 331
         if(preg_match('/^SearchForm_.+/', $view)){
332
-        	if(strpos($view, 'popup_query_form')){
333
-        		$qsd->setFormName('popup_query_form');
334
-            	$parsedView = 'advanced';
335
-        	}else{
336
-        		$qsd->setFormName('search_form');
337
-            	$parsedView = preg_replace("/^SearchForm_/", "", $view);
338
-        	}
332
+            if(strpos($view, 'popup_query_form')){
333
+                $qsd->setFormName('popup_query_form');
334
+                $parsedView = 'advanced';
335
+            }else{
336
+                $qsd->setFormName('search_form');
337
+                $parsedView = preg_replace("/^SearchForm_/", "", $view);
338
+            }
339 339
             //Loop through the Meta-Data fields to see which ones need quick search support
340 340
             foreach($defs as $f) {
341 341
                 $field = $f;
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], $field['id_name']);
374 374
                         }
375 375
                     } else {
376
-                         $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
377
-                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
378
-                             $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
379
-                             $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
380
-                         } else {
381
-                             $sqs_objects[$name.'_'.$parsedView]['populate_list'] = $field['field_list'];
382
-                             $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
383
-                         }
376
+                            $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
377
+                            if(!isset($field['field_list']) && !isset($field['populate_list'])) {
378
+                                $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
379
+                                $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
380
+                            } else {
381
+                                $sqs_objects[$name.'_'.$parsedView]['populate_list'] = $field['field_list'];
382
+                                $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
383
+                            }
384 384
                     }
385 385
                 } else if($field['type'] == 'parent') {
386 386
                     $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent();
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
             } //foreach
389 389
 
390 390
             foreach ( $sqs_objects as $name => $field )
391
-               foreach ( $field['populate_list'] as $key => $fieldname )
391
+                foreach ( $field['populate_list'] as $key => $fieldname )
392 392
                     $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
393 393
         }else{
394 394
             //Loop through the Meta-Data fields to see which ones need quick search support
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                             $field['id_name'] = $module.$field['id_name'];
414 414
                     }
415 415
                 }
416
-				$name = $qsd->form_name . '_' . $field['name'];
416
+                $name = $qsd->form_name . '_' . $field['name'];
417 417
 
418 418
 
419 419
                 if($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si',$name) || !empty($field['quicksearch']))) {
@@ -427,15 +427,15 @@  discard block
 block discarded – undo
427 427
                         } else if($matches[0] == 'Users'){
428 428
                             if($field['name'] == 'reports_to_name'){
429 429
                                 $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
430
-                             // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
430
+                                // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
431 431
                             }elseif($field['name'] == 'assigned_user_name'){
432
-                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
433
-                             }
434
-                             else
435
-                             {
436
-                                 $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
432
+                                    $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
433
+                                }
434
+                                else
435
+                                {
436
+                                    $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
437 437
 
438
-							}
438
+                            }
439 439
                         } else if($matches[0] == 'Campaigns') {
440 440
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
441 441
                         } else if($matches[0] == 'Accounts') {
@@ -486,39 +486,39 @@  discard block
 block discarded – undo
486 486
                 //merge populate_list && field_list with vardef
487 487
                 if (!empty($field['field_list']) && !empty($field['populate_list'])) {
488 488
                     for ($j=0; $j<count($field['field_list']); $j++) {
489
-                		//search for the same couple (field_list_item,populate_field_item)
490
-               			$field_list_item = $field['field_list'][$j];
491
-               			$field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
492
-               			$populate_list_item = $field['populate_list'][$j];
493
-                		$found = false;
494
-                		for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
495
-                			if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus)
496
-                				$populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
497
-                				$found = true;
498
-                				break;
499
-                			}
500
-                		}
501
-                		if (!$found) {
502
-                			$sqs_objects[$name]['field_list'][] = $field['populate_list'][$j]; // as in lines 462 and 463
503
-                			$sqs_objects[$name]['populate_list'][] = $field['field_list'][$j];
504
-                		}
505
-                	}
489
+                        //search for the same couple (field_list_item,populate_field_item)
490
+                            $field_list_item = $field['field_list'][$j];
491
+                            $field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
492
+                            $populate_list_item = $field['populate_list'][$j];
493
+                        $found = false;
494
+                        for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
495
+                            if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus)
496
+                                $populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
497
+                                $found = true;
498
+                                break;
499
+                            }
500
+                        }
501
+                        if (!$found) {
502
+                            $sqs_objects[$name]['field_list'][] = $field['populate_list'][$j]; // as in lines 462 and 463
503
+                            $sqs_objects[$name]['populate_list'][] = $field['field_list'][$j];
504
+                        }
505
+                    }
506 506
                 }
507 507
 
508 508
             } //foreach
509 509
         }
510 510
 
511
-       //Implement QuickSearch for the field
512
-       if(!empty($sqs_objects) && count($sqs_objects) > 0) {
513
-           $quicksearch_js = '<script language="javascript">';
514
-           $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
515
-           $json = getJSONobj();
516
-           foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
517
-               $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
518
-           }
519
-           return $quicksearch_js . '</script>';
520
-       }
521
-       return '';
511
+        //Implement QuickSearch for the field
512
+        if(!empty($sqs_objects) && count($sqs_objects) > 0) {
513
+            $quicksearch_js = '<script language="javascript">';
514
+            $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
515
+            $json = getJSONobj();
516
+            foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
517
+                $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
518
+            }
519
+            return $quicksearch_js . '</script>';
520
+        }
521
+        return '';
522 522
     }
523 523
 
524 524
     
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
     /**
58 58
      * @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
59 59
      */
60
-    public function TemplateHandler(){
60
+    public function TemplateHandler() {
61 61
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
62
-        if(isset($GLOBALS['log'])) {
62
+        if (isset($GLOBALS['log'])) {
63 63
             $GLOBALS['log']->deprecated($deprecatedMessage);
64 64
         }
65 65
         else {
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
     }
70 70
 
71 71
 
72
-    function loadSmarty(){
73
-        if(empty($this->ss)){
72
+    function loadSmarty() {
73
+        if (empty($this->ss)) {
74 74
             $this->ss = new Sugar_Smarty();
75 75
         }
76 76
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     static function clearAll() {
85 85
     	global $beanList;
86
-		foreach($beanList as $module_dir =>$object_name){
86
+		foreach ($beanList as $module_dir =>$object_name) {
87 87
                 TemplateHandler::clearCache($module_dir);
88 88
 		}
89 89
     }
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
      * @param String $module The module directory to clear
97 97
      * @param String $view Optional view value (DetailView, EditView, etc.)
98 98
      */
99
-    static function clearCache($module, $view=''){
100
-        $cacheDir = create_cache_directory('modules/'. $module . '/');
99
+    static function clearCache($module, $view = '') {
100
+        $cacheDir = create_cache_directory('modules/'.$module.'/');
101 101
         $d = dir($cacheDir);
102
-        while($e = $d->read()){
103
-            if(!empty($view) && $e != $view )continue;
104
-            $end =strlen($e) - 4;
105
-            if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){
106
-                unlink($cacheDir . $e);
102
+        while ($e = $d->read()) {
103
+            if (!empty($view) && $e != $view)continue;
104
+            $end = strlen($e) - 4;
105
+            if (is_file($cacheDir.$e) && $end > 1 && substr($e, $end) == '.tpl') {
106
+                unlink($cacheDir.$e);
107 107
             }
108 108
         }
109 109
     }
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
     function buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs) {
122 122
         $this->loadSmarty();
123 123
 
124
-        $cacheDir = create_cache_directory($this->templateDir. $module . '/');
125
-        $file = $cacheDir . $view . '.tpl';
126
-        $string = '{* Create Date: ' . date('Y-m-d H:i:s') . "*}\n";
124
+        $cacheDir = create_cache_directory($this->templateDir.$module.'/');
125
+        $file = $cacheDir.$view.'.tpl';
126
+        $string = '{* Create Date: '.date('Y-m-d H:i:s')."*}\n";
127 127
         $this->ss->left_delimiter = '{{';
128 128
         $this->ss->right_delimiter = '}}';
129 129
         $this->ss->assign('module', $module);
130 130
         $this->ss->assign('built_in_buttons', array('CANCEL', 'DELETE', 'DUPLICATE', 'EDIT', 'FIND_DUPLICATES', 'SAVE', 'CONNECTOR'));
131 131
         $contents = $this->ss->fetch($tpl);
132 132
         //Insert validation and quicksearch stuff here
133
-        if($view == 'EditView' || strpos($view,'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
133
+        if ($view == 'EditView' || strpos($view, 'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
134 134
 
135 135
             global $dictionary, $beanList, $app_strings, $mod_strings;
136 136
             $mod = $beanList[$module];
137 137
 
138
-            if($mod == 'aCase') {
138
+            if ($mod == 'aCase') {
139 139
                 $mod = 'Case';
140 140
             }
141 141
 
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
             //Retrieve all panel field definitions with displayParams Array field set
145 145
             $panelFields = array();
146 146
 
147
-            foreach($metaDataDefs['panels'] as $panel) {
148
-                    foreach($panel as $row) {
149
-                            foreach($row as $entry) {
150
-                                    if(empty($entry)) {
147
+            foreach ($metaDataDefs['panels'] as $panel) {
148
+                    foreach ($panel as $row) {
149
+                            foreach ($row as $entry) {
150
+                                    if (empty($entry)) {
151 151
                                        continue;
152 152
                                     }
153 153
 
154
-                                    if(is_array($entry) &&
154
+                                    if (is_array($entry) &&
155 155
                                        isset($entry['name']) &&
156 156
                                        isset($entry['displayParams']) &&
157 157
                                        isset($entry['displayParams']['required']) &&
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                                        $panelFields[$entry['name']] = $entry;
160 160
                                     }
161 161
 
162
-                                    if(is_array($entry)) {
162
+                                    if (is_array($entry)) {
163 163
                                       $defs2[$entry['name']] = $entry;
164 164
                                     } else {
165 165
                                       $defs2[$entry] = array('name' => $entry);
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
                     } //foreach
169 169
             } //foreach
170 170
 
171
-            foreach($panelFields as $field=>$value) {
171
+            foreach ($panelFields as $field=>$value) {
172 172
                       $nameList = array();
173
-                      if(!is_array($value['displayParams']['required'])) {
173
+                      if (!is_array($value['displayParams']['required'])) {
174 174
                          $nameList[] = $field;
175 175
                       } else {
176
-                         foreach($value['displayParams']['required'] as $groupedField) {
176
+                         foreach ($value['displayParams']['required'] as $groupedField) {
177 177
                                  $nameList[] = $groupedField;
178 178
                          }
179 179
                       }
180 180
 
181
-                      foreach($nameList as $x) {
182
-                         if(isset($defs[$x]) &&
181
+                      foreach ($nameList as $x) {
182
+                         if (isset($defs[$x]) &&
183 183
                             isset($defs[$x]['type']) &&
184 184
                             !isset($defs[$x]['required'])) {
185 185
                             $defs[$x]['required'] = true;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
             $javascript->setSugarBean($sugarbean);
200 200
             if ($view != "ConvertLead")
201
-                $javascript->addAllFields('', null,true);
201
+                $javascript->addAllFields('', null, true);
202 202
 
203 203
             $validatedFields = array();
204 204
             $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
@@ -209,20 +209,20 @@  discard block
 block discarded – undo
209 209
             //3) not have validateDepedency set to false in metadata
210 210
             //4) have id_name in vardef entry
211 211
             //5) not already been added to Array
212
-            foreach($sugarbean->field_name_map as $name=>$def) {
212
+            foreach ($sugarbean->field_name_map as $name=>$def) {
213 213
 
214
-               if($def['type']=='relate' &&
214
+               if ($def['type'] == 'relate' &&
215 215
                   isset($defs2[$name]) &&
216 216
                   (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) &&
217 217
                   isset($def['id_name']) &&
218 218
                   !in_array($name, $validatedFields)) {
219 219
 
220
-                  if(isset($mod_strings[$def['vname']])
220
+                  if (isset($mod_strings[$def['vname']])
221 221
                         || isset($app_strings[$def['vname']])
222
-                        || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
222
+                        || translate($def['vname'], $sugarbean->module_dir) != $def['vname']) {
223 223
                      $vname = $def['vname'];
224 224
                   }
225
-                  else{
225
+                  else {
226 226
                      $vname = "undefined";
227 227
                   }
228 228
                   $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
             $contents .= $javascript->getScript();
235 235
             $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module);
236 236
             $contents .= "{/literal}\n";
237
-        }else if(preg_match('/^SearchForm_.+/', $view)){
237
+        } else if (preg_match('/^SearchForm_.+/', $view)) {
238 238
             global $dictionary, $beanList, $app_strings, $mod_strings;
239 239
             $mod = $beanList[$module];
240 240
 
241
-            if($mod == 'aCase') {
241
+            if ($mod == 'aCase') {
242 242
                 $mod = 'Case';
243 243
             }
244 244
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         //Remove all the copyright comments
252 252
         $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents);
253 253
 
254
-        if($fh = @sugar_fopen($file, 'w')) {
254
+        if ($fh = @sugar_fopen($file, 'w')) {
255 255
             fputs($fh, $contents);
256 256
             fclose($fh);
257 257
         }
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
      * @param module string module name
268 268
      * @param view string view need (eg DetailView, EditView, etc)
269 269
      */
270
-    function checkTemplate($module, $view, $checkFormName = false, $formName='') {
271
-        if(inDeveloperMode() || !empty($_SESSION['developerMode'])){
270
+    function checkTemplate($module, $view, $checkFormName = false, $formName = '') {
271
+        if (inDeveloperMode() || !empty($_SESSION['developerMode'])) {
272 272
             return false;
273 273
         }
274 274
         $view = $checkFormName ? $formName : $view;
275
-        return file_exists($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
275
+        return file_exists($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
276 276
     }
277 277
 
278 278
     /**
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
      */
287 287
     function displayTemplate($module, $view, $tpl, $ajaxSave = false, $metaDataDefs = null) {
288 288
         $this->loadSmarty();
289
-        if(!$this->checkTemplate($module, $view)) {
289
+        if (!$this->checkTemplate($module, $view)) {
290 290
             $this->buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs);
291 291
         }
292
-        $file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl';
293
-        if(file_exists($file)) {
292
+        $file = $this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl';
293
+        if (file_exists($file)) {
294 294
            return $this->ss->fetch($file);
295 295
         } else {
296 296
            global $app_strings;
297
-           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
298
-           return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
297
+           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'].": $file");
298
+           return $app_strings['ERR_NO_SUCH_FILE'].": $file";
299 299
         }
300 300
     }
301 301
 
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
      * @param view string view need (eg DetailView, EditView, etc)
307 307
      */
308 308
     function deleteTemplate($module, $view) {
309
-        if(is_file($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl')) {
309
+        if (is_file($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl')) {
310 310
             // Bug #54634 : RTC 18144 : Cannot add more than 1 user to role but popup is multi-selectable
311
-            if ( !isset($this->ss) )
311
+            if (!isset($this->ss))
312 312
             {
313 313
                 $this->loadSmarty();
314 314
             }
315
-            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
315
+            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
316 316
             SugarCache::cleanFile($cache_file_name);
317 317
 
318
-            return unlink($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
318
+            return unlink($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
319 319
         }
320 320
         return false;
321 321
     }
@@ -332,47 +332,47 @@  discard block
 block discarded – undo
332 332
      * @param strign $module
333 333
      * @return string
334 334
      */
335
-    public function createQuickSearchCode($defs, $defs2, $view = '', $module='')
335
+    public function createQuickSearchCode($defs, $defs2, $view = '', $module = '')
336 336
     {
337 337
         $sqs_objects = array();
338 338
         require_once('include/QuickSearchDefaults.php');
339
-        if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
339
+        if (isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
340 340
         {
341 341
             $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup());
342
-        }else
342
+        } else
343 343
         {
344 344
             $qsd = QuickSearchDefaults::getQuickSearchDefaults(array());
345 345
         }
346 346
         $qsd->setFormName($view);
347
-        if(preg_match('/^SearchForm_.+/', $view)){
348
-        	if(strpos($view, 'popup_query_form')){
347
+        if (preg_match('/^SearchForm_.+/', $view)) {
348
+        	if (strpos($view, 'popup_query_form')) {
349 349
         		$qsd->setFormName('popup_query_form');
350 350
             	$parsedView = 'advanced';
351
-        	}else{
351
+        	} else {
352 352
         		$qsd->setFormName('search_form');
353 353
             	$parsedView = preg_replace("/^SearchForm_/", "", $view);
354 354
         	}
355 355
             //Loop through the Meta-Data fields to see which ones need quick search support
356
-            foreach($defs as $f) {
356
+            foreach ($defs as $f) {
357 357
                 $field = $f;
358
-                $name = $qsd->form_name . '_' . $field['name'];
358
+                $name = $qsd->form_name.'_'.$field['name'];
359 359
 
360
-                if($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si',$name)  || !empty($field['quicksearch']) ) {
361
-                    if(preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
360
+                if ($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch'])) {
361
+                    if (preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
362 362
 
363
-                        if($matches[0] == 'Campaigns') {
363
+                        if ($matches[0] == 'Campaigns') {
364 364
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
365
-                        } else if($matches[0] == 'Users'){
365
+                        } else if ($matches[0] == 'Users') {
366 366
 
367
-                            if(!empty($f['name']) && !empty($f['id_name'])) {
368
-                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']);
367
+                            if (!empty($f['name']) && !empty($f['id_name'])) {
368
+                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'], $f['id_name']);
369 369
                             }
370 370
                             else {
371 371
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser();
372 372
                             }
373
-                        } else if($matches[0] == 'Campaigns') {
373
+                        } else if ($matches[0] == 'Campaigns') {
374 374
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
375
-                        } else if($matches[0] == 'Accounts') {
375
+                        } else if ($matches[0] == 'Accounts') {
376 376
                             $nameKey = $name;
377 377
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
378 378
 
@@ -385,12 +385,12 @@  discard block
 block discarded – undo
385 385
                             $shippingKey = isset($f['displayParams']['shippingKey']) ? $f['displayParams']['shippingKey'] : null;
386 386
                             $additionalFields = isset($f['displayParams']['additionalFields']) ? $f['displayParams']['additionalFields'] : null;
387 387
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
388
-                        } else if($matches[0] == 'Contacts'){
388
+                        } else if ($matches[0] == 'Contacts') {
389 389
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], $field['id_name']);
390 390
                         }
391 391
                     } else {
392 392
                          $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
393
-                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
393
+                         if (!isset($field['field_list']) && !isset($field['populate_list'])) {
394 394
                              $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
395 395
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
396 396
                          } else {
@@ -398,63 +398,63 @@  discard block
 block discarded – undo
398 398
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
399 399
                          }
400 400
                     }
401
-                } else if($field['type'] == 'parent') {
401
+                } else if ($field['type'] == 'parent') {
402 402
                     $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent();
403 403
                 } //if-else
404 404
             } //foreach
405 405
 
406
-            foreach ( $sqs_objects as $name => $field )
407
-               foreach ( $field['populate_list'] as $key => $fieldname )
408
-                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
409
-        }else{
406
+            foreach ($sqs_objects as $name => $field)
407
+               foreach ($field['populate_list'] as $key => $fieldname)
408
+                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key].'_'.$parsedView;
409
+        } else {
410 410
             //Loop through the Meta-Data fields to see which ones need quick search support
411
-            foreach($defs2 as $f) {
412
-                if(!isset($defs[$f['name']])) continue;
411
+            foreach ($defs2 as $f) {
412
+                if (!isset($defs[$f['name']])) continue;
413 413
 
414 414
                 $field = $defs[$f['name']];
415 415
                 if ($view == "ConvertLead")
416 416
                 {
417
-                    $field['name'] = $module . $field['name'];
417
+                    $field['name'] = $module.$field['name'];
418 418
                     if (isset($field['module']) && isset($field['id_name']) && substr($field['id_name'], -4) == "_ida") {
419 419
                         $lc_module = strtolower($field['module']);
420 420
                         $ida_suffix = "_".$lc_module.$lc_module."_ida";
421 421
                         if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) {
422
-                            $field['id_name'] = $module . $field['id_name'];
422
+                            $field['id_name'] = $module.$field['id_name'];
423 423
                         }
424 424
                         else
425
-                            $field['id_name'] = $field['name'] . "_" . $field['id_name'];
425
+                            $field['id_name'] = $field['name']."_".$field['id_name'];
426 426
                     }
427 427
                     else {
428 428
                         if (!empty($field['id_name']))
429 429
                             $field['id_name'] = $module.$field['id_name'];
430 430
                     }
431 431
                 }
432
-				$name = $qsd->form_name . '_' . $field['name'];
432
+				$name = $qsd->form_name.'_'.$field['name'];
433 433
 
434 434
 
435
-                if($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si',$name) || !empty($field['quicksearch']))) {
436
-                    if (!preg_match('/_c$/si',$name)
437
-                        && (!isset($field['id_name']) || !preg_match('/_c$/si',$field['id_name']))
435
+                if ($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch']))) {
436
+                    if (!preg_match('/_c$/si', $name)
437
+                        && (!isset($field['id_name']) || !preg_match('/_c$/si', $field['id_name']))
438 438
                         && preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)
439 439
                     ) {
440 440
 
441
-                        if($matches[0] == 'Campaigns') {
441
+                        if ($matches[0] == 'Campaigns') {
442 442
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
443
-                        } else if($matches[0] == 'Users'){
444
-                            if($field['name'] == 'reports_to_name'){
445
-                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
443
+                        } else if ($matches[0] == 'Users') {
444
+                            if ($field['name'] == 'reports_to_name') {
445
+                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name', 'reports_to_id');
446 446
                              // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
447
-                            }elseif($field['name'] == 'assigned_user_name'){
448
-                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
447
+                            }elseif ($field['name'] == 'assigned_user_name') {
448
+                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name', 'assigned_user_id');
449 449
                              }
450 450
                              else
451 451
                              {
452 452
                                  $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
453 453
 
454 454
 							}
455
-                        } else if($matches[0] == 'Campaigns') {
455
+                        } else if ($matches[0] == 'Campaigns') {
456 456
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
457
-                        } else if($matches[0] == 'Accounts') {
457
+                        } else if ($matches[0] == 'Accounts') {
458 458
                             $nameKey = $name;
459 459
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
460 460
 
@@ -467,15 +467,15 @@  discard block
 block discarded – undo
467 467
                             $shippingKey = SugarArray::staticGet($f, 'displayParams.shippingKey');
468 468
                             $additionalFields = SugarArray::staticGet($f, 'displayParams.additionalFields');
469 469
                             $sqs_objects[$name] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
470
-                        } else if($matches[0] == 'Contacts'){
470
+                        } else if ($matches[0] == 'Contacts') {
471 471
                             $sqs_objects[$name] = $qsd->getQSContact($field['name'], $field['id_name']);
472
-                            if(preg_match('/_c$/si',$name) || !empty($field['quicksearch'])){
472
+                            if (preg_match('/_c$/si', $name) || !empty($field['quicksearch'])) {
473 473
                                 $sqs_objects[$name]['field_list'] = array('salutation', 'first_name', 'last_name', 'id');
474 474
                             }
475 475
                         }
476 476
                     } else {
477 477
                         $sqs_objects[$name] = $qsd->getQSParent($field['module']);
478
-                        if(!isset($field['field_list']) && !isset($field['populate_list'])) {
478
+                        if (!isset($field['field_list']) && !isset($field['populate_list'])) {
479 479
                             $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']);
480 480
                             // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname'
481 481
                             if (!isset($field['rname']))
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
                             {
485 485
                                 $sqs_objects[$name]['field_list'] = array($field['rname'], 'id');
486 486
                                 $sqs_objects[$name]['order'] = $field['rname'];
487
-                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'],'op'=>'like_custom','end'=>'%','value'=>''));
487
+                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'], 'op'=>'like_custom', 'end'=>'%', 'value'=>''));
488 488
                             }
489 489
                         } else {
490 490
                             $sqs_objects[$name]['populate_list'] = $field['field_list'];
491 491
                             $sqs_objects[$name]['field_list'] = $field['populate_list'];
492 492
                         }
493 493
                     }
494
-                } else if($field['type'] == 'parent') {
494
+                } else if ($field['type'] == 'parent') {
495 495
                     $sqs_objects[$name] = $qsd->getQSParent();
496 496
                 } //if-else
497 497
 
@@ -501,13 +501,13 @@  discard block
 block discarded – undo
501 501
 
502 502
                 //merge populate_list && field_list with vardef
503 503
                 if (!empty($field['field_list']) && !empty($field['populate_list'])) {
504
-                    for ($j=0; $j<count($field['field_list']); $j++) {
504
+                    for ($j = 0; $j < count($field['field_list']); $j++) {
505 505
                 		//search for the same couple (field_list_item,populate_field_item)
506 506
                			$field_list_item = $field['field_list'][$j];
507
-               			$field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
507
+               			$field_list_item_alternate = $qsd->form_name.'_'.$field['field_list'][$j];
508 508
                			$populate_list_item = $field['populate_list'][$j];
509 509
                 		$found = false;
510
-                		for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
510
+                		for ($k = 0; $k < count($sqs_objects[$name]['field_list']); $k++) {
511 511
                 			if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus)
512 512
                 				$populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
513 513
                 				$found = true;
@@ -525,14 +525,14 @@  discard block
 block discarded – undo
525 525
         }
526 526
 
527 527
        //Implement QuickSearch for the field
528
-       if(!empty($sqs_objects) && count($sqs_objects) > 0) {
528
+       if (!empty($sqs_objects) && count($sqs_objects) > 0) {
529 529
            $quicksearch_js = '<script language="javascript">';
530
-           $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
530
+           $quicksearch_js .= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
531 531
            $json = getJSONobj();
532
-           foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
532
+           foreach ($sqs_objects as $sqsfield=>$sqsfieldArray) {
533 533
                $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
534 534
            }
535
-           return $quicksearch_js . '</script>';
535
+           return $quicksearch_js.'</script>';
536 536
        }
537 537
        return '';
538 538
     }
Please login to merge, or discard this patch.
Braces   +33 added lines, -29 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@  discard block
 block discarded – undo
61 61
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
62 62
         if(isset($GLOBALS['log'])) {
63 63
             $GLOBALS['log']->deprecated($deprecatedMessage);
64
-        }
65
-        else {
64
+        } else {
66 65
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
67 66
         }
68 67
         self::__construct();
@@ -100,7 +99,9 @@  discard block
 block discarded – undo
100 99
         $cacheDir = create_cache_directory('modules/'. $module . '/');
101 100
         $d = dir($cacheDir);
102 101
         while($e = $d->read()){
103
-            if(!empty($view) && $e != $view )continue;
102
+            if(!empty($view) && $e != $view ) {
103
+                continue;
104
+            }
104 105
             $end =strlen($e) - 4;
105 106
             if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){
106 107
                 unlink($cacheDir . $e);
@@ -197,8 +198,9 @@  discard block
 block discarded – undo
197 198
             $javascript->setFormName($view);
198 199
 
199 200
             $javascript->setSugarBean($sugarbean);
200
-            if ($view != "ConvertLead")
201
-                $javascript->addAllFields('', null,true);
201
+            if ($view != "ConvertLead") {
202
+                            $javascript->addAllFields('', null,true);
203
+            }
202 204
 
203 205
             $validatedFields = array();
204 206
             $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
@@ -221,8 +223,7 @@  discard block
 block discarded – undo
221 223
                         || isset($app_strings[$def['vname']])
222 224
                         || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
223 225
                      $vname = $def['vname'];
224
-                  }
225
-                  else{
226
+                  } else{
226 227
                      $vname = "undefined";
227 228
                   }
228 229
                   $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
@@ -234,7 +235,7 @@  discard block
 block discarded – undo
234 235
             $contents .= $javascript->getScript();
235 236
             $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module);
236 237
             $contents .= "{/literal}\n";
237
-        }else if(preg_match('/^SearchForm_.+/', $view)){
238
+        } else if(preg_match('/^SearchForm_.+/', $view)){
238 239
             global $dictionary, $beanList, $app_strings, $mod_strings;
239 240
             $mod = $beanList[$module];
240 241
 
@@ -336,10 +337,12 @@  discard block
 block discarded – undo
336 337
     {
337 338
         $sqs_objects = array();
338 339
         require_once('include/QuickSearchDefaults.php');
339
-        if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
340
+        if(isset($this) && $this instanceof TemplateHandler) {
341
+            //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
340 342
         {
341 343
             $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup());
342
-        }else
344
+        }
345
+        } else
343 346
         {
344 347
             $qsd = QuickSearchDefaults::getQuickSearchDefaults(array());
345 348
         }
@@ -348,7 +351,7 @@  discard block
 block discarded – undo
348 351
         	if(strpos($view, 'popup_query_form')){
349 352
         		$qsd->setFormName('popup_query_form');
350 353
             	$parsedView = 'advanced';
351
-        	}else{
354
+        	} else{
352 355
         		$qsd->setFormName('search_form');
353 356
             	$parsedView = preg_replace("/^SearchForm_/", "", $view);
354 357
         	}
@@ -366,8 +369,7 @@  discard block
 block discarded – undo
366 369
 
367 370
                             if(!empty($f['name']) && !empty($f['id_name'])) {
368 371
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']);
369
-                            }
370
-                            else {
372
+                            } else {
371 373
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser();
372 374
                             }
373 375
                         } else if($matches[0] == 'Campaigns') {
@@ -403,13 +405,16 @@  discard block
 block discarded – undo
403 405
                 } //if-else
404 406
             } //foreach
405 407
 
406
-            foreach ( $sqs_objects as $name => $field )
407
-               foreach ( $field['populate_list'] as $key => $fieldname )
408
+            foreach ( $sqs_objects as $name => $field ) {
409
+                           foreach ( $field['populate_list'] as $key => $fieldname )
408 410
                     $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
409
-        }else{
411
+            }
412
+        } else{
410 413
             //Loop through the Meta-Data fields to see which ones need quick search support
411 414
             foreach($defs2 as $f) {
412
-                if(!isset($defs[$f['name']])) continue;
415
+                if(!isset($defs[$f['name']])) {
416
+                    continue;
417
+                }
413 418
 
414 419
                 $field = $defs[$f['name']];
415 420
                 if ($view == "ConvertLead")
@@ -420,13 +425,13 @@  discard block
 block discarded – undo
420 425
                         $ida_suffix = "_".$lc_module.$lc_module."_ida";
421 426
                         if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) {
422 427
                             $field['id_name'] = $module . $field['id_name'];
428
+                        } else {
429
+                                                    $field['id_name'] = $field['name'] . "_" . $field['id_name'];
430
+                        }
431
+                    } else {
432
+                        if (!empty($field['id_name'])) {
433
+                                                    $field['id_name'] = $module.$field['id_name'];
423 434
                         }
424
-                        else
425
-                            $field['id_name'] = $field['name'] . "_" . $field['id_name'];
426
-                    }
427
-                    else {
428
-                        if (!empty($field['id_name']))
429
-                            $field['id_name'] = $module.$field['id_name'];
430 435
                     }
431 436
                 }
432 437
 				$name = $qsd->form_name . '_' . $field['name'];
@@ -444,10 +449,9 @@  discard block
 block discarded – undo
444 449
                             if($field['name'] == 'reports_to_name'){
445 450
                                 $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
446 451
                              // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
447
-                            }elseif($field['name'] == 'assigned_user_name'){
452
+                            } elseif($field['name'] == 'assigned_user_name'){
448 453
                                  $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
449
-                             }
450
-                             else
454
+                             } else
451 455
                              {
452 456
                                  $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
453 457
 
@@ -478,9 +482,9 @@  discard block
 block discarded – undo
478 482
                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
479 483
                             $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']);
480 484
                             // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname'
481
-                            if (!isset($field['rname']))
482
-                                $sqs_objects[$name]['field_list'] = array('name', 'id');
483
-                            else
485
+                            if (!isset($field['rname'])) {
486
+                                                            $sqs_objects[$name]['field_list'] = array('name', 'id');
487
+                            } else
484 488
                             {
485 489
                                 $sqs_objects[$name]['field_list'] = array($field['rname'], 'id');
486 490
                                 $sqs_objects[$name]['order'] = $field['rname'];
Please login to merge, or discard this patch.
include/connectors/ConnectorFactory.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -44,45 +44,45 @@
 block discarded – undo
44 44
  */
45 45
 class ConnectorFactory{
46 46
 
47
-	static $source_map = array();
47
+    static $source_map = array();
48 48
 
49
-	public static function getInstance($source_name){
50
-		if(empty(self::$source_map[$source_name])) {
51
-			require_once('include/connectors/sources/SourceFactory.php');
52
-			require_once('include/connectors/component.php');
53
-			$source = SourceFactory::getSource($source_name);
54
-			$component = new component();
55
-			$component->setSource($source);
56
-			$component->init();
57
-			self::$source_map[$source_name] = $component;
58
-		}
59
-		return self::$source_map[$source_name];
60
-	}
49
+    public static function getInstance($source_name){
50
+        if(empty(self::$source_map[$source_name])) {
51
+            require_once('include/connectors/sources/SourceFactory.php');
52
+            require_once('include/connectors/component.php');
53
+            $source = SourceFactory::getSource($source_name);
54
+            $component = new component();
55
+            $component->setSource($source);
56
+            $component->init();
57
+            self::$source_map[$source_name] = $component;
58
+        }
59
+        return self::$source_map[$source_name];
60
+    }
61 61
 
62
-	/**
63
-	 * Split the class name by _ and go through the class name
64
-	 * which represents the inheritance structure to load up all required parents.
65
-	 * @param string $class the root class we want to load.
66
-	 */
67
-	public static function load($class, $type){
68
-		self::loadClass($class, $type);
69
-	}
62
+    /**
63
+     * Split the class name by _ and go through the class name
64
+     * which represents the inheritance structure to load up all required parents.
65
+     * @param string $class the root class we want to load.
66
+     */
67
+    public static function load($class, $type){
68
+        self::loadClass($class, $type);
69
+    }
70 70
 
71
-	/**
72
-	 * include a source class file.
73
-	 * @param string $class a class file to include.
74
-	 */
75
-	public static function loadClass($class, $type){
76
-		$dir = str_replace('_','/',$class);
77
-		$parts = explode("/", $dir);
78
-		$file = $parts[count($parts)-1] . '.php';
79
-		if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){
80
-			require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file");
81
-		} else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
82
-			require_once("modules/Connectors/connectors/{$type}/{$dir}/$file");
83
-		} else if(file_exists("connectors/{$type}/{$dir}/$file")) {
84
-			require_once("connectors/{$type}/{$dir}/$file");
85
-		}
86
-	}
71
+    /**
72
+     * include a source class file.
73
+     * @param string $class a class file to include.
74
+     */
75
+    public static function loadClass($class, $type){
76
+        $dir = str_replace('_','/',$class);
77
+        $parts = explode("/", $dir);
78
+        $file = $parts[count($parts)-1] . '.php';
79
+        if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){
80
+            require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file");
81
+        } else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
82
+            require_once("modules/Connectors/connectors/{$type}/{$dir}/$file");
83
+        } else if(file_exists("connectors/{$type}/{$dir}/$file")) {
84
+            require_once("connectors/{$type}/{$dir}/$file");
85
+        }
86
+    }
87 87
 }
88 88
 ?>
89 89
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 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.
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
  * Connector factory
43 43
  * @api
44 44
  */
45
-class ConnectorFactory{
45
+class ConnectorFactory {
46 46
 
47 47
 	static $source_map = array();
48 48
 
49
-	public static function getInstance($source_name){
50
-		if(empty(self::$source_map[$source_name])) {
49
+	public static function getInstance($source_name) {
50
+		if (empty(self::$source_map[$source_name])) {
51 51
 			require_once('include/connectors/sources/SourceFactory.php');
52 52
 			require_once('include/connectors/component.php');
53 53
 			$source = SourceFactory::getSource($source_name);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * which represents the inheritance structure to load up all required parents.
65 65
 	 * @param string $class the root class we want to load.
66 66
 	 */
67
-	public static function load($class, $type){
67
+	public static function load($class, $type) {
68 68
 		self::loadClass($class, $type);
69 69
 	}
70 70
 
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 	 * include a source class file.
73 73
 	 * @param string $class a class file to include.
74 74
 	 */
75
-	public static function loadClass($class, $type){
76
-		$dir = str_replace('_','/',$class);
75
+	public static function loadClass($class, $type) {
76
+		$dir = str_replace('_', '/', $class);
77 77
 		$parts = explode("/", $dir);
78
-		$file = $parts[count($parts)-1] . '.php';
79
-		if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){
78
+		$file = $parts[count($parts) - 1].'.php';
79
+		if (file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")) {
80 80
 			require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file");
81
-		} else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
81
+		} else if (file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) {
82 82
 			require_once("modules/Connectors/connectors/{$type}/{$dir}/$file");
83
-		} else if(file_exists("connectors/{$type}/{$dir}/$file")) {
83
+		} else if (file_exists("connectors/{$type}/{$dir}/$file")) {
84 84
 			require_once("connectors/{$type}/{$dir}/$file");
85 85
 		}
86 86
 	}
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.
include/MVC/View/SugarView.php 4 patches
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1387,18 +1387,18 @@
 block discarded – undo
1387 1387
 		//$params = array();
1388 1388
         if (isset($this->action)){
1389 1389
             switch ($this->action) {
1390
-            case 'EditView':
1391
-                if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1392
-                    $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1393
-                    $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1394
-                }
1395
-                else
1396
-                    $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
1397
-                break;
1398
-            case 'DetailView':
1399
-                $beanName = $this->bean->get_summary_text();
1400
-                $params[] = $beanName;
1401
-                break;
1390
+                case 'EditView':
1391
+                    if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1392
+                        $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1393
+                        $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1394
+                    }
1395
+                    else
1396
+                        $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
1397
+                    break;
1398
+                case 'DetailView':
1399
+                    $beanName = $this->bean->get_summary_text();
1400
+                    $params[] = $beanName;
1401
+                    break;
1402 1402
             }
1403 1403
         }
1404 1404
 
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 
126 126
         //For the ajaxUI, we need to use output buffering to return the page in an ajax friendly format
127 127
         if ($this->_getOption('json_output')){
128
-			ob_start();
129
-			if(!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
130
-				echo $this->_getModLanguageJS();
131
-			}
132
-		}
128
+            ob_start();
129
+            if(!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
130
+                echo $this->_getModLanguageJS();
131
+            }
132
+        }
133 133
 
134 134
         if ($this->_getOption('show_header')) {
135 135
             $this->displayHeader();
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
             $module = $this->module;
176 176
             $ajax_ret = array(
177 177
                 'content' => mb_detect_encoding($content) == "UTF-8" ? $content : utf8_encode($content),
178
-                 'menu' => array(
179
-                     'module' => $module,
180
-                     'label' => translate($module),
181
-                     $this->getMenu($module),
182
-                 ),
178
+                    'menu' => array(
179
+                        'module' => $module,
180
+                        'label' => translate($module),
181
+                        $this->getMenu($module),
182
+                    ),
183 183
                 'title' => $this->getBrowserTitle(),
184 184
                 'action' => isset($_REQUEST['action']) ? $_REQUEST['action'] : "",
185 185
                 'record' => isset($_REQUEST['record']) ? $_REQUEST['record'] : "",
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
                         "URL"   => current($attributevalue),
423 423
                         "SUBMENU" => array(),
424 424
                         );
425
-                   if(substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
426
-                       $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"],11);
427
-                       $gcls[$key]["URL"] = "javascript:void(0)";
428
-                   }
425
+                    if(substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
426
+                        $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"],11);
427
+                        $gcls[$key]["URL"] = "javascript:void(0)";
428
+                    }
429 429
                 }
430 430
                 // and now the sublinks
431 431
                 if ( $linkattribute == 'submenu' && is_array($attributevalue) ) {
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
                             "LABEL" => key($submenulinkinfo),
435 435
                             "URL"   => current($submenulinkinfo),
436 436
                         );
437
-                       if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438
-                           $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
439
-                           $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
440
-                       }
437
+                        if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
438
+                            $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
439
+                            $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
440
+                        }
441 441
                 }
442 442
             }
443 443
         }
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
             $ss->assign("shortcutExtraMenu",$shortcutExtraMenu);
666 666
         }
667 667
 
668
-       if(!empty($current_user)){
669
-       	$ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
670
-       }
668
+        if(!empty($current_user)){
669
+            $ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
670
+        }
671 671
 
672 672
 
673 673
         $imageURL = SugarThemeRegistry::current()->getImageURL("dashboard.png");
674 674
         $homeImage = "<img src='$imageURL'>";
675
-		$ss->assign("homeImage",$homeImage);
675
+        $ss->assign("homeImage",$homeImage);
676 676
         global $mod_strings;
677 677
         $mod_strings = $bakModStrings;
678 678
         $headerTpl = $themeObject->getTemplate('header.tpl');
@@ -777,12 +777,12 @@  discard block
 block discarded – undo
777 777
         list ($num_grp_sep, $dec_sep) = get_number_seperators();
778 778
 
779 779
         $the_script = "<script type=\"text/javascript\">\n" . "\tvar time_reg_format = '" .
780
-             $timereg['format'] . "';\n" . "\tvar date_reg_format = '" .
781
-             $datereg['format'] . "';\n" . "\tvar date_reg_positions = { $date_pos };\n" .
782
-             "\tvar time_separator = '$time_separator';\n" .
783
-             "\tvar cal_date_format = '$cal_date_format';\n" .
784
-             "\tvar time_offset = $hour_offset;\n" . "\tvar num_grp_sep = '$num_grp_sep';\n" .
785
-             "\tvar dec_sep = '$dec_sep';\n" . "</script>";
780
+                $timereg['format'] . "';\n" . "\tvar date_reg_format = '" .
781
+                $datereg['format'] . "';\n" . "\tvar date_reg_positions = { $date_pos };\n" .
782
+                "\tvar time_separator = '$time_separator';\n" .
783
+                "\tvar cal_date_format = '$cal_date_format';\n" .
784
+                "\tvar time_offset = $hour_offset;\n" . "\tvar num_grp_sep = '$num_grp_sep';\n" .
785
+                "\tvar dec_sep = '$dec_sep';\n" . "</script>";
786 786
 
787 787
         return $the_script;
788 788
     }
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
             }
848 848
             echo getVersionedScript('cache/jsLanguage/'. $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
849 849
 
850
-			echo $this->_getModLanguageJS();
850
+            echo $this->_getModLanguageJS();
851 851
 
852 852
             if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
853 853
                 echo getVersionedScript('modules/Sync/headersync.js');
@@ -863,13 +863,13 @@  discard block
 block discarded – undo
863 863
         }
864 864
     }
865 865
 
866
-	protected function _getModLanguageJS(){
867
-		if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) {
868
-			require_once ('include/language/jsLanguage.php');
869
-			jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']);
870
-		}
871
-		return getVersionedScript("cache/jsLanguage/{$this->module}/". $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
872
-	}
866
+    protected function _getModLanguageJS(){
867
+        if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) {
868
+            require_once ('include/language/jsLanguage.php');
869
+            jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']);
870
+        }
871
+        return getVersionedScript("cache/jsLanguage/{$this->module}/". $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
872
+    }
873 873
 
874 874
     /**
875 875
      * Called from process(). This method will display the footer on the page.
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
         global $sugar_config;
883 883
         global $app_strings;
884 884
         global $mod_strings;
885
-		$themeObject = SugarThemeRegistry::current();
885
+        $themeObject = SugarThemeRegistry::current();
886 886
         //decide whether or not to show themepicker, default is to show
887 887
         $showThemePicker = true;
888 888
         if (isset($sugar_config['showThemePicker'])) {
@@ -893,30 +893,30 @@  discard block
 block discarded – undo
893 893
         $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
894 894
         $ss->assign('MOD',return_module_language($GLOBALS['current_language'], 'Users'));
895 895
 
896
-		$bottomLinkList = array();
897
-		 if (isset($this->action) && $this->action != "EditView") {
898
-			 $bottomLinkList['print'] = array($app_strings['LNK_PRINT'] => getPrintLink());
899
-		}
900
-		$bottomLinkList['backtotop'] = array($app_strings['LNK_BACKTOTOP'] => 'javascript:SUGAR.util.top();');
901
-
902
-		$bottomLinksStr = "";
903
-		foreach($bottomLinkList as $key => $value) {
904
-			foreach($value as $text => $link) {
905
-				   $href = $link;
906
-				   if(substr($link, 0, 11) == "javascript:") {
907
-                       $onclick = " onclick=\"".substr($link,11)."\"";
908
-                       $href = "javascript:void(0)";
909
-                   } else {
910
-                   		$onclick = "";
911
-                   	}
896
+        $bottomLinkList = array();
897
+            if (isset($this->action) && $this->action != "EditView") {
898
+                $bottomLinkList['print'] = array($app_strings['LNK_PRINT'] => getPrintLink());
899
+        }
900
+        $bottomLinkList['backtotop'] = array($app_strings['LNK_BACKTOTOP'] => 'javascript:SUGAR.util.top();');
901
+
902
+        $bottomLinksStr = "";
903
+        foreach($bottomLinkList as $key => $value) {
904
+            foreach($value as $text => $link) {
905
+                    $href = $link;
906
+                    if(substr($link, 0, 11) == "javascript:") {
907
+                        $onclick = " onclick=\"".substr($link,11)."\"";
908
+                        $href = "javascript:void(0)";
909
+                    } else {
910
+                            $onclick = "";
911
+                        }
912 912
                 $imageURL = SugarThemeRegistry::current()->getImageURL($key.'.gif');
913
-				$bottomLinksStr .= "<a href=\"{$href}\"";
914
-				$bottomLinksStr .= (isset($onclick)) ? $onclick : "";
915
-				$bottomLinksStr .= "><img src='{$imageURL}' alt=''>"; //keeping alt blank on purpose for 508 (text will be read instead)
916
-				$bottomLinksStr .= " ".$text."</a>";
917
-			}
918
-		}
919
-		$ss->assign("BOTTOMLINKS",$bottomLinksStr);
913
+                $bottomLinksStr .= "<a href=\"{$href}\"";
914
+                $bottomLinksStr .= (isset($onclick)) ? $onclick : "";
915
+                $bottomLinksStr .= "><img src='{$imageURL}' alt=''>"; //keeping alt blank on purpose for 508 (text will be read instead)
916
+                $bottomLinksStr .= " ".$text."</a>";
917
+            }
918
+        }
919
+        $ss->assign("BOTTOMLINKS",$bottomLinksStr);
920 920
         if (SugarConfig::getInstance()->get('calculate_response_time', false))
921 921
             $ss->assign('STATISTICS',$this->_getStatistics());
922 922
 
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
         $attribLinkImg = "<img style='margin-top: 2px' border='0' width='120' height='34' src='include/images/poweredby_sugarcrm_65.png' alt='Powered By SugarCRM'>\n";
947 947
 
948 948
 
949
-		// handle resizing of the company logo correctly on the fly
949
+        // handle resizing of the company logo correctly on the fly
950 950
         $companyLogoURL = $themeObject->getImageURL('company_logo.png');
951 951
         $companyLogoURL_arr = explode('?', $companyLogoURL);
952 952
         $companyLogoURL = $companyLogoURL_arr[0];
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 
1070 1070
 
1071 1071
         $trackerManager = TrackerManager::getInstance();
1072
-	    $trackerManager->save();
1072
+        $trackerManager->save();
1073 1073
 
1074 1074
     }
1075 1075
 
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
         $deltaTime = $endTime - $GLOBALS['startTime'];
1110 1110
         $response_time_string = $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME'] . ' ' . number_format(round($deltaTime, 2), 2) . ' ' . $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME_SECONDS'];
1111 1111
         $return = $response_time_string;
1112
-       // $return .= '<br />';
1112
+        // $return .= '<br />';
1113 1113
         if (!empty($GLOBALS['sugar_config']['show_page_resources'])) {
1114 1114
             // Print out the resources used in constructing the page.
1115 1115
             $included_files = get_included_files();
@@ -1170,8 +1170,8 @@  discard block
 block discarded – undo
1170 1170
             {
1171 1171
                 $data = array
1172 1172
                 (
1173
-                   !empty($this->module) ? $this->module : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1174
-                   !empty($this->action) ? $this->action : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1173
+                    !empty($this->module) ? $this->module : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1174
+                    !empty($this->action) ? $this->action : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1175 1175
                 );
1176 1176
 
1177 1177
                 $output = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_LOG_MESSAGE'], $data) . $newline;
@@ -1240,15 +1240,15 @@  discard block
 block discarded – undo
1240 1240
     }
1241 1241
 
1242 1242
     /**
1243
-    * Returns the module name which should be highlighted in the module menu
1243
+     * Returns the module name which should be highlighted in the module menu
1244 1244
      */
1245 1245
     protected function _getModuleTab()
1246 1246
     {
1247 1247
         global $app_list_strings, $moduleTabMap, $current_user;
1248 1248
 
1249
-		$userTabs = query_module_access_list($current_user);
1250
-		//If the home tab is in the user array use it as the default tab, otherwise use the first element in the tab array
1251
-		$defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1249
+        $userTabs = query_module_access_list($current_user);
1250
+        //If the home tab is in the user array use it as the default tab, otherwise use the first element in the tab array
1251
+        $defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1252 1252
 
1253 1253
         // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
1254 1254
         if ( !empty($_REQUEST['module_tab']) )
@@ -1264,17 +1264,17 @@  discard block
 block discarded – undo
1264 1264
         elseif ( !isset($app_list_strings['moduleList'][$this->module]) )
1265 1265
             return $defaultTab;
1266 1266
         elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" )
1267
-        	return $defaultTab;
1267
+            return $defaultTab;
1268 1268
         else
1269 1269
             return $this->module;
1270 1270
     }
1271 1271
 
1272
-   /**
1273
-    * Return the "breadcrumbs" to display at the top of the page
1274
-    *
1275
-    * @param  bool $show_help optional, true if we show the help links
1276
-    * @return HTML string containing breadcrumb title
1277
-    */
1272
+    /**
1273
+     * Return the "breadcrumbs" to display at the top of the page
1274
+     *
1275
+     * @param  bool $show_help optional, true if we show the help links
1276
+     * @return HTML string containing breadcrumb title
1277
+     */
1278 1278
     public function getModuleTitle(
1279 1279
         $show_help = true
1280 1280
         )
@@ -1288,13 +1288,13 @@  discard block
 block discarded – undo
1288 1288
         $params = $this->_getModuleTitleParams();
1289 1289
         $index = 0;
1290 1290
 
1291
-		if(SugarThemeRegistry::current()->directionality == "rtl") {
1292
-			$params = array_reverse($params);
1293
-		}
1294
-		if(count($params) > 1) {
1295
-			array_shift($params);
1296
-		}
1297
-		$count = count($params);
1291
+        if(SugarThemeRegistry::current()->directionality == "rtl") {
1292
+            $params = array_reverse($params);
1293
+        }
1294
+        if(count($params) > 1) {
1295
+            array_shift($params);
1296
+        }
1297
+        $count = count($params);
1298 1298
         $paramString = '';
1299 1299
         foreach($params as $parm){
1300 1300
             $index++;
@@ -1305,13 +1305,13 @@  discard block
 block discarded – undo
1305 1305
         }
1306 1306
 
1307 1307
         if(!empty($paramString)){
1308
-               $theTitle .= "<h2> $paramString </h2>";
1308
+                $theTitle .= "<h2> $paramString </h2>";
1309 1309
 
1310 1310
             if($this->type == "detail"){
1311 1311
                 $theTitle .= "<div class='favorite' record_id='" . $this->bean->id . "' module='" . $this->bean->module_dir . "'><div class='favorite_icon_outline'>" . SugarThemeRegistry::current()->getImage('favorite-star-outline','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div>
1312 1312
                                                     <div class='favorite_icon_fill'>" . SugarThemeRegistry::current()->getImage('favorite-star','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div></div>";
1313 1313
             }
1314
-           }
1314
+            }
1315 1315
 
1316 1316
         // bug 56131 - restore conditional so that link doesn't appear where it shouldn't
1317 1317
         if($show_help || $this->type == 'list') {
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
     protected function _getModuleTitleParams($browserTitle = false)
1385 1385
     {
1386 1386
         $params = array($this->_getModuleTitleListParam($browserTitle));
1387
-		//$params = array();
1387
+        //$params = array();
1388 1388
         if (isset($this->action)){
1389 1389
             switch ($this->action) {
1390 1390
             case 'EditView':
@@ -1414,48 +1414,48 @@  discard block
 block discarded – undo
1414 1414
      */
1415 1415
     protected function _getModuleTitleListParam( $browserTitle = false )
1416 1416
     {
1417
-    	global $current_user;
1418
-    	global $app_strings;
1419
-
1420
-    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1421
-    		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1422
-    	else
1423
-    		$firstParam = $this->module;
1424
-
1425
-    	$iconPath = $this->getModuleTitleIconPath($this->module);
1426
-    	if($this->action == "ListView" || $this->action == "index") {
1427
-    	    if (!empty($iconPath) && !$browserTitle) {
1428
-    	    	if (SugarThemeRegistry::current()->directionality == "ltr") {
1429
-    	    		return $app_strings['LBL_SEARCH']."&nbsp;"
1430
-    	    			 . "$firstParam";
1431
-
1432
-    	    	} else {
1433
-					return "$firstParam"
1434
-					     . "&nbsp;".$app_strings['LBL_SEARCH'];
1435
-    	    	}
1436
-			} else {
1437
-				return $firstParam;
1438
-			}
1439
-    	}
1440
-    	else {
1441
-		    if (!empty($iconPath) && !$browserTitle) {
1442
-				//return "<a href='index.php?module={$this->module}&action=index'>$this->module</a>";
1443
-			} else {
1444
-				return $firstParam;
1445
-			}
1446
-    	}
1417
+        global $current_user;
1418
+        global $app_strings;
1419
+
1420
+        if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1421
+            $firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1422
+        else
1423
+            $firstParam = $this->module;
1424
+
1425
+        $iconPath = $this->getModuleTitleIconPath($this->module);
1426
+        if($this->action == "ListView" || $this->action == "index") {
1427
+            if (!empty($iconPath) && !$browserTitle) {
1428
+                if (SugarThemeRegistry::current()->directionality == "ltr") {
1429
+                    return $app_strings['LBL_SEARCH']."&nbsp;"
1430
+                            . "$firstParam";
1431
+
1432
+                } else {
1433
+                    return "$firstParam"
1434
+                            . "&nbsp;".$app_strings['LBL_SEARCH'];
1435
+                }
1436
+            } else {
1437
+                return $firstParam;
1438
+            }
1439
+        }
1440
+        else {
1441
+            if (!empty($iconPath) && !$browserTitle) {
1442
+                //return "<a href='index.php?module={$this->module}&action=index'>$this->module</a>";
1443
+            } else {
1444
+                return $firstParam;
1445
+            }
1446
+        }
1447 1447
     }
1448 1448
 
1449 1449
     protected function getModuleTitleIconPath($module)
1450 1450
     {
1451
-    	$iconPath = "";
1452
-    	if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1453
-    		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1454
-    	}
1455
-    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1456
-    		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1457
-    	}
1458
-    	return $iconPath;
1451
+        $iconPath = "";
1452
+        if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1453
+            $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1454
+        }
1455
+        else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1456
+            $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1457
+        }
1458
+        return $iconPath;
1459 1459
     }
1460 1460
 
1461 1461
     /**
@@ -1485,11 +1485,11 @@  discard block
 block discarded – undo
1485 1485
      */
1486 1486
     public function getBreadCrumbSymbol()
1487 1487
     {
1488
-    	if(SugarThemeRegistry::current()->directionality == "ltr") {
1489
-        	return "<span class='pointer'>&raquo;</span>";
1488
+        if(SugarThemeRegistry::current()->directionality == "ltr") {
1489
+            return "<span class='pointer'>&raquo;</span>";
1490 1490
         }
1491 1491
         else {
1492
-        	return "<span class='pointer'>&laquo;</span>";
1492
+            return "<span class='pointer'>&laquo;</span>";
1493 1493
         }
1494 1494
     }
1495 1495
 
@@ -1658,20 +1658,20 @@  discard block
 block discarded – undo
1658 1658
     }
1659 1659
 
1660 1660
     /**
1661
-	 * Determines whether the state of the post global array indicates there was an error uploading a
1661
+     * Determines whether the state of the post global array indicates there was an error uploading a
1662 1662
      * file that exceeds the post_max_size setting.  Such an error can be detected if:
1663 1663
      *  1. The Server['REQUEST_METHOD'] will still point to POST
1664 1664
      *  2. POST and FILES global arrays will be returned empty despite the request method
1665 1665
      * This also results in a redirect to the home page (due to lack of module and action in POST)
1666 1666
      *
1667
-	 * @return boolean indicating true or false
1668
-	 */
1667
+     * @return boolean indicating true or false
1668
+     */
1669 1669
     public function checkPostMaxSizeError(){
1670
-         //if the referrer is post, and the post array is empty, then an error has occurred, most likely
1671
-         //while uploading a file that exceeds the post_max_size.
1672
-         if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
1673
-             $GLOBALS['log']->fatal($GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT']);
1674
-             return true;
1670
+            //if the referrer is post, and the post array is empty, then an error has occurred, most likely
1671
+            //while uploading a file that exceeds the post_max_size.
1672
+            if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
1673
+                $GLOBALS['log']->fatal($GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT']);
1674
+                return true;
1675 1675
         }
1676 1676
         return false;
1677 1677
     }
Please login to merge, or discard this patch.
Spacing   +230 added lines, -231 removed lines patch added patch discarded remove patch
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function SugarView($bean = null,
100 100
         $view_object_map = array()
101
-        ){
101
+        ) {
102 102
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
103
-        if(isset($GLOBALS['log'])) {
103
+        if (isset($GLOBALS['log'])) {
104 104
             $GLOBALS['log']->deprecated($deprecatedMessage);
105 105
         }
106 106
         else {
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
         $this->_trackView();
142 142
 
143 143
         //For the ajaxUI, we need to use output buffering to return the page in an ajax friendly format
144
-        if ($this->_getOption('json_output')){
144
+        if ($this->_getOption('json_output')) {
145 145
 			ob_start();
146
-			if(!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
146
+			if (!empty($_REQUEST['ajax_load']) && !empty($_REQUEST['loadLanguageJS'])) {
147 147
 				echo $this->_getModLanguageJS();
148 148
 			}
149 149
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         $this->preDisplay();
159 159
         $this->displayErrors();
160 160
         $this->display();
161
-        if ( !empty($this->module) ) {
161
+        if (!empty($this->module)) {
162 162
             $GLOBALS['logic_hook']->call_custom_logic($this->module, 'after_ui_frame');
163 163
         } else {
164 164
             $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_frame');
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
                 'favicon' => $this->getFavicon(),
204 204
             );
205 205
 
206
-            if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic)
206
+            if (SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic)
207 207
                 $ajax_ret['moduleList'] = $this->displayHeader(true);
208 208
 
209
-            if(empty($this->responseTime))
209
+            if (empty($this->responseTime))
210 210
                 $this->_calculateFooterMetrics();
211 211
             $ajax_ret['responseTime'] = $this->responseTime;
212 212
             $json = getJSONobj();
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
     {
226 226
         $errors = '';
227 227
 
228
-        foreach($this->errors as $error) {
229
-            $errors .= '<span class="error">' . $error . '</span><br>';
228
+        foreach ($this->errors as $error) {
229
+            $errors .= '<span class="error">'.$error.'</span><br>';
230 230
         }
231 231
 
232
-        if ( !$this->suppressDisplayErrors ) {
232
+        if (!$this->suppressDisplayErrors) {
233 233
             echo $errors;
234 234
         }
235 235
         else {
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
     {
267 267
         $action = strtolower($this->action);
268 268
         //Skip save, tracked in SugarBean instead
269
-        if($action == 'save') {
269
+        if ($action == 'save') {
270 270
         return;
271 271
         }
272 272
 
273 273
 
274 274
         $trackerManager = TrackerManager::getInstance();
275 275
         $timeStamp = TimeDate::getInstance()->nowDb();
276
-        if($monitor = $trackerManager->getMonitor('tracker')){
276
+        if ($monitor = $trackerManager->getMonitor('tracker')) {
277 277
             $monitor->setValue('action', $action);
278 278
             $monitor->setValue('user_id', $GLOBALS['current_user']->id);
279 279
             $monitor->setValue('module_name', $this->module);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
             //If visible is true, but there is no bean, do not track (invalid/unauthorized reference)
290 290
             //Also, do not track save actions where there is no bean id
291
-            if($monitor->visible && empty($this->bean->id)) {
291
+            if ($monitor->visible && empty($this->bean->id)) {
292 292
             $trackerManager->unsetMonitor($monitor);
293 293
             return;
294 294
             }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     /**
301 301
      * Displays the header on section of the page; basically everything before the content
302 302
      */
303
-    public function displayHeader($retModTabs=false)
303
+    public function displayHeader($retModTabs = false)
304 304
     {
305 305
         global $theme;
306 306
         global $max_tabs;
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         $ss->assign("APP", $app_strings);
321 321
         $ss->assign("THEME", $theme);
322 322
         $ss->assign("THEME_CONFIG", $themeObject->getConfig());
323
-        $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true':'false');
323
+        $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false');
324 324
         $ss->assign("MODULE_NAME", $this->module);
325 325
         $ss->assign("langHeader", get_language_header());
326 326
 
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
         if ($this->_getOption('view_print')) {
337 337
             $css .= '<link rel="stylesheet" type="text/css" href="'.$themeObject->getCSSURL('print.css').'" media="all" />';
338 338
         }
339
-        $ss->assign("SUGAR_CSS",$css);
339
+        $ss->assign("SUGAR_CSS", $css);
340 340
 
341 341
         // get javascript
342 342
         ob_start();
343 343
         $this->renderJavascript();
344 344
 
345
-        $ss->assign("SUGAR_JS",ob_get_contents().$themeObject->getJS());
345
+        $ss->assign("SUGAR_JS", ob_get_contents().$themeObject->getJS());
346 346
         ob_end_clean();
347 347
 
348 348
         // get favicon
349
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
349
+        if (isset($GLOBALS['sugar_config']['default_module_favicon']))
350 350
             $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
351 351
         else
352 352
             $module_favicon = false;
@@ -356,24 +356,24 @@  discard block
 block discarded – undo
356 356
 
357 357
         // build the shortcut menu
358 358
         $shortcut_menu = array();
359
-        foreach ( $this->getMenu() as $key => $menu_item )
359
+        foreach ($this->getMenu() as $key => $menu_item)
360 360
             $shortcut_menu[$key] = array(
361 361
                 "URL"         => $menu_item[0],
362 362
                 "LABEL"       => $menu_item[1],
363 363
                 "MODULE_NAME" => $menu_item[2],
364 364
                 "IMAGE"       => $themeObject
365
-                    ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
365
+                    ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
366 366
                 );
367
-        $ss->assign("SHORTCUT_MENU",$shortcut_menu);
367
+        $ss->assign("SHORTCUT_MENU", $shortcut_menu);
368 368
 
369 369
         // handle rtl text direction
370
-        if(isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL'){
370
+        if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
371 371
             $_SESSION['RTL'] = true;
372 372
         }
373
-        if(isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR'){
373
+        if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
374 374
             unset($_SESSION['RTL']);
375 375
         }
376
-        if(isset($_SESSION['RTL']) && $_SESSION['RTL']){
376
+        if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
377 377
             $ss->assign("DIR", 'dir="RTL"');
378 378
         }
379 379
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
         $companyLogoURL = $companyLogoURL_arr[0];
384 384
 
385 385
         $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
386
-        if(!empty($company_logo_attributes)) {
386
+        if (!empty($company_logo_attributes)) {
387 387
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
388 388
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
389 389
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
@@ -392,16 +392,16 @@  discard block
 block discarded – undo
392 392
             // Always need to md5 the file
393 393
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
394 394
 
395
-            list($width,$height) = getimagesize($companyLogoURL);
396
-            if ( $width > 212 || $height > 40 ) {
397
-                $resizePctWidth  = ($width - 212)/212;
398
-                $resizePctHeight = ($height - 40)/40;
399
-                if ( $resizePctWidth > $resizePctHeight )
395
+            list($width, $height) = getimagesize($companyLogoURL);
396
+            if ($width > 212 || $height > 40) {
397
+                $resizePctWidth  = ($width - 212) / 212;
398
+                $resizePctHeight = ($height - 40) / 40;
399
+                if ($resizePctWidth > $resizePctHeight)
400 400
                     $resizeAmount = $width / 212;
401 401
                 else
402 402
                     $resizeAmount = $height / 40;
403
-                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
404
-                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
403
+                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
404
+                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
405 405
             }
406 406
             else {
407 407
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
@@ -417,110 +417,110 @@  discard block
 block discarded – undo
417 417
                                 )
418 418
             );
419 419
         }
420
-        $ss->assign("COMPANY_LOGO_URL",getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
420
+        $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
421 421
 
422 422
         // get the global links
423 423
         $gcls = array();
424 424
         $global_control_links = array();
425 425
         require("include/globalControlLinks.php");
426 426
 
427
-        foreach($global_control_links as $key => $value) {
428
-            if ($key == 'users')  {   //represents logout link.
427
+        foreach ($global_control_links as $key => $value) {
428
+            if ($key == 'users') {   //represents logout link.
429 429
                 $ss->assign("LOGOUT_LINK", $value['linkinfo'][key($value['linkinfo'])]);
430
-                $ss->assign("LOGOUT_LABEL", key($value['linkinfo']));//key value for first element.
430
+                $ss->assign("LOGOUT_LABEL", key($value['linkinfo'])); //key value for first element.
431 431
                 continue;
432 432
             }
433 433
 
434 434
             foreach ($value as $linkattribute => $attributevalue) {
435 435
                 // get the main link info
436
-                if ( $linkattribute == 'linkinfo' ) {
436
+                if ($linkattribute == 'linkinfo') {
437 437
                     $gcls[$key] = array(
438 438
                         "LABEL" => key($attributevalue),
439 439
                         "URL"   => current($attributevalue),
440 440
                         "SUBMENU" => array(),
441 441
                         );
442
-                   if(substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
443
-                       $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"],11);
442
+                   if (substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
443
+                       $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"], 11);
444 444
                        $gcls[$key]["URL"] = "javascript:void(0)";
445 445
                    }
446 446
                 }
447 447
                 // and now the sublinks
448
-                if ( $linkattribute == 'submenu' && is_array($attributevalue) ) {
448
+                if ($linkattribute == 'submenu' && is_array($attributevalue)) {
449 449
                     foreach ($attributevalue as $submenulinkkey => $submenulinkinfo)
450 450
                         $gcls[$key]['SUBMENU'][$submenulinkkey] = array(
451 451
                             "LABEL" => key($submenulinkinfo),
452 452
                             "URL"   => current($submenulinkinfo),
453 453
                         );
454
-                       if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
455
-                           $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
454
+                       if (substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
455
+                           $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 11);
456 456
                            $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
457 457
                        }
458 458
                 }
459 459
             }
460 460
         }
461
-        $ss->assign("GCLS",$gcls);
461
+        $ss->assign("GCLS", $gcls);
462 462
 
463 463
         $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : '');
464 464
 
465 465
         if ($this->action == "EditView" || $this->action == "Login")
466 466
             $ss->assign("ONLOAD", 'onload="set_focus()"');
467 467
 
468
-        $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
468
+        $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
469 469
 
470 470
         // get other things needed for page style popup
471 471
         if (isset($_SESSION["authenticated_user_id"])) {
472 472
             // get the current user name and id
473 473
             $ss->assign("CURRENT_USER", $current_user->full_name == '' || !showFullName()
474
-                ? $current_user->user_name : $current_user->full_name );
474
+                ? $current_user->user_name : $current_user->full_name);
475 475
             $ss->assign("CURRENT_USER_ID", $current_user->id);
476 476
 
477 477
             // get the last viewed records
478 478
             require_once("modules/Favorites/Favorites.php");
479 479
             $favorites = new Favorites();
480 480
             $favorite_records = $favorites->getCurrentUserSidebarFavorites();
481
-            $ss->assign("favoriteRecords",$favorite_records);
481
+            $ss->assign("favoriteRecords", $favorite_records);
482 482
 
483 483
             $tracker = new Tracker();
484 484
             $history = $tracker->get_recently_viewed($current_user->id);
485
-            $ss->assign("recentRecords",$this->processRecentRecords($history));
485
+            $ss->assign("recentRecords", $this->processRecentRecords($history));
486 486
         }
487 487
 
488 488
         $bakModStrings = $mod_strings;
489
-        if (isset($_SESSION["authenticated_user_id"]) ) {
489
+        if (isset($_SESSION["authenticated_user_id"])) {
490 490
             // get the module list
491 491
             $moduleTopMenu = array();
492 492
 
493 493
             $max_tabs = $current_user->getPreference('max_tabs');
494 494
             // Attempt to correct if max tabs count is extremely high.
495
-            if ( !isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10 ) {
495
+            if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
496 496
                 $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
497 497
                 $current_user->setPreference('max_tabs', $max_tabs, 0, 'global');
498 498
             }
499 499
 
500 500
             $moduleTab = $this->_getModuleTab();
501
-            $ss->assign('MODULE_TAB',$moduleTab);
501
+            $ss->assign('MODULE_TAB', $moduleTab);
502 502
 
503 503
 
504 504
             // See if they are using grouped tabs or not (removed in 6.0, returned in 6.1)
505 505
             $user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
506
-            if ( !isset($user_navigation_paradigm) ) {
506
+            if (!isset($user_navigation_paradigm)) {
507 507
                 $user_navigation_paradigm = $GLOBALS['sugar_config']['default_navigation_paradigm'];
508 508
             }
509 509
 
510 510
 
511 511
             // Get the full module list for later use
512
-            foreach ( query_module_access_list($current_user) as $module ) {
512
+            foreach (query_module_access_list($current_user) as $module) {
513 513
                 // Bug 25948 - Check for the module being in the moduleList
514
-                if ( isset($app_list_strings['moduleList'][$module]) ) {
514
+                if (isset($app_list_strings['moduleList'][$module])) {
515 515
                     $fullModuleList[$module] = $app_list_strings['moduleList'][$module];
516 516
                 }
517 517
             }
518 518
 
519 519
 
520
-            if(!should_hide_iframes()) {
520
+            if (!should_hide_iframes()) {
521 521
                 $iFrame = new iFrame();
522 522
                 $frames = $iFrame->lookup_frames('tab');
523
-                foreach($frames as $key => $values){
523
+                foreach ($frames as $key => $values) {
524 524
                         $fullModuleList[$key] = $values;
525 525
                 }
526 526
             }
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                 unset($fullModuleList['iFrames']);
529 529
             }
530 530
 
531
-            if ( $user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
531
+            if ($user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
532 532
                 // We are using grouped tabs
533 533
                 require_once('include/GroupedTabs/GroupedTabStructure.php');
534 534
                 $groupedTabsClass = new GroupedTabStructure();
@@ -536,12 +536,12 @@  discard block
 block discarded – undo
536 536
                 //handle with submoremodules
537 537
                 $max_tabs = $current_user->getPreference('max_tabs');
538 538
                 // If the max_tabs isn't set incorrectly, set it within the range, to the default max sub tabs size
539
-                if ( !isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10){
539
+                if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
540 540
                     // We have a default value. Use it
541
-                    if(isset($GLOBALS['sugar_config']['default_max_tabs'])){
541
+                    if (isset($GLOBALS['sugar_config']['default_max_tabs'])) {
542 542
                         $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
543 543
                     }
544
-                    else{
544
+                    else {
545 545
                         $max_tabs = 8;
546 546
                     }
547 547
                 }
@@ -554,22 +554,22 @@  discard block
 block discarded – undo
554 554
 
555 555
                 // Setup the default group tab.
556 556
                 $allGroup = $app_strings['LBL_TABGROUP_ALL'];
557
-                $ss->assign('currentGroupTab',$allGroup);
557
+                $ss->assign('currentGroupTab', $allGroup);
558 558
                 $currentGroupTab = $allGroup;
559 559
                 $usersGroup = $current_user->getPreference('theme_current_group');
560 560
                 // Figure out which tab they currently have selected (stored as a user preference)
561
-                if ( !empty($usersGroup) && isset($groupTabs[$usersGroup]) ) {
561
+                if (!empty($usersGroup) && isset($groupTabs[$usersGroup])) {
562 562
                     $currentGroupTab = $usersGroup;
563 563
                 } else {
564
-                    $current_user->setPreference('theme_current_group',$currentGroupTab);
564
+                    $current_user->setPreference('theme_current_group', $currentGroupTab);
565 565
                 }
566 566
 
567
-                $ss->assign('currentGroupTab',$currentGroupTab);
567
+                $ss->assign('currentGroupTab', $currentGroupTab);
568 568
                 $usingGroupTabs = true;
569 569
 
570 570
             } else {
571 571
                 // Setup the default group tab.
572
-                $ss->assign('currentGroupTab',$app_strings['LBL_TABGROUP_ALL']);
572
+                $ss->assign('currentGroupTab', $app_strings['LBL_TABGROUP_ALL']);
573 573
 
574 574
                 $usingGroupTabs = false;
575 575
 
@@ -581,31 +581,31 @@  discard block
 block discarded – undo
581 581
             $topTabList = array();
582 582
 
583 583
             // Now time to go through each of the tab sets and fix them up.
584
-            foreach ( $groupTabs as $tabIdx => $tabData ) {
584
+            foreach ($groupTabs as $tabIdx => $tabData) {
585 585
                 $topTabs = $tabData['modules'];
586
-                if ( ! is_array($topTabs) ) {
586
+                if (!is_array($topTabs)) {
587 587
                     $topTabs = array();
588 588
                 }
589 589
                 $extraTabs = array();
590 590
 
591 591
                 // Split it in to the tabs that go across the top, and the ones that are on the extra menu.
592
-                if ( count($topTabs) > $max_tabs ) {
593
-                    $extraTabs = array_splice($topTabs,$max_tabs);
592
+                if (count($topTabs) > $max_tabs) {
593
+                    $extraTabs = array_splice($topTabs, $max_tabs);
594 594
                 }
595 595
                 // Make sure the current module is accessable through one of the top tabs
596
-                if ( !isset($topTabs[$moduleTab]) ) {
596
+                if (!isset($topTabs[$moduleTab])) {
597 597
                     // Nope, we need to add it.
598 598
                     // First, take it out of the extra menu, if it's there
599
-                    if ( isset($extraTabs[$moduleTab]) ) {
599
+                    if (isset($extraTabs[$moduleTab])) {
600 600
                         unset($extraTabs[$moduleTab]);
601 601
                     }
602
-                    if ( count($topTabs) >= $max_tabs - 1 ) {
602
+                    if (count($topTabs) >= $max_tabs - 1) {
603 603
                         // We already have the maximum number of tabs, so we need to shuffle the last one
604 604
                         // from the top to the first one of the extras
605
-                        $lastElem = array_splice($topTabs,$max_tabs-1);
605
+                        $lastElem = array_splice($topTabs, $max_tabs - 1);
606 606
                         $extraTabs = $lastElem + $extraTabs;
607 607
                     }
608
-                    if ( !empty($moduleTab) ) {
608
+                    if (!empty($moduleTab)) {
609 609
                         $topTabs[$moduleTab] = $app_list_strings['moduleList'][$moduleTab];
610 610
                     }
611 611
                 }
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                 */
625 625
 
626 626
                 // Get a unique list of the top tabs so we can build the popup menus for them
627
-                foreach ( $topTabs as $moduleKey => $module ) {
627
+                foreach ($topTabs as $moduleKey => $module) {
628 628
                     $topTabList[$moduleKey] = $module;
629 629
                 }
630 630
 
@@ -633,67 +633,67 @@  discard block
 block discarded – undo
633 633
             }
634 634
         }
635 635
 
636
-        if ( isset($topTabList) && is_array($topTabList) ) {
636
+        if (isset($topTabList) && is_array($topTabList)) {
637 637
             // Adding shortcuts array to menu array for displaying shortcuts associated with each module
638 638
             $shortcutTopMenu = array();
639
-            foreach($topTabList as $module_key => $label) {
639
+            foreach ($topTabList as $module_key => $label) {
640 640
                 global $mod_strings;
641 641
                 $mod_strings = return_module_language($current_language, $module_key);
642
-                foreach ( $this->getMenu($module_key) as $key => $menu_item ) {
642
+                foreach ($this->getMenu($module_key) as $key => $menu_item) {
643 643
                     $shortcutTopMenu[$module_key][$key] = array(
644 644
                         "URL"         => $menu_item[0],
645 645
                         "LABEL"       => $menu_item[1],
646 646
                         "MODULE_NAME" => $menu_item[2],
647 647
                         "IMAGE"       => $themeObject
648
-                        ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
648
+                        ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
649 649
                         "ID"          => $menu_item[2]."_link",
650 650
                         );
651 651
                 }
652 652
             }
653
-            if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true);
654
-            $ss->assign("groupTabs",$groupTabs);
655
-            $ss->assign("shortcutTopMenu",$shortcutTopMenu);
656
-            $ss->assign('USE_GROUP_TABS',$usingGroupTabs);
653
+            if (!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true);
654
+            $ss->assign("groupTabs", $groupTabs);
655
+            $ss->assign("shortcutTopMenu", $shortcutTopMenu);
656
+            $ss->assign('USE_GROUP_TABS', $usingGroupTabs);
657 657
 
658 658
             // This is here for backwards compatibility, someday, somewhere, it will be able to be removed
659
-            $ss->assign("moduleTopMenu",$groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
660
-            $ss->assign("moduleExtraMenu",$groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
659
+            $ss->assign("moduleTopMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
660
+            $ss->assign("moduleExtraMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
661 661
 
662 662
 
663 663
         }
664 664
 
665
-        if ( isset($extraTabs) && is_array($extraTabs) ) {
665
+        if (isset($extraTabs) && is_array($extraTabs)) {
666 666
             // Adding shortcuts array to extra menu array for displaying shortcuts associated with each module
667 667
             $shortcutExtraMenu = array();
668
-            foreach($extraTabs as $module_key => $label) {
668
+            foreach ($extraTabs as $module_key => $label) {
669 669
                 global $mod_strings;
670 670
                 $mod_strings = return_module_language($current_language, $module_key);
671
-                foreach ( $this->getMenu($module_key) as $key => $menu_item ) {
671
+                foreach ($this->getMenu($module_key) as $key => $menu_item) {
672 672
                     $shortcutExtraMenu[$module_key][$key] = array(
673 673
                         "URL"         => $menu_item[0],
674 674
                         "LABEL"       => $menu_item[1],
675 675
                         "MODULE_NAME" => $menu_item[2],
676 676
                         "IMAGE"       => $themeObject
677
-                        ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
677
+                        ->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]),
678 678
                         "ID"          => $menu_item[2]."_link",
679 679
                         );
680 680
                 }
681 681
             }
682
-            $ss->assign("shortcutExtraMenu",$shortcutExtraMenu);
682
+            $ss->assign("shortcutExtraMenu", $shortcutExtraMenu);
683 683
         }
684 684
 
685
-       if(!empty($current_user)){
685
+       if (!empty($current_user)) {
686 686
        	$ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
687 687
        }
688 688
 
689 689
 
690 690
         $imageURL = SugarThemeRegistry::current()->getImageURL("dashboard.png");
691 691
         $homeImage = "<img src='$imageURL'>";
692
-		$ss->assign("homeImage",$homeImage);
692
+		$ss->assign("homeImage", $homeImage);
693 693
         global $mod_strings;
694 694
         $mod_strings = $bakModStrings;
695 695
         $headerTpl = $themeObject->getTemplate('header.tpl');
696
-        if (inDeveloperMode() )
696
+        if (inDeveloperMode())
697 697
             $ss->clear_compiled_tpl($headerTpl);
698 698
 
699 699
         if ($retModTabs)
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
             $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
706 706
 
707 707
             $errorMessages = SugarApplication::getErrorMessages();
708
-            if ( !empty($errorMessages)) {
709
-                foreach ( $errorMessages as $error_message ) {
710
-                    echo('<p class="error">' . $error_message.'</p>');
708
+            if (!empty($errorMessages)) {
709
+                foreach ($errorMessages as $error_message) {
710
+                    echo('<p class="error">'.$error_message.'</p>');
711 711
                 }
712 712
             }
713 713
         }
@@ -742,13 +742,13 @@  discard block
 block discarded – undo
742 742
     {
743 743
         global $sugar_config, $timedate;
744 744
 
745
-        if(isset($this->bean->module_dir)){
745
+        if (isset($this->bean->module_dir)) {
746 746
             echo "<script>var module_sugar_grp1 = '{$this->bean->module_dir}';</script>";
747 747
         }
748
-        if(isset($_REQUEST['action'])){
748
+        if (isset($_REQUEST['action'])) {
749 749
             echo "<script>var action_sugar_grp1 = '{$_REQUEST['action']}';</script>";
750 750
         }
751
-        echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
751
+        echo '<script>jscal_today = 1000*'.$timedate->asUserTs($timedate->getNow()).'; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
752 752
         if (!is_file(sugar_cached("include/javascript/sugar_grp1.js"))) {
753 753
             $_REQUEST['root_directory'] = ".";
754 754
             require_once("jssource/minify_utils.php");
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
             if ( typeof(SUGAR.themes) == 'undefined' ) SUGAR.themes = {};
765 765
         </script>
766 766
 EOQ;
767
-        if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
767
+        if (isset($sugar_config['disc_client']) && $sugar_config['disc_client'])
768 768
             echo getVersionedScript('modules/Sync/headersync.js');
769 769
     }
770 770
 
@@ -793,13 +793,13 @@  discard block
 block discarded – undo
793 793
         require_once ('modules/Currencies/Currency.php');
794 794
         list ($num_grp_sep, $dec_sep) = get_number_seperators();
795 795
 
796
-        $the_script = "<script type=\"text/javascript\">\n" . "\tvar time_reg_format = '" .
797
-             $timereg['format'] . "';\n" . "\tvar date_reg_format = '" .
798
-             $datereg['format'] . "';\n" . "\tvar date_reg_positions = { $date_pos };\n" .
799
-             "\tvar time_separator = '$time_separator';\n" .
800
-             "\tvar cal_date_format = '$cal_date_format';\n" .
801
-             "\tvar time_offset = $hour_offset;\n" . "\tvar num_grp_sep = '$num_grp_sep';\n" .
802
-             "\tvar dec_sep = '$dec_sep';\n" . "</script>";
796
+        $the_script = "<script type=\"text/javascript\">\n"."\tvar time_reg_format = '".
797
+             $timereg['format']."';\n"."\tvar date_reg_format = '".
798
+             $datereg['format']."';\n"."\tvar date_reg_positions = { $date_pos };\n".
799
+             "\tvar time_separator = '$time_separator';\n".
800
+             "\tvar cal_date_format = '$cal_date_format';\n".
801
+             "\tvar time_offset = $hour_offset;\n"."\tvar num_grp_sep = '$num_grp_sep';\n".
802
+             "\tvar dec_sep = '$dec_sep';\n"."</script>";
803 803
 
804 804
         return $the_script;
805 805
     }
@@ -827,13 +827,13 @@  discard block
 block discarded – undo
827 827
                 "sugar_cache_dir" => "cache/",
828 828
                 );
829 829
 
830
-            if(isset($this->bean->module_dir)){
830
+            if (isset($this->bean->module_dir)) {
831 831
                 $js_vars['module_sugar_grp1'] = $this->bean->module_dir;
832 832
             }
833
-            if(isset($_REQUEST['action'])){
833
+            if (isset($_REQUEST['action'])) {
834 834
                 $js_vars['action_sugar_grp1'] = $_REQUEST['action'];
835 835
             }
836
-            echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
836
+            echo '<script>jscal_today = 1000*'.$timedate->asUserTs($timedate->getNow()).'; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
837 837
             if (!is_file(sugar_cached("include/javascript/sugar_grp1.js")) || !is_file(sugar_cached("include/javascript/sugar_grp1_yui.js")) || !is_file(sugar_cached("include/javascript/sugar_grp1_jquery.js"))) {
838 838
                 $_REQUEST['root_directory'] = ".";
839 839
                 require_once("jssource/minify_utils.php");
@@ -846,33 +846,33 @@  discard block
 block discarded – undo
846 846
 
847 847
             // output necessary config js in the top of the page
848 848
             $config_js = $this->getSugarConfigJS();
849
-            if(!empty($config_js)){
849
+            if (!empty($config_js)) {
850 850
                 echo "<script>\n".implode("\n", $config_js)."</script>\n";
851 851
             }
852 852
 
853
-            if ( isset($sugar_config['email_sugarclient_listviewmaxselect']) ) {
853
+            if (isset($sugar_config['email_sugarclient_listviewmaxselect'])) {
854 854
                 echo "<script>SUGAR.config.email_sugarclient_listviewmaxselect = {$GLOBALS['sugar_config']['email_sugarclient_listviewmaxselect']};</script>";
855 855
             }
856 856
 
857
-            $image_server = (defined('TEMPLATE_URL'))?TEMPLATE_URL . '/':'';
858
-            echo '<script type="text/javascript">SUGAR.themes.image_server="' . $image_server . '";</script>'; // cn: bug 12274 - create session-stored key to defend against CSRF
859
-            echo '<script type="text/javascript">var name_format = "' . $locale->getLocaleFormatMacro() . '";</script>';
857
+            $image_server = (defined('TEMPLATE_URL')) ? TEMPLATE_URL.'/' : '';
858
+            echo '<script type="text/javascript">SUGAR.themes.image_server="'.$image_server.'";</script>'; // cn: bug 12274 - create session-stored key to defend against CSRF
859
+            echo '<script type="text/javascript">var name_format = "'.$locale->getLocaleFormatMacro().'";</script>';
860 860
             echo self::getJavascriptValidation();
861
-            if (!is_file(sugar_cached('jsLanguage/') . $GLOBALS['current_language'] . '.js')) {
861
+            if (!is_file(sugar_cached('jsLanguage/').$GLOBALS['current_language'].'.js')) {
862 862
                 require_once ('include/language/jsLanguage.php');
863 863
                 jsLanguage::createAppStringsCache($GLOBALS['current_language']);
864 864
             }
865
-            echo getVersionedScript('cache/jsLanguage/'. $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
865
+            echo getVersionedScript('cache/jsLanguage/'.$GLOBALS['current_language'].'.js', $GLOBALS['sugar_config']['js_lang_version']);
866 866
 
867 867
 			echo $this->_getModLanguageJS();
868 868
 
869
-            if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
869
+            if (isset($sugar_config['disc_client']) && $sugar_config['disc_client'])
870 870
                 echo getVersionedScript('modules/Sync/headersync.js');
871 871
 
872 872
 
873 873
             //echo out the $js_vars variables as javascript variables
874 874
             echo "<script type='text/javascript'>\n";
875
-            foreach($js_vars as $var=>$value)
875
+            foreach ($js_vars as $var=>$value)
876 876
             {
877 877
                 echo "var {$var} = '{$value}';\n";
878 878
             }
@@ -880,12 +880,12 @@  discard block
 block discarded – undo
880 880
         }
881 881
     }
882 882
 
883
-	protected function _getModLanguageJS(){
884
-		if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) {
883
+	protected function _getModLanguageJS() {
884
+		if (!is_file(sugar_cached('jsLanguage/').$this->module.'/'.$GLOBALS['current_language'].'.js')) {
885 885
 			require_once ('include/language/jsLanguage.php');
886 886
 			jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']);
887 887
 		}
888
-		return getVersionedScript("cache/jsLanguage/{$this->module}/". $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
888
+		return getVersionedScript("cache/jsLanguage/{$this->module}/".$GLOBALS['current_language'].'.js', $GLOBALS['sugar_config']['js_lang_version']);
889 889
 	}
890 890
 
891 891
     /**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
         }
908 908
 
909 909
         $ss = new Sugar_Smarty();
910
-        $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
911
-        $ss->assign('MOD',return_module_language($GLOBALS['current_language'], 'Users'));
910
+        $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
911
+        $ss->assign('MOD', return_module_language($GLOBALS['current_language'], 'Users'));
912 912
 
913 913
 		$bottomLinkList = array();
914 914
 		 if (isset($this->action) && $this->action != "EditView") {
@@ -917,11 +917,11 @@  discard block
 block discarded – undo
917 917
 		$bottomLinkList['backtotop'] = array($app_strings['LNK_BACKTOTOP'] => 'javascript:SUGAR.util.top();');
918 918
 
919 919
 		$bottomLinksStr = "";
920
-		foreach($bottomLinkList as $key => $value) {
921
-			foreach($value as $text => $link) {
920
+		foreach ($bottomLinkList as $key => $value) {
921
+			foreach ($value as $text => $link) {
922 922
 				   $href = $link;
923
-				   if(substr($link, 0, 11) == "javascript:") {
924
-                       $onclick = " onclick=\"".substr($link,11)."\"";
923
+				   if (substr($link, 0, 11) == "javascript:") {
924
+                       $onclick = " onclick=\"".substr($link, 11)."\"";
925 925
                        $href = "javascript:void(0)";
926 926
                    } else {
927 927
                    		$onclick = "";
@@ -933,9 +933,9 @@  discard block
 block discarded – undo
933 933
 				$bottomLinksStr .= " ".$text."</a>";
934 934
 			}
935 935
 		}
936
-		$ss->assign("BOTTOMLINKS",$bottomLinksStr);
936
+		$ss->assign("BOTTOMLINKS", $bottomLinksStr);
937 937
         if (SugarConfig::getInstance()->get('calculate_response_time', false))
938
-            $ss->assign('STATISTICS',$this->_getStatistics());
938
+            $ss->assign('STATISTICS', $this->_getStatistics());
939 939
 
940 940
         // Under the License referenced above, you are required to leave in all copyright statements in both
941 941
         // the code and end-user application.
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
         $companyLogoURL = $companyLogoURL_arr[0];
970 970
 
971 971
         $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
972
-        if(!empty($company_logo_attributes)) {
972
+        if (!empty($company_logo_attributes)) {
973 973
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
974 974
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
975 975
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
@@ -978,16 +978,16 @@  discard block
 block discarded – undo
978 978
             // Always need to md5 the file
979 979
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
980 980
 
981
-            list($width,$height) = getimagesize($companyLogoURL);
982
-            if ( $width > 212 || $height > 40 ) {
983
-                $resizePctWidth  = ($width - 212)/212;
984
-                $resizePctHeight = ($height - 40)/40;
985
-                if ( $resizePctWidth > $resizePctHeight )
981
+            list($width, $height) = getimagesize($companyLogoURL);
982
+            if ($width > 212 || $height > 40) {
983
+                $resizePctWidth  = ($width - 212) / 212;
984
+                $resizePctHeight = ($height - 40) / 40;
985
+                if ($resizePctWidth > $resizePctHeight)
986 986
                     $resizeAmount = $width / 212;
987 987
                 else
988 988
                     $resizeAmount = $height / 40;
989
-                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
990
-                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
989
+                $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
990
+                $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
991 991
             }
992 992
             else {
993 993
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
@@ -1003,28 +1003,28 @@  discard block
 block discarded – undo
1003 1003
                                 )
1004 1004
             );
1005 1005
         }
1006
-        $ss->assign("COMPANY_LOGO_URL",getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
1006
+        $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL)."&logo_md5=".$ss->get_template_vars("COMPANY_LOGO_MD5"));
1007 1007
 
1008 1008
         // Bug 38594 - Add in Trademark wording
1009 1009
         $copyright .= 'SugarCRM is a trademark of SugarCRM, Inc. All other company and product names may be trademarks of the respective companies with which they are associated.<br />';
1010 1010
 
1011 1011
         //rrs bug: 20923 - if this image does not exist as per the license, then the proper image will be displayed regardless, so no need
1012 1012
         //to display an empty image here.
1013
-        if(file_exists('include/images/poweredby_sugarcrm_65.png')){
1013
+        if (file_exists('include/images/poweredby_sugarcrm_65.png')) {
1014 1014
             $copyright .= $attribLinkImg;
1015 1015
         }
1016 1016
         // End Required Image
1017
-        $ss->assign('COPYRIGHT',$copyright);
1017
+        $ss->assign('COPYRIGHT', $copyright);
1018 1018
 
1019 1019
         // here we allocate the help link data
1020 1020
         $help_actions_blacklist = array('Login'); // we don't want to show a context help link here
1021
-        if (!in_array($this->action,$help_actions_blacklist)) {
1021
+        if (!in_array($this->action, $help_actions_blacklist)) {
1022 1022
             $url = 'javascript:void(window.open(\'index.php?module=Administration&action=SupportPortal&view=documentation&version='.$GLOBALS['sugar_version'].'&edition='.$GLOBALS['sugar_flavor'].'&lang='.$GLOBALS['current_language'].
1023 1023
                         '&help_module='.$this->module.'&help_action='.$this->action.'&key='.$GLOBALS['server_unique_key'].'\'))';
1024 1024
             $label = (isset($GLOBALS['app_list_strings']['moduleList'][$this->module]) ?
1025
-                        $GLOBALS['app_list_strings']['moduleList'][$this->module] : $this->module). ' '.$app_strings['LNK_HELP'];
1026
-            $ss->assign('HELP_LINK',SugarThemeRegistry::current()->getLink($url, $label, "id='help_link_two'",
1027
-                'help-dashlet.png', 'class="icon"',null,null,'','left'));
1025
+                        $GLOBALS['app_list_strings']['moduleList'][$this->module] : $this->module).' '.$app_strings['LNK_HELP'];
1026
+            $ss->assign('HELP_LINK', SugarThemeRegistry::current()->getLink($url, $label, "id='help_link_two'",
1027
+                'help-dashlet.png', 'class="icon"', null, null, '', 'left'));
1028 1028
         }
1029 1029
         // end
1030 1030
 
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
      */
1038 1038
     protected function _displaySubPanels()
1039 1039
     {
1040
-        if (isset($this->bean) && !empty($this->bean->id) && (file_exists('modules/' . $this->module . '/metadata/subpaneldefs.php') || file_exists('custom/modules/' . $this->module . '/metadata/subpaneldefs.php') || file_exists('custom/modules/' . $this->module . '/Ext/Layoutdefs/layoutdefs.ext.php'))) {
1040
+        if (isset($this->bean) && !empty($this->bean->id) && (file_exists('modules/'.$this->module.'/metadata/subpaneldefs.php') || file_exists('custom/modules/'.$this->module.'/metadata/subpaneldefs.php') || file_exists('custom/modules/'.$this->module.'/Ext/Layoutdefs/layoutdefs.ext.php'))) {
1041 1041
             $GLOBALS['focus'] = $this->bean;
1042 1042
             require_once ('include/SubPanel/SubPanelTiles.php');
1043 1043
             $subpanel = new SubPanelTiles($this->bean, $this->module);
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
      */
1096 1096
     protected function _checkModule()
1097 1097
     {
1098
-        if(!empty($this->module) && !file_exists('modules/'.$this->module)){
1098
+        if (!empty($this->module) && !file_exists('modules/'.$this->module)) {
1099 1099
             $error = str_replace("[module]", "$this->module", $GLOBALS['app_strings']['ERR_CANNOT_FIND_MODULE']);
1100 1100
             $GLOBALS['log']->fatal($error);
1101 1101
             echo $error;
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
     {
1125 1125
         $endTime = microtime(true);
1126 1126
         $deltaTime = $endTime - $GLOBALS['startTime'];
1127
-        $response_time_string = $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME'] . ' ' . number_format(round($deltaTime, 2), 2) . ' ' . $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME_SECONDS'];
1127
+        $response_time_string = $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME'].' '.number_format(round($deltaTime, 2), 2).' '.$GLOBALS['app_strings']['LBL_SERVER_RESPONSE_TIME_SECONDS'];
1128 1128
         $return = $response_time_string;
1129 1129
        // $return .= '<br />';
1130 1130
         if (!empty($GLOBALS['sugar_config']['show_page_resources'])) {
@@ -1135,16 +1135,16 @@  discard block
 block discarded – undo
1135 1135
             // I believe the full get_include_files result set appears to have one entry for each file in real
1136 1136
             // case, and one entry in all lower case.
1137 1137
             $list_of_files_case_insensitive = array();
1138
-            foreach($included_files as $key => $name) {
1138
+            foreach ($included_files as $key => $name) {
1139 1139
                 // preserve the first capitalization encountered.
1140
-                $list_of_files_case_insensitive[mb_strtolower($name) ] = $name;
1140
+                $list_of_files_case_insensitive[mb_strtolower($name)] = $name;
1141 1141
             }
1142
-            $return .= $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_RESOURCES'] . '(' . DBManager::getQueryCount() . ',' . sizeof($list_of_files_case_insensitive) . ')<br>';
1142
+            $return .= $GLOBALS['app_strings']['LBL_SERVER_RESPONSE_RESOURCES'].'('.DBManager::getQueryCount().','.sizeof($list_of_files_case_insensitive).')<br>';
1143 1143
             // Display performance of the internal and external caches....
1144 1144
             $cacheStats = SugarCache::instance()->getCacheStats();
1145
-            $return .= "External cache (hits/total=ratio) local ({$cacheStats['localHits']}/{$cacheStats['requests']}=" . round($cacheStats['localHits']*100/$cacheStats['requests'], 0) . "%)";
1146
-            $return .= " external ({$cacheStats['externalHits']}/{$cacheStats['requests']}=" . round($cacheStats['externalHits']*100/$cacheStats['requests'], 0) . "%)<br />";
1147
-            $return .= " misses ({$cacheStats['misses']}/{$cacheStats['requests']}=" . round($cacheStats['misses']*100/$cacheStats['requests'], 0) . "%)<br />";
1145
+            $return .= "External cache (hits/total=ratio) local ({$cacheStats['localHits']}/{$cacheStats['requests']}=".round($cacheStats['localHits'] * 100 / $cacheStats['requests'], 0)."%)";
1146
+            $return .= " external ({$cacheStats['externalHits']}/{$cacheStats['requests']}=".round($cacheStats['externalHits'] * 100 / $cacheStats['requests'], 0)."%)<br />";
1147
+            $return .= " misses ({$cacheStats['misses']}/{$cacheStats['requests']}=".round($cacheStats['misses'] * 100 / $cacheStats['requests'], 0)."%)<br />";
1148 1148
         }
1149 1149
 
1150 1150
         $return .= $this->logMemoryStatistics();
@@ -1161,37 +1161,36 @@  discard block
 block discarded – undo
1161 1161
      * @param $newline String of newline character to use (defaults to </ br>)
1162 1162
      * @return $message String formatted message about memory statistics
1163 1163
      */
1164
-    protected function logMemoryStatistics($newline='<br>')
1164
+    protected function logMemoryStatistics($newline = '<br>')
1165 1165
     {
1166 1166
         $log_message = '';
1167 1167
 
1168
-        if(!empty($GLOBALS['sugar_config']['log_memory_usage']))
1168
+        if (!empty($GLOBALS['sugar_config']['log_memory_usage']))
1169 1169
         {
1170
-            if(function_exists('memory_get_usage'))
1170
+            if (function_exists('memory_get_usage'))
1171 1171
             {
1172 1172
                 $memory_usage = memory_get_usage();
1173 1173
                 $bytes = $GLOBALS['app_strings']['LBL_SERVER_MEMORY_BYTES'];
1174 1174
                 $data = array($memory_usage, $bytes);
1175
-                $log_message = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_USAGE'], $data) . $newline;
1175
+                $log_message = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_USAGE'], $data).$newline;
1176 1176
             }
1177 1177
 
1178
-            if(function_exists('memory_get_peak_usage'))
1178
+            if (function_exists('memory_get_peak_usage'))
1179 1179
             {
1180 1180
                 $memory_peak_usage = memory_get_peak_usage();
1181 1181
                 $bytes = $GLOBALS['app_strings']['LBL_SERVER_MEMORY_BYTES'];
1182 1182
                 $data = array($memory_peak_usage, $bytes);
1183
-                $log_message .= string_format($GLOBALS['app_strings']['LBL_SERVER_PEAK_MEMORY_USAGE'], $data) . $newline;
1183
+                $log_message .= string_format($GLOBALS['app_strings']['LBL_SERVER_PEAK_MEMORY_USAGE'], $data).$newline;
1184 1184
             }
1185 1185
 
1186
-            if(!empty($log_message))
1186
+            if (!empty($log_message))
1187 1187
             {
1188
-                $data = array
1189
-                (
1188
+                $data = array(
1190 1189
                    !empty($this->module) ? $this->module : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1191 1190
                    !empty($this->action) ? $this->action : $GLOBALS['app_strings']['LBL_LINK_NONE'],
1192 1191
                 );
1193 1192
 
1194
-                $output = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_LOG_MESSAGE'], $data) . $newline;
1193
+                $output = string_format($GLOBALS['app_strings']['LBL_SERVER_MEMORY_LOG_MESSAGE'], $data).$newline;
1195 1194
                 $output .= $log_message;
1196 1195
                 $fp = fopen("memory_usage.log", "ab");
1197 1196
                 fwrite($fp, $output);
@@ -1215,30 +1214,30 @@  discard block
 block discarded – undo
1215 1214
     {
1216 1215
         global $current_language, $current_user, $mod_strings, $app_strings, $module_menu;
1217 1216
 
1218
-        if ( empty($module) )
1217
+        if (empty($module))
1219 1218
             $module = $this->module;
1220 1219
 
1221 1220
         //Need to make sure the mod_strings match the requested module or Menus may fail
1222 1221
         $curr_mod_strings = $mod_strings;
1223
-        $mod_strings = return_module_language ( $current_language, $module ) ;
1222
+        $mod_strings = return_module_language($current_language, $module);
1224 1223
 
1225 1224
         $module_menu = array();
1226 1225
 
1227
-        if (file_exists('modules/' . $module . '/Menu.php')) {
1228
-            require('modules/' . $module . '/Menu.php');
1226
+        if (file_exists('modules/'.$module.'/Menu.php')) {
1227
+            require('modules/'.$module.'/Menu.php');
1229 1228
         }
1230
-        if (file_exists('custom/modules/' . $module . '/Ext/Menus/menu.ext.php')) {
1231
-            require('custom/modules/' . $module . '/Ext/Menus/menu.ext.php');
1229
+        if (file_exists('custom/modules/'.$module.'/Ext/Menus/menu.ext.php')) {
1230
+            require('custom/modules/'.$module.'/Ext/Menus/menu.ext.php');
1232 1231
         }
1233
-        if (!file_exists('modules/' . $module . '/Menu.php')
1234
-                && !file_exists('custom/modules/' . $module . '/Ext/Menus/menu.ext.php')
1232
+        if (!file_exists('modules/'.$module.'/Menu.php')
1233
+                && !file_exists('custom/modules/'.$module.'/Ext/Menus/menu.ext.php')
1235 1234
                 && !empty($GLOBALS['mod_strings']['LNK_NEW_RECORD'])) {
1236 1235
             $module_menu[] = array("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView",
1237
-                $GLOBALS['mod_strings']['LNK_NEW_RECORD'],"{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module" ,$module );
1236
+                $GLOBALS['mod_strings']['LNK_NEW_RECORD'], "{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module", $module);
1238 1237
             $module_menu[] = array("index.php?module=$module&action=index", $GLOBALS['mod_strings']['LNK_LIST'],
1239 1238
                 $module, $module);
1240
-            if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) )
1241
-                if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) )
1239
+            if (($this->bean instanceOf SugarBean) && !empty($this->bean->importable))
1240
+                if (!empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]))
1242 1241
                     $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1243 1242
                         $mod_strings['LNK_IMPORT_'.strtoupper($module)], "Import", $module);
1244 1243
                 else
@@ -1265,22 +1264,22 @@  discard block
 block discarded – undo
1265 1264
 
1266 1265
 		$userTabs = query_module_access_list($current_user);
1267 1266
 		//If the home tab is in the user array use it as the default tab, otherwise use the first element in the tab array
1268
-		$defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1267
+		$defaultTab = (in_array("Home", $userTabs)) ? "Home" : key($userTabs);
1269 1268
 
1270 1269
         // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
1271
-        if ( !empty($_REQUEST['module_tab']) )
1270
+        if (!empty($_REQUEST['module_tab']))
1272 1271
             return $_REQUEST['module_tab'];
1273
-        elseif ( isset($moduleTabMap[$this->module]) )
1272
+        elseif (isset($moduleTabMap[$this->module]))
1274 1273
             return $moduleTabMap[$this->module];
1275 1274
         // Special cases
1276
-        elseif ( $this->module == 'MergeRecords' )
1275
+        elseif ($this->module == 'MergeRecords')
1277 1276
             return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module'];
1278
-        elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' )
1277
+        elseif ($this->module == 'Users' && $this->action == 'SetTimezone')
1279 1278
             return $defaultTab;
1280 1279
         // Default anonymous pages to be under Home
1281
-        elseif ( !isset($app_list_strings['moduleList'][$this->module]) )
1280
+        elseif (!isset($app_list_strings['moduleList'][$this->module]))
1282 1281
             return $defaultTab;
1283
-        elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" )
1282
+        elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui")
1284 1283
         	return $defaultTab;
1285 1284
         else
1286 1285
             return $this->module;
@@ -1300,42 +1299,42 @@  discard block
 block discarded – undo
1300 1299
 
1301 1300
         $theTitle = "<div class='moduleTitle'>\n";
1302 1301
 
1303
-        $module = preg_replace("/ /","",$this->module);
1302
+        $module = preg_replace("/ /", "", $this->module);
1304 1303
 
1305 1304
         $params = $this->_getModuleTitleParams();
1306 1305
         $index = 0;
1307 1306
 
1308
-		if(SugarThemeRegistry::current()->directionality == "rtl") {
1307
+		if (SugarThemeRegistry::current()->directionality == "rtl") {
1309 1308
 			$params = array_reverse($params);
1310 1309
 		}
1311
-		if(count($params) > 1) {
1310
+		if (count($params) > 1) {
1312 1311
 			array_shift($params);
1313 1312
 		}
1314 1313
 		$count = count($params);
1315 1314
         $paramString = '';
1316
-        foreach($params as $parm){
1315
+        foreach ($params as $parm) {
1317 1316
             $index++;
1318 1317
             $paramString .= $parm;
1319
-            if($index < $count){
1318
+            if ($index < $count) {
1320 1319
                 $paramString .= $this->getBreadCrumbSymbol();
1321 1320
             }
1322 1321
         }
1323 1322
 
1324
-        if(!empty($paramString)){
1323
+        if (!empty($paramString)) {
1325 1324
                $theTitle .= "<h2> $paramString </h2>";
1326 1325
 
1327
-            if($this->type == "detail"){
1328
-                $theTitle .= "<div class='favorite' record_id='" . $this->bean->id . "' module='" . $this->bean->module_dir . "'><div class='favorite_icon_outline'>" . SugarThemeRegistry::current()->getImage('favorite-star-outline','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div>
1329
-                                                    <div class='favorite_icon_fill'>" . SugarThemeRegistry::current()->getImage('favorite-star','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0"  align="absmiddle"', null,null,'.gif',translate('LBL_DASHLET_EDIT', 'Home')) . "</div></div>";
1326
+            if ($this->type == "detail") {
1327
+                $theTitle .= "<div class='favorite' record_id='".$this->bean->id."' module='".$this->bean->module_dir."'><div class='favorite_icon_outline'>".SugarThemeRegistry::current()->getImage('favorite-star-outline', 'title="'.translate('LBL_DASHLET_EDIT', 'Home').'" border="0"  align="absmiddle"', null, null, '.gif', translate('LBL_DASHLET_EDIT', 'Home'))."</div>
1328
+                                                    <div class='favorite_icon_fill'>" . SugarThemeRegistry::current()->getImage('favorite-star', 'title="'.translate('LBL_DASHLET_EDIT', 'Home').'" border="0"  align="absmiddle"', null, null, '.gif', translate('LBL_DASHLET_EDIT', 'Home'))."</div></div>";
1330 1329
             }
1331 1330
            }
1332 1331
 
1333 1332
         // bug 56131 - restore conditional so that link doesn't appear where it shouldn't
1334
-        if($show_help || $this->type == 'list') {
1333
+        if ($show_help || $this->type == 'list') {
1335 1334
             $theTitle .= "<span class='utils'>";
1336 1335
             $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
1337
-            if($this->type == 'list') $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>';$url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1338
-            if($show_help) {
1336
+            if ($this->type == 'list') $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>'; $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1337
+            if ($show_help) {
1339 1338
                 $theTitle .= <<<EOHTML
1340 1339
 &nbsp;
1341 1340
 <a id="create_image" href="{$url}" class="utilsLink">
@@ -1361,31 +1360,31 @@  discard block
 block discarded – undo
1361 1360
     {
1362 1361
         $metadataFile = null;
1363 1362
         $foundViewDefs = false;
1364
-        $viewDef = strtolower($this->type) . 'viewdefs';
1365
-        $coreMetaPath = 'modules/'.$this->module.'/metadata/' . $viewDef . '.php';
1366
-        if(file_exists('custom/' .$coreMetaPath )){
1367
-            $metadataFile = 'custom/' . $coreMetaPath;
1363
+        $viewDef = strtolower($this->type).'viewdefs';
1364
+        $coreMetaPath = 'modules/'.$this->module.'/metadata/'.$viewDef.'.php';
1365
+        if (file_exists('custom/'.$coreMetaPath)) {
1366
+            $metadataFile = 'custom/'.$coreMetaPath;
1368 1367
             $foundViewDefs = true;
1369
-        }else{
1370
-            if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
1368
+        } else {
1369
+            if (file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')) {
1371 1370
                 require_once('custom/modules/'.$this->module.'/metadata/metafiles.php');
1372
-                if(!empty($metafiles[$this->module][$viewDef])){
1371
+                if (!empty($metafiles[$this->module][$viewDef])) {
1373 1372
                     $metadataFile = $metafiles[$this->module][$viewDef];
1374 1373
                     $foundViewDefs = true;
1375 1374
                 }
1376
-            }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
1375
+            }elseif (file_exists('modules/'.$this->module.'/metadata/metafiles.php')) {
1377 1376
                 require_once('modules/'.$this->module.'/metadata/metafiles.php');
1378
-                if(!empty($metafiles[$this->module][$viewDef])){
1377
+                if (!empty($metafiles[$this->module][$viewDef])) {
1379 1378
                     $metadataFile = $metafiles[$this->module][$viewDef];
1380 1379
                     $foundViewDefs = true;
1381 1380
                 }
1382 1381
             }
1383 1382
         }
1384 1383
 
1385
-        if(!$foundViewDefs && file_exists($coreMetaPath)){
1384
+        if (!$foundViewDefs && file_exists($coreMetaPath)) {
1386 1385
                 $metadataFile = $coreMetaPath;
1387 1386
         }
1388
-        $GLOBALS['log']->debug("metadatafile=". $metadataFile);
1387
+        $GLOBALS['log']->debug("metadatafile=".$metadataFile);
1389 1388
 
1390 1389
         return $metadataFile;
1391 1390
     }
@@ -1402,10 +1401,10 @@  discard block
 block discarded – undo
1402 1401
     {
1403 1402
         $params = array($this->_getModuleTitleListParam($browserTitle));
1404 1403
 		//$params = array();
1405
-        if (isset($this->action)){
1404
+        if (isset($this->action)) {
1406 1405
             switch ($this->action) {
1407 1406
             case 'EditView':
1408
-                if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1407
+                if (!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1409 1408
                     $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1410 1409
                     $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1411 1410
                 }
@@ -1429,18 +1428,18 @@  discard block
 block discarded – undo
1429 1428
      *                           there should be no HTML in the string
1430 1429
      * @return string
1431 1430
      */
1432
-    protected function _getModuleTitleListParam( $browserTitle = false )
1431
+    protected function _getModuleTitleListParam($browserTitle = false)
1433 1432
     {
1434 1433
     	global $current_user;
1435 1434
     	global $app_strings;
1436 1435
 
1437
-    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1436
+    	if (!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1438 1437
     		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1439 1438
     	else
1440 1439
     		$firstParam = $this->module;
1441 1440
 
1442 1441
     	$iconPath = $this->getModuleTitleIconPath($this->module);
1443
-    	if($this->action == "ListView" || $this->action == "index") {
1442
+    	if ($this->action == "ListView" || $this->action == "index") {
1444 1443
     	    if (!empty($iconPath) && !$browserTitle) {
1445 1444
     	    	if (SugarThemeRegistry::current()->directionality == "ltr") {
1446 1445
     	    		return $app_strings['LBL_SEARCH']."&nbsp;"
@@ -1466,10 +1465,10 @@  discard block
 block discarded – undo
1466 1465
     protected function getModuleTitleIconPath($module)
1467 1466
     {
1468 1467
     	$iconPath = "";
1469
-    	if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1468
+    	if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png', false))) {
1470 1469
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1471 1470
     	}
1472
-    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1471
+    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png', false))) {
1473 1472
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1474 1473
     	}
1475 1474
     	return $iconPath;
@@ -1486,11 +1485,11 @@  discard block
 block discarded – undo
1486 1485
         global $app_strings;
1487 1486
 
1488 1487
         $browserTitle = $app_strings['LBL_BROWSER_TITLE'];
1489
-        if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') )
1488
+        if ($this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login'))
1490 1489
             return $browserTitle;
1491 1490
         $params = $this->_getModuleTitleParams(true);
1492
-        foreach ($params as $value )
1493
-            $browserTitle = strip_tags($value) . ' &raquo; ' . $browserTitle;
1491
+        foreach ($params as $value)
1492
+            $browserTitle = strip_tags($value).' &raquo; '.$browserTitle;
1494 1493
 
1495 1494
         return $browserTitle;
1496 1495
     }
@@ -1502,7 +1501,7 @@  discard block
 block discarded – undo
1502 1501
      */
1503 1502
     public function getBreadCrumbSymbol()
1504 1503
     {
1505
-    	if(SugarThemeRegistry::current()->directionality == "ltr") {
1504
+    	if (SugarThemeRegistry::current()->directionality == "ltr") {
1506 1505
         	return "<span class='pointer'>&raquo;</span>";
1507 1506
         }
1508 1507
         else {
@@ -1515,29 +1514,29 @@  discard block
 block discarded – undo
1515 1514
      *
1516 1515
      * @return array
1517 1516
      */
1518
-    protected function getSugarConfigJS(){
1517
+    protected function getSugarConfigJS() {
1519 1518
         global $sugar_config;
1520 1519
 
1521 1520
         // Set all the config parameters in the JS config as necessary
1522 1521
         $config_js = array();
1523 1522
         // AjaxUI stock banned modules
1524 1523
         $config_js[] = "SUGAR.config.stockAjaxBannedModules = ".json_encode(ajaxBannedModules()).";";
1525
-        if ( isset($sugar_config['quicksearch_querydelay']) ) {
1524
+        if (isset($sugar_config['quicksearch_querydelay'])) {
1526 1525
             $config_js[] = $this->prepareConfigVarForJs('quicksearch_querydelay', $sugar_config['quicksearch_querydelay']);
1527 1526
         }
1528
-        if ( empty($sugar_config['disableAjaxUI']) ) {
1527
+        if (empty($sugar_config['disableAjaxUI'])) {
1529 1528
             $config_js[] = "SUGAR.config.disableAjaxUI = false;";
1530 1529
         }
1531
-        else{
1530
+        else {
1532 1531
             $config_js[] = "SUGAR.config.disableAjaxUI = true;";
1533 1532
         }
1534
-        if ( !empty($sugar_config['addAjaxBannedModules']) ){
1533
+        if (!empty($sugar_config['addAjaxBannedModules'])) {
1535 1534
             $config_js[] = $this->prepareConfigVarForJs('addAjaxBannedModules', $sugar_config['addAjaxBannedModules']);
1536 1535
         }
1537
-        if ( !empty($sugar_config['overrideAjaxBannedModules']) ){
1536
+        if (!empty($sugar_config['overrideAjaxBannedModules'])) {
1538 1537
             $config_js[] = $this->prepareConfigVarForJs('overrideAjaxBannedModules', $sugar_config['overrideAjaxBannedModules']);
1539 1538
         }
1540
-        if (!empty($sugar_config['js_available']) && is_array ($sugar_config['js_available']))
1539
+        if (!empty($sugar_config['js_available']) && is_array($sugar_config['js_available']))
1541 1540
         {
1542 1541
             foreach ($sugar_config['js_available'] as $configKey)
1543 1542
             {
@@ -1598,7 +1597,7 @@  discard block
 block discarded – undo
1598 1597
     protected function getFavicon()
1599 1598
     {
1600 1599
         // get favicon
1601
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
1600
+        if (isset($GLOBALS['sugar_config']['default_module_favicon']))
1602 1601
             $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
1603 1602
         else
1604 1603
             $module_favicon = false;
@@ -1606,10 +1605,10 @@  discard block
 block discarded – undo
1606 1605
         $themeObject = SugarThemeRegistry::current();
1607 1606
 
1608 1607
         $favicon = '';
1609
-        if ( $module_favicon )
1610
-            $favicon = $themeObject->getImageURL($this->module.'.gif',false);
1611
-        if ( !sugar_is_file($favicon) || !$module_favicon )
1612
-            $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
1608
+        if ($module_favicon)
1609
+            $favicon = $themeObject->getImageURL($this->module.'.gif', false);
1610
+        if (!sugar_is_file($favicon) || !$module_favicon)
1611
+            $favicon = $themeObject->getImageURL('sugar_icon.ico', false);
1613 1612
 
1614 1613
         $extension = pathinfo($favicon, PATHINFO_EXTENSION);
1615 1614
         switch ($extension)
@@ -1666,10 +1665,10 @@  discard block
 block discarded – undo
1666 1665
      * @return array augmented history with image link and shortened name
1667 1666
      */
1668 1667
     protected function processRecentRecords($history) {
1669
-        foreach ( $history as $key => $row ) {
1668
+        foreach ($history as $key => $row) {
1670 1669
             $history[$key]['item_summary_short'] = to_html(getTrackerSubstring($row['item_summary'])); //bug 56373 - need to re-HTML-encode
1671 1670
             $history[$key]['image'] = SugarThemeRegistry::current()
1672
-                ->getImage($row['module_name'],'border="0" align="absmiddle"',null,null,'.gif',$row['item_summary']);
1671
+                ->getImage($row['module_name'], 'border="0" align="absmiddle"', null, null, '.gif', $row['item_summary']);
1673 1672
         }
1674 1673
         return $history;
1675 1674
     }
@@ -1683,10 +1682,10 @@  discard block
 block discarded – undo
1683 1682
      *
1684 1683
 	 * @return boolean indicating true or false
1685 1684
 	 */
1686
-    public function checkPostMaxSizeError(){
1685
+    public function checkPostMaxSizeError() {
1687 1686
          //if the referrer is post, and the post array is empty, then an error has occurred, most likely
1688 1687
          //while uploading a file that exceeds the post_max_size.
1689
-         if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
1688
+         if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
1690 1689
              $GLOBALS['log']->fatal($GLOBALS['app_strings']['UPLOAD_ERROR_HOME_TEXT']);
1691 1690
              return true;
1692 1691
         }
Please login to merge, or discard this patch.
Braces   +132 added lines, -107 removed lines patch added patch discarded remove patch
@@ -102,8 +102,7 @@  discard block
 block discarded – undo
102 102
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
103 103
         if(isset($GLOBALS['log'])) {
104 104
             $GLOBALS['log']->deprecated($deprecatedMessage);
105
-        }
106
-        else {
105
+        } else {
107 106
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
108 107
         }
109 108
         self::__construct($bean, $view_object_map);
@@ -178,13 +177,17 @@  discard block
 block discarded – undo
178 177
             echo $jsAlerts->getScript();
179 178
         }
180 179
 
181
-        if ($this->_getOption('show_subpanels') && !empty($_REQUEST['record'])) $this->_displaySubPanels();
180
+        if ($this->_getOption('show_subpanels') && !empty($_REQUEST['record'])) {
181
+            $this->_displaySubPanels();
182
+        }
182 183
 
183 184
         if ($this->action === 'Login') {
184 185
             //this is needed for a faster loading login page ie won't render unless the tables are closed
185 186
             ob_flush();
186 187
         }
187
-        if ($this->_getOption('show_footer')) $this->displayFooter();
188
+        if ($this->_getOption('show_footer')) {
189
+            $this->displayFooter();
190
+        }
188 191
         $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_footer');
189 192
         if ($this->_getOption('json_output'))
190 193
         {
@@ -203,11 +206,13 @@  discard block
 block discarded – undo
203 206
                 'favicon' => $this->getFavicon(),
204 207
             );
205 208
 
206
-            if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic)
207
-                $ajax_ret['moduleList'] = $this->displayHeader(true);
209
+            if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic) {
210
+                            $ajax_ret['moduleList'] = $this->displayHeader(true);
211
+            }
208 212
 
209
-            if(empty($this->responseTime))
210
-                $this->_calculateFooterMetrics();
213
+            if(empty($this->responseTime)) {
214
+                            $this->_calculateFooterMetrics();
215
+            }
211 216
             $ajax_ret['responseTime'] = $this->responseTime;
212 217
             $json = getJSONobj();
213 218
             echo $json->encode($ajax_ret);
@@ -231,8 +236,7 @@  discard block
 block discarded – undo
231 236
 
232 237
         if ( !$this->suppressDisplayErrors ) {
233 238
             echo $errors;
234
-        }
235
-        else {
239
+        } else {
236 240
             return $errors;
237 241
         }
238 242
     }
@@ -346,24 +350,26 @@  discard block
 block discarded – undo
346 350
         ob_end_clean();
347 351
 
348 352
         // get favicon
349
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
350
-            $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
351
-        else
352
-            $module_favicon = false;
353
+        if(isset($GLOBALS['sugar_config']['default_module_favicon'])) {
354
+                    $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
355
+        } else {
356
+                    $module_favicon = false;
357
+        }
353 358
 
354 359
         $favicon = $this->getFavicon();
355 360
         $ss->assign('FAVICON_URL', $favicon['url']);
356 361
 
357 362
         // build the shortcut menu
358 363
         $shortcut_menu = array();
359
-        foreach ( $this->getMenu() as $key => $menu_item )
360
-            $shortcut_menu[$key] = array(
364
+        foreach ( $this->getMenu() as $key => $menu_item ) {
365
+                    $shortcut_menu[$key] = array(
361 366
                 "URL"         => $menu_item[0],
362 367
                 "LABEL"       => $menu_item[1],
363 368
                 "MODULE_NAME" => $menu_item[2],
364 369
                 "IMAGE"       => $themeObject
365 370
                     ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]),
366 371
                 );
372
+        }
367 373
         $ss->assign("SHORTCUT_MENU",$shortcut_menu);
368 374
 
369 375
         // handle rtl text direction
@@ -387,8 +393,7 @@  discard block
 block discarded – undo
387 393
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
388 394
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
389 395
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
390
-        }
391
-        else {
396
+        } else {
392 397
             // Always need to md5 the file
393 398
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
394 399
 
@@ -396,14 +401,14 @@  discard block
 block discarded – undo
396 401
             if ( $width > 212 || $height > 40 ) {
397 402
                 $resizePctWidth  = ($width - 212)/212;
398 403
                 $resizePctHeight = ($height - 40)/40;
399
-                if ( $resizePctWidth > $resizePctHeight )
400
-                    $resizeAmount = $width / 212;
401
-                else
402
-                    $resizeAmount = $height / 40;
404
+                if ( $resizePctWidth > $resizePctHeight ) {
405
+                                    $resizeAmount = $width / 212;
406
+                } else {
407
+                                    $resizeAmount = $height / 40;
408
+                }
403 409
                 $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
404 410
                 $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
405
-            }
406
-            else {
411
+            } else {
407 412
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
408 413
                 $ss->assign("COMPANY_LOGO_HEIGHT", $height);
409 414
             }
@@ -446,11 +451,12 @@  discard block
 block discarded – undo
446 451
                 }
447 452
                 // and now the sublinks
448 453
                 if ( $linkattribute == 'submenu' && is_array($attributevalue) ) {
449
-                    foreach ($attributevalue as $submenulinkkey => $submenulinkinfo)
450
-                        $gcls[$key]['SUBMENU'][$submenulinkkey] = array(
454
+                    foreach ($attributevalue as $submenulinkkey => $submenulinkinfo) {
455
+                                            $gcls[$key]['SUBMENU'][$submenulinkkey] = array(
451 456
                             "LABEL" => key($submenulinkinfo),
452 457
                             "URL"   => current($submenulinkinfo),
453 458
                         );
459
+                    }
454 460
                        if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
455 461
                            $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11);
456 462
                            $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
@@ -462,8 +468,9 @@  discard block
 block discarded – undo
462 468
 
463 469
         $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : '');
464 470
 
465
-        if ($this->action == "EditView" || $this->action == "Login")
466
-            $ss->assign("ONLOAD", 'onload="set_focus()"');
471
+        if ($this->action == "EditView" || $this->action == "Login") {
472
+                    $ss->assign("ONLOAD", 'onload="set_focus()"');
473
+        }
467 474
 
468 475
         $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"]));
469 476
 
@@ -523,8 +530,7 @@  discard block
 block discarded – undo
523 530
                 foreach($frames as $key => $values){
524 531
                         $fullModuleList[$key] = $values;
525 532
                 }
526
-            }
527
-            elseif (isset($fullModuleList['iFrames'])) {
533
+            } elseif (isset($fullModuleList['iFrames'])) {
528 534
                 unset($fullModuleList['iFrames']);
529 535
             }
530 536
 
@@ -540,8 +546,7 @@  discard block
 block discarded – undo
540 546
                     // We have a default value. Use it
541 547
                     if(isset($GLOBALS['sugar_config']['default_max_tabs'])){
542 548
                         $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
543
-                    }
544
-                    else{
549
+                    } else{
545 550
                         $max_tabs = 8;
546 551
                     }
547 552
                 }
@@ -650,7 +655,9 @@  discard block
 block discarded – undo
650 655
                         );
651 656
                 }
652 657
             }
653
-            if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true);
658
+            if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) {
659
+                $ss->assign('lock_homepage', true);
660
+            }
654 661
             $ss->assign("groupTabs",$groupTabs);
655 662
             $ss->assign("shortcutTopMenu",$shortcutTopMenu);
656 663
             $ss->assign('USE_GROUP_TABS',$usingGroupTabs);
@@ -693,8 +700,9 @@  discard block
 block discarded – undo
693 700
         global $mod_strings;
694 701
         $mod_strings = $bakModStrings;
695 702
         $headerTpl = $themeObject->getTemplate('header.tpl');
696
-        if (inDeveloperMode() )
697
-            $ss->clear_compiled_tpl($headerTpl);
703
+        if (inDeveloperMode() ) {
704
+                    $ss->clear_compiled_tpl($headerTpl);
705
+        }
698 706
 
699 707
         if ($retModTabs)
700 708
         {
@@ -733,8 +741,9 @@  discard block
 block discarded – undo
733 741
         global $gridline, $request_string, $modListHeader, $dashletData, $authController, $locale, $currentModule, $import_bean_map, $image_path, $license;
734 742
         global $user_unique_key, $server_unique_key, $barChartColors, $modules_exempt_from_availability_check, $dictionary, $current_language, $beanList, $beanFiles, $sugar_build, $sugar_codename;
735 743
         global $timedate, $login_error; // cn: bug 13855 - timedate not available to classic views.
736
-        if (!empty($this->module))
737
-            $currentModule = $this->module;
744
+        if (!empty($this->module)) {
745
+                    $currentModule = $this->module;
746
+        }
738 747
         require_once ($file);
739 748
     }
740 749
 
@@ -764,8 +773,9 @@  discard block
 block discarded – undo
764 773
             if ( typeof(SUGAR.themes) == 'undefined' ) SUGAR.themes = {};
765 774
         </script>
766 775
 EOQ;
767
-        if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
768
-            echo getVersionedScript('modules/Sync/headersync.js');
776
+        if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client']) {
777
+                    echo getVersionedScript('modules/Sync/headersync.js');
778
+        }
769 779
     }
770 780
 
771 781
     /**
@@ -866,8 +876,9 @@  discard block
 block discarded – undo
866 876
 
867 877
 			echo $this->_getModLanguageJS();
868 878
 
869
-            if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client'])
870
-                echo getVersionedScript('modules/Sync/headersync.js');
879
+            if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client']) {
880
+                            echo getVersionedScript('modules/Sync/headersync.js');
881
+            }
871 882
 
872 883
 
873 884
             //echo out the $js_vars variables as javascript variables
@@ -934,8 +945,9 @@  discard block
 block discarded – undo
934 945
 			}
935 946
 		}
936 947
 		$ss->assign("BOTTOMLINKS",$bottomLinksStr);
937
-        if (SugarConfig::getInstance()->get('calculate_response_time', false))
938
-            $ss->assign('STATISTICS',$this->_getStatistics());
948
+        if (SugarConfig::getInstance()->get('calculate_response_time', false)) {
949
+                    $ss->assign('STATISTICS',$this->_getStatistics());
950
+        }
939 951
 
940 952
         // Under the License referenced above, you are required to leave in all copyright statements in both
941 953
         // the code and end-user application.
@@ -973,8 +985,7 @@  discard block
 block discarded – undo
973 985
             $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
974 986
             $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
975 987
             $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
976
-        }
977
-        else {
988
+        } else {
978 989
             // Always need to md5 the file
979 990
             $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
980 991
 
@@ -982,14 +993,14 @@  discard block
 block discarded – undo
982 993
             if ( $width > 212 || $height > 40 ) {
983 994
                 $resizePctWidth  = ($width - 212)/212;
984 995
                 $resizePctHeight = ($height - 40)/40;
985
-                if ( $resizePctWidth > $resizePctHeight )
986
-                    $resizeAmount = $width / 212;
987
-                else
988
-                    $resizeAmount = $height / 40;
996
+                if ( $resizePctWidth > $resizePctHeight ) {
997
+                                    $resizeAmount = $width / 212;
998
+                } else {
999
+                                    $resizeAmount = $height / 40;
1000
+                }
989 1001
                 $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount)));
990 1002
                 $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount)));
991
-            }
992
-            else {
1003
+            } else {
993 1004
                 $ss->assign("COMPANY_LOGO_WIDTH", $width);
994 1005
                 $ss->assign("COMPANY_LOGO_HEIGHT", $height);
995 1006
             }
@@ -1047,8 +1058,9 @@  discard block
 block discarded – undo
1047 1058
 
1048 1059
     protected function _buildModuleList()
1049 1060
     {
1050
-        if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
1051
-            $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
1061
+        if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader'])) {
1062
+                    $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
1063
+        }
1052 1064
     }
1053 1065
 
1054 1066
     /**
@@ -1068,7 +1080,9 @@  discard block
 block discarded – undo
1068 1080
             return $this->options['show_all'];
1069 1081
         } elseif (!empty($this->options) && isset($this->options[$option])) {
1070 1082
             return $this->options[$option];
1071
-        } else return $default;
1083
+        } else {
1084
+            return $default;
1085
+        }
1072 1086
     }
1073 1087
 
1074 1088
     /**
@@ -1105,10 +1119,11 @@  discard block
 block discarded – undo
1105 1119
 
1106 1120
     public function renderJavascript()
1107 1121
     {
1108
-        if ($this->action !== 'Login')
1109
-            $this->_displayJavascript();
1110
-        else
1111
-            $this->_displayLoginJS();
1122
+        if ($this->action !== 'Login') {
1123
+                    $this->_displayJavascript();
1124
+        } else {
1125
+                    $this->_displayLoginJS();
1126
+        }
1112 1127
     }
1113 1128
 
1114 1129
     private function _calculateFooterMetrics()
@@ -1215,8 +1230,9 @@  discard block
 block discarded – undo
1215 1230
     {
1216 1231
         global $current_language, $current_user, $mod_strings, $app_strings, $module_menu;
1217 1232
 
1218
-        if ( empty($module) )
1219
-            $module = $this->module;
1233
+        if ( empty($module) ) {
1234
+                    $module = $this->module;
1235
+        }
1220 1236
 
1221 1237
         //Need to make sure the mod_strings match the requested module or Menus may fail
1222 1238
         $curr_mod_strings = $mod_strings;
@@ -1237,13 +1253,14 @@  discard block
 block discarded – undo
1237 1253
                 $GLOBALS['mod_strings']['LNK_NEW_RECORD'],"{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module" ,$module );
1238 1254
             $module_menu[] = array("index.php?module=$module&action=index", $GLOBALS['mod_strings']['LNK_LIST'],
1239 1255
                 $module, $module);
1240
-            if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) )
1241
-                if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) )
1256
+            if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) ) {
1257
+                            if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) )
1242 1258
                     $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1243 1259
                         $mod_strings['LNK_IMPORT_'.strtoupper($module)], "Import", $module);
1244
-                else
1245
-                    $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1260
+            } else {
1261
+                                    $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index",
1246 1262
                         $app_strings['LBL_IMPORT'], "Import", $module);
1263
+                }
1247 1264
         }
1248 1265
         if (file_exists('custom/application/Ext/Menus/menu.ext.php')) {
1249 1266
             require('custom/application/Ext/Menus/menu.ext.php');
@@ -1268,22 +1285,25 @@  discard block
 block discarded – undo
1268 1285
 		$defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs);
1269 1286
 
1270 1287
         // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
1271
-        if ( !empty($_REQUEST['module_tab']) )
1272
-            return $_REQUEST['module_tab'];
1273
-        elseif ( isset($moduleTabMap[$this->module]) )
1274
-            return $moduleTabMap[$this->module];
1288
+        if ( !empty($_REQUEST['module_tab']) ) {
1289
+                    return $_REQUEST['module_tab'];
1290
+        } elseif ( isset($moduleTabMap[$this->module]) ) {
1291
+                    return $moduleTabMap[$this->module];
1292
+        }
1275 1293
         // Special cases
1276
-        elseif ( $this->module == 'MergeRecords' )
1277
-            return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module'];
1278
-        elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' )
1279
-            return $defaultTab;
1294
+        elseif ( $this->module == 'MergeRecords' ) {
1295
+                    return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module'];
1296
+        } elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' ) {
1297
+                    return $defaultTab;
1298
+        }
1280 1299
         // Default anonymous pages to be under Home
1281
-        elseif ( !isset($app_list_strings['moduleList'][$this->module]) )
1282
-            return $defaultTab;
1283
-        elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" )
1284
-        	return $defaultTab;
1285
-        else
1286
-            return $this->module;
1300
+        elseif ( !isset($app_list_strings['moduleList'][$this->module]) ) {
1301
+                    return $defaultTab;
1302
+        } elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" ) {
1303
+                	return $defaultTab;
1304
+        } else {
1305
+                    return $this->module;
1306
+        }
1287 1307
     }
1288 1308
 
1289 1309
    /**
@@ -1334,7 +1354,10 @@  discard block
 block discarded – undo
1334 1354
         if($show_help || $this->type == 'list') {
1335 1355
             $theTitle .= "<span class='utils'>";
1336 1356
             $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif');
1337
-            if($this->type == 'list') $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>';$url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1357
+            if($this->type == 'list') {
1358
+                $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>';
1359
+            }
1360
+            $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView");
1338 1361
             if($show_help) {
1339 1362
                 $theTitle .= <<<EOHTML
1340 1363
 &nbsp;
@@ -1366,14 +1389,14 @@  discard block
 block discarded – undo
1366 1389
         if(file_exists('custom/' .$coreMetaPath )){
1367 1390
             $metadataFile = 'custom/' . $coreMetaPath;
1368 1391
             $foundViewDefs = true;
1369
-        }else{
1392
+        } else{
1370 1393
             if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
1371 1394
                 require_once('custom/modules/'.$this->module.'/metadata/metafiles.php');
1372 1395
                 if(!empty($metafiles[$this->module][$viewDef])){
1373 1396
                     $metadataFile = $metafiles[$this->module][$viewDef];
1374 1397
                     $foundViewDefs = true;
1375 1398
                 }
1376
-            }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
1399
+            } elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
1377 1400
                 require_once('modules/'.$this->module.'/metadata/metafiles.php');
1378 1401
                 if(!empty($metafiles[$this->module][$viewDef])){
1379 1402
                     $metadataFile = $metafiles[$this->module][$viewDef];
@@ -1408,9 +1431,9 @@  discard block
 block discarded – undo
1408 1431
                 if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) {
1409 1432
                     $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>";
1410 1433
                     $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
1434
+                } else {
1435
+                                    $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
1411 1436
                 }
1412
-                else
1413
-                    $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
1414 1437
                 break;
1415 1438
             case 'DetailView':
1416 1439
                 $beanName = $this->bean->get_summary_text();
@@ -1434,10 +1457,11 @@  discard block
 block discarded – undo
1434 1457
     	global $current_user;
1435 1458
     	global $app_strings;
1436 1459
 
1437
-    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module]))
1438
-    		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1439
-    	else
1440
-    		$firstParam = $this->module;
1460
+    	if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module])) {
1461
+    	    		$firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module];
1462
+    	} else {
1463
+    	    		$firstParam = $this->module;
1464
+    	}
1441 1465
 
1442 1466
     	$iconPath = $this->getModuleTitleIconPath($this->module);
1443 1467
     	if($this->action == "ListView" || $this->action == "index") {
@@ -1453,8 +1477,7 @@  discard block
 block discarded – undo
1453 1477
 			} else {
1454 1478
 				return $firstParam;
1455 1479
 			}
1456
-    	}
1457
-    	else {
1480
+    	} else {
1458 1481
 		    if (!empty($iconPath) && !$browserTitle) {
1459 1482
 				//return "<a href='index.php?module={$this->module}&action=index'>$this->module</a>";
1460 1483
 			} else {
@@ -1468,8 +1491,7 @@  discard block
 block discarded – undo
1468 1491
     	$iconPath = "";
1469 1492
     	if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) {
1470 1493
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png');
1471
-    	}
1472
-    	else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1494
+    	} else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) {
1473 1495
     		$iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png');
1474 1496
     	}
1475 1497
     	return $iconPath;
@@ -1486,11 +1508,13 @@  discard block
 block discarded – undo
1486 1508
         global $app_strings;
1487 1509
 
1488 1510
         $browserTitle = $app_strings['LBL_BROWSER_TITLE'];
1489
-        if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') )
1490
-            return $browserTitle;
1511
+        if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') ) {
1512
+                    return $browserTitle;
1513
+        }
1491 1514
         $params = $this->_getModuleTitleParams(true);
1492
-        foreach ($params as $value )
1493
-            $browserTitle = strip_tags($value) . ' &raquo; ' . $browserTitle;
1515
+        foreach ($params as $value ) {
1516
+                    $browserTitle = strip_tags($value) . ' &raquo; ' . $browserTitle;
1517
+        }
1494 1518
 
1495 1519
         return $browserTitle;
1496 1520
     }
@@ -1504,8 +1528,7 @@  discard block
 block discarded – undo
1504 1528
     {
1505 1529
     	if(SugarThemeRegistry::current()->directionality == "ltr") {
1506 1530
         	return "<span class='pointer'>&raquo;</span>";
1507
-        }
1508
-        else {
1531
+        } else {
1509 1532
         	return "<span class='pointer'>&laquo;</span>";
1510 1533
         }
1511 1534
     }
@@ -1527,8 +1550,7 @@  discard block
 block discarded – undo
1527 1550
         }
1528 1551
         if ( empty($sugar_config['disableAjaxUI']) ) {
1529 1552
             $config_js[] = "SUGAR.config.disableAjaxUI = false;";
1530
-        }
1531
-        else{
1553
+        } else{
1532 1554
             $config_js[] = "SUGAR.config.disableAjaxUI = true;";
1533 1555
         }
1534 1556
         if ( !empty($sugar_config['addAjaxBannedModules']) ){
@@ -1598,18 +1620,21 @@  discard block
 block discarded – undo
1598 1620
     protected function getFavicon()
1599 1621
     {
1600 1622
         // get favicon
1601
-        if(isset($GLOBALS['sugar_config']['default_module_favicon']))
1602
-            $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
1603
-        else
1604
-            $module_favicon = false;
1623
+        if(isset($GLOBALS['sugar_config']['default_module_favicon'])) {
1624
+                    $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
1625
+        } else {
1626
+                    $module_favicon = false;
1627
+        }
1605 1628
 
1606 1629
         $themeObject = SugarThemeRegistry::current();
1607 1630
 
1608 1631
         $favicon = '';
1609
-        if ( $module_favicon )
1610
-            $favicon = $themeObject->getImageURL($this->module.'.gif',false);
1611
-        if ( !sugar_is_file($favicon) || !$module_favicon )
1612
-            $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
1632
+        if ( $module_favicon ) {
1633
+                    $favicon = $themeObject->getImageURL($this->module.'.gif',false);
1634
+        }
1635
+        if ( !sugar_is_file($favicon) || !$module_favicon ) {
1636
+                    $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
1637
+        }
1613 1638
 
1614 1639
         $extension = pathinfo($favicon, PATHINFO_EXTENSION);
1615 1640
         switch ($extension)
Please login to merge, or discard this patch.
include/MVC/Controller/ControllerFactory.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -44,43 +44,43 @@
 block discarded – undo
44 44
  */
45 45
 class ControllerFactory
46 46
 {
47
-	/**
48
-	 * Obtain an instance of the correct controller.
49
-	 *
50
-	 * @return an instance of SugarController
51
-	 */
52
-	static function getController($module){
53
-		$class = ucfirst($module).'Controller';
54
-		$customClass = 'Custom' . $class;
55
-		if(file_exists('custom/modules/'.$module.'/controller.php')){
56
-			$customClass = 'Custom' . $class;
57
-			require_once('custom/modules/'.$module.'/controller.php');
58
-			if(class_exists($customClass)){
59
-				$controller = new $customClass();
60
-			}else if(class_exists($class)){
61
-				$controller = new $class();
62
-			}
63
-		}elseif(file_exists('modules/'.$module.'/controller.php')){
64
-			require_once('modules/'.$module.'/controller.php');
65
-			if(class_exists($customClass)){
66
-				$controller = new $customClass();
67
-			}else if(class_exists($class)){
68
-				$controller = new $class();
69
-			}
70
-		}else{
71
-			if(file_exists('custom/include/MVC/Controller/SugarController.php')){
72
-				require_once('custom/include/MVC/Controller/SugarController.php');
73
-			}
74
-			if(class_exists('CustomSugarController')){
75
-				$controller = new CustomSugarController();
76
-			}else{
77
-			$controller = new SugarController();
78
-			}
79
-		}
80
-		//setup the controller
81
-		$controller->setup($module);
82
-		return $controller;
83
-	}
47
+    /**
48
+     * Obtain an instance of the correct controller.
49
+     *
50
+     * @return an instance of SugarController
51
+     */
52
+    static function getController($module){
53
+        $class = ucfirst($module).'Controller';
54
+        $customClass = 'Custom' . $class;
55
+        if(file_exists('custom/modules/'.$module.'/controller.php')){
56
+            $customClass = 'Custom' . $class;
57
+            require_once('custom/modules/'.$module.'/controller.php');
58
+            if(class_exists($customClass)){
59
+                $controller = new $customClass();
60
+            }else if(class_exists($class)){
61
+                $controller = new $class();
62
+            }
63
+        }elseif(file_exists('modules/'.$module.'/controller.php')){
64
+            require_once('modules/'.$module.'/controller.php');
65
+            if(class_exists($customClass)){
66
+                $controller = new $customClass();
67
+            }else if(class_exists($class)){
68
+                $controller = new $class();
69
+            }
70
+        }else{
71
+            if(file_exists('custom/include/MVC/Controller/SugarController.php')){
72
+                require_once('custom/include/MVC/Controller/SugarController.php');
73
+            }
74
+            if(class_exists('CustomSugarController')){
75
+                $controller = new CustomSugarController();
76
+            }else{
77
+            $controller = new SugarController();
78
+            }
79
+        }
80
+        //setup the controller
81
+        $controller->setup($module);
82
+        return $controller;
83
+    }
84 84
 
85 85
 }
86 86
 ?>
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,31 +49,31 @@
 block discarded – undo
49 49
 	 *
50 50
 	 * @return an instance of SugarController
51 51
 	 */
52
-	static function getController($module){
52
+	static function getController($module) {
53 53
 		$class = ucfirst($module).'Controller';
54
-		$customClass = 'Custom' . $class;
55
-		if(file_exists('custom/modules/'.$module.'/controller.php')){
56
-			$customClass = 'Custom' . $class;
54
+		$customClass = 'Custom'.$class;
55
+		if (file_exists('custom/modules/'.$module.'/controller.php')) {
56
+			$customClass = 'Custom'.$class;
57 57
 			require_once('custom/modules/'.$module.'/controller.php');
58
-			if(class_exists($customClass)){
58
+			if (class_exists($customClass)) {
59 59
 				$controller = new $customClass();
60
-			}else if(class_exists($class)){
60
+			} else if (class_exists($class)) {
61 61
 				$controller = new $class();
62 62
 			}
63
-		}elseif(file_exists('modules/'.$module.'/controller.php')){
63
+		}elseif (file_exists('modules/'.$module.'/controller.php')) {
64 64
 			require_once('modules/'.$module.'/controller.php');
65
-			if(class_exists($customClass)){
65
+			if (class_exists($customClass)) {
66 66
 				$controller = new $customClass();
67
-			}else if(class_exists($class)){
67
+			} else if (class_exists($class)) {
68 68
 				$controller = new $class();
69 69
 			}
70
-		}else{
71
-			if(file_exists('custom/include/MVC/Controller/SugarController.php')){
70
+		} else {
71
+			if (file_exists('custom/include/MVC/Controller/SugarController.php')) {
72 72
 				require_once('custom/include/MVC/Controller/SugarController.php');
73 73
 			}
74
-			if(class_exists('CustomSugarController')){
74
+			if (class_exists('CustomSugarController')) {
75 75
 				$controller = new CustomSugarController();
76
-			}else{
76
+			} else {
77 77
 			$controller = new SugarController();
78 78
 			}
79 79
 		}
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -57,23 +57,23 @@
 block discarded – undo
57 57
 			require_once('custom/modules/'.$module.'/controller.php');
58 58
 			if(class_exists($customClass)){
59 59
 				$controller = new $customClass();
60
-			}else if(class_exists($class)){
60
+			} else if(class_exists($class)){
61 61
 				$controller = new $class();
62 62
 			}
63
-		}elseif(file_exists('modules/'.$module.'/controller.php')){
63
+		} elseif(file_exists('modules/'.$module.'/controller.php')){
64 64
 			require_once('modules/'.$module.'/controller.php');
65 65
 			if(class_exists($customClass)){
66 66
 				$controller = new $customClass();
67
-			}else if(class_exists($class)){
67
+			} else if(class_exists($class)){
68 68
 				$controller = new $class();
69 69
 			}
70
-		}else{
70
+		} else{
71 71
 			if(file_exists('custom/include/MVC/Controller/SugarController.php')){
72 72
 				require_once('custom/include/MVC/Controller/SugarController.php');
73 73
 			}
74 74
 			if(class_exists('CustomSugarController')){
75 75
 				$controller = new CustomSugarController();
76
-			}else{
76
+			} else{
77 77
 			$controller = new SugarController();
78 78
 			}
79 79
 		}
Please login to merge, or discard this patch.
include/MVC/Controller/action_view_map.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
  * To change the template for this generated file go to
44 44
  * Window - Preferences - PHPeclipse - PHP - Code Templates
45 45
  */
46
- //format '<action_name>' => '<view_name>'
46
+    //format '<action_name>' => '<view_name>'
47 47
 $action_view_map['multieditview']= 'multiedit';
48 48
 $action_view_map['detailview']= 'detail';
49 49
 $action_view_map['editview']= 'edit';
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,21 +44,21 @@
 block discarded – undo
44 44
  * Window - Preferences - PHPeclipse - PHP - Code Templates
45 45
  */
46 46
  //format '<action_name>' => '<view_name>'
47
-$action_view_map['multieditview']= 'multiedit';
48
-$action_view_map['detailview']= 'detail';
49
-$action_view_map['editview']= 'edit';
50
-$action_view_map['listview']= 'list';
51
-$action_view_map['popup']= 'popup';
52
-$action_view_map['vcard']= 'vcard';
53
-$action_view_map['importvcard']= 'importvcard';
54
-$action_view_map['importvcardsave']= 'importvcardsave';
55
-$action_view_map['modulelistmenu']= 'modulelistmenu';
56
-$action_view_map['favorites']= 'favorites';
57
-$action_view_map['ajaxui']= 'ajaxui';
58
-$action_view_map['noaccess']= 'noaccess';
47
+$action_view_map['multieditview'] = 'multiedit';
48
+$action_view_map['detailview'] = 'detail';
49
+$action_view_map['editview'] = 'edit';
50
+$action_view_map['listview'] = 'list';
51
+$action_view_map['popup'] = 'popup';
52
+$action_view_map['vcard'] = 'vcard';
53
+$action_view_map['importvcard'] = 'importvcard';
54
+$action_view_map['importvcardsave'] = 'importvcardsave';
55
+$action_view_map['modulelistmenu'] = 'modulelistmenu';
56
+$action_view_map['favorites'] = 'favorites';
57
+$action_view_map['ajaxui'] = 'ajaxui';
58
+$action_view_map['noaccess'] = 'noaccess';
59 59
 
60 60
 // SugarPDF
61
-$action_view_map['sugarpdf']= 'sugarpdf';
61
+$action_view_map['sugarpdf'] = 'sugarpdf';
62 62
 $action_view_map['dc'] = 'dc';
63 63
 $action_view_map['dcajax'] = 'dcajax';
64 64
 $action_view_map['quick'] = 'quick';
Please login to merge, or discard this patch.
include/MVC/Controller/file_access_control_map.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -46,29 +46,29 @@
 block discarded – undo
46 46
  * Contributor(s): ______________________________________..
47 47
  ********************************************************************************/
48 48
 $file_access_control_map = array(
49
-	'modules' => array(
50
-		'administration' => array(
51
-			'actions' => array(
52
-				'backups',
53
-				'updater',
54
-			),
55
-			'links'	=> array(
56
-				'update',
57
-				'backup_management',
58
-				'upgrade_wizard',
59
-				'moduleBuilder',
60
-			),
61
-		),
62
-		'upgradewizard' => array(
63
-				'actions' => array(
64
-					'index',
65
-				),
66
-		),
67
-		'modulebuilder' => array(
68
-				'actions' => array(
69
-					'index' => array('params' => array('type' => array('mb'))),
70
-				),
71
-		),
72
-	)
49
+    'modules' => array(
50
+        'administration' => array(
51
+            'actions' => array(
52
+                'backups',
53
+                'updater',
54
+            ),
55
+            'links'	=> array(
56
+                'update',
57
+                'backup_management',
58
+                'upgrade_wizard',
59
+                'moduleBuilder',
60
+            ),
61
+        ),
62
+        'upgradewizard' => array(
63
+                'actions' => array(
64
+                    'index',
65
+                ),
66
+        ),
67
+        'modulebuilder' => array(
68
+                'actions' => array(
69
+                    'index' => array('params' => array('type' => array('mb'))),
70
+                ),
71
+        ),
72
+    )
73 73
 );
74 74
 ?>
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 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.
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.
include/javascript/getYUIComboFile.php 3 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 
43 43
 $yui_path = array(
44 44
     "2.9.0" => "include/javascript/yui",
45
-	"2_9_0" => "include/javascript/yui",
46
-	"3.3.0" => "include/javascript/yui3",
47
-	"3_3_0" => "include/javascript/yui3"
45
+    "2_9_0" => "include/javascript/yui",
46
+    "3.3.0" => "include/javascript/yui3",
47
+    "3_3_0" => "include/javascript/yui3"
48 48
 );
49 49
 $types = array(
50 50
     "js" => "application/javascript",
51
-	"css" => "text/css",
51
+    "css" => "text/css",
52 52
 );
53 53
 $out = "";
54 54
 
@@ -57,36 +57,36 @@  discard block
 block discarded – undo
57 57
 
58 58
 foreach ($_REQUEST as $param => $val)
59 59
 {
60
-	//No backtracking in the path
61
-	if (strpos($param, "..") !== false)
60
+    //No backtracking in the path
61
+    if (strpos($param, "..") !== false)
62 62
         continue;
63 63
 
64
-	$version = explode("/", $param);
65
-	$version = $version[0];
64
+    $version = explode("/", $param);
65
+    $version = $version[0];
66 66
     if (empty($yui_path[$version])) continue;
67 67
 
68 68
     $path = $yui_path[$version] . substr($param, strlen($version));
69 69
 
70
-	$extension = substr($path, strrpos($path, "_") + 1);
70
+    $extension = substr($path, strrpos($path, "_") + 1);
71 71
 
72
-	//Only allowed file extensions
73
-	if (empty($types[$extension]))
74
-	   continue;
72
+    //Only allowed file extensions
73
+    if (empty($types[$extension]))
74
+        continue;
75 75
 
76
-	if (empty($contentType))
76
+    if (empty($contentType))
77 77
     {
78 78
         $contentType = $types[$extension];
79 79
     }
80
-	//Put together the final filepath
81
-	$path = substr($path, 0, strrpos($path, "_")) . "." . $extension;
82
-	$contents = '';
83
-	if (is_file($path)) {
84
-	   $out .= "/*" . $path . "*/\n";
85
-	   $contents =  file_get_contents($path);
86
-	   $out .= $contents . "\n";
87
-	}
88
-	$path = empty($contents) ? $path : $contents;
89
-	$allpath .= md5($path);
80
+    //Put together the final filepath
81
+    $path = substr($path, 0, strrpos($path, "_")) . "." . $extension;
82
+    $contents = '';
83
+    if (is_file($path)) {
84
+        $out .= "/*" . $path . "*/\n";
85
+        $contents =  file_get_contents($path);
86
+        $out .= $contents . "\n";
87
+    }
88
+    $path = empty($contents) ? $path : $contents;
89
+    $allpath .= md5($path);
90 90
 }
91 91
 
92 92
 $etag = '"'.md5($allpath).'"';
Please login to merge, or discard this patch.
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.
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	$version = $version[0];
66 66
     if (empty($yui_path[$version])) continue;
67 67
 
68
-    $path = $yui_path[$version] . substr($param, strlen($version));
68
+    $path = $yui_path[$version].substr($param, strlen($version));
69 69
 
70 70
 	$extension = substr($path, strrpos($path, "_") + 1);
71 71
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
         $contentType = $types[$extension];
79 79
     }
80 80
 	//Put together the final filepath
81
-	$path = substr($path, 0, strrpos($path, "_")) . "." . $extension;
81
+	$path = substr($path, 0, strrpos($path, "_")).".".$extension;
82 82
 	$contents = '';
83 83
 	if (is_file($path)) {
84
-	   $out .= "/*" . $path . "*/\n";
85
-	   $contents =  file_get_contents($path);
86
-	   $out .= $contents . "\n";
84
+	   $out .= "/*".$path."*/\n";
85
+	   $contents = file_get_contents($path);
86
+	   $out .= $contents."\n";
87 87
 	}
88 88
 	$path = empty($contents) ? $path : $contents;
89 89
 	$allpath .= md5($path);
@@ -95,6 +95,6 @@  discard block
 block discarded – undo
95 95
 header("Cache-Control: private");
96 96
 header("Pragma: dummy=bogus");
97 97
 header("Etag: $etag");
98
-header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000));
98
+header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000));
99 99
 header("Content-Type: $contentType");
100 100
 echo ($out);
101 101
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 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.
@@ -38,7 +40,9 @@  discard block
 block discarded – undo
38 40
  * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
39 41
  ********************************************************************************/
40 42
 
41
-if (empty($_REQUEST)) die();
43
+if (empty($_REQUEST)) {
44
+    die();
45
+}
42 46
 
43 47
 $yui_path = array(
44 48
     "2.9.0" => "include/javascript/yui",
@@ -58,20 +62,24 @@  discard block
 block discarded – undo
58 62
 foreach ($_REQUEST as $param => $val)
59 63
 {
60 64
 	//No backtracking in the path
61
-	if (strpos($param, "..") !== false)
62
-        continue;
65
+	if (strpos($param, "..") !== false) {
66
+	        continue;
67
+	}
63 68
 
64 69
 	$version = explode("/", $param);
65 70
 	$version = $version[0];
66
-    if (empty($yui_path[$version])) continue;
71
+    if (empty($yui_path[$version])) {
72
+        continue;
73
+    }
67 74
 
68 75
     $path = $yui_path[$version] . substr($param, strlen($version));
69 76
 
70 77
 	$extension = substr($path, strrpos($path, "_") + 1);
71 78
 
72 79
 	//Only allowed file extensions
73
-	if (empty($types[$extension]))
74
-	   continue;
80
+	if (empty($types[$extension])) {
81
+		   continue;
82
+	}
75 83
 
76 84
 	if (empty($contentType))
77 85
     {
Please login to merge, or discard this patch.
include/Dashlets/DashletGenericChart.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function setRefreshIcon()
141 141
     {
142
-    	$additionalTitle = '';
142
+        $additionalTitle = '';
143 143
         if($this->isRefreshable)
144 144
 
145 145
             $additionalTitle .= '<a href="#" onclick="SUGAR.mySugar.retrieveDashlet(\''
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     public function displayScript()
166 166
     {
167 167
 
168
-		require_once('include/SugarCharts/SugarChartFactory.php');
169
-		$sugarChart = SugarChartFactory::getInstance();
170
-		return $sugarChart->getDashletScript($this->id);
168
+        require_once('include/SugarCharts/SugarChartFactory.php');
169
+        $sugarChart = SugarChartFactory::getInstance();
170
+        return $sugarChart->getDashletScript($this->id);
171 171
 
172 172
     }
173 173
 
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
         $this->getConfigureSmartyInstance()->assign('showClearButton', $this->isConfigPanelClearShown);
273 273
         
274 274
         if($this->isAutoRefreshable()) {
275
-       		$this->getConfigureSmartyInstance()->assign('isRefreshable', true);
276
-			$this->getConfigureSmartyInstance()->assign('autoRefresh', $GLOBALS['app_strings']['LBL_DASHLET_CONFIGURE_AUTOREFRESH']);
277
-			$this->getConfigureSmartyInstance()->assign('autoRefreshOptions', $this->getAutoRefreshOptions());
278
-			$this->getConfigureSmartyInstance()->assign('autoRefreshSelect', $this->autoRefresh);
279
-		}
275
+                $this->getConfigureSmartyInstance()->assign('isRefreshable', true);
276
+            $this->getConfigureSmartyInstance()->assign('autoRefresh', $GLOBALS['app_strings']['LBL_DASHLET_CONFIGURE_AUTOREFRESH']);
277
+            $this->getConfigureSmartyInstance()->assign('autoRefreshOptions', $this->getAutoRefreshOptions());
278
+            $this->getConfigureSmartyInstance()->assign('autoRefreshSelect', $this->autoRefresh);
279
+        }
280 280
 
281 281
         return parent::displayOptions() . $this->getConfigureSmartyInstance()->fetch($this->_configureTpl);
282 282
     }
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             $dashletOffset = 0;
340 340
             $module = $_REQUEST['module'];
341 341
             if(isset($_REQUEST[$module.'2_'.strtoupper($this->getSeedBean()->object_name).'_offset'])) {
342
-            	$dashletOffset = $_REQUEST[$module.'2_'.strtoupper($this->getSeedBean()->object_name).'_offset'];
342
+                $dashletOffset = $_REQUEST[$module.'2_'.strtoupper($this->getSeedBean()->object_name).'_offset'];
343 343
             }
344 344
         }
345 345
 
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 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.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     /**
60 60
      * @see Dashlet::$isRefreshable
61 61
      */
62
-    public $isRefreshable  = true;
62
+    public $isRefreshable = true;
63 63
 
64 64
     /**
65 65
      * location of smarty template file for configuring
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
     {
106 106
         parent::Dashlet($id);
107 107
 
108
-        if ( isset($options) ) {
109
-            foreach ( $options as $key => $value ) {
108
+        if (isset($options)) {
109
+            foreach ($options as $key => $value) {
110 110
                 $this->$key = $value;
111 111
             }
112 112
         }
113 113
 
114 114
         // load searchfields
115 115
         $classname = get_class($this);
116
-        if ( is_file("modules/Charts/Dashlets/$classname/$classname.data.php") ) {
116
+        if (is_file("modules/Charts/Dashlets/$classname/$classname.data.php")) {
117 117
             require("modules/Charts/Dashlets/$classname/$classname.data.php");
118 118
             $this->_searchFields = $dashletData[$classname]['searchFields'];
119 119
         }
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
         // load language files
122 122
         $this->loadLanguage($classname, 'modules/Charts/Dashlets/');
123 123
 
124
-        if ( empty($options['title']) )
124
+        if (empty($options['title']))
125 125
             $this->title = $this->dashletStrings['LBL_TITLE'];
126
-        if ( isset($options['autoRefresh']) )
126
+        if (isset($options['autoRefresh']))
127 127
             $this->autoRefresh = $options['autoRefresh'];
128 128
 
129 129
         $this->layoutManager = new LayoutManager();
130 130
         $this->layoutManager->setAttribute('context', 'Report');
131 131
         // fake a reporter object here just to pass along the db type used in many widgets.
132 132
         // this should be taken out when sugarwidgets change
133
-        $temp = (object) array('db' => &$GLOBALS['db'], 'report_def_str' => '');
133
+        $temp = (object)array('db' => &$GLOBALS['db'], 'report_def_str' => '');
134 134
         $this->layoutManager->setAttributePtr('reporter', $temp);
135 135
     }
136 136
 
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
     public function setRefreshIcon()
141 141
     {
142 142
     	$additionalTitle = '';
143
-        if($this->isRefreshable)
143
+        if ($this->isRefreshable)
144 144
 
145 145
             $additionalTitle .= '<a href="#" onclick="SUGAR.mySugar.retrieveDashlet(\''
146 146
                 . $this->id
147 147
                 . '\',\'predefined_chart\'); return false;"><!--not_in_theme!-->'
148 148
                 . SugarThemeRegistry::current()->getImage(
149 149
                     'dashlet-header-refresh',
150
-                    'border="0" align="absmiddle" title="'. translate('LBL_DASHLET_REFRESH', 'Home') . '"',
150
+                    'border="0" align="absmiddle" title="'.translate('LBL_DASHLET_REFRESH', 'Home').'"',
151 151
                     null,
152 152
                     null,
153 153
                     '.gif',
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     protected function getConfigureSmartyInstance()
179 179
     {
180
-        if ( !($this->_configureSS instanceof Sugar_Smarty) ) {
180
+        if (!($this->_configureSS instanceof Sugar_Smarty)) {
181 181
 
182 182
             $this->_configureSS = new Sugar_Smarty();
183 183
         }
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
 
201 201
         $options = array();
202 202
 
203
-        foreach($req as $name => $value)
204
-            if(!is_array($value)) $req[$name] = trim($value);
203
+        foreach ($req as $name => $value)
204
+            if (!is_array($value)) $req[$name] = trim($value);
205 205
 
206
-        foreach($this->_searchFields as $name => $params) {
206
+        foreach ($this->_searchFields as $name => $params) {
207 207
             $widgetDef = $params;
208
-            if ( isset($this->getSeedBean()->field_defs[$name]) )
208
+            if (isset($this->getSeedBean()->field_defs[$name]))
209 209
                 $widgetDef = $this->getSeedBean()->field_defs[$name];
210
-            if ( $widgetDef['type'] == 'date')           // special case date types
210
+            if ($widgetDef['type'] == 'date')           // special case date types
211 211
                 $options[$widgetDef['name']] = $timedate->swap_formats($req['type_'.$widgetDef['name']], $timedate->get_date_format(), $timedate->dbDayFormat);
212
-            elseif ( $widgetDef['type'] == 'time')       // special case time types
212
+            elseif ($widgetDef['type'] == 'time')       // special case time types
213 213
                 $options[$widgetDef['name']] = $timedate->swap_formats($req['type_'.$widgetDef['name']], $timedate->get_time_format(), $timedate->dbTimeFormat);
214
-            elseif ( $widgetDef['type'] == 'datepicker') // special case datepicker types
214
+            elseif ($widgetDef['type'] == 'datepicker') // special case datepicker types
215 215
                 $options[$widgetDef['name']] = $timedate->swap_formats($req[$widgetDef['name']], $timedate->get_date_format(), $timedate->dbDayFormat);
216 216
             elseif (!empty($req[$widgetDef['name']]))
217 217
                 $options[$widgetDef['name']] = $req[$widgetDef['name']];
@@ -234,36 +234,36 @@  discard block
 block discarded – undo
234 234
     {
235 235
         $currentSearchFields = array();
236 236
 
237
-        if ( is_array($this->_searchFields) ) {
238
-            foreach($this->_searchFields as $name=>$params) {
239
-                if(!empty($name)) {
237
+        if (is_array($this->_searchFields)) {
238
+            foreach ($this->_searchFields as $name=>$params) {
239
+                if (!empty($name)) {
240 240
                     $name = strtolower($name);
241 241
                     $currentSearchFields[$name] = array();
242 242
 
243 243
                     $widgetDef = $params;
244
-                    if ( isset($this->getSeedBean()->field_defs[$name]) )
244
+                    if (isset($this->getSeedBean()->field_defs[$name]))
245 245
                         $widgetDef = $this->getSeedBean()->field_defs[$name];
246 246
 
247
-                    if($widgetDef['type'] == 'enum' || $widgetDef['type'] == 'singleenum') $widgetDef['remove_blank'] = true; // remove the blank option for the dropdown
247
+                    if ($widgetDef['type'] == 'enum' || $widgetDef['type'] == 'singleenum') $widgetDef['remove_blank'] = true; // remove the blank option for the dropdown
248 248
 
249
-                    if ( empty($widgetDef['input_name0']) )
249
+                    if (empty($widgetDef['input_name0']))
250 250
                         $widgetDef['input_name0'] = empty($this->$name) ? '' : $this->$name;
251 251
                     $currentSearchFields[$name]['label'] = translate($widgetDef['vname'], $this->getSeedBean()->module_dir);
252
-                    if ( $currentSearchFields[$name]['label'] == $widgetDef['vname'] )
252
+                    if ($currentSearchFields[$name]['label'] == $widgetDef['vname'])
253 253
                         $currentSearchFields[$name]['label'] = translate($widgetDef['vname'], 'Charts');
254 254
                     $currentSearchFields[$name]['input'] = $this->layoutManager->widgetDisplayInput($widgetDef, true, (empty($this->$name) ? '' : $this->$name));
255 255
                 }
256 256
                 else { // ability to create spacers in input fields
257
-                    $currentSearchFields['blank' + $count]['label'] = '';
258
-                    $currentSearchFields['blank' + $count]['input'] = '';
257
+                    $currentSearchFields['blank' +$count]['label'] = '';
258
+                    $currentSearchFields['blank' +$count]['input'] = '';
259 259
                     $count++;
260 260
                 }
261 261
             }
262 262
         }
263 263
         $this->currentSearchFields = $currentSearchFields;
264
-        $this->getConfigureSmartyInstance()->assign('title',translate('LBL_TITLE','Charts'));
265
-        $this->getConfigureSmartyInstance()->assign('save',$GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL']);
266
-        $this->getConfigureSmartyInstance()->assign('clear',$GLOBALS['app_strings']['LBL_CLEAR_BUTTON_LABEL']);
264
+        $this->getConfigureSmartyInstance()->assign('title', translate('LBL_TITLE', 'Charts'));
265
+        $this->getConfigureSmartyInstance()->assign('save', $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL']);
266
+        $this->getConfigureSmartyInstance()->assign('clear', $GLOBALS['app_strings']['LBL_CLEAR_BUTTON_LABEL']);
267 267
         $this->getConfigureSmartyInstance()->assign('id', $this->id);
268 268
         $this->getConfigureSmartyInstance()->assign('searchFields', $this->currentSearchFields);
269 269
         $this->getConfigureSmartyInstance()->assign('dashletTitle', $this->title);
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
         $this->getConfigureSmartyInstance()->assign('module', $_REQUEST['module']);
272 272
         $this->getConfigureSmartyInstance()->assign('showClearButton', $this->isConfigPanelClearShown);
273 273
         
274
-        if($this->isAutoRefreshable()) {
274
+        if ($this->isAutoRefreshable()) {
275 275
        		$this->getConfigureSmartyInstance()->assign('isRefreshable', true);
276 276
 			$this->getConfigureSmartyInstance()->assign('autoRefresh', $GLOBALS['app_strings']['LBL_DASHLET_CONFIGURE_AUTOREFRESH']);
277 277
 			$this->getConfigureSmartyInstance()->assign('autoRefreshOptions', $this->getAutoRefreshOptions());
278 278
 			$this->getConfigureSmartyInstance()->assign('autoRefreshSelect', $this->autoRefresh);
279 279
 		}
280 280
 
281
-        return parent::displayOptions() . $this->getConfigureSmartyInstance()->fetch($this->_configureTpl);
281
+        return parent::displayOptions().$this->getConfigureSmartyInstance()->fetch($this->_configureTpl);
282 282
     }
283 283
 
284 284
     /**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      */
290 290
     protected function getSeedBean()
291 291
     {
292
-        if ( !($this->_seedBean instanceof SugarBean) )
292
+        if (!($this->_seedBean instanceof SugarBean))
293 293
             $this->_seedBean = SugarModule::get($this->_seedName)->loadBean();
294 294
 
295 295
         return $this->_seedBean;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function display()
324 324
     {
325
-        return parent::display() . $this->processAutoRefresh();
325
+        return parent::display().$this->processAutoRefresh();
326 326
     }
327 327
 
328 328
     /**
@@ -335,28 +335,28 @@  discard block
 block discarded – undo
335 335
     {
336 336
         global $sugar_config;
337 337
 
338
-        if ( empty($dashletOffset) ) {
338
+        if (empty($dashletOffset)) {
339 339
             $dashletOffset = 0;
340 340
             $module = $_REQUEST['module'];
341
-            if(isset($_REQUEST[$module.'2_'.strtoupper($this->getSeedBean()->object_name).'_offset'])) {
341
+            if (isset($_REQUEST[$module.'2_'.strtoupper($this->getSeedBean()->object_name).'_offset'])) {
342 342
             	$dashletOffset = $_REQUEST[$module.'2_'.strtoupper($this->getSeedBean()->object_name).'_offset'];
343 343
             }
344 344
         }
345 345
 
346
-        if ( !$this->isRefreshable ) {
346
+        if (!$this->isRefreshable) {
347 347
             return '';
348 348
         }
349
-        if ( !empty($sugar_config['dashlet_auto_refresh_min']) && $sugar_config['dashlet_auto_refresh_min'] == -1 ) {
349
+        if (!empty($sugar_config['dashlet_auto_refresh_min']) && $sugar_config['dashlet_auto_refresh_min'] == -1) {
350 350
             return '';
351 351
         }
352 352
         $autoRefreshSS = new Sugar_Smarty();
353 353
         $autoRefreshSS->assign('dashletOffset', $dashletOffset);
354 354
         $autoRefreshSS->assign('dashletId', $this->id);
355
-        $autoRefreshSS->assign('strippedDashletId', str_replace("-","",$this->id)); //javascript doesn't like "-" in function names
355
+        $autoRefreshSS->assign('strippedDashletId', str_replace("-", "", $this->id)); //javascript doesn't like "-" in function names
356 356
         $autoRefreshSS->assign('dashletRefreshInterval', $this->getAutoRefresh());
357 357
         $autoRefreshSS->assign('url', "predefined_chart");
358 358
         $tpl = 'include/Dashlets/DashletGenericAutoRefresh.tpl';
359
-        if ( $_REQUEST['action'] == "DynamicAction" ) {
359
+        if ($_REQUEST['action'] == "DynamicAction") {
360 360
             $tpl = 'include/Dashlets/DashletGenericAutoRefreshDynamic.tpl';
361 361
         }
362 362
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
         $row = $db->fetchByAssoc($result);
374 374
 
375
-        while ($row != null){
375
+        while ($row != null) {
376 376
             $dataSet[] = $row;
377 377
             $row = $db->fetchByAssoc($result);
378 378
         }
@@ -392,19 +392,19 @@  discard block
 block discarded – undo
392 392
     bool $ifsort2                 Whether to sort by the second column or just translate the second column.
393 393
      * @return        The sorted and translated data.
394 394
      */
395
-    function sortData($data_set, $keycolname1=null, $translate1=false, $keycolname2=null, $translate2=false, $ifsort2=false) {
395
+    function sortData($data_set, $keycolname1 = null, $translate1 = false, $keycolname2 = null, $translate2 = false, $ifsort2 = false) {
396 396
         //You can set whether the columns need to be translated or sorted. It the column needn't to be translated, the sorting must be done in SQL, this function will not do the sorting.
397 397
         global $app_list_strings;
398 398
         $sortby1[] = array();
399 399
         foreach ($data_set as $row) {
400
-            $sortby1[]  = $row[$keycolname1];
400
+            $sortby1[] = $row[$keycolname1];
401 401
         }
402 402
         $sortby1 = array_unique($sortby1);
403 403
         //The data is from the database, the sorting should be done in the sql. So I will not do the sort here.
404
-        if($translate1) {
404
+        if ($translate1) {
405 405
             $temp_sortby1 = array();
406
-            foreach(array_keys($app_list_strings[$keycolname1.'_dom']) as $sortby1_value) {
407
-                if(in_array($sortby1_value, $sortby1)) {
406
+            foreach (array_keys($app_list_strings[$keycolname1.'_dom']) as $sortby1_value) {
407
+                if (in_array($sortby1_value, $sortby1)) {
408 408
                     $temp_sortby1[] = $sortby1_value;
409 409
                 }
410 410
             }
@@ -412,21 +412,21 @@  discard block
 block discarded – undo
412 412
         }
413 413
 
414 414
         //if(isset($sortby1[0]) && $sortby1[0]=='') unset($sortby1[0]);//the beginning of lead_source_dom is blank.
415
-        if(isset($sortby1[0]) && $sortby1[0]==array()) unset($sortby1[0]);//the beginning of month after search is blank.
415
+        if (isset($sortby1[0]) && $sortby1[0] == array()) unset($sortby1[0]); //the beginning of month after search is blank.
416 416
 
417
-        if($ifsort2==false) $sortby2=array(0);
417
+        if ($ifsort2 == false) $sortby2 = array(0);
418 418
 
419
-        if($keycolname2!=null) {
419
+        if ($keycolname2 != null) {
420 420
             $sortby2 = array();
421 421
             foreach ($data_set as $row) {
422
-                $sortby2[]  = $row[$keycolname2];
422
+                $sortby2[] = $row[$keycolname2];
423 423
             }
424 424
             //The data is from the database, the sorting should be done in the sql. So I will not do the sort here.
425 425
             $sortby2 = array_unique($sortby2);
426
-            if($translate2) {
426
+            if ($translate2) {
427 427
                 $temp_sortby2 = array();
428
-                foreach(array_keys($app_list_strings[$keycolname2.'_dom']) as $sortby2_value) {
429
-                    if(in_array($sortby2_value, $sortby2)) {
428
+                foreach (array_keys($app_list_strings[$keycolname2.'_dom']) as $sortby2_value) {
429
+                    if (in_array($sortby2_value, $sortby2)) {
430 430
                         $temp_sortby2[] = $sortby2_value;
431 431
                     }
432 432
                 }
@@ -434,42 +434,42 @@  discard block
 block discarded – undo
434 434
             }
435 435
         }
436 436
 
437
-        $data=array();
437
+        $data = array();
438 438
 
439
-        foreach($sortby1 as $sort1) {
440
-            foreach($sortby2 as $sort2) {
441
-                if($ifsort2) $a=0;
442
-                foreach($data_set as $key => $value){
443
-                    if($value[$keycolname1] == $sort1 && (!$ifsort2 || $value[$keycolname2]== $sort2)) {
444
-                        if($translate1) {
439
+        foreach ($sortby1 as $sort1) {
440
+            foreach ($sortby2 as $sort2) {
441
+                if ($ifsort2) $a = 0;
442
+                foreach ($data_set as $key => $value) {
443
+                    if ($value[$keycolname1] == $sort1 && (!$ifsort2 || $value[$keycolname2] == $sort2)) {
444
+                        if ($translate1) {
445 445
                             $value[$keycolname1.'_dom_option'] = $value[$keycolname1];
446 446
                             $value[$keycolname1] = $app_list_strings[$keycolname1.'_dom'][$value[$keycolname1]];
447 447
                         }
448
-                        if($translate2) {
448
+                        if ($translate2) {
449 449
                             $value[$keycolname2.'_dom_option'] = $value[$keycolname2];
450 450
                             $value[$keycolname2] = $app_list_strings[$keycolname2.'_dom'][$value[$keycolname2]];
451 451
                         }
452 452
                         array_push($data, $value);
453 453
                         unset($data_set[$key]);
454
-                        $a=1;
454
+                        $a = 1;
455 455
                     }
456 456
                 }
457
-                if($ifsort2 && $a==0) {//Add 0 for sorting by the second column, if the first row doesn't have a certain col, it will fill the column with 0.
458
-                    $val=array();
457
+                if ($ifsort2 && $a == 0) {//Add 0 for sorting by the second column, if the first row doesn't have a certain col, it will fill the column with 0.
458
+                    $val = array();
459 459
                     $val['total'] = 0;
460 460
                     $val['count'] = 0;
461
-                    if($translate1) {
461
+                    if ($translate1) {
462 462
                         $val[$keycolname1] = $app_list_strings[$keycolname1.'_dom'][$sort1];
463 463
                         $val[$keycolname1.'_dom_option'] = $sort1;
464 464
                     }
465 465
                     else {
466 466
                         $val[$keycolname1] = $sort1;
467 467
                     }
468
-                    if($translate2) {
468
+                    if ($translate2) {
469 469
                         $val[$keycolname2] = $app_list_strings[$keycolname2.'_dom'][$sort2];
470 470
                         $val[$keycolname2.'_dom_option'] = $sort2;
471 471
                     }
472
-                    elseif($keycolname2!=null) {
472
+                    elseif ($keycolname2 != null) {
473 473
                         $val[$keycolname2] = $sort2;
474 474
                     }
475 475
                     array_push($data, $val);
Please login to merge, or discard this patch.
Braces   +59 added lines, -36 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.
@@ -121,10 +123,12 @@  discard block
 block discarded – undo
121 123
         // load language files
122 124
         $this->loadLanguage($classname, 'modules/Charts/Dashlets/');
123 125
 
124
-        if ( empty($options['title']) )
125
-            $this->title = $this->dashletStrings['LBL_TITLE'];
126
-        if ( isset($options['autoRefresh']) )
127
-            $this->autoRefresh = $options['autoRefresh'];
126
+        if ( empty($options['title']) ) {
127
+                    $this->title = $this->dashletStrings['LBL_TITLE'];
128
+        }
129
+        if ( isset($options['autoRefresh']) ) {
130
+                    $this->autoRefresh = $options['autoRefresh'];
131
+        }
128 132
 
129 133
         $this->layoutManager = new LayoutManager();
130 134
         $this->layoutManager->setAttribute('context', 'Report');
@@ -140,8 +144,8 @@  discard block
 block discarded – undo
140 144
     public function setRefreshIcon()
141 145
     {
142 146
     	$additionalTitle = '';
143
-        if($this->isRefreshable)
144
-
147
+        if($this->isRefreshable) {
148
+        
145 149
             $additionalTitle .= '<a href="#" onclick="SUGAR.mySugar.retrieveDashlet(\''
146 150
                 . $this->id
147 151
                 . '\',\'predefined_chart\'); return false;"><!--not_in_theme!-->'
@@ -154,6 +158,7 @@  discard block
 block discarded – undo
154 158
                     translate('LBL_DASHLET_REFRESH', 'Home')
155 159
                 )
156 160
                 . '</a>';
161
+        }
157 162
         return $additionalTitle;
158 163
     }
159 164
 
@@ -200,25 +205,32 @@  discard block
 block discarded – undo
200 205
 
201 206
         $options = array();
202 207
 
203
-        foreach($req as $name => $value)
204
-            if(!is_array($value)) $req[$name] = trim($value);
208
+        foreach($req as $name => $value) {
209
+                    if(!is_array($value)) $req[$name] = trim($value);
210
+        }
205 211
 
206 212
         foreach($this->_searchFields as $name => $params) {
207 213
             $widgetDef = $params;
208
-            if ( isset($this->getSeedBean()->field_defs[$name]) )
209
-                $widgetDef = $this->getSeedBean()->field_defs[$name];
210
-            if ( $widgetDef['type'] == 'date')           // special case date types
214
+            if ( isset($this->getSeedBean()->field_defs[$name]) ) {
215
+                            $widgetDef = $this->getSeedBean()->field_defs[$name];
216
+            }
217
+            if ( $widgetDef['type'] == 'date') {
218
+                // special case date types
211 219
                 $options[$widgetDef['name']] = $timedate->swap_formats($req['type_'.$widgetDef['name']], $timedate->get_date_format(), $timedate->dbDayFormat);
212
-            elseif ( $widgetDef['type'] == 'time')       // special case time types
220
+            } elseif ( $widgetDef['type'] == 'time') {
221
+                // special case time types
213 222
                 $options[$widgetDef['name']] = $timedate->swap_formats($req['type_'.$widgetDef['name']], $timedate->get_time_format(), $timedate->dbTimeFormat);
214
-            elseif ( $widgetDef['type'] == 'datepicker') // special case datepicker types
223
+            } elseif ( $widgetDef['type'] == 'datepicker') {
224
+                // special case datepicker types
215 225
                 $options[$widgetDef['name']] = $timedate->swap_formats($req[$widgetDef['name']], $timedate->get_date_format(), $timedate->dbDayFormat);
216
-            elseif (!empty($req[$widgetDef['name']]))
217
-                $options[$widgetDef['name']] = $req[$widgetDef['name']];
226
+            } elseif (!empty($req[$widgetDef['name']])) {
227
+                            $options[$widgetDef['name']] = $req[$widgetDef['name']];
228
+            }
218 229
         }
219 230
 
220
-        if (!empty($req['dashletTitle']))
221
-            $options['title'] = $req['dashletTitle'];
231
+        if (!empty($req['dashletTitle'])) {
232
+                    $options['title'] = $req['dashletTitle'];
233
+        }
222 234
 
223 235
         $options['autoRefresh'] = empty($req['autoRefresh']) ? '0' : $req['autoRefresh'];
224 236
 
@@ -241,19 +253,24 @@  discard block
 block discarded – undo
241 253
                     $currentSearchFields[$name] = array();
242 254
 
243 255
                     $widgetDef = $params;
244
-                    if ( isset($this->getSeedBean()->field_defs[$name]) )
245
-                        $widgetDef = $this->getSeedBean()->field_defs[$name];
256
+                    if ( isset($this->getSeedBean()->field_defs[$name]) ) {
257
+                                            $widgetDef = $this->getSeedBean()->field_defs[$name];
258
+                    }
246 259
 
247
-                    if($widgetDef['type'] == 'enum' || $widgetDef['type'] == 'singleenum') $widgetDef['remove_blank'] = true; // remove the blank option for the dropdown
260
+                    if($widgetDef['type'] == 'enum' || $widgetDef['type'] == 'singleenum') {
261
+                        $widgetDef['remove_blank'] = true;
262
+                    }
263
+                    // remove the blank option for the dropdown
248 264
 
249
-                    if ( empty($widgetDef['input_name0']) )
250
-                        $widgetDef['input_name0'] = empty($this->$name) ? '' : $this->$name;
265
+                    if ( empty($widgetDef['input_name0']) ) {
266
+                                            $widgetDef['input_name0'] = empty($this->$name) ? '' : $this->$name;
267
+                    }
251 268
                     $currentSearchFields[$name]['label'] = translate($widgetDef['vname'], $this->getSeedBean()->module_dir);
252
-                    if ( $currentSearchFields[$name]['label'] == $widgetDef['vname'] )
253
-                        $currentSearchFields[$name]['label'] = translate($widgetDef['vname'], 'Charts');
269
+                    if ( $currentSearchFields[$name]['label'] == $widgetDef['vname'] ) {
270
+                                            $currentSearchFields[$name]['label'] = translate($widgetDef['vname'], 'Charts');
271
+                    }
254 272
                     $currentSearchFields[$name]['input'] = $this->layoutManager->widgetDisplayInput($widgetDef, true, (empty($this->$name) ? '' : $this->$name));
255
-                }
256
-                else { // ability to create spacers in input fields
273
+                } else { // ability to create spacers in input fields
257 274
                     $currentSearchFields['blank' + $count]['label'] = '';
258 275
                     $currentSearchFields['blank' + $count]['input'] = '';
259 276
                     $count++;
@@ -289,8 +306,9 @@  discard block
 block discarded – undo
289 306
      */
290 307
     protected function getSeedBean()
291 308
     {
292
-        if ( !($this->_seedBean instanceof SugarBean) )
293
-            $this->_seedBean = SugarModule::get($this->_seedName)->loadBean();
309
+        if ( !($this->_seedBean instanceof SugarBean) ) {
310
+                    $this->_seedBean = SugarModule::get($this->_seedName)->loadBean();
311
+        }
294 312
 
295 313
         return $this->_seedBean;
296 314
     }
@@ -412,9 +430,14 @@  discard block
 block discarded – undo
412 430
         }
413 431
 
414 432
         //if(isset($sortby1[0]) && $sortby1[0]=='') unset($sortby1[0]);//the beginning of lead_source_dom is blank.
415
-        if(isset($sortby1[0]) && $sortby1[0]==array()) unset($sortby1[0]);//the beginning of month after search is blank.
433
+        if(isset($sortby1[0]) && $sortby1[0]==array()) {
434
+            unset($sortby1[0]);
435
+        }
436
+        //the beginning of month after search is blank.
416 437
 
417
-        if($ifsort2==false) $sortby2=array(0);
438
+        if($ifsort2==false) {
439
+            $sortby2=array(0);
440
+        }
418 441
 
419 442
         if($keycolname2!=null) {
420 443
             $sortby2 = array();
@@ -438,7 +461,9 @@  discard block
 block discarded – undo
438 461
 
439 462
         foreach($sortby1 as $sort1) {
440 463
             foreach($sortby2 as $sort2) {
441
-                if($ifsort2) $a=0;
464
+                if($ifsort2) {
465
+                    $a=0;
466
+                }
442 467
                 foreach($data_set as $key => $value){
443 468
                     if($value[$keycolname1] == $sort1 && (!$ifsort2 || $value[$keycolname2]== $sort2)) {
444 469
                         if($translate1) {
@@ -461,15 +486,13 @@  discard block
 block discarded – undo
461 486
                     if($translate1) {
462 487
                         $val[$keycolname1] = $app_list_strings[$keycolname1.'_dom'][$sort1];
463 488
                         $val[$keycolname1.'_dom_option'] = $sort1;
464
-                    }
465
-                    else {
489
+                    } else {
466 490
                         $val[$keycolname1] = $sort1;
467 491
                     }
468 492
                     if($translate2) {
469 493
                         $val[$keycolname2] = $app_list_strings[$keycolname2.'_dom'][$sort2];
470 494
                         $val[$keycolname2.'_dom_option'] = $sort2;
471
-                    }
472
-                    elseif($keycolname2!=null) {
495
+                    } elseif($keycolname2!=null) {
473 496
                         $val[$keycolname2] = $sort2;
474 497
                     }
475 498
                     array_push($data, $val);
Please login to merge, or discard this patch.