Completed
Push — console-installer ( 03fc02...67c42e )
by Adam
72:27 queued 53:14
created
include/database/MssqlManager.php 1 patch
Braces   +202 added lines, -159 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.
@@ -168,8 +170,9 @@  discard block
 block discarded – undo
168 170
     {
169 171
         global $sugar_config;
170 172
 
171
-        if (is_null($configOptions))
172
-            $configOptions = $sugar_config['dbconfig'];
173
+        if (is_null($configOptions)) {
174
+                    $configOptions = $sugar_config['dbconfig'];
175
+        }
173 176
 
174 177
         //SET DATEFORMAT to 'YYYY-MM-DD''
175 178
         ini_set('mssql.datetimeconvert', '0');
@@ -258,8 +261,9 @@  discard block
 block discarded – undo
258 261
 			}
259 262
          }
260 263
 
261
-        if(!$this->checkError('Could Not Connect', $dieOnError))
262
-            $GLOBALS['log']->info("connected to db");
264
+        if(!$this->checkError('Could Not Connect', $dieOnError)) {
265
+                    $GLOBALS['log']->info("connected to db");
266
+        }
263 267
 
264 268
         $this->connectOptions = $configOptions;
265 269
 
@@ -284,8 +288,9 @@  discard block
 block discarded – undo
284 288
             return $this->queryArray($sql, $dieOnError, $msg, $suppress);
285 289
         }
286 290
         // Flag if there are odd number of single quotes
287
-        if ((substr_count($sql, "'") & 1))
288
-            $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes.");
291
+        if ((substr_count($sql, "'") & 1)) {
292
+                    $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes.");
293
+        }
289 294
 
290 295
 		$sql = $this->_appendN($sql);
291 296
 
@@ -308,14 +313,16 @@  discard block
 block discarded – undo
308 313
 			$sqlpos2 = strpos($sqlmsg, 'Warning:');
309 314
 			$sqlpos3 = strpos($sqlmsg, 'Checking identity information:');
310 315
 
311
-			if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false)		// if sqlmsg has 'Changed database context to', just log it
316
+			if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) {
317
+			    // if sqlmsg has 'Changed database context to', just log it
312 318
 				$GLOBALS['log']->debug($sqlmsg . ": " . $sql );
313
-			else {
319
+			} else {
314 320
 				$GLOBALS['log']->fatal($sqlmsg . ": " . $sql );
315
-				if($dieOnError)
316
-					sugar_die('SQL Error : ' . $sqlmsg);
317
-				else
318
-					echo 'SQL Error : ' . $sqlmsg;
321
+				if($dieOnError) {
322
+									sugar_die('SQL Error : ' . $sqlmsg);
323
+				} else {
324
+									echo 'SQL Error : ' . $sqlmsg;
325
+				}
319 326
 			}
320 327
         }
321 328
 
@@ -340,8 +347,9 @@  discard block
 block discarded – undo
340 347
     private function handleUnionLimitQuery($sql, $start, $count)
341 348
     {
342 349
         //set the start to 0, no negs
343
-        if ($start < 0)
344
-            $start=0;
350
+        if ($start < 0) {
351
+                    $start=0;
352
+        }
345 353
 
346 354
         $GLOBALS['log']->debug(print_r(func_get_args(),true));
347 355
 
@@ -390,8 +398,7 @@  discard block
 block discarded – undo
390 398
                 $rowNumOrderBy = 'id';
391 399
                 $unionOrderBy = "";
392 400
             }
393
-        }
394
-        else {
401
+        } else {
395 402
             //there are no order by elements, so just pass back string
396 403
             $unionsql = $sql;
397 404
             //with no guidance on what to use for required order by in rownumber function,
@@ -413,8 +420,7 @@  discard block
 block discarded – undo
413 420
         if ($count == 1 && $start == 0)
414 421
         {
415 422
             $limitUnionSQL = "SELECT TOP $count * FROM (" .$unionsql .") as top_count ".$unionOrderBy;
416
-        }
417
-        else
423
+        } else
418 424
         {
419 425
             $limitUnionSQL = "SELECT TOP $count * FROM( select ROW_NUMBER() OVER ( order by "
420 426
             .$rowNumOrderBy.") AS row_number, * FROM ("
@@ -436,11 +442,12 @@  discard block
 block discarded – undo
436 442
         $count = (int)$count;
437 443
         $newSQL = $sql;
438 444
         $distinctSQLARRAY = array();
439
-        if (strpos($sql, "UNION") && !preg_match("/(')(UNION).?(')/i", $sql))
440
-            $newSQL = $this->handleUnionLimitQuery($sql,$start,$count);
441
-        else {
442
-            if ($start < 0)
443
-                $start = 0;
445
+        if (strpos($sql, "UNION") && !preg_match("/(')(UNION).?(')/i", $sql)) {
446
+                    $newSQL = $this->handleUnionLimitQuery($sql,$start,$count);
447
+        } else {
448
+            if ($start < 0) {
449
+                            $start = 0;
450
+            }
444 451
             $GLOBALS['log']->debug(print_r(func_get_args(),true));
445 452
             $this->lastsql = $sql;
446 453
             $matches = array();
@@ -461,20 +468,17 @@  discard block
 block discarded – undo
461 468
                                     " . $selectPart[2] . $orderByMatch[1]. "
462 469
                                 ) AS a
463 470
                                 WHERE row_number > $start";
464
-                        }
465
-                        else {
471
+                        } else {
466 472
                             $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3];
467 473
                         }
468
-                    }
469
-                    else {
474
+                    } else {
470 475
                         $distinct_o = strpos($match_two, "distinct");
471 476
                         $up_to_distinct_str = substr($match_two, 0, $distinct_o);
472 477
                         //check to see if the distinct is within a function, if so, then proceed as normal
473 478
                         if (strpos($up_to_distinct_str,"(")) {
474 479
                             //proceed as normal
475 480
                             $newSQL = $matches[1] . " TOP $count " . $matches[2] . $matches[3];
476
-                        }
477
-                        else {
481
+                        } else {
478 482
                             //if distinct is not within a function, then parse
479 483
                             //string contains distinct clause, "TOP needs to come after Distinct"
480 484
                             //get position of distinct
@@ -556,8 +560,7 @@  discard block
 block discarded – undo
556 560
                                                 group by " . $grpByStr . "
557 561
                                         ) AS a
558 562
                                         WHERE row_number > $start";
559
-                        }
560
-                        else {
563
+                        } else {
561 564
                         $newSQL = "SELECT TOP $count * FROM
562 565
                                     (
563 566
                                         " . $matches[1] . " ROW_NUMBER()
@@ -566,7 +569,7 @@  discard block
 block discarded – undo
566 569
                                     ) AS a
567 570
                                     WHERE row_number > $start";
568 571
                         }
569
-                    }else{
572
+                    } else{
570 573
                         //if there is a distinct clause, form query with rownumber after distinct
571 574
                         if ($hasDistinct) {
572 575
                              $newSQL = "SELECT TOP $count * FROM
@@ -577,8 +580,7 @@  discard block
 block discarded – undo
577 580
                                             )
578 581
                                             AS a
579 582
                                             WHERE row_number > $start";
580
-                        }
581
-                        else {
583
+                        } else {
582 584
                              $newSQL = "SELECT TOP $count * FROM
583 585
                                            (
584 586
                                   " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY " . $sqlArray['FROM'][0]['alias'] . ".id) AS row_number, " . $matches[2] . $matches[3]. "
@@ -617,8 +619,9 @@  discard block
 block discarded – undo
617 619
         //strip all single quotes out
618 620
         $count = substr_count ( $p_sql, $strip_beg);
619 621
         $increment = 1;
620
-        if ($strip_beg != $strip_end)
621
-            $increment = 2;
622
+        if ($strip_beg != $strip_end) {
623
+                    $increment = 2;
624
+        }
622 625
 
623 626
         $i=0;
624 627
         $offset = 0;
@@ -780,9 +783,10 @@  discard block
 block discarded – undo
780 783
     {
781 784
         $sql = strtolower($sql);
782 785
         $orig_order_match = trim($orig_order_match);
783
-        if (strpos($orig_order_match, ".") != 0)
784
-            //this has a tablename defined, pass in the order match
786
+        if (strpos($orig_order_match, ".") != 0) {
787
+                    //this has a tablename defined, pass in the order match
785 788
             return $orig_order_match;
789
+        }
786 790
 
787 791
         // If there is no ordering direction (ASC/DESC), use ASC by default
788 792
         if (strpos($orig_order_match, " ") === false) {
@@ -824,15 +828,15 @@  discard block
 block discarded – undo
824 828
             //break out of here, log this
825 829
             $GLOBALS['log']->debug("No match was found for order by, pass string back untouched as: $orig_order_match");
826 830
             return $orig_order_match;
827
-        }
828
-        else {
831
+        } else {
829 832
             //if found, then parse and return
830 833
             //grab string up to the aliased column
831 834
             $GLOBALS['log']->debug("order by found, process sql string");
832 835
 
833 836
             $psql = (trim($this->getAliasFromSQL($sql, $orderMatch )));
834
-            if (empty($psql))
835
-                $psql = trim(substr($sql, 0, $found_in_sql));
837
+            if (empty($psql)) {
838
+                            $psql = trim(substr($sql, 0, $found_in_sql));
839
+            }
836 840
 
837 841
             //grab the last comma before the alias
838 842
             preg_match('/\s+' . trim($orderMatch). '/', $psql, $match, PREG_OFFSET_CAPTURE);
@@ -845,8 +849,9 @@  discard block
 block discarded – undo
845 849
             //this is especially true for unified search from home screen
846 850
 
847 851
             $alias_beg_pos = 0;
848
-            if(strpos($psql, " as "))
849
-                $alias_beg_pos = strpos($psql, " as ");
852
+            if(strpos($psql, " as ")) {
853
+                            $alias_beg_pos = strpos($psql, " as ");
854
+            }
850 855
 
851 856
             // Bug # 44923 - This breaks the query and does not properly filter isnull
852 857
             // as there are other functions such as ltrim and rtrim.
@@ -883,8 +888,9 @@  discard block
 block discarded – undo
883 888
         //correct table name.
884 889
         if (($module_str != 'Reports' && $module_str != 'SavedReport') && isset($beanList[$module_str])  &&  isset($beanFiles[$beanList[$module_str]])){
885 890
             //if the class is not already loaded, then load files
886
-            if (!class_exists($beanList[$module_str]))
887
-                require_once($beanFiles[$beanList[$module_str]]);
891
+            if (!class_exists($beanList[$module_str])) {
892
+                            require_once($beanFiles[$beanList[$module_str]]);
893
+            }
888 894
 
889 895
             //instantiate new bean
890 896
             $module_bean = new $beanList[$module_str]();
@@ -897,8 +903,7 @@  discard block
 block discarded – undo
897 903
                 $GLOBALS['log']->debug("Could not find table name for module $module_str. ");
898 904
                 $tbl_name = $module_str;
899 905
             }
900
-        }
901
-        else {
906
+        } else {
902 907
             //since the module does NOT exist in beanlist, then we have to parse the string
903 908
             //and grab the table name from the passed in sql
904 909
             $GLOBALS['log']->debug("Could not find table name from module in request, retrieve from passed in sql");
@@ -919,8 +924,9 @@  discard block
 block discarded – undo
919 924
                 // MFH BUG #14009: Also check to see if there are any carriage returns before the next space so that we don't grab any arbitrary joins or other tables.
920 925
                 $carriage_ret = strpos($tableEnd,"\n");
921 926
                 $next_space = strpos($tableEnd," " );
922
-                if ($carriage_ret < $next_space)
923
-                    $next_space = $carriage_ret;
927
+                if ($carriage_ret < $next_space) {
928
+                                    $next_space = $carriage_ret;
929
+                }
924 930
                 if ($next_space > 0) {
925 931
                     $tbl_name= substr($tableEnd,0, $next_space);
926 932
                     if(empty($tbl_name)){
@@ -943,18 +949,17 @@  discard block
 block discarded – undo
943 949
                         || $alias_tbl_name == "outer"
944 950
                         || $alias_tbl_name == "right") {
945 951
                         //not aliased, do nothing
946
-                    }
947
-                    elseif ($alias_tbl_name == "as") {
952
+                    } elseif ($alias_tbl_name == "as") {
948 953
                             //the next word is the table name
949 954
                             $aliasTableEnd = trim(substr($aliasTableEnd, $alias_space));
950 955
                             $alias_space = strpos ($aliasTableEnd, " " );
951 956
                             if ($alias_space > 0) {
952 957
                                 $alias_tbl_name= trim(substr($aliasTableEnd,0, $alias_space));
953
-                                if (!empty($alias_tbl_name))
954
-                                    $tbl_name = $alias_tbl_name;
958
+                                if (!empty($alias_tbl_name)) {
959
+                                                                    $tbl_name = $alias_tbl_name;
960
+                                }
955 961
                             }
956
-                    }
957
-                    else {
962
+                    } else {
958 963
                         //this is table alias
959 964
                         $tbl_name = $alias_tbl_name;
960 965
                     }
@@ -974,16 +979,19 @@  discard block
 block discarded – undo
974 979
 	{
975 980
 		$field_array = array();
976 981
 
977
-		if(! isset($result) || empty($result))
978
-            return 0;
982
+		if(! isset($result) || empty($result)) {
983
+		            return 0;
984
+		}
979 985
 
980 986
         $i = 0;
981 987
         while ($i < mssql_num_fields($result)) {
982 988
             $meta = mssql_fetch_field($result, $i);
983
-            if (!$meta)
984
-                return 0;
985
-            if($make_lower_case==true)
986
-                $meta->name = strtolower($meta->name);
989
+            if (!$meta) {
990
+                            return 0;
991
+            }
992
+            if($make_lower_case==true) {
993
+                            $meta->name = strtolower($meta->name);
994
+            }
987 995
 
988 996
             $field_array[] = $meta->name;
989 997
 
@@ -1006,7 +1014,9 @@  discard block
 block discarded – undo
1006 1014
 	 */
1007 1015
 	public function fetchRow($result)
1008 1016
 	{
1009
-		if (empty($result))	return false;
1017
+		if (empty($result)) {
1018
+		    return false;
1019
+		}
1010 1020
 
1011 1021
         $row = mssql_fetch_assoc($result);
1012 1022
         //MSSQL returns a space " " when a varchar column is empty ("") and not null.
@@ -1088,8 +1098,9 @@  discard block
 block discarded – undo
1088 1098
             $tables = array();
1089 1099
             $r = $this->query('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES');
1090 1100
             if (is_resource($r)) {
1091
-                while ($a = $this->fetchByAssoc($r))
1092
-                    $tables[] = $a['TABLE_NAME'];
1101
+                while ($a = $this->fetchByAssoc($r)) {
1102
+                                    $tables[] = $a['TABLE_NAME'];
1103
+                }
1093 1104
 
1094 1105
                 return $tables;
1095 1106
             }
@@ -1246,12 +1257,14 @@  discard block
 block discarded – undo
1246 1257
      */
1247 1258
 	public function createTableSQLParams($tablename, $fieldDefs, $indices)
1248 1259
     {
1249
-        if (empty($tablename) || empty($fieldDefs))
1250
-            return '';
1260
+        if (empty($tablename) || empty($fieldDefs)) {
1261
+                    return '';
1262
+        }
1251 1263
 
1252 1264
         $columns = $this->columnSQLRep($fieldDefs, false, $tablename);
1253
-        if (empty($columns))
1254
-            return '';
1265
+        if (empty($columns)) {
1266
+                    return '';
1267
+        }
1255 1268
 
1256 1269
         return "CREATE TABLE $tablename ($columns)";
1257 1270
     }
@@ -1263,7 +1276,9 @@  discard block
 block discarded – undo
1263 1276
     public function isTextType($type)
1264 1277
     {
1265 1278
         $type = strtolower($type);
1266
-        if(!isset($this->type_map[$type])) return false;
1279
+        if(!isset($this->type_map[$type])) {
1280
+            return false;
1281
+        }
1267 1282
         return in_array($this->type_map[$type], array('ntext','text','image', 'nvarchar(max)'));
1268 1283
     }
1269 1284
 
@@ -1316,8 +1331,9 @@  discard block
 block discarded – undo
1316 1331
             $f_def  = $this->oneColumnSQLRep($def, $ignoreRequired,$tablename, true);
1317 1332
             $f_stmt = "ALTER COLUMN ".$f_def['name'].' '.$f_def['colType'].' '.
1318 1333
                         $f_def['required'].' '.$f_def['auto_increment']."\n";
1319
-            if (!empty( $f_def['default']))
1320
-                $f_stmt .= " ALTER TABLE " . $tablename .  " ADD  ". $f_def['default'] . " FOR " . $def['name'];
1334
+            if (!empty( $f_def['default'])) {
1335
+                            $f_stmt .= " ALTER TABLE " . $tablename .  " ADD  ". $f_def['default'] . " FOR " . $def['name'];
1336
+            }
1321 1337
             return $f_stmt;
1322 1338
             break;
1323 1339
         default:
@@ -1355,8 +1371,7 @@  discard block
 block discarded – undo
1355 1371
 
1356 1372
           		$columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename);
1357 1373
       		}
1358
-        }
1359
-        else {
1374
+        } else {
1360 1375
             //if the column is being modified drop the default value
1361 1376
       		//constraint if it exists. alterSQLRep will add the constraint back
1362 1377
       		if (!empty($constraints[$fieldDefs['name']])) {
@@ -1391,8 +1406,9 @@  discard block
 block discarded – undo
1391 1406
      */
1392 1407
     public function setAutoIncrementStart($table, $field_name, $start_value)
1393 1408
     {
1394
-        if($start_value > 1)
1395
-            $start_value -= 1;
1409
+        if($start_value > 1) {
1410
+                    $start_value -= 1;
1411
+        }
1396 1412
 		$this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS");
1397 1413
         return true;
1398 1414
     }
@@ -1428,10 +1444,11 @@  discard block
 block discarded – undo
1428 1444
         $indices = array();
1429 1445
         while (($row=$this->fetchByAssoc($result)) != null) {
1430 1446
             $index_type = 'index';
1431
-            if ($row['is_primary_key'] == '1')
1432
-                $index_type = 'primary';
1433
-            elseif ($row['is_unique'] == 1 )
1434
-                $index_type = 'unique';
1447
+            if ($row['is_primary_key'] == '1') {
1448
+                            $index_type = 'primary';
1449
+            } elseif ($row['is_unique'] == 1 ) {
1450
+                            $index_type = 'unique';
1451
+            }
1435 1452
             $name = strtolower($row['index_name']);
1436 1453
             $indices[$name]['name']     = $name;
1437 1454
             $indices[$name]['type']     = $index_type;
@@ -1456,18 +1473,19 @@  discard block
 block discarded – undo
1456 1473
             if ( $row['TYPE_NAME'] == 'decimal' ) {
1457 1474
                 $columns[$column_name]['len']=strtolower($row['PRECISION']);
1458 1475
                 $columns[$column_name]['len'].=','.strtolower($row['SCALE']);
1476
+            } elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) {
1477
+							$columns[$column_name]['len']=strtolower($row['PRECISION']);
1478
+			} elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) {
1479
+                            $columns[$column_name]['len']=strtolower($row['LENGTH']);
1459 1480
             }
1460
-			elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) )
1461
-				$columns[$column_name]['len']=strtolower($row['PRECISION']);
1462
-            elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) )
1463
-                $columns[$column_name]['len']=strtolower($row['LENGTH']);
1464 1481
             if ( stristr($row['TYPE_NAME'],'identity') ) {
1465 1482
                 $columns[$column_name]['auto_increment'] = '1';
1466 1483
                 $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME']));
1467 1484
             }
1468 1485
 
1469
-            if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI')))
1470
-                $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true';
1486
+            if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) {
1487
+                            $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true';
1488
+            }
1471 1489
 
1472 1490
             $column_def = 1;
1473 1491
             if ( strtolower($tablename) == 'relationships' ) {
@@ -1476,12 +1494,13 @@  discard block
 block discarded – undo
1476 1494
             if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) {	// NOTE Not using !empty as an empty string may be a viable default value.
1477 1495
                 $matches = array();
1478 1496
                 $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES);
1479
-                if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) )
1480
-                    $columns[$column_name]['default'] = $matches[1];
1481
-                elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) )
1482
-                    $columns[$column_name]['default'] = $matches[1];
1483
-                else
1484
-                    $columns[$column_name]['default'] = $row['COLUMN_DEF'];
1497
+                if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) {
1498
+                                    $columns[$column_name]['default'] = $matches[1];
1499
+                } elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) {
1500
+                                    $columns[$column_name]['default'] = $matches[1];
1501
+                } else {
1502
+                                    $columns[$column_name]['default'] = $row['COLUMN_DEF'];
1503
+                }
1485 1504
             }
1486 1505
         }
1487 1506
         return $columns;
@@ -1513,53 +1532,61 @@  discard block
 block discarded – undo
1513 1532
         // generic indices
1514 1533
         case 'index':
1515 1534
         case 'alternate_key':
1516
-            if ($drop)
1517
-                $sql = "DROP INDEX {$name} ON {$table}";
1518
-            else
1519
-                $sql = "CREATE INDEX {$name} ON {$table} ({$fields})";
1535
+            if ($drop) {
1536
+                            $sql = "DROP INDEX {$name} ON {$table}";
1537
+            } else {
1538
+                            $sql = "CREATE INDEX {$name} ON {$table} ({$fields})";
1539
+            }
1520 1540
             break;
1521 1541
         case 'clustered':
1522
-            if ($drop)
1523
-                $sql = "DROP INDEX {$name} ON {$table}";
1524
-            else
1525
-                $sql = "CREATE CLUSTERED INDEX $name ON $table ($fields)";
1542
+            if ($drop) {
1543
+                            $sql = "DROP INDEX {$name} ON {$table}";
1544
+            } else {
1545
+                            $sql = "CREATE CLUSTERED INDEX $name ON $table ($fields)";
1546
+            }
1526 1547
             break;
1527 1548
             // constraints as indices
1528 1549
         case 'unique':
1529
-            if ($drop)
1530
-                $sql = "ALTER TABLE {$table} DROP CONSTRAINT $name";
1531
-            else
1532
-                $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE ({$fields})";
1550
+            if ($drop) {
1551
+                            $sql = "ALTER TABLE {$table} DROP CONSTRAINT $name";
1552
+            } else {
1553
+                            $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE ({$fields})";
1554
+            }
1533 1555
             break;
1534 1556
         case 'primary':
1535
-            if ($drop)
1536
-                $sql = "ALTER TABLE {$table} DROP CONSTRAINT {$name}";
1537
-            else
1538
-                $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} PRIMARY KEY ({$fields})";
1557
+            if ($drop) {
1558
+                            $sql = "ALTER TABLE {$table} DROP CONSTRAINT {$name}";
1559
+            } else {
1560
+                            $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name} PRIMARY KEY ({$fields})";
1561
+            }
1539 1562
             break;
1540 1563
         case 'foreign':
1541
-            if ($drop)
1542
-                $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})";
1543
-            else
1544
-                $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name}  FOREIGN KEY ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignFields']})";
1564
+            if ($drop) {
1565
+                            $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})";
1566
+            } else {
1567
+                            $sql = "ALTER TABLE {$table} ADD CONSTRAINT {$name}  FOREIGN KEY ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignFields']})";
1568
+            }
1545 1569
             break;
1546 1570
         case 'fulltext':
1547 1571
             if ($this->full_text_indexing_enabled() && $drop) {
1548 1572
                 $sql = "DROP FULLTEXT INDEX ON {$table}";
1549 1573
             } elseif ($this->full_text_indexing_enabled()) {
1550 1574
                 $catalog_name=$this->ftsCatalogName();
1551
-                if ( isset($definition['catalog_name']) && $definition['catalog_name'] != 'default')
1552
-                    $catalog_name = $definition['catalog_name'];
1575
+                if ( isset($definition['catalog_name']) && $definition['catalog_name'] != 'default') {
1576
+                                    $catalog_name = $definition['catalog_name'];
1577
+                }
1553 1578
 
1554 1579
                 $language = "Language 1033";
1555
-                if (isset($definition['language']) && !empty($definition['language']))
1556
-                    $language = "Language " . $definition['language'];
1580
+                if (isset($definition['language']) && !empty($definition['language'])) {
1581
+                                    $language = "Language " . $definition['language'];
1582
+                }
1557 1583
 
1558 1584
                 $key_index = $definition['key_index'];
1559 1585
 
1560 1586
                 $change_tracking = "auto";
1561
-                if (isset($definition['change_tracking']) && !empty($definition['change_tracking']))
1562
-                    $change_tracking = $definition['change_tracking'];
1587
+                if (isset($definition['change_tracking']) && !empty($definition['change_tracking'])) {
1588
+                                    $change_tracking = $definition['change_tracking'];
1589
+                }
1563 1590
 
1564 1591
                 $sql = " CREATE FULLTEXT INDEX ON $table ($fields $language) KEY INDEX $key_index ON $catalog_name WITH CHANGE_TRACKING $change_tracking" ;
1565 1592
             }
@@ -1585,12 +1612,14 @@  discard block
 block discarded – undo
1585 1612
     protected function full_text_indexing_enabled($dbname = null)
1586 1613
     {
1587 1614
         // check to see if we already have install setting in session
1588
-    	if(!isset($_SESSION['IsFulltextInstalled']))
1589
-            $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed();
1615
+    	if(!isset($_SESSION['IsFulltextInstalled'])) {
1616
+    	            $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed();
1617
+    	}
1590 1618
 
1591 1619
         // check to see if FTS Indexing service is installed
1592
-        if(empty($_SESSION['IsFulltextInstalled']))
1593
-            return false;
1620
+        if(empty($_SESSION['IsFulltextInstalled'])) {
1621
+                    return false;
1622
+        }
1594 1623
 
1595 1624
         // grab the dbname if it was not passed through
1596 1625
 		if (empty($dbname)) {
@@ -1639,8 +1668,9 @@  discard block
 block discarded – undo
1639 1668
     {
1640 1669
         static $results = array();
1641 1670
 
1642
-        if ( empty($column) && isset($results[$table]) )
1643
-            return $results[$table];
1671
+        if ( empty($column) && isset($results[$table]) ) {
1672
+                    return $results[$table];
1673
+        }
1644 1674
 
1645 1675
         $query = <<<EOQ
1646 1676
 select s.name, o.name, c.name dtrt, d.name ctrt
@@ -1653,18 +1683,20 @@  discard block
 block discarded – undo
1653 1683
             on s.schema_id = o.schema_id
1654 1684
     where o.name = '$table'
1655 1685
 EOQ;
1656
-        if ( !empty($column) )
1657
-            $query .= " and c.name = '$column'";
1686
+        if ( !empty($column) ) {
1687
+                    $query .= " and c.name = '$column'";
1688
+        }
1658 1689
         $res = $this->query($query);
1659 1690
         if ( !empty($column) ) {
1660 1691
             $row = $this->fetchByAssoc($res);
1661
-            if (!empty($row))
1662
-                return $row['ctrt'];
1663
-        }
1664
-        else {
1692
+            if (!empty($row)) {
1693
+                            return $row['ctrt'];
1694
+            }
1695
+        } else {
1665 1696
             $returnResult = array();
1666
-            while ( $row = $this->fetchByAssoc($res) )
1667
-                $returnResult[$row['dtrt']] = $row['ctrt'];
1697
+            while ( $row = $this->fetchByAssoc($res) ) {
1698
+                            $returnResult[$row['dtrt']] = $row['ctrt'];
1699
+            }
1668 1700
             $results[$table] = $returnResult;
1669 1701
             return $returnResult;
1670 1702
         }
@@ -1679,8 +1711,9 @@  discard block
 block discarded – undo
1679 1711
     {
1680 1712
         parent::massageFieldDef($fieldDef,$tablename);
1681 1713
 
1682
-        if ($fieldDef['type'] == 'int')
1683
-            $fieldDef['len'] = '4';
1714
+        if ($fieldDef['type'] == 'int') {
1715
+                    $fieldDef['len'] = '4';
1716
+        }
1684 1717
 
1685 1718
         if(empty($fieldDef['len']))
1686 1719
         {
@@ -1709,9 +1742,10 @@  discard block
 block discarded – undo
1709 1742
         {
1710 1743
             $fieldDef['default'] = '0';
1711 1744
         }
1712
-		if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) )
1713
-			$fieldDef['default'] = '';
1714
-//        if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) )
1745
+		if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) ) {
1746
+					$fieldDef['default'] = '';
1747
+		}
1748
+		//        if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) )
1715 1749
 //            $fieldDef['len'] = '1';
1716 1750
 //		if ($fieldDef['type'] == 'bool' && empty($fieldDef['len']) )
1717 1751
 //            $fieldDef['len'] = '1';
@@ -1755,13 +1789,15 @@  discard block
 block discarded – undo
1755 1789
 		$ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true);
1756 1790
 
1757 1791
 		// Bug 24307 - Don't add precision for float fields.
1758
-		if ( stristr($ref['colType'],'float') )
1759
-			$ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']);
1792
+		if ( stristr($ref['colType'],'float') ) {
1793
+					$ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']);
1794
+		}
1760 1795
 
1761
-        if ( $return_as_array )
1762
-            return $ref;
1763
-        else
1764
-            return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}";
1796
+        if ( $return_as_array ) {
1797
+                    return $ref;
1798
+        } else {
1799
+                    return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}";
1800
+        }
1765 1801
 	}
1766 1802
 
1767 1803
     /**
@@ -1799,8 +1835,9 @@  discard block
 block discarded – undo
1799 1835
      */
1800 1836
     protected function freeDbResult($dbResult)
1801 1837
     {
1802
-        if(!empty($dbResult))
1803
-            mssql_free_result($dbResult);
1838
+        if(!empty($dbResult)) {
1839
+                    mssql_free_result($dbResult);
1840
+        }
1804 1841
     }
1805 1842
 
1806 1843
 	/**
@@ -1810,7 +1847,9 @@  discard block
 block discarded – undo
1810 1847
     public function lastDbError()
1811 1848
     {
1812 1849
         $sqlmsg = mssql_get_last_message();
1813
-        if(empty($sqlmsg)) return false;
1850
+        if(empty($sqlmsg)) {
1851
+            return false;
1852
+        }
1814 1853
         global $app_strings;
1815 1854
         if (empty($app_strings)
1816 1855
 		    or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])
@@ -1833,11 +1872,11 @@  discard block
 block discarded – undo
1833 1872
                 //only if connection if made before languge is set.
1834 1873
                 $GLOBALS['log']->debug("Ignoring this database message: " . $sqlmsg);
1835 1874
                 return false;
1836
-            }
1837
-            else {
1875
+            } else {
1838 1876
                 $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']);
1839
-                if ( $sqlpos !== false )
1840
-                    return false;
1877
+                if ( $sqlpos !== false ) {
1878
+                                    return false;
1879
+                }
1841 1880
             }
1842 1881
         }
1843 1882
 
@@ -1882,8 +1921,9 @@  discard block
 block discarded – undo
1882 1921
     protected function _appendN($sql)
1883 1922
     {
1884 1923
         // If there are no single quotes, don't bother, will just assume there is no character data
1885
-        if (strpos($sql, "'") === false)
1886
-            return $sql;
1924
+        if (strpos($sql, "'") === false) {
1925
+                    return $sql;
1926
+        }
1887 1927
 
1888 1928
         // Flag if there are odd number of single quotes, just continue without trying to append N
1889 1929
         if ((substr_count($sql, "'") & 1)) {
@@ -1922,14 +1962,17 @@  discard block
 block discarded – undo
1922 1962
             }
1923 1963
         }
1924 1964
 
1925
-        if (!empty($replace))
1926
-            $sql = str_replace(array_keys($replace), $replace, $sql);
1965
+        if (!empty($replace)) {
1966
+                    $sql = str_replace(array_keys($replace), $replace, $sql);
1967
+        }
1927 1968
 
1928
-        if (!empty($pairs))
1929
-            $sql = str_replace(array_keys($pairs), $pairs, $sql);
1969
+        if (!empty($pairs)) {
1970
+                    $sql = str_replace(array_keys($pairs), $pairs, $sql);
1971
+        }
1930 1972
 
1931
-        if(strpos($sql, "<@#@#@PAIR@#@#@>"))
1932
-            $sql = str_replace(array('<@#@#@PAIR@#@#@>'), array("''"), $sql);
1973
+        if(strpos($sql, "<@#@#@PAIR@#@#@>")) {
1974
+                    $sql = str_replace(array('<@#@#@PAIR@#@#@>'), array("''"), $sql);
1975
+        }
1933 1976
 
1934 1977
         return $sql;
1935 1978
     }
Please login to merge, or discard this patch.
install/installConfig.php 1 patch
Braces   +40 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -89,7 +91,9 @@  discard block
 block discarded – undo
89 91
         $out = "<select name=\"$name\">";
90 92
         foreach($options as $key => $value) {
91 93
             $selected = '';
92
-            if($key==$default) $selected = ' selected="selected"';
94
+            if($key==$default) {
95
+                $selected = ' selected="selected"';
96
+            }
93 97
             $out .= "<option label=\"$value\" value=\"$key\"$selected>$value</option>";
94 98
         }
95 99
         $out .= "</select>";
@@ -275,8 +279,7 @@  discard block
 block discarded – undo
275 279
                 if(!empty($value)) {
276 280
                     if(!empty($value['required'])) {
277 281
                         $form .= "<span class=\"required\">*</span>";
278
-                    }
279
-                    else {
282
+                    } else {
280 283
                     }
281 284
                     if(!empty($_SESSION[$name])) {
282 285
                         $sessval = $_SESSION[$name];
@@ -295,7 +298,7 @@  discard block
 block discarded – undo
295 298
                     //if the type is password, set a hidden field to capture the value.  This is so that we can properly encode special characters, which is a limitation with password fields
296 299
                     if($type=='password'){
297 300
                         $form .= "</div><div class=\"install_block\"><label>{$mod_strings['LBL_DBCONF_TITLE_PSWD_INFO_LABEL']}</label><span>&nbsp;</span><input type='$type' name='{$name}_entry' id='{$name}_entry' value='".urldecode($sessval)."'><input type='hidden' name='$name' id='$name' value='".urldecode($sessval)."'></div><div class=\"install_block\">";
298
-                    }else{
301
+                    } else{
299 302
                         $form .= "<input type='$type' name='$name' id='$name' value='$sessval'>";
300 303
                     }
301 304
 
@@ -559,7 +562,9 @@  discard block
 block discarded – undo
559 562
         $notify_allow_default_outbound_checked = empty($_SESSION['notify_allow_default_outbound']) ? '' : ' checked="checked" ';
560 563
 
561 564
         // set default smtp toggle buttons selected value
562
-        if(empty($_SESSION['smtp_tab_selected'])) $_SESSION['smtp_tab_selected'] = 'smtp_tab_other';
565
+        if(empty($_SESSION['smtp_tab_selected'])) {
566
+            $_SESSION['smtp_tab_selected'] = 'smtp_tab_other';
567
+        }
563 568
 
564 569
         $out .= <<<EOQ
565 570
         <div class="floatbox full" id="fb2">
@@ -1705,28 +1710,37 @@  discard block
 block discarded – undo
1705 1710
 
1706 1711
 
1707 1712
 if( is_file("config.php") ){
1708
-    if(!empty($sugar_config['default_theme']))
1709
-        $_SESSION['site_default_theme'] = $sugar_config['default_theme'];
1713
+    if(!empty($sugar_config['default_theme'])) {
1714
+            $_SESSION['site_default_theme'] = $sugar_config['default_theme'];
1715
+    }
1710 1716
 
1711
-    if(!empty($sugar_config['disable_persistent_connections']))
1712
-        $_SESSION['disable_persistent_connections'] =
1717
+    if(!empty($sugar_config['disable_persistent_connections'])) {
1718
+            $_SESSION['disable_persistent_connections'] =
1713 1719
             $sugar_config['disable_persistent_connections'];
1714
-    if(!empty($sugar_config['default_language']))
1715
-        $_SESSION['default_language'] = $sugar_config['default_language'];
1716
-    if(!empty($sugar_config['translation_string_prefix']))
1717
-        $_SESSION['translation_string_prefix'] = $sugar_config['translation_string_prefix'];
1718
-    if(!empty($sugar_config['default_charset']))
1719
-        $_SESSION['default_charset'] = $sugar_config['default_charset'];
1720
-
1721
-    if(!empty($sugar_config['default_currency_name']))
1722
-        $_SESSION['default_currency_name'] = $sugar_config['default_currency_name'];
1723
-    if(!empty($sugar_config['default_currency_symbol']))
1724
-        $_SESSION['default_currency_symbol'] = $sugar_config['default_currency_symbol'];
1725
-    if(!empty($sugar_config['default_currency_iso4217']))
1726
-        $_SESSION['default_currency_iso4217'] = $sugar_config['default_currency_iso4217'];
1727
-
1728
-    if(!empty($sugar_config['rss_cache_time']))
1729
-        $_SESSION['rss_cache_time'] = $sugar_config['rss_cache_time'];
1720
+    }
1721
+    if(!empty($sugar_config['default_language'])) {
1722
+            $_SESSION['default_language'] = $sugar_config['default_language'];
1723
+    }
1724
+    if(!empty($sugar_config['translation_string_prefix'])) {
1725
+            $_SESSION['translation_string_prefix'] = $sugar_config['translation_string_prefix'];
1726
+    }
1727
+    if(!empty($sugar_config['default_charset'])) {
1728
+            $_SESSION['default_charset'] = $sugar_config['default_charset'];
1729
+    }
1730
+
1731
+    if(!empty($sugar_config['default_currency_name'])) {
1732
+            $_SESSION['default_currency_name'] = $sugar_config['default_currency_name'];
1733
+    }
1734
+    if(!empty($sugar_config['default_currency_symbol'])) {
1735
+            $_SESSION['default_currency_symbol'] = $sugar_config['default_currency_symbol'];
1736
+    }
1737
+    if(!empty($sugar_config['default_currency_iso4217'])) {
1738
+            $_SESSION['default_currency_iso4217'] = $sugar_config['default_currency_iso4217'];
1739
+    }
1740
+
1741
+    if(!empty($sugar_config['rss_cache_time'])) {
1742
+            $_SESSION['rss_cache_time'] = $sugar_config['rss_cache_time'];
1743
+    }
1730 1744
     if(!empty($sugar_config['languages']))
1731 1745
     {
1732 1746
         // We need to encode the languages in a way that can be retrieved later.
Please login to merge, or discard this patch.
include/InlineEditing/InlineEditing.php 1 patch
Braces   +31 added lines, -21 removed lines patch added patch discarded remove patch
@@ -75,7 +75,9 @@  discard block
 block discarded – undo
75 75
             $vardef['type'] = 'varchar';
76 76
         }
77 77
 
78
-        if (isset($vardef['precision'])) unset($vardef['precision']);
78
+        if (isset($vardef['precision'])) {
79
+            unset($vardef['precision']);
80
+        }
79 81
 
80 82
         //$vardef['precision'] = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
81 83
 
@@ -115,8 +117,9 @@  discard block
 block discarded – undo
115 117
         if (isset($vardef['function'])
116 118
             && ($vardef['function'] == 'getEmailAddressWidget'
117 119
                 || $vardef['function']['name'] == 'getEmailAddressWidget')
118
-        )
119
-            unset($vardef['function']);
120
+        ) {
121
+                    unset($vardef['function']);
122
+        }
120 123
 
121 124
         if (isset($vardef['name']) && ($vardef['name'] == 'date_modified')) {
122 125
             $vardef['name'] = 'aow_temp_date';
@@ -149,8 +152,9 @@  discard block
 block discarded – undo
149 152
         }
150 153
 
151 154
         // hack to disable one of the js calls in this control
152
-        if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown'))
153
-            $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}";
155
+        if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) {
156
+                    $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}";
157
+        }
154 158
 
155 159
 
156 160
 
@@ -186,8 +190,9 @@  discard block
 block discarded – undo
186 190
     $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week());
187 191
 
188 192
     $fieldlist = array();
189
-    if (!isset($focus) || !($focus instanceof SugarBean))
190
-        require_once($beanFiles[$beanList[$module]]);
193
+    if (!isset($focus) || !($focus instanceof SugarBean)) {
194
+            require_once($beanFiles[$beanList[$module]]);
195
+    }
191 196
     $focus = new $beanList[$module];
192 197
     // create the dropdowns for the parent type fields
193 198
     $vardefFields[$fieldname] = $focus->field_defs[$fieldname];
@@ -197,11 +202,13 @@  discard block
 block discarded – undo
197 202
     foreach ($vardefFields as $name => $properties) {
198 203
         $fieldlist[$name] = $properties;
199 204
         // fill in enums
200
-        if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']]))
201
-            $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']];
205
+        if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) {
206
+                    $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']];
207
+        }
202 208
         // Bug 32626: fall back on checking the mod_strings if not in the app_list_strings
203
-        elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']]))
204
-            $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']];
209
+        elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) {
210
+                    $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']];
211
+        }
205 212
     }
206 213
 
207 214
     // fill in function return values
@@ -209,8 +216,9 @@  discard block
 block discarded – undo
209 216
         if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') {
210 217
             $function = $fieldlist[$fieldname]['function']['name'];
211 218
             // include various functions required in the various vardefs
212
-            if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include']))
213
-                require_once($fieldlist[$fieldname]['function']['include']);
219
+            if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) {
220
+                            require_once($fieldlist[$fieldname]['function']['include']);
221
+            }
214 222
             $_REQUEST[$fieldname] = $value;
215 223
             $value = $function($focus, $fieldname, $value, $view);
216 224
 
@@ -308,14 +316,14 @@  discard block
 block discarded – undo
308 316
 
309 317
         if ($bean->field_defs[$field]['type'] == "multienum") {
310 318
             $bean->$field = encodeMultienumValue($value);
311
-        }else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){
319
+        } else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){
312 320
             $save_field = $bean->field_defs[$field]['id_name'];
313 321
             $bean->$save_field = $value;
314 322
             if ($bean->field_defs[$field]['type'] == 'parent') {
315 323
                 $bean->parent_type = $_REQUEST['parent_type'];
316 324
                 $bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name
317 325
             }
318
-        }else{
326
+        } else{
319 327
             $bean->$field = $value;
320 328
         }
321 329
 
@@ -450,14 +458,15 @@  discard block
 block discarded – undo
450 458
 
451 459
         //To fix github bug 880 (the rname was null and was causing a 500 error in the getFieldValueFromModule call to $fieldname
452 460
         $fieldName = 'name';//$vardef['name'];
453
-        if(!is_null($vardef['rname']))
454
-            $fieldName = $vardef['rname'];
461
+        if(!is_null($vardef['rname'])) {
462
+                    $fieldName = $vardef['rname'];
463
+        }
455 464
 
456 465
         if($vardef['ext2']){
457 466
 
458 467
             $value .= getFieldValueFromModule($fieldName,$vardef['ext2'],$record) . "</a>";
459 468
 
460
-        }else if(!empty($vardef['rname'])){
469
+        } else if(!empty($vardef['rname'])){
461 470
             $value .= getFieldValueFromModule($fieldName,$vardef['module'],$record) . "</a>";
462 471
 
463 472
         } else {
@@ -472,8 +481,9 @@  discard block
 block discarded – undo
472 481
 function getFieldValueFromModule($fieldname, $module, $id)
473 482
 {
474 483
     //Github bug 880, if the fieldname is null, do no call from bean
475
-    if(is_null($fieldname))
476
-        return '';
484
+    if(is_null($fieldname)) {
485
+            return '';
486
+    }
477 487
 
478 488
     $bean = BeanFactory::getBean($module, $id);
479 489
     if (is_object($bean) && $bean->id != "") {
@@ -497,7 +507,7 @@  discard block
 block discarded – undo
497 507
 
498 508
     if($bean->ACLAccess('EditView')) {
499 509
         return true;
500
-    }else {
510
+    } else {
501 511
         return false;
502 512
     }
503 513
 }
Please login to merge, or discard this patch.
install/performSetup.php 1 patch
Braces   +28 added lines, -13 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.
@@ -243,8 +245,9 @@  discard block
 block discarded – undo
243 245
 	    $focus = new $bean();
244 246
 	}
245 247
 
246
-	if ( $bean == 'Configurator' )
247
-	    continue;
248
+	if ( $bean == 'Configurator' ) {
249
+		    continue;
250
+	}
248 251
 
249 252
     $table_name = $focus->table_name;
250 253
     //installStatus(sprintf($mod_strings['STAT_CREATE_DB_TABLE'], $focus->table_name ));
@@ -278,8 +281,9 @@  discard block
 block discarded – undo
278 281
             if( $bean == "User" ){
279 282
                 $new_tables = 1;
280 283
             }
281
-            if($bean == "Administration")
282
-                $new_config = 1;
284
+            if($bean == "Administration") {
285
+                            $new_config = 1;
286
+            }
283 287
 
284 288
 
285 289
         }
@@ -404,8 +408,9 @@  discard block
 block discarded – undo
404 408
     }
405 409
     if ($fp && (!isset($_SESSION['oc_install']) || $_SESSION['oc_install'] == false)) {
406 410
         @fclose($fp);
407
-        if ($next_step == 9999)
408
-            $next_step = 8;
411
+        if ($next_step == 9999) {
412
+                    $next_step = 8;
413
+        }
409 414
         $fpResult = <<<FP
410 415
      <form action="install.php" method="post" name="form" id="form">
411 416
      <input type="hidden" name="current_step" value="{$next_step}">
@@ -423,7 +428,7 @@  discard block
 block discarded – undo
423 428
 
424 429
     if( isset($_SESSION['setup_site_sugarbeet_automatic_checks']) && $_SESSION['setup_site_sugarbeet_automatic_checks'] == true){
425 430
         set_CheckUpdates_config_setting('automatic');
426
-    }else{
431
+    } else{
427 432
         set_CheckUpdates_config_setting('manual');
428 433
     }
429 434
     if(!empty($_SESSION['setup_system_name'])){
@@ -554,10 +559,18 @@  discard block
 block discarded – undo
554 559
 
555 560
 installLog('handleOverride');
556 561
 // add local settings to config overrides
557
-if(!empty($_SESSION['default_date_format'])) $sugar_config['default_date_format'] = $_SESSION['default_date_format'];
558
-if(!empty($_SESSION['default_time_format'])) $sugar_config['default_time_format'] = $_SESSION['default_time_format'];
559
-if(!empty($_SESSION['default_language'])) $sugar_config['default_language'] = $_SESSION['default_language'];
560
-if(!empty($_SESSION['default_locale_name_format'])) $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format'];
562
+if(!empty($_SESSION['default_date_format'])) {
563
+    $sugar_config['default_date_format'] = $_SESSION['default_date_format'];
564
+}
565
+if(!empty($_SESSION['default_time_format'])) {
566
+    $sugar_config['default_time_format'] = $_SESSION['default_time_format'];
567
+}
568
+if(!empty($_SESSION['default_language'])) {
569
+    $sugar_config['default_language'] = $_SESSION['default_language'];
570
+}
571
+if(!empty($_SESSION['default_locale_name_format'])) {
572
+    $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format'];
573
+}
561 574
 //$configurator->handleOverride();
562 575
 
563 576
 
@@ -638,7 +651,9 @@  discard block
 block discarded – undo
638 651
 
639 652
 // restore superglobals and vars
640 653
 $GLOBALS = $varStack['GLOBALS'];
641
-foreach($varStack['defined_vars'] as $__key => $__value) $$__key = $__value;
654
+foreach($varStack['defined_vars'] as $__key => $__value) {
655
+    $$__key = $__value;
656
+}
642 657
 
643 658
 
644 659
 
Please login to merge, or discard this patch.
modules/ProspectLists/ProspectList.php 1 patch
Braces   +42 added lines, -31 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.
@@ -103,8 +105,7 @@  discard block
 block discarded – undo
103 105
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
104 106
         if(isset($GLOBALS['log'])) {
105 107
             $GLOBALS['log']->deprecated($deprecatedMessage);
106
-        }
107
-        else {
108
+        } else {
108 109
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
109 110
         }
110 111
         self::__construct();
@@ -137,19 +138,21 @@  discard block
 block discarded – undo
137 138
 			$where_auto = '1=1';
138 139
 				if($show_deleted == 0){
139 140
                 	$where_auto = "$this->table_name.deleted=0";
140
-				}else if($show_deleted == 1){
141
+				} else if($show_deleted == 1){
141 142
                 	$where_auto = "$this->table_name.deleted=1";
142 143
 				}
143 144
 
144
-		if($where != "")
145
-			$query .= "where $where AND ".$where_auto;
146
-		else
147
-			$query .= "where ".$where_auto;
145
+		if($where != "") {
146
+					$query .= "where $where AND ".$where_auto;
147
+		} else {
148
+					$query .= "where ".$where_auto;
149
+		}
148 150
 
149
-		if($order_by != "")
150
-			$query .= " ORDER BY $order_by";
151
-		else
152
-			$query .= " ORDER BY prospect_lists.name";
151
+		if($order_by != "") {
152
+					$query .= " ORDER BY $order_by";
153
+		} else {
154
+					$query .= " ORDER BY prospect_lists.name";
155
+		}
153 156
 
154 157
 		return $query;
155 158
 	}
@@ -167,15 +170,17 @@  discard block
 block discarded – undo
167 170
 
168 171
 		$where_auto = " prospect_lists.deleted=0";
169 172
 
170
-        if($where != "")
171
-                $query .= " WHERE $where AND ".$where_auto;
172
-        else
173
-                $query .= " WHERE ".$where_auto;
173
+        if($where != "") {
174
+                        $query .= " WHERE $where AND ".$where_auto;
175
+        } else {
176
+                        $query .= " WHERE ".$where_auto;
177
+        }
174 178
 
175
-        if($order_by != "")
176
-                $query .= " ORDER BY $order_by";
177
-        else
178
-                $query .= " ORDER BY prospect_lists.name";
179
+        if($order_by != "") {
180
+                        $query .= " ORDER BY $order_by";
181
+        } else {
182
+                        $query .= " ORDER BY prospect_lists.name";
183
+        }
179 184
         return $query;
180 185
     }
181 186
 
@@ -302,12 +307,15 @@  discard block
 block discarded – undo
302 307
 	function save_relationship_changes($is_update, $exclude = array())
303 308
     {
304 309
     	parent::save_relationship_changes($is_update, $exclude);
305
-		if($this->lead_id != "")
306
-	   		$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
307
-    	if($this->contact_id != "")
308
-    		$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
309
-    	if($this->prospect_id != "")
310
-    		$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
310
+		if($this->lead_id != "") {
311
+			   		$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
312
+		}
313
+    	if($this->contact_id != "") {
314
+    	    		$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
315
+    	}
316
+    	if($this->prospect_id != "") {
317
+    	    		$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
318
+    	}
311 319
     }
312 320
 
313 321
 	function set_prospect_relationship($prospect_list_id, &$link_ids, $link_name)
@@ -365,10 +373,11 @@  discard block
 block discarded – undo
365 373
 
366 374
 		$row = $this->db->fetchByAssoc($result);
367 375
 
368
-		if($row)
369
-			return $row['num'];
370
-		else
371
-			return 0;
376
+		if($row) {
377
+					return $row['num'];
378
+		} else {
379
+					return 0;
380
+		}
372 381
 	}
373 382
 
374 383
 
@@ -390,7 +399,9 @@  discard block
 block discarded – undo
390 399
 		$the_where = "";
391 400
 		foreach($where_clauses as $clause)
392 401
 		{
393
-			if($the_where != "") $the_where .= " or ";
402
+			if($the_where != "") {
403
+			    $the_where .= " or ";
404
+			}
394 405
 			$the_where .= $clause;
395 406
 		}
396 407
 
Please login to merge, or discard this patch.