@@ -1,5 +1,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -1,5 +1,7 @@ discard block |
||
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. |
@@ -185,8 +187,9 @@ discard block |
||
185 | 187 | $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
186 | 188 | |
187 | 189 | |
188 | - if($keepResult) |
|
189 | - $this->lastResult = $result; |
|
190 | + if($keepResult) { |
|
191 | + $this->lastResult = $result; |
|
192 | + } |
|
190 | 193 | |
191 | 194 | $this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError); |
192 | 195 | return $result; |
@@ -236,8 +239,9 @@ discard block |
||
236 | 239 | */ |
237 | 240 | protected function freeDbResult($dbResult) |
238 | 241 | { |
239 | - if(!empty($dbResult)) |
|
240 | - mysql_free_result($dbResult); |
|
242 | + if(!empty($dbResult)) { |
|
243 | + mysql_free_result($dbResult); |
|
244 | + } |
|
241 | 245 | } |
242 | 246 | |
243 | 247 | |
@@ -260,8 +264,9 @@ discard block |
||
260 | 264 | { |
261 | 265 | $start = (int)$start; |
262 | 266 | $count = (int)$count; |
263 | - if ($start < 0) |
|
264 | - $start = 0; |
|
267 | + if ($start < 0) { |
|
268 | + $start = 0; |
|
269 | + } |
|
265 | 270 | $GLOBALS['log']->debug('Limit Query:' . $sql. ' Start: ' .$start . ' count: ' . $count); |
266 | 271 | |
267 | 272 | $sql = "$sql LIMIT $start,$count"; |
@@ -286,21 +291,27 @@ discard block |
||
286 | 291 | $result = $this->query('EXPLAIN ' . $sql); |
287 | 292 | $badQuery = array(); |
288 | 293 | while ($row = $this->fetchByAssoc($result)) { |
289 | - if (empty($row['table'])) |
|
290 | - continue; |
|
294 | + if (empty($row['table'])) { |
|
295 | + continue; |
|
296 | + } |
|
291 | 297 | $badQuery[$row['table']] = ''; |
292 | - if (strtoupper($row['type']) == 'ALL') |
|
293 | - $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
294 | - if (empty($row['key'])) |
|
295 | - $badQuery[$row['table']] .= ' No Index Key Used;'; |
|
296 | - if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0) |
|
297 | - $badQuery[$row['table']] .= ' Using FileSort;'; |
|
298 | - if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using temporary') > 0) |
|
299 | - $badQuery[$row['table']] .= ' Using Temporary Table;'; |
|
298 | + if (strtoupper($row['type']) == 'ALL') { |
|
299 | + $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
300 | + } |
|
301 | + if (empty($row['key'])) { |
|
302 | + $badQuery[$row['table']] .= ' No Index Key Used;'; |
|
303 | + } |
|
304 | + if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0) { |
|
305 | + $badQuery[$row['table']] .= ' Using FileSort;'; |
|
306 | + } |
|
307 | + if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using temporary') > 0) { |
|
308 | + $badQuery[$row['table']] .= ' Using Temporary Table;'; |
|
309 | + } |
|
300 | 310 | } |
301 | 311 | |
302 | - if ( empty($badQuery) ) |
|
303 | - return true; |
|
312 | + if ( empty($badQuery) ) { |
|
313 | + return true; |
|
314 | + } |
|
304 | 315 | |
305 | 316 | foreach($badQuery as $table=>$data ){ |
306 | 317 | if(!empty($data)){ |
@@ -308,8 +319,7 @@ discard block |
||
308 | 319 | if(!empty($GLOBALS['sugar_config']['check_query_log'])){ |
309 | 320 | $GLOBALS['log']->fatal($sql); |
310 | 321 | $GLOBALS['log']->fatal('CHECK QUERY:' .$warning); |
311 | - } |
|
312 | - else{ |
|
322 | + } else{ |
|
313 | 323 | $GLOBALS['log']->warn('CHECK QUERY:' .$warning); |
314 | 324 | } |
315 | 325 | } |
@@ -333,14 +343,18 @@ discard block |
||
333 | 343 | $matches = array(); |
334 | 344 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*)\)|)( unsigned)?/i', $row['Type'], $matches); |
335 | 345 | $columns[$name]['type']=strtolower($matches[1][0]); |
336 | - if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) ) |
|
337 | - $columns[$name]['len']=strtolower($matches[2][0]); |
|
338 | - if ( stristr($row['Extra'],'auto_increment') ) |
|
339 | - $columns[$name]['auto_increment'] = '1'; |
|
340 | - if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI')) |
|
341 | - $columns[$name]['required'] = 'true'; |
|
342 | - if (!empty($row['Default']) ) |
|
343 | - $columns[$name]['default'] = $row['Default']; |
|
346 | + if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) ) { |
|
347 | + $columns[$name]['len']=strtolower($matches[2][0]); |
|
348 | + } |
|
349 | + if ( stristr($row['Extra'],'auto_increment') ) { |
|
350 | + $columns[$name]['auto_increment'] = '1'; |
|
351 | + } |
|
352 | + if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI')) { |
|
353 | + $columns[$name]['required'] = 'true'; |
|
354 | + } |
|
355 | + if (!empty($row['Default']) ) { |
|
356 | + $columns[$name]['default'] = $row['Default']; |
|
357 | + } |
|
344 | 358 | } |
345 | 359 | return $columns; |
346 | 360 | } |
@@ -352,17 +366,20 @@ discard block |
||
352 | 366 | { |
353 | 367 | $field_array = array(); |
354 | 368 | |
355 | - if(empty($result)) |
|
356 | - return 0; |
|
369 | + if(empty($result)) { |
|
370 | + return 0; |
|
371 | + } |
|
357 | 372 | |
358 | 373 | $fields = mysql_num_fields($result); |
359 | 374 | for ($i=0; $i < $fields; $i++) { |
360 | 375 | $meta = mysql_fetch_field($result, $i); |
361 | - if (!$meta) |
|
362 | - return array(); |
|
376 | + if (!$meta) { |
|
377 | + return array(); |
|
378 | + } |
|
363 | 379 | |
364 | - if($make_lower_case == true) |
|
365 | - $meta->name = strtolower($meta->name); |
|
380 | + if($make_lower_case == true) { |
|
381 | + $meta->name = strtolower($meta->name); |
|
382 | + } |
|
366 | 383 | |
367 | 384 | $field_array[] = $meta->name; |
368 | 385 | } |
@@ -375,7 +392,9 @@ discard block |
||
375 | 392 | */ |
376 | 393 | public function fetchRow($result) |
377 | 394 | { |
378 | - if (empty($result)) return false; |
|
395 | + if (empty($result)) { |
|
396 | + return false; |
|
397 | + } |
|
379 | 398 | |
380 | 399 | return mysql_fetch_assoc($result); |
381 | 400 | } |
@@ -419,7 +438,9 @@ discard block |
||
419 | 438 | |
420 | 439 | if ($this->getDatabase()) { |
421 | 440 | $result = $this->query("SHOW TABLES LIKE ".$this->quoted($tableName)); |
422 | - if(empty($result)) return false; |
|
441 | + if(empty($result)) { |
|
442 | + return false; |
|
443 | + } |
|
423 | 444 | $row = $this->fetchByAssoc($result); |
424 | 445 | return !empty($row); |
425 | 446 | } |
@@ -474,8 +495,9 @@ discard block |
||
474 | 495 | { |
475 | 496 | global $sugar_config; |
476 | 497 | |
477 | - if(is_null($configOptions)) |
|
478 | - $configOptions = $sugar_config['dbconfig']; |
|
498 | + if(is_null($configOptions)) { |
|
499 | + $configOptions = $sugar_config['dbconfig']; |
|
500 | + } |
|
479 | 501 | |
480 | 502 | if ($this->getOption('persistent')) { |
481 | 503 | $this->database = @mysql_pconnect( |
@@ -528,8 +550,9 @@ discard block |
||
528 | 550 | } |
529 | 551 | mysql_query($names, $this->database); |
530 | 552 | |
531 | - if(!$this->checkError('Could Not Connect:', $dieOnError)) |
|
532 | - $GLOBALS['log']->info("connected to db"); |
|
553 | + if(!$this->checkError('Could Not Connect:', $dieOnError)) { |
|
554 | + $GLOBALS['log']->info("connected to db"); |
|
555 | + } |
|
533 | 556 | $this->connectOptions = $configOptions; |
534 | 557 | |
535 | 558 | $GLOBALS['log']->info("Connect:".$this->database); |
@@ -546,8 +569,9 @@ discard block |
||
546 | 569 | { |
547 | 570 | $sql = parent::repairTableParams($tablename,$fielddefs,$indices,false,$engine); |
548 | 571 | |
549 | - if ( $sql == '' ) |
|
550 | - return ''; |
|
572 | + if ( $sql == '' ) { |
|
573 | + return ''; |
|
574 | + } |
|
551 | 575 | |
552 | 576 | if ( stristr($sql,'create table') ) |
553 | 577 | { |
@@ -574,8 +598,9 @@ discard block |
||
574 | 598 | $sql = str_replace("\n","",$sql); |
575 | 599 | $sql = "ALTER TABLE $tablename $sql"; |
576 | 600 | |
577 | - if ( $execute ) |
|
578 | - $this->query($sql,'Error with MySQL repair table'); |
|
601 | + if ( $execute ) { |
|
602 | + $this->query($sql,'Error with MySQL repair table'); |
|
603 | + } |
|
579 | 604 | |
580 | 605 | // and re-add the comments at the beginning |
581 | 606 | $sql = implode("\n",$commentBlocks) . "\n". $sql . "\n"; |
@@ -672,15 +697,18 @@ discard block |
||
672 | 697 | */ |
673 | 698 | protected function isEngineEnabled($engine) |
674 | 699 | { |
675 | - if(!is_string($engine)) return false; |
|
700 | + if(!is_string($engine)) { |
|
701 | + return false; |
|
702 | + } |
|
676 | 703 | |
677 | 704 | $engine = strtoupper($engine); |
678 | 705 | |
679 | 706 | $r = $this->query("SHOW ENGINES"); |
680 | 707 | |
681 | - while ( $row = $this->fetchByAssoc($r) ) |
|
682 | - if ( strtoupper($row['Engine']) == $engine ) |
|
708 | + while ( $row = $this->fetchByAssoc($r) ) { |
|
709 | + if ( strtoupper($row['Engine']) == $engine ) |
|
683 | 710 | return ($row['Support']=='YES' || $row['Support']=='DEFAULT'); |
711 | + } |
|
684 | 712 | |
685 | 713 | return false; |
686 | 714 | } |
@@ -708,18 +736,22 @@ discard block |
||
708 | 736 | */ |
709 | 737 | public function createTableSQLParams($tablename, $fieldDefs, $indices, $engine = null) |
710 | 738 | { |
711 | - if ( empty($engine) && isset($fieldDefs['engine'])) |
|
712 | - $engine = $fieldDefs['engine']; |
|
713 | - if ( !$this->isEngineEnabled($engine) ) |
|
714 | - $engine = ''; |
|
739 | + if ( empty($engine) && isset($fieldDefs['engine'])) { |
|
740 | + $engine = $fieldDefs['engine']; |
|
741 | + } |
|
742 | + if ( !$this->isEngineEnabled($engine) ) { |
|
743 | + $engine = ''; |
|
744 | + } |
|
715 | 745 | |
716 | 746 | $columns = $this->columnSQLRep($fieldDefs, false, $tablename); |
717 | - if (empty($columns)) |
|
718 | - return false; |
|
747 | + if (empty($columns)) { |
|
748 | + return false; |
|
749 | + } |
|
719 | 750 | |
720 | 751 | $keys = $this->keysSQL($indices); |
721 | - if (!empty($keys)) |
|
722 | - $keys = ",$keys"; |
|
752 | + if (!empty($keys)) { |
|
753 | + $keys = ",$keys"; |
|
754 | + } |
|
723 | 755 | |
724 | 756 | // cn: bug 9873 - module tables do not get created in utf8 with assoc collation |
725 | 757 | $collation = $this->getOption('collation'); |
@@ -728,8 +760,9 @@ discard block |
||
728 | 760 | } |
729 | 761 | $sql = "CREATE TABLE $tablename ($columns $keys) CHARACTER SET utf8 COLLATE $collation"; |
730 | 762 | |
731 | - if (!empty($engine)) |
|
732 | - $sql.= " ENGINE=$engine"; |
|
763 | + if (!empty($engine)) { |
|
764 | + $sql.= " ENGINE=$engine"; |
|
765 | + } |
|
733 | 766 | |
734 | 767 | return $sql; |
735 | 768 | } |
@@ -758,13 +791,15 @@ discard block |
||
758 | 791 | |
759 | 792 | // bug 22338 - don't set a default value on text or blob fields |
760 | 793 | if ( isset($ref['default']) && |
761 | - in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob'))) |
|
762 | - $ref['default'] = ''; |
|
794 | + in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob'))) { |
|
795 | + $ref['default'] = ''; |
|
796 | + } |
|
763 | 797 | |
764 | - if ( $return_as_array ) |
|
765 | - return $ref; |
|
766 | - else |
|
767 | - return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
|
798 | + if ( $return_as_array ) { |
|
799 | + return $ref; |
|
800 | + } else { |
|
801 | + return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
|
802 | + } |
|
768 | 803 | } |
769 | 804 | |
770 | 805 | /** |
@@ -775,16 +810,18 @@ discard block |
||
775 | 810 | $columns = array(); |
776 | 811 | if ($this->isFieldArray($fieldDefs)){ |
777 | 812 | foreach ($fieldDefs as $def){ |
778 | - if ($action == 'drop') |
|
779 | - $columns[] = $def['name']; |
|
780 | - else |
|
781 | - $columns[] = $this->oneColumnSQLRep($def, $ignoreRequired); |
|
813 | + if ($action == 'drop') { |
|
814 | + $columns[] = $def['name']; |
|
815 | + } else { |
|
816 | + $columns[] = $this->oneColumnSQLRep($def, $ignoreRequired); |
|
817 | + } |
|
782 | 818 | } |
783 | 819 | } else { |
784 | - if ($action == 'drop') |
|
785 | - $columns[] = $fieldDefs['name']; |
|
786 | - else |
|
787 | - $columns[] = $this->oneColumnSQLRep($fieldDefs); |
|
820 | + if ($action == 'drop') { |
|
821 | + $columns[] = $fieldDefs['name']; |
|
822 | + } else { |
|
823 | + $columns[] = $this->oneColumnSQLRep($fieldDefs); |
|
824 | + } |
|
788 | 825 | } |
789 | 826 | |
790 | 827 | return "ALTER TABLE $tablename $action COLUMN ".implode(",$action column ", $columns); |
@@ -806,23 +843,27 @@ discard block |
||
806 | 843 | { |
807 | 844 | // check if the passed value is an array of fields. |
808 | 845 | // if not, convert it into an array |
809 | - if (!$this->isFieldArray($indices)) |
|
810 | - $indices[] = $indices; |
|
846 | + if (!$this->isFieldArray($indices)) { |
|
847 | + $indices[] = $indices; |
|
848 | + } |
|
811 | 849 | |
812 | 850 | $columns = array(); |
813 | 851 | foreach ($indices as $index) { |
814 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
815 | - continue; |
|
816 | - if (isset($index['source']) && $index['source'] != 'db') |
|
817 | - continue; |
|
852 | + if(!empty($index['db']) && $index['db'] != $this->dbType) { |
|
853 | + continue; |
|
854 | + } |
|
855 | + if (isset($index['source']) && $index['source'] != 'db') { |
|
856 | + continue; |
|
857 | + } |
|
818 | 858 | |
819 | 859 | $type = $index['type']; |
820 | 860 | $name = $index['name']; |
821 | 861 | |
822 | - if (is_array($index['fields'])) |
|
823 | - $fields = implode(", ", $index['fields']); |
|
824 | - else |
|
825 | - $fields = $index['fields']; |
|
862 | + if (is_array($index['fields'])) { |
|
863 | + $fields = implode(", ", $index['fields']); |
|
864 | + } else { |
|
865 | + $fields = $index['fields']; |
|
866 | + } |
|
826 | 867 | |
827 | 868 | switch ($type) { |
828 | 869 | case 'unique': |
@@ -841,16 +882,18 @@ discard block |
||
841 | 882 | * that this can easily be fixed by referring to db dictionary |
842 | 883 | * to find the correct primary field name |
843 | 884 | */ |
844 | - if ( $alter_table ) |
|
845 | - $columns[] = " INDEX $name ($fields)"; |
|
846 | - else |
|
847 | - $columns[] = " KEY $name ($fields)"; |
|
885 | + if ( $alter_table ) { |
|
886 | + $columns[] = " INDEX $name ($fields)"; |
|
887 | + } else { |
|
888 | + $columns[] = " KEY $name ($fields)"; |
|
889 | + } |
|
848 | 890 | break; |
849 | 891 | case 'fulltext': |
850 | - if ($this->full_text_indexing_installed()) |
|
851 | - $columns[] = " FULLTEXT ($fields)"; |
|
852 | - else |
|
853 | - $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name); |
|
892 | + if ($this->full_text_indexing_installed()) { |
|
893 | + $columns[] = " FULLTEXT ($fields)"; |
|
894 | + } else { |
|
895 | + $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name); |
|
896 | + } |
|
854 | 897 | break; |
855 | 898 | } |
856 | 899 | } |
@@ -892,8 +935,9 @@ discard block |
||
892 | 935 | { |
893 | 936 | $result = $this->query("SHOW TABLE STATUS LIKE '$table'"); |
894 | 937 | $row = $this->fetchByAssoc($result); |
895 | - if (!empty($row['Auto_increment'])) |
|
896 | - return $row['Auto_increment']; |
|
938 | + if (!empty($row['Auto_increment'])) { |
|
939 | + return $row['Auto_increment']; |
|
940 | + } |
|
897 | 941 | |
898 | 942 | return ""; |
899 | 943 | } |
@@ -911,8 +955,7 @@ discard block |
||
911 | 955 | $index_type='index'; |
912 | 956 | if ($row['Key_name'] =='PRIMARY') { |
913 | 957 | $index_type='primary'; |
914 | - } |
|
915 | - elseif ( $row['Non_unique'] == '0' ) { |
|
958 | + } elseif ( $row['Non_unique'] == '0' ) { |
|
916 | 959 | $index_type='unique'; |
917 | 960 | } |
918 | 961 | $name = strtolower($row['Key_name']); |
@@ -938,29 +981,33 @@ discard block |
||
938 | 981 | case 'index': |
939 | 982 | case 'alternate_key': |
940 | 983 | case 'clustered': |
941 | - if ($drop) |
|
942 | - $sql = "ALTER TABLE {$table} DROP INDEX {$name} "; |
|
943 | - else |
|
944 | - $sql = "ALTER TABLE {$table} ADD INDEX {$name} ({$fields})"; |
|
984 | + if ($drop) { |
|
985 | + $sql = "ALTER TABLE {$table} DROP INDEX {$name} "; |
|
986 | + } else { |
|
987 | + $sql = "ALTER TABLE {$table} ADD INDEX {$name} ({$fields})"; |
|
988 | + } |
|
945 | 989 | break; |
946 | 990 | // constraints as indices |
947 | 991 | case 'unique': |
948 | - if ($drop) |
|
949 | - $sql = "ALTER TABLE {$table} DROP INDEX $name"; |
|
950 | - else |
|
951 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT UNIQUE {$name} ({$fields})"; |
|
992 | + if ($drop) { |
|
993 | + $sql = "ALTER TABLE {$table} DROP INDEX $name"; |
|
994 | + } else { |
|
995 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT UNIQUE {$name} ({$fields})"; |
|
996 | + } |
|
952 | 997 | break; |
953 | 998 | case 'primary': |
954 | - if ($drop) |
|
955 | - $sql = "ALTER TABLE {$table} DROP PRIMARY KEY"; |
|
956 | - else |
|
957 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT PRIMARY KEY ({$fields})"; |
|
999 | + if ($drop) { |
|
1000 | + $sql = "ALTER TABLE {$table} DROP PRIMARY KEY"; |
|
1001 | + } else { |
|
1002 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT PRIMARY KEY ({$fields})"; |
|
1003 | + } |
|
958 | 1004 | break; |
959 | 1005 | case 'foreign': |
960 | - if ($drop) |
|
961 | - $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})"; |
|
962 | - else |
|
963 | - $sql = "ALTER TABLE {$table} ADD CONSTRAINT FOREIGN KEY {$name} ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignField']})"; |
|
1006 | + if ($drop) { |
|
1007 | + $sql = "ALTER TABLE {$table} DROP FOREIGN KEY ({$fields})"; |
|
1008 | + } else { |
|
1009 | + $sql = "ALTER TABLE {$table} ADD CONSTRAINT FOREIGN KEY {$name} ({$fields}) REFERENCES {$definition['foreignTable']}({$definition['foreignField']})"; |
|
1010 | + } |
|
964 | 1011 | break; |
965 | 1012 | } |
966 | 1013 | return $sql; |
@@ -1003,22 +1050,30 @@ discard block |
||
1003 | 1050 | ($fieldDef['dbType'] == 'text' |
1004 | 1051 | || $fieldDef['dbType'] == 'blob' |
1005 | 1052 | || $fieldDef['dbType'] == 'longtext' |
1006 | - || $fieldDef['dbType'] == 'longblob' )) |
|
1007 | - unset($fieldDef['default']); |
|
1008 | - if ($fieldDef['dbType'] == 'uint') |
|
1009 | - $fieldDef['len'] = '10'; |
|
1010 | - if ($fieldDef['dbType'] == 'ulong') |
|
1011 | - $fieldDef['len'] = '20'; |
|
1012 | - if ($fieldDef['dbType'] == 'bool') |
|
1013 | - $fieldDef['type'] = 'tinyint'; |
|
1014 | - if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) ) |
|
1015 | - $fieldDef['default'] = '0'; |
|
1016 | - if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) ) |
|
1017 | - $fieldDef['len'] = '255'; |
|
1018 | - if ($fieldDef['dbType'] == 'uint') |
|
1019 | - $fieldDef['len'] = '10'; |
|
1020 | - if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) ) |
|
1021 | - $fieldDef['len'] = '11'; |
|
1053 | + || $fieldDef['dbType'] == 'longblob' )) { |
|
1054 | + unset($fieldDef['default']); |
|
1055 | + } |
|
1056 | + if ($fieldDef['dbType'] == 'uint') { |
|
1057 | + $fieldDef['len'] = '10'; |
|
1058 | + } |
|
1059 | + if ($fieldDef['dbType'] == 'ulong') { |
|
1060 | + $fieldDef['len'] = '20'; |
|
1061 | + } |
|
1062 | + if ($fieldDef['dbType'] == 'bool') { |
|
1063 | + $fieldDef['type'] = 'tinyint'; |
|
1064 | + } |
|
1065 | + if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) ) { |
|
1066 | + $fieldDef['default'] = '0'; |
|
1067 | + } |
|
1068 | + if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) ) { |
|
1069 | + $fieldDef['len'] = '255'; |
|
1070 | + } |
|
1071 | + if ($fieldDef['dbType'] == 'uint') { |
|
1072 | + $fieldDef['len'] = '10'; |
|
1073 | + } |
|
1074 | + if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) ) { |
|
1075 | + $fieldDef['len'] = '11'; |
|
1076 | + } |
|
1022 | 1077 | |
1023 | 1078 | if($fieldDef['dbType'] == 'decimal') { |
1024 | 1079 | if(isset($fieldDef['len'])) { |
@@ -1058,8 +1113,9 @@ discard block |
||
1058 | 1113 | } |
1059 | 1114 | if (!empty($sql)) { |
1060 | 1115 | $sql = "ALTER TABLE $tablename " . join(",", $sql) . ";"; |
1061 | - if($execute) |
|
1062 | - $this->query($sql); |
|
1116 | + if($execute) { |
|
1117 | + $this->query($sql); |
|
1118 | + } |
|
1063 | 1119 | } else { |
1064 | 1120 | $sql = ''; |
1065 | 1121 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -135,8 +137,9 @@ discard block |
||
135 | 137 | $result = $suppress?@mysqli_query($this->database,$sql):mysqli_query($this->database,$sql); |
136 | 138 | $md5 = md5($sql); |
137 | 139 | |
138 | - if (empty($queryMD5[$md5])) |
|
139 | - $queryMD5[$md5] = true; |
|
140 | + if (empty($queryMD5[$md5])) { |
|
141 | + $queryMD5[$md5] = true; |
|
142 | + } |
|
140 | 143 | |
141 | 144 | $this->query_time = microtime(true) - $this->query_time; |
142 | 145 | $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
@@ -154,8 +157,9 @@ discard block |
||
154 | 157 | */ |
155 | 158 | |
156 | 159 | |
157 | - if($keepResult) |
|
158 | - $this->lastResult = $result; |
|
160 | + if($keepResult) { |
|
161 | + $this->lastResult = $result; |
|
162 | + } |
|
159 | 163 | $this->checkError($msg.' Query Failed: ' . $sql, $dieOnError); |
160 | 164 | |
161 | 165 | return $result; |
@@ -208,8 +212,9 @@ discard block |
||
208 | 212 | */ |
209 | 213 | protected function freeDbResult($dbResult) |
210 | 214 | { |
211 | - if(!empty($dbResult)) |
|
212 | - mysqli_free_result($dbResult); |
|
215 | + if(!empty($dbResult)) { |
|
216 | + mysqli_free_result($dbResult); |
|
217 | + } |
|
213 | 218 | } |
214 | 219 | |
215 | 220 | /** |
@@ -219,17 +224,20 @@ discard block |
||
219 | 224 | { |
220 | 225 | $field_array = array(); |
221 | 226 | |
222 | - if (!isset($result) || empty($result)) |
|
223 | - return 0; |
|
227 | + if (!isset($result) || empty($result)) { |
|
228 | + return 0; |
|
229 | + } |
|
224 | 230 | |
225 | 231 | $i = 0; |
226 | 232 | while ($i < mysqli_num_fields($result)) { |
227 | 233 | $meta = mysqli_fetch_field_direct($result, $i); |
228 | - if (!$meta) |
|
229 | - return 0; |
|
234 | + if (!$meta) { |
|
235 | + return 0; |
|
236 | + } |
|
230 | 237 | |
231 | - if($make_lower_case == true) |
|
232 | - $meta->name = strtolower($meta->name); |
|
238 | + if($make_lower_case == true) { |
|
239 | + $meta->name = strtolower($meta->name); |
|
240 | + } |
|
233 | 241 | |
234 | 242 | $field_array[] = $meta->name; |
235 | 243 | |
@@ -244,10 +252,15 @@ discard block |
||
244 | 252 | */ |
245 | 253 | public function fetchRow($result) |
246 | 254 | { |
247 | - if (empty($result)) return false; |
|
255 | + if (empty($result)) { |
|
256 | + return false; |
|
257 | + } |
|
248 | 258 | |
249 | 259 | $row = mysqli_fetch_assoc($result); |
250 | - if($row == null) $row = false; //Make sure MySQLi driver results are consistent with other database drivers |
|
260 | + if($row == null) { |
|
261 | + $row = false; |
|
262 | + } |
|
263 | + //Make sure MySQLi driver results are consistent with other database drivers |
|
251 | 264 | return $row; |
252 | 265 | } |
253 | 266 | |
@@ -266,8 +279,9 @@ discard block |
||
266 | 279 | { |
267 | 280 | global $sugar_config; |
268 | 281 | |
269 | - if (is_null($configOptions)) |
|
270 | - $configOptions = $sugar_config['dbconfig']; |
|
282 | + if (is_null($configOptions)) { |
|
283 | + $configOptions = $sugar_config['dbconfig']; |
|
284 | + } |
|
271 | 285 | |
272 | 286 | if(!isset($this->database)) { |
273 | 287 | |
@@ -318,8 +332,9 @@ discard block |
||
318 | 332 | } |
319 | 333 | mysqli_query($this->database,$names); |
320 | 334 | |
321 | - if($this->checkError('Could Not Connect', $dieOnError)) |
|
322 | - $GLOBALS['log']->info("connected to db"); |
|
335 | + if($this->checkError('Could Not Connect', $dieOnError)) { |
|
336 | + $GLOBALS['log']->info("connected to db"); |
|
337 | + } |
|
323 | 338 | |
324 | 339 | $this->connectOptions = $configOptions; |
325 | 340 | return true; |
@@ -1,5 +1,7 @@ discard block |
||
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. |
@@ -191,15 +193,25 @@ discard block |
||
191 | 193 | */ |
192 | 194 | protected static function scanDriverDir($dir, &$drivers, $validate = true) |
193 | 195 | { |
194 | - if(!is_dir($dir)) return; |
|
196 | + if(!is_dir($dir)) { |
|
197 | + return; |
|
198 | + } |
|
195 | 199 | $scandir = opendir($dir); |
196 | - if($scandir === false) return; |
|
200 | + if($scandir === false) { |
|
201 | + return; |
|
202 | + } |
|
197 | 203 | while(($name = readdir($scandir)) !== false) { |
198 | - if(substr($name, -11) != "Manager.php") continue; |
|
199 | - if($name == "DBManager.php") continue; |
|
204 | + if(substr($name, -11) != "Manager.php") { |
|
205 | + continue; |
|
206 | + } |
|
207 | + if($name == "DBManager.php") { |
|
208 | + continue; |
|
209 | + } |
|
200 | 210 | require_once("$dir/$name"); |
201 | 211 | $classname = substr($name, 0, -4); |
202 | - if(!class_exists($classname)) continue; |
|
212 | + if(!class_exists($classname)) { |
|
213 | + continue; |
|
214 | + } |
|
203 | 215 | $driver = new $classname; |
204 | 216 | if(!$validate || $driver->valid()) { |
205 | 217 | if(empty($drivers[$driver->dbType])) { |
@@ -236,7 +248,9 @@ discard block |
||
236 | 248 | |
237 | 249 | $result = array(); |
238 | 250 | foreach($drivers as $type => $tdrivers) { |
239 | - if(empty($tdrivers)) continue; |
|
251 | + if(empty($tdrivers)) { |
|
252 | + continue; |
|
253 | + } |
|
240 | 254 | if(count($tdrivers) > 1) { |
241 | 255 | usort($tdrivers, array(__CLASS__, "_compareDrivers")); |
242 | 256 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -135,9 +137,13 @@ discard block |
||
135 | 137 | } |
136 | 138 | |
137 | 139 | //when processing a multi-select popup. |
138 | - if($this->process_for_popups && $this->multi_select_popup) $this->shouldProcess =true; |
|
140 | + if($this->process_for_popups && $this->multi_select_popup) { |
|
141 | + $this->shouldProcess =true; |
|
142 | + } |
|
139 | 143 | //mass update turned off? |
140 | - if(!$this->show_mass_update) $this->shouldProcess = false; |
|
144 | + if(!$this->show_mass_update) { |
|
145 | + $this->shouldProcess = false; |
|
146 | + } |
|
141 | 147 | if(is_subclass_of($seed, "SugarBean")) { |
142 | 148 | if($seed->bean_implements('ACL')) { |
143 | 149 | if(!ACLController::checkAccess($seed->module_dir,'list',true)) { |
@@ -188,8 +194,9 @@ discard block |
||
188 | 194 | { |
189 | 195 | $this->source_module = $source_module; |
190 | 196 | $this->subpanel_module = $subpanel_def->name; |
191 | - if(!isset($this->xTemplate)) |
|
192 | - $this->createXTemplate(); |
|
197 | + if(!isset($this->xTemplate)) { |
|
198 | + $this->createXTemplate(); |
|
199 | + } |
|
193 | 200 | |
194 | 201 | $html_var = $this->subpanel_module . "_CELL"; |
195 | 202 | |
@@ -280,8 +287,9 @@ discard block |
||
280 | 287 | if ( empty($data) ) { |
281 | 288 | $this->xTemplate->assign("ROW_COLOR", 'oddListRow'); |
282 | 289 | $thepanel=$subpanel_def; |
283 | - if($subpanel_def->isCollection()) |
|
284 | - $thepanel=$subpanel_def->get_header_panel_def(); |
|
290 | + if($subpanel_def->isCollection()) { |
|
291 | + $thepanel=$subpanel_def->get_header_panel_def(); |
|
292 | + } |
|
285 | 293 | $this->xTemplate->assign("COL_COUNT", count($thepanel->get_list_fields())); |
286 | 294 | $this->xTemplate->parse($xtemplateSection.".nodata"); |
287 | 295 | } |
@@ -339,8 +347,7 @@ discard block |
||
339 | 347 | { |
340 | 348 | $ROW_COLOR = 'oddListRow'; |
341 | 349 | $BG_COLOR = $odd_bg; |
342 | - } |
|
343 | - else |
|
350 | + } else |
|
344 | 351 | { |
345 | 352 | $ROW_COLOR = 'evenListRow'; |
346 | 353 | $BG_COLOR = $even_bg; |
@@ -353,8 +360,9 @@ discard block |
||
353 | 360 | $layout_manager->setAttribute('context','List'); |
354 | 361 | $layout_manager->setAttribute('image_path',$this->local_image_path); |
355 | 362 | $layout_manager->setAttribute('module_name', $subpanel_def->_instance_properties['module']); |
356 | - if(!empty($this->child_focus)) |
|
357 | - $layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir); |
|
363 | + if(!empty($this->child_focus)) { |
|
364 | + $layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir); |
|
365 | + } |
|
358 | 366 | |
359 | 367 | //AG$subpanel_data = $this->list_field_defs; |
360 | 368 | //$bla = array_pop($subpanel_data); |
@@ -389,7 +397,9 @@ discard block |
||
389 | 397 | $linked_field=$thepanel->get_data_source_name(); |
390 | 398 | $linked_field_set=$thepanel->get_data_source_name(true); |
391 | 399 | static $count; |
392 | - if(!isset($count))$count = 0; |
|
400 | + if(!isset($count)) { |
|
401 | + $count = 0; |
|
402 | + } |
|
393 | 403 | /* BEGIN - SECURITY GROUPS */ |
394 | 404 | /** |
395 | 405 | $field_acl['DetailView'] = $aItem->ACLAccess('DetailView'); |
@@ -420,7 +430,7 @@ discard block |
||
420 | 430 | $this->xTemplate->assign('CELL', $widget_contents); |
421 | 431 | $this->xTemplate->parse($xtemplateSection.".row.cell"); |
422 | 432 | |
423 | - }else if($usage != 'query_only') |
|
433 | + } else if($usage != 'query_only') |
|
424 | 434 | { |
425 | 435 | $list_field['name']=$field_name; |
426 | 436 | |
@@ -435,8 +445,11 @@ discard block |
||
435 | 445 | $list_field['owner_id'] = false; |
436 | 446 | $list_field['owner_module'] = false; |
437 | 447 | } |
438 | - if(isset($list_field['alias'])) $list_field['name'] = $list_field['alias']; |
|
439 | - else $list_field['name']=$field_name; |
|
448 | + if(isset($list_field['alias'])) { |
|
449 | + $list_field['name'] = $list_field['alias']; |
|
450 | + } else { |
|
451 | + $list_field['name']=$field_name; |
|
452 | + } |
|
440 | 453 | $list_field['fields'] = $fields; |
441 | 454 | $list_field['module'] = $aItem->module_dir; |
442 | 455 | $list_field['start_link_wrapper'] = $this->start_link_wrapper; |
@@ -485,7 +498,9 @@ discard block |
||
485 | 498 | $count++; |
486 | 499 | $this->xTemplate->assign('CELL_COUNT', $count); |
487 | 500 | $this->xTemplate->assign('CLASS', ""); |
488 | - if ( empty($widget_contents) ) $widget_contents = ' '; |
|
501 | + if ( empty($widget_contents) ) { |
|
502 | + $widget_contents = ' '; |
|
503 | + } |
|
489 | 504 | $this->xTemplate->assign('CELL', $widget_contents); |
490 | 505 | $this->xTemplate->parse($xtemplateSection.".row.cell"); |
491 | 506 | } else { |
@@ -495,7 +510,9 @@ discard block |
||
495 | 510 | $widget_contents = $layout_manager->widgetDisplay($list_field); |
496 | 511 | $this->xTemplate->assign('CELL_COUNT', $count); |
497 | 512 | $this->xTemplate->assign('CLASS', ""); |
498 | - if ( empty($widget_contents) ) $widget_contents = ' '; |
|
513 | + if ( empty($widget_contents) ) { |
|
514 | + $widget_contents = ' '; |
|
515 | + } |
|
499 | 516 | $this->xTemplate->assign('CELL', $widget_contents); |
500 | 517 | $this->xTemplate->parse($xtemplateSection.".row.cell"); |
501 | 518 | } elseif (preg_match("/button/i", $list_field['name'])) { |
@@ -503,8 +520,7 @@ discard block |
||
503 | 520 | { |
504 | 521 | $button_contents[] = $_content; |
505 | 522 | unset($_content); |
506 | - } |
|
507 | - else |
|
523 | + } else |
|
508 | 524 | { |
509 | 525 | $button_contents[] = ''; |
510 | 526 | } |
@@ -513,7 +529,9 @@ discard block |
||
513 | 529 | $this->xTemplate->assign('CLASS', ""); |
514 | 530 | $widget_contents = $layout_manager->widgetDisplay($list_field); |
515 | 531 | $this->xTemplate->assign('CELL_COUNT', $count); |
516 | - if ( empty($widget_contents) ) $widget_contents = ' '; |
|
532 | + if ( empty($widget_contents) ) { |
|
533 | + $widget_contents = ' '; |
|
534 | + } |
|
517 | 535 | $this->xTemplate->assign('CELL', $widget_contents); |
518 | 536 | $this->xTemplate->parse($xtemplateSection.".row.cell"); |
519 | 537 | } |
@@ -541,8 +559,7 @@ discard block |
||
541 | 559 | 'class' => 'clickMenu subpanel records fancymenu button', |
542 | 560 | 'flat' => false //assign flat value as false to display dropdown menu at any other preferences. |
543 | 561 | ), $this->xTemplate); |
544 | - } |
|
545 | - else |
|
562 | + } else |
|
546 | 563 | { |
547 | 564 | $action_button = ''; |
548 | 565 | } |
@@ -629,11 +646,13 @@ discard block |
||
629 | 646 | */ |
630 | 647 | function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) { |
631 | 648 | $this->setXTemplatePath($XTemplatePath); |
632 | - if(isset($modString)) |
|
633 | - $this->setModStrings($modString); |
|
634 | - if(isset($imagePath)) |
|
635 | - $this->setImagePath($imagePath); |
|
636 | -} |
|
649 | + if(isset($modString)) { |
|
650 | + $this->setModStrings($modString); |
|
651 | + } |
|
652 | + if(isset($imagePath)) { |
|
653 | + $this->setImagePath($imagePath); |
|
654 | + } |
|
655 | + } |
|
637 | 656 | |
638 | 657 | |
639 | 658 | function getOrderBy($varName, $defaultOrderBy='', $force_sortorder='') { |
@@ -714,7 +733,7 @@ discard block |
||
714 | 733 | } |
715 | 734 | //Just clear from url... |
716 | 735 | $this->appendToBaseUrl[$orderByColumn] = false; |
717 | - }else { |
|
736 | + } else { |
|
718 | 737 | $this->query_orderby = ""; |
719 | 738 | } |
720 | 739 | $this->sortby = $sortBy; |
@@ -759,8 +778,10 @@ discard block |
||
759 | 778 | */ |
760 | 779 | function setTheme($theme) { |
761 | 780 | $this->local_theme = $theme; |
762 | - if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme); |
|
763 | -} |
|
781 | + if(isset($this->xTemplate)) { |
|
782 | + $this->xTemplate->assign("THEME", $this->local_theme); |
|
783 | + } |
|
784 | + } |
|
764 | 785 | |
765 | 786 | /**sets the AppStrings used only use if it is different from the global |
766 | 787 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
@@ -770,8 +791,10 @@ discard block |
||
770 | 791 | function setAppStrings($app_strings) { |
771 | 792 | unset($this->local_app_strings); |
772 | 793 | $this->local_app_strings = $app_strings; |
773 | - if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings); |
|
774 | -} |
|
794 | + if(isset($this->xTemplate)) { |
|
795 | + $this->xTemplate->assign("APP", $this->local_app_strings); |
|
796 | + } |
|
797 | + } |
|
775 | 798 | |
776 | 799 | /**sets the ModStrings used |
777 | 800 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
@@ -781,8 +804,10 @@ discard block |
||
781 | 804 | function setModStrings($mod_strings) { |
782 | 805 | unset($this->local_module_strings); |
783 | 806 | $this->local_mod_strings = $mod_strings; |
784 | - if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings); |
|
785 | -} |
|
807 | + if(isset($this->xTemplate)) { |
|
808 | + $this->xTemplate->assign("MOD", $this->local_mod_strings); |
|
809 | + } |
|
810 | + } |
|
786 | 811 | |
787 | 812 | /**sets the ImagePath used |
788 | 813 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
@@ -794,8 +819,10 @@ discard block |
||
794 | 819 | if(empty($this->local_image_path)) { |
795 | 820 | $this->local_image_path = SugarThemeRegistry::get($this->local_theme)->getImagePath(); |
796 | 821 | } |
797 | - if(isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path); |
|
798 | -} |
|
822 | + if(isset($this->xTemplate)) { |
|
823 | + $this->xTemplate->assign("IMAGE_PATH", $this->local_image_path); |
|
824 | + } |
|
825 | + } |
|
799 | 826 | |
800 | 827 | /**sets the currentModule only use if this is different from the global |
801 | 828 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
@@ -805,8 +832,10 @@ discard block |
||
805 | 832 | function setCurrentModule($currentModule) { |
806 | 833 | unset($this->local_current_module); |
807 | 834 | $this->local_current_module = $currentModule; |
808 | - if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module); |
|
809 | -} |
|
835 | + if(isset($this->xTemplate)) { |
|
836 | + $this->xTemplate->assign("MODULE_NAME", $this->local_current_module); |
|
837 | + } |
|
838 | + } |
|
810 | 839 | |
811 | 840 | /**INTERNAL FUNCTION creates an XTemplate DO NOT CALL THIS THIS IS AN INTERNAL FUNCTION |
812 | 841 | * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
@@ -819,7 +848,9 @@ discard block |
||
819 | 848 | |
820 | 849 | $this->xTemplate = new XTemplate($this->xTemplatePath); |
821 | 850 | $this->xTemplate->assign("APP", $this->local_app_strings); |
822 | - if(isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings); |
|
851 | + if(isset($this->local_mod_strings)) { |
|
852 | + $this->xTemplate->assign("MOD", $this->local_mod_strings); |
|
853 | + } |
|
823 | 854 | $this->xTemplate->assign("THEME", $this->local_theme); |
824 | 855 | $this->xTemplate->assign("IMAGE_PATH", $this->local_image_path); |
825 | 856 | $this->xTemplate->assign("MODULE_NAME", $this->local_current_module); |
@@ -896,7 +927,9 @@ discard block |
||
896 | 927 | } |
897 | 928 | |
898 | 929 | function setUserVariable($localVarName,$varName, $value) { |
899 | - if($this->is_dynamic || $localVarName == 'CELL')return; |
|
930 | + if($this->is_dynamic || $localVarName == 'CELL') { |
|
931 | + return; |
|
932 | + } |
|
900 | 933 | global $current_user; |
901 | 934 | $current_user->setPreference($this->local_current_module."_".$localVarName."_".$varName, $value); |
902 | 935 | } |
@@ -920,7 +953,9 @@ discard block |
||
920 | 953 | |
921 | 954 | function getUserVariable($localVarName, $varName) { |
922 | 955 | global $current_user; |
923 | - if($this->is_dynamic || $localVarName == 'CELL')return; |
|
956 | + if($this->is_dynamic || $localVarName == 'CELL') { |
|
957 | + return; |
|
958 | + } |
|
924 | 959 | if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) { |
925 | 960 | |
926 | 961 | $this->setUserVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]); |
@@ -999,11 +1034,21 @@ discard block |
||
999 | 1034 | //$filter = array('id', 'full_name'); |
1000 | 1035 | $filter=array(); |
1001 | 1036 | $ret_array = $seed->create_new_list_query($this->query_orderby, $this->query_where, $filter, $params, 0, '', true, $seed, true); |
1002 | - if(!is_array($params)) $params = array(); |
|
1003 | - if(!isset($params['custom_select'])) $params['custom_select'] = ''; |
|
1004 | - if(!isset($params['custom_from'])) $params['custom_from'] = ''; |
|
1005 | - if(!isset($params['custom_where'])) $params['custom_where'] = ''; |
|
1006 | - if(!isset($params['custom_order_by'])) $params['custom_order_by'] = ''; |
|
1037 | + if(!is_array($params)) { |
|
1038 | + $params = array(); |
|
1039 | + } |
|
1040 | + if(!isset($params['custom_select'])) { |
|
1041 | + $params['custom_select'] = ''; |
|
1042 | + } |
|
1043 | + if(!isset($params['custom_from'])) { |
|
1044 | + $params['custom_from'] = ''; |
|
1045 | + } |
|
1046 | + if(!isset($params['custom_where'])) { |
|
1047 | + $params['custom_where'] = ''; |
|
1048 | + } |
|
1049 | + if(!isset($params['custom_order_by'])) { |
|
1050 | + $params['custom_order_by'] = ''; |
|
1051 | + } |
|
1007 | 1052 | $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by']; |
1008 | 1053 | SugarVCR::store($seed->module_dir, $main_query); |
1009 | 1054 | //ADDING VCR CONTROL |
@@ -1064,8 +1109,7 @@ discard block |
||
1064 | 1109 | { |
1065 | 1110 | $sort_order['session'] = $sort_order['session'] == 'asc' ? 'desc' : 'asc'; |
1066 | 1111 | } |
1067 | - } |
|
1068 | - else |
|
1112 | + } else |
|
1069 | 1113 | { |
1070 | 1114 | $sort_order['session'] = null; |
1071 | 1115 | } |
@@ -1097,7 +1141,7 @@ discard block |
||
1097 | 1141 | if(!empty($this->response)){ |
1098 | 1142 | $response =& $this->response; |
1099 | 1143 | echo 'cached'; |
1100 | - }else{ |
|
1144 | + } else{ |
|
1101 | 1145 | $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def); |
1102 | 1146 | $this->response =& $response; |
1103 | 1147 | } |
@@ -1105,7 +1149,9 @@ discard block |
||
1105 | 1149 | $row_count = $response['row_count']; |
1106 | 1150 | $next_offset = $response['next_offset']; |
1107 | 1151 | $previous_offset = $response['previous_offset']; |
1108 | - if(!empty($response['current_offset']))$current_offset = $response['current_offset']; |
|
1152 | + if(!empty($response['current_offset'])) { |
|
1153 | + $current_offset = $response['current_offset']; |
|
1154 | + } |
|
1109 | 1155 | global $list_view_row_count; |
1110 | 1156 | $list_view_row_count = $row_count; |
1111 | 1157 | $this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean,$subpanel_def); |
@@ -1116,7 +1162,9 @@ discard block |
||
1116 | 1162 | function getBaseURL($html_varName) { |
1117 | 1163 | static $cache = array(); |
1118 | 1164 | |
1119 | - if(!empty($cache[$html_varName]))return $cache[$html_varName]; |
|
1165 | + if(!empty($cache[$html_varName])) { |
|
1166 | + return $cache[$html_varName]; |
|
1167 | + } |
|
1120 | 1168 | $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount','current_query_by_page'); |
1121 | 1169 | if(!empty($this->base_URL)) { |
1122 | 1170 | return $this->base_URL; |
@@ -1136,10 +1184,11 @@ discard block |
||
1136 | 1184 | { |
1137 | 1185 | if(is_array($value)) { |
1138 | 1186 | foreach($value as $valuename=>$valuevalue) { |
1139 | - if(substr_count($baseurl, '?') > 0) |
|
1140 | - $baseurl .= "&{$name}[]=".$valuevalue; |
|
1141 | - else |
|
1142 | - $baseurl .= "?{$name}[]=".$valuevalue; |
|
1187 | + if(substr_count($baseurl, '?') > 0) { |
|
1188 | + $baseurl .= "&{$name}[]=".$valuevalue; |
|
1189 | + } else { |
|
1190 | + $baseurl .= "?{$name}[]=".$valuevalue; |
|
1191 | + } |
|
1143 | 1192 | } |
1144 | 1193 | } else { |
1145 | 1194 | $value = urlencode($value); |
@@ -1158,9 +1207,15 @@ discard block |
||
1158 | 1207 | if(substr_count($baseurl, '?') == 0) { |
1159 | 1208 | $baseurl .= '?'; |
1160 | 1209 | } |
1161 | - if(isset($_REQUEST['action'])) $baseurl.= '&action='.$_REQUEST['action']; |
|
1162 | - if(isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record']; |
|
1163 | - if(isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module']; |
|
1210 | + if(isset($_REQUEST['action'])) { |
|
1211 | + $baseurl.= '&action='.$_REQUEST['action']; |
|
1212 | + } |
|
1213 | + if(isset($_REQUEST['record'])) { |
|
1214 | + $baseurl .= '&record='.$_REQUEST['record']; |
|
1215 | + } |
|
1216 | + if(isset($_REQUEST['module'])) { |
|
1217 | + $baseurl .= '&module='.$_REQUEST['module']; |
|
1218 | + } |
|
1164 | 1219 | } |
1165 | 1220 | |
1166 | 1221 | $baseurl .= "&".ListView::getSessionVariableName($html_varName,"offset")."="; |
@@ -1187,11 +1242,13 @@ discard block |
||
1187 | 1242 | |
1188 | 1243 | $start_record = $current_offset + 1; |
1189 | 1244 | |
1190 | - if(!is_numeric($col_count)) |
|
1191 | - $col_count = 20; |
|
1245 | + if(!is_numeric($col_count)) { |
|
1246 | + $col_count = 20; |
|
1247 | + } |
|
1192 | 1248 | |
1193 | - if($row_count == 0) |
|
1194 | - $start_record = 0; |
|
1249 | + if($row_count == 0) { |
|
1250 | + $start_record = 0; |
|
1251 | + } |
|
1195 | 1252 | |
1196 | 1253 | $end_record = $start_record + $this->records_per_page; |
1197 | 1254 | // back up the the last page. |
@@ -1199,10 +1256,11 @@ discard block |
||
1199 | 1256 | $end_record = $row_count+1; |
1200 | 1257 | } |
1201 | 1258 | // Determine the start location of the last page |
1202 | - if($row_count == 0) |
|
1203 | - $number_pages = 0; |
|
1204 | - else |
|
1205 | - $number_pages = floor(($row_count - 1) / $this->records_per_page); |
|
1259 | + if($row_count == 0) { |
|
1260 | + $number_pages = 0; |
|
1261 | + } else { |
|
1262 | + $number_pages = floor(($row_count - 1) / $this->records_per_page); |
|
1263 | + } |
|
1206 | 1264 | |
1207 | 1265 | $last_offset = $number_pages * $this->records_per_page; |
1208 | 1266 | |
@@ -1262,7 +1320,7 @@ discard block |
||
1262 | 1320 | $onClick = ''; |
1263 | 1321 | if(0 != preg_match('/javascript.*/', $start_URL)){ |
1264 | 1322 | $onClick = "\"$start_URL;\""; |
1265 | - }else{ |
|
1323 | + } else{ |
|
1266 | 1324 | $onClick ="'location.href=\"$start_URL\";'"; |
1267 | 1325 | } |
1268 | 1326 | $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>"; |
@@ -1270,7 +1328,7 @@ discard block |
||
1270 | 1328 | $onClick = ''; |
1271 | 1329 | if(0 != preg_match('/javascript.*/', $previous_URL)){ |
1272 | 1330 | $onClick = "\"$previous_URL;\""; |
1273 | - }else{ |
|
1331 | + } else{ |
|
1274 | 1332 | $onClick = "'location.href=\"$previous_URL\";'"; |
1275 | 1333 | } |
1276 | 1334 | $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>"; |
@@ -1294,7 +1352,7 @@ discard block |
||
1294 | 1352 | $onClick = ''; |
1295 | 1353 | if(0 != preg_match('/javascript.*/', $next_URL)){ |
1296 | 1354 | $onClick = "\"$next_URL;\""; |
1297 | - }else{ |
|
1355 | + } else{ |
|
1298 | 1356 | $onClick ="'location.href=\"$next_URL\";'"; |
1299 | 1357 | } |
1300 | 1358 | $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>"; |
@@ -1302,7 +1360,7 @@ discard block |
||
1302 | 1360 | $onClick = ''; |
1303 | 1361 | if(0 != preg_match('/javascript.*/', $end_URL)){ |
1304 | 1362 | $onClick = "\"$end_URL;\""; |
1305 | - }else{ |
|
1363 | + } else{ |
|
1306 | 1364 | $onClick = "'location.href=\"$end_URL\";'"; |
1307 | 1365 | } |
1308 | 1366 | $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>"; |
@@ -1451,18 +1509,17 @@ discard block |
||
1451 | 1509 | //attempt to get the query to recreate this subpanel |
1452 | 1510 | if(!empty($this->response)){ |
1453 | 1511 | $response =& $this->response; |
1454 | - }else{ |
|
1512 | + } else{ |
|
1455 | 1513 | $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def); |
1456 | 1514 | $this->response = $response; |
1457 | 1515 | } |
1458 | 1516 | //if query is present, then pass it in as parameter |
1459 | 1517 | if (isset($response['query']) && !empty($response['query'])){ |
1460 | 1518 | $html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']); |
1461 | - }else{ |
|
1519 | + } else{ |
|
1462 | 1520 | $html_text .= $subpanelTiles->get_buttons($subpanel_def); |
1463 | 1521 | } |
1464 | - } |
|
1465 | - else { |
|
1522 | + } else { |
|
1466 | 1523 | $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" nowrap>$select_link $export_link $delete_link $selected_objects_span"; |
1467 | 1524 | } |
1468 | 1525 | $html_text .= "</td>\n<td nowrap align=\"right\">".$start_link." ".$previous_link." <span class='pageNumbers'>(".$start_record." - ".$end_record." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.")</span> ".$next_link." ".$end_link."</td></tr></table>\n"; |
@@ -1490,9 +1547,15 @@ discard block |
||
1490 | 1547 | } |
1491 | 1548 | if($_SERVER['REQUEST_METHOD'] == 'POST') { |
1492 | 1549 | $this->base_URL .= '?'; |
1493 | - if(isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action']; |
|
1494 | - if(isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record']; |
|
1495 | - if(isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module']; |
|
1550 | + if(isset($_REQUEST['action'])) { |
|
1551 | + $this->base_URL .= '&action='.$_REQUEST['action']; |
|
1552 | + } |
|
1553 | + if(isset($_REQUEST['record'])) { |
|
1554 | + $this->base_URL .= '&record='.$_REQUEST['record']; |
|
1555 | + } |
|
1556 | + if(isset($_REQUEST['module'])) { |
|
1557 | + $this->base_URL .= '&module='.$_REQUEST['module']; |
|
1558 | + } |
|
1496 | 1559 | } |
1497 | 1560 | $this->base_URL .= "&".$this->getSessionVariableName($html_varName,"offset")."="; |
1498 | 1561 | } |
@@ -1623,8 +1686,7 @@ discard block |
||
1623 | 1686 | { |
1624 | 1687 | $ROW_COLOR = 'oddListRow'; |
1625 | 1688 | $BG_COLOR = $odd_bg; |
1626 | - } |
|
1627 | - else |
|
1689 | + } else |
|
1628 | 1690 | { |
1629 | 1691 | $ROW_COLOR = 'evenListRow'; |
1630 | 1692 | $BG_COLOR = $even_bg; |
@@ -1640,8 +1702,7 @@ discard block |
||
1640 | 1702 | $this->xTemplate->assign('VALUE', $aItem); |
1641 | 1703 | $this->xTemplate->assign('INDEX', $count); |
1642 | 1704 | |
1643 | - } |
|
1644 | - else |
|
1705 | + } else |
|
1645 | 1706 | { |
1646 | 1707 | //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail |
1647 | 1708 | // Bug #2786 |
@@ -1657,7 +1718,9 @@ discard block |
||
1657 | 1718 | $results = $ad_function($fields); |
1658 | 1719 | $results['string'] = str_replace(array("'", "'"), '\'', $results['string']); // no xss! |
1659 | 1720 | |
1660 | - if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE']; |
|
1721 | + if(trim($results['string']) == '') { |
|
1722 | + $results['string'] = $app_strings['LBL_NONE']; |
|
1723 | + } |
|
1661 | 1724 | $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']].'</a>'; |
1662 | 1725 | } |
1663 | 1726 | |
@@ -1781,12 +1844,21 @@ discard block |
||
1781 | 1844 | $cell_width = empty($widget_args['width']) ? '' : $widget_args['width']; |
1782 | 1845 | $this->xTemplate->assign('HEADER_CELL', $widget_contents); |
1783 | 1846 | static $count; |
1784 | - if(!isset($count))$count = 0; else $count++; |
|
1785 | - if($col_count == 0 || $column_name == 'name') $footable = 'data-toggle="true"'; |
|
1786 | - else { |
|
1847 | + if(!isset($count)) { |
|
1848 | + $count = 0; |
|
1849 | + } else { |
|
1850 | + $count++; |
|
1851 | + } |
|
1852 | + if($col_count == 0 || $column_name == 'name') { |
|
1853 | + $footable = 'data-toggle="true"'; |
|
1854 | + } else { |
|
1787 | 1855 | $footable = 'data-hide="phone"'; |
1788 | - if ($col_count > 2) $footable = 'data-hide="phone,phonelandscape"'; |
|
1789 | - if ($col_count > 4) $footable = 'data-hide="phone,phonelandscape,tablet"'; |
|
1856 | + if ($col_count > 2) { |
|
1857 | + $footable = 'data-hide="phone,phonelandscape"'; |
|
1858 | + } |
|
1859 | + if ($col_count > 4) { |
|
1860 | + $footable = 'data-hide="phone,phonelandscape,tablet"'; |
|
1861 | + } |
|
1790 | 1862 | } |
1791 | 1863 | $this->xTemplate->assign('FOOTABLE', $footable); |
1792 | 1864 | $this->xTemplate->assign('CELL_COUNT', $count); |
@@ -1918,7 +1990,7 @@ discard block |
||
1918 | 1990 | $sortStr = translate('LBL_ALT_SORT'); |
1919 | 1991 | if($upDown == '_down'){ |
1920 | 1992 | $sortStr = translate('LBL_ALT_SORT_DESC'); |
1921 | - }elseif($upDown == '_up'){ |
|
1993 | + } elseif($upDown == '_up'){ |
|
1922 | 1994 | $sortStr = translate('LBL_ALT_SORT_ASC'); |
1923 | 1995 | } |
1924 | 1996 | return " width='$width' height='$height' align='absmiddle' alt='$sortStr'>"; |
@@ -1932,8 +2004,9 @@ discard block |
||
1932 | 2004 | |
1933 | 2005 | // Check the cache |
1934 | 2006 | $result = sugar_cache_retrieve($cache_key); |
1935 | - if(!empty($result)) |
|
1936 | - return $result; |
|
2007 | + if(!empty($result)) { |
|
2008 | + return $result; |
|
2009 | + } |
|
1937 | 2010 | |
1938 | 2011 | // No cache hit. Calculate the value and return. |
1939 | 2012 | $result = getimagesize($image); |
@@ -1949,8 +2022,9 @@ discard block |
||
1949 | 2022 | |
1950 | 2023 | // Check the cache |
1951 | 2024 | $result = sugar_cache_retrieve($cache_key); |
1952 | - if(!empty($result)) |
|
1953 | - return $result; |
|
2025 | + if(!empty($result)) { |
|
2026 | + return $result; |
|
2027 | + } |
|
1954 | 2028 | |
1955 | 2029 | // No cache hit. Calculate the value and return. |
1956 | 2030 | $result = getimagesize($image); |
@@ -1983,12 +2057,10 @@ discard block |
||
1983 | 2057 | if($orderBy == 'amount') |
1984 | 2058 | { |
1985 | 2059 | $this->xTemplateAssign('amount_arrow', $imgArrow); |
1986 | - } |
|
1987 | - else if($orderBy == 'amount_usdollar') |
|
2060 | + } else if($orderBy == 'amount_usdollar') |
|
1988 | 2061 | { |
1989 | 2062 | $this->xTemplateAssign('amount_usdollar_arrow', $imgArrow); |
1990 | - } |
|
1991 | - else |
|
2063 | + } else |
|
1992 | 2064 | { |
1993 | 2065 | $this->xTemplateAssign($orderBy.'_arrow', $imgArrow); |
1994 | 2066 | } |
@@ -2018,8 +2090,7 @@ discard block |
||
2018 | 2090 | { |
2019 | 2091 | $list_field['label'] = translate($key,$child_focus->module_dir); |
2020 | 2092 | $this->list_field_defs[$i]['label'] = preg_replace('/:$/','',$list_field['label']); |
2021 | - } |
|
2022 | - else |
|
2093 | + } else |
|
2023 | 2094 | { |
2024 | 2095 | $this->list_field_defs[$i]['label'] =' '; |
2025 | 2096 | } |
@@ -2049,8 +2120,7 @@ discard block |
||
2049 | 2120 | function getLocalSessionVariable($localVarName,$varName) { |
2050 | 2121 | if(isset($_SESSION[$localVarName."_".$varName])) { |
2051 | 2122 | return $_SESSION[$localVarName."_".$varName]; |
2052 | - } |
|
2053 | - else{ |
|
2123 | + } else{ |
|
2054 | 2124 | return ""; |
2055 | 2125 | } |
2056 | 2126 | } |
@@ -2058,7 +2128,9 @@ discard block |
||
2058 | 2128 | /* Set to true if you want Additional Details to appear in the listview |
2059 | 2129 | */ |
2060 | 2130 | function setAdditionalDetails($value = true, $function = '') { |
2061 | - if(!empty($function)) $this->additionalDetailsFunction = $function; |
|
2131 | + if(!empty($function)) { |
|
2132 | + $this->additionalDetailsFunction = $function; |
|
2133 | + } |
|
2062 | 2134 | $this->_additionalDetails = $value; |
2063 | 2135 | } |
2064 | 2136 |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -84,8 +86,7 @@ discard block |
||
84 | 86 | } |
85 | 87 | $_SESSION[$this->var_order_by] = array('orderBy'=>$orderBy, 'direction'=> $direction); |
86 | 88 | $_SESSION['lvd']['last_ob'] = $orderBy; |
87 | - } |
|
88 | - else { |
|
89 | + } else { |
|
89 | 90 | $userPreferenceOrder = $GLOBALS['current_user']->getPreference('listviewOrder', $this->var_name); |
90 | 91 | if(!empty($_SESSION[$this->var_order_by])) { |
91 | 92 | $orderBy = $_SESSION[$this->var_order_by]['orderBy']; |
@@ -183,7 +184,7 @@ discard block |
||
183 | 184 | function getTotalCount($main_query){ |
184 | 185 | if(!empty($this->count_query)){ |
185 | 186 | $count_query = $this->count_query; |
186 | - }else{ |
|
187 | + } else{ |
|
187 | 188 | $count_query = $this->seed->create_list_count_query($main_query); |
188 | 189 | } |
189 | 190 | $result = $this->db->query($count_query); |
@@ -246,8 +247,7 @@ discard block |
||
246 | 247 | // if $params tell us to override all ordering |
247 | 248 | if(!empty($params['overrideOrder']) && !empty($params['orderBy'])) { |
248 | 249 | $order = $this->getOrderBy(strtolower($params['orderBy']), (empty($params['sortOrder']) ? '' : $params['sortOrder'])); // retreive from $_REQUEST |
249 | - } |
|
250 | - else { |
|
250 | + } else { |
|
251 | 251 | $order = $this->getOrderBy(); // retreive from $_REQUEST |
252 | 252 | } |
253 | 253 | |
@@ -274,8 +274,9 @@ discard block |
||
274 | 274 | } else { |
275 | 275 | $orderBy = $order['orderBy'] . ' ' . $order['sortOrder']; |
276 | 276 | //wdong, Bug 25476, fix the sorting problem of Oracle. |
277 | - if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code']) |
|
278 | - $orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder']; |
|
277 | + if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code']) { |
|
278 | + $orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder']; |
|
279 | + } |
|
279 | 280 | } |
280 | 281 | |
281 | 282 | if (empty($params['skipOrderSave'])) { // don't save preferences if told so |
@@ -293,11 +294,21 @@ discard block |
||
293 | 294 | $ret_array['inner_join'] = ' ' . implode(' ', $this->seed->listview_inner_join) . ' '; |
294 | 295 | } |
295 | 296 | |
296 | - if(!is_array($params)) $params = array(); |
|
297 | - if(!isset($params['custom_select'])) $params['custom_select'] = ''; |
|
298 | - if(!isset($params['custom_from'])) $params['custom_from'] = ''; |
|
299 | - if(!isset($params['custom_where'])) $params['custom_where'] = ''; |
|
300 | - if(!isset($params['custom_order_by'])) $params['custom_order_by'] = ''; |
|
297 | + if(!is_array($params)) { |
|
298 | + $params = array(); |
|
299 | + } |
|
300 | + if(!isset($params['custom_select'])) { |
|
301 | + $params['custom_select'] = ''; |
|
302 | + } |
|
303 | + if(!isset($params['custom_from'])) { |
|
304 | + $params['custom_from'] = ''; |
|
305 | + } |
|
306 | + if(!isset($params['custom_where'])) { |
|
307 | + $params['custom_where'] = ''; |
|
308 | + } |
|
309 | + if(!isset($params['custom_order_by'])) { |
|
310 | + $params['custom_order_by'] = ''; |
|
311 | + } |
|
301 | 312 | $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by']; |
302 | 313 | //C.L. - Fix for 23461 |
303 | 314 | if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') { |
@@ -305,13 +316,14 @@ discard block |
||
305 | 316 | } |
306 | 317 | if($limit < -1) { |
307 | 318 | $result = $this->db->query($main_query); |
308 | - } |
|
309 | - else { |
|
319 | + } else { |
|
310 | 320 | if($limit == -1) { |
311 | 321 | $limit = $this->getLimit(); |
312 | 322 | } |
313 | 323 | $dyn_offset = $this->getOffset(); |
314 | - if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset; |
|
324 | + if($dyn_offset > 0 || !is_int($dyn_offset)) { |
|
325 | + $offset = $dyn_offset; |
|
326 | + } |
|
315 | 327 | |
316 | 328 | if(strcmp($offset, 'end') == 0){ |
317 | 329 | $totalCount = $this->getTotalCount($main_query); |
@@ -319,8 +331,7 @@ discard block |
||
319 | 331 | } |
320 | 332 | if($this->seed->ACLAccess('ListView')) { |
321 | 333 | $result = $this->db->limitQuery($main_query, $offset, $limit + 1); |
322 | - } |
|
323 | - else { |
|
334 | + } else { |
|
324 | 335 | $result = array(); |
325 | 336 | } |
326 | 337 | |
@@ -388,7 +399,9 @@ discard block |
||
388 | 399 | if(!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) { |
389 | 400 | $post_retrieve[$rows[$rowIndex[0]]['parent_type']] = array(); |
390 | 401 | } |
391 | - if(!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent'); |
|
402 | + if(!empty($rows[$rowIndex[0]]['parent_id'])) { |
|
403 | + $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent'); |
|
404 | + } |
|
392 | 405 | } |
393 | 406 | if(isset($post_retrieve)) { |
394 | 407 | $parent_fields = $seed->retrieve_parent_fields($post_retrieve); |
@@ -416,7 +429,7 @@ discard block |
||
416 | 429 | } |
417 | 430 | if($idIndex[$row[$id_field]][0] == $dataIndex){ |
418 | 431 | $pageData['tag'][$dataIndex] = $temp->listviewACLHelper(); |
419 | - }else{ |
|
432 | + } else{ |
|
420 | 433 | $pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]]; |
421 | 434 | } |
422 | 435 | $data[$dataIndex] = $temp->get_list_view_data($filter_fields); |
@@ -430,8 +443,7 @@ discard block |
||
430 | 443 | if($additionalDetailsAllow) { |
431 | 444 | if($this->additionalDetailsAjax) { |
432 | 445 | $ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']); |
433 | - } |
|
434 | - else { |
|
446 | + } else { |
|
435 | 447 | $additionalDetailsFile = 'modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php'; |
436 | 448 | if(file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php')){ |
437 | 449 | $additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php'; |
@@ -456,7 +468,9 @@ discard block |
||
456 | 468 | |
457 | 469 | if($offset > 0) { |
458 | 470 | $prevOffset = $offset - $limit; |
459 | - if($prevOffset < 0)$prevOffset = 0; |
|
471 | + if($prevOffset < 0) { |
|
472 | + $prevOffset = 0; |
|
473 | + } |
|
460 | 474 | } |
461 | 475 | $totalCount = $count + $offset; |
462 | 476 | |
@@ -490,16 +504,19 @@ discard block |
||
490 | 504 | isset($_REQUEST["module"]) && $_REQUEST["module"] == "MergeRecords") |
491 | 505 | { |
492 | 506 | $queryString = "-advanced_search"; |
493 | - } |
|
494 | - else if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "basic_search") |
|
507 | + } else if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "basic_search") |
|
495 | 508 | { |
496 | - if($seed->module_dir == "Reports") $searchMetaData = SearchFormReports::retrieveReportsSearchDefs(); |
|
497 | - else $searchMetaData = SearchForm::retrieveSearchDefs($seed->module_dir); |
|
509 | + if($seed->module_dir == "Reports") { |
|
510 | + $searchMetaData = SearchFormReports::retrieveReportsSearchDefs(); |
|
511 | + } else { |
|
512 | + $searchMetaData = SearchForm::retrieveSearchDefs($seed->module_dir); |
|
513 | + } |
|
498 | 514 | |
499 | 515 | $basicSearchFields = array(); |
500 | 516 | |
501 | - if( isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']) ) |
|
502 | - $basicSearchFields = $searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']; |
|
517 | + if( isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']) ) { |
|
518 | + $basicSearchFields = $searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']; |
|
519 | + } |
|
503 | 520 | |
504 | 521 | foreach( $basicSearchFields as $basicSearchField) |
505 | 522 | { |
@@ -573,8 +590,7 @@ discard block |
||
573 | 590 | { |
574 | 591 | $queries['endPage'] = $queries['baseURL']; |
575 | 592 | $queries['endPage'][$this->var_offset] = $endOffset; |
576 | - } |
|
577 | - else |
|
593 | + } else |
|
578 | 594 | { |
579 | 595 | $queries['endPage'] = $queries['baseURL']; |
580 | 596 | $queries['endPage'][$this->var_offset] = 'end'; |
@@ -1,5 +1,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -84,7 +84,9 @@ discard block |
||
84 | 84 | $cacheDir = create_cache_directory('modules/'. $module . '/'); |
85 | 85 | $d = dir($cacheDir); |
86 | 86 | while($e = $d->read()){ |
87 | - if(!empty($view) && $e != $view )continue; |
|
87 | + if(!empty($view) && $e != $view ) { |
|
88 | + continue; |
|
89 | + } |
|
88 | 90 | $end =strlen($e) - 4; |
89 | 91 | if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){ |
90 | 92 | unlink($cacheDir . $e); |
@@ -181,8 +183,9 @@ discard block |
||
181 | 183 | $javascript->setFormName($view); |
182 | 184 | |
183 | 185 | $javascript->setSugarBean($sugarbean); |
184 | - if ($view != "ConvertLead") |
|
185 | - $javascript->addAllFields('', null,true); |
|
186 | + if ($view != "ConvertLead") { |
|
187 | + $javascript->addAllFields('', null,true); |
|
188 | + } |
|
186 | 189 | |
187 | 190 | $validatedFields = array(); |
188 | 191 | $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id'); |
@@ -205,8 +208,7 @@ discard block |
||
205 | 208 | || isset($app_strings[$def['vname']]) |
206 | 209 | || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) { |
207 | 210 | $vname = $def['vname']; |
208 | - } |
|
209 | - else{ |
|
211 | + } else{ |
|
210 | 212 | $vname = "undefined"; |
211 | 213 | } |
212 | 214 | $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']); |
@@ -218,7 +220,7 @@ discard block |
||
218 | 220 | $contents .= $javascript->getScript(); |
219 | 221 | $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module); |
220 | 222 | $contents .= "{/literal}\n"; |
221 | - }else if(preg_match('/^SearchForm_.+/', $view)){ |
|
223 | + } else if(preg_match('/^SearchForm_.+/', $view)){ |
|
222 | 224 | global $dictionary, $beanList, $app_strings, $mod_strings; |
223 | 225 | $mod = $beanList[$module]; |
224 | 226 | |
@@ -320,10 +322,12 @@ discard block |
||
320 | 322 | { |
321 | 323 | $sqs_objects = array(); |
322 | 324 | require_once('include/QuickSearchDefaults.php'); |
323 | - if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler |
|
325 | + if(isset($this) && $this instanceof TemplateHandler) { |
|
326 | + //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler |
|
324 | 327 | { |
325 | 328 | $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup()); |
326 | - }else |
|
329 | + } |
|
330 | + } else |
|
327 | 331 | { |
328 | 332 | $qsd = QuickSearchDefaults::getQuickSearchDefaults(array()); |
329 | 333 | } |
@@ -332,7 +336,7 @@ discard block |
||
332 | 336 | if(strpos($view, 'popup_query_form')){ |
333 | 337 | $qsd->setFormName('popup_query_form'); |
334 | 338 | $parsedView = 'advanced'; |
335 | - }else{ |
|
339 | + } else{ |
|
336 | 340 | $qsd->setFormName('search_form'); |
337 | 341 | $parsedView = preg_replace("/^SearchForm_/", "", $view); |
338 | 342 | } |
@@ -350,8 +354,7 @@ discard block |
||
350 | 354 | |
351 | 355 | if(!empty($f['name']) && !empty($f['id_name'])) { |
352 | 356 | $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']); |
353 | - } |
|
354 | - else { |
|
357 | + } else { |
|
355 | 358 | $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser(); |
356 | 359 | } |
357 | 360 | } else if($matches[0] == 'Campaigns') { |
@@ -387,13 +390,16 @@ discard block |
||
387 | 390 | } //if-else |
388 | 391 | } //foreach |
389 | 392 | |
390 | - foreach ( $sqs_objects as $name => $field ) |
|
391 | - foreach ( $field['populate_list'] as $key => $fieldname ) |
|
393 | + foreach ( $sqs_objects as $name => $field ) { |
|
394 | + foreach ( $field['populate_list'] as $key => $fieldname ) |
|
392 | 395 | $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView; |
393 | - }else{ |
|
396 | + } |
|
397 | + } else{ |
|
394 | 398 | //Loop through the Meta-Data fields to see which ones need quick search support |
395 | 399 | foreach($defs2 as $f) { |
396 | - if(!isset($defs[$f['name']])) continue; |
|
400 | + if(!isset($defs[$f['name']])) { |
|
401 | + continue; |
|
402 | + } |
|
397 | 403 | |
398 | 404 | $field = $defs[$f['name']]; |
399 | 405 | if ($view == "ConvertLead") |
@@ -404,13 +410,13 @@ discard block |
||
404 | 410 | $ida_suffix = "_".$lc_module.$lc_module."_ida"; |
405 | 411 | if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) { |
406 | 412 | $field['id_name'] = $module . $field['id_name']; |
413 | + } else { |
|
414 | + $field['id_name'] = $field['name'] . "_" . $field['id_name']; |
|
415 | + } |
|
416 | + } else { |
|
417 | + if (!empty($field['id_name'])) { |
|
418 | + $field['id_name'] = $module.$field['id_name']; |
|
407 | 419 | } |
408 | - else |
|
409 | - $field['id_name'] = $field['name'] . "_" . $field['id_name']; |
|
410 | - } |
|
411 | - else { |
|
412 | - if (!empty($field['id_name'])) |
|
413 | - $field['id_name'] = $module.$field['id_name']; |
|
414 | 420 | } |
415 | 421 | } |
416 | 422 | $name = $qsd->form_name . '_' . $field['name']; |
@@ -428,10 +434,9 @@ discard block |
||
428 | 434 | if($field['name'] == 'reports_to_name'){ |
429 | 435 | $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id'); |
430 | 436 | // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user |
431 | - }elseif($field['name'] == 'assigned_user_name'){ |
|
437 | + } elseif($field['name'] == 'assigned_user_name'){ |
|
432 | 438 | $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id'); |
433 | - } |
|
434 | - else |
|
439 | + } else |
|
435 | 440 | { |
436 | 441 | $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']); |
437 | 442 | |
@@ -462,9 +467,9 @@ discard block |
||
462 | 467 | if(!isset($field['field_list']) && !isset($field['populate_list'])) { |
463 | 468 | $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']); |
464 | 469 | // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname' |
465 | - if (!isset($field['rname'])) |
|
466 | - $sqs_objects[$name]['field_list'] = array('name', 'id'); |
|
467 | - else |
|
470 | + if (!isset($field['rname'])) { |
|
471 | + $sqs_objects[$name]['field_list'] = array('name', 'id'); |
|
472 | + } else |
|
468 | 473 | { |
469 | 474 | $sqs_objects[$name]['field_list'] = array($field['rname'], 'id'); |
470 | 475 | $sqs_objects[$name]['order'] = $field['rname']; |
@@ -161,13 +161,17 @@ discard block |
||
161 | 161 | echo $jsAlerts->getScript(); |
162 | 162 | } |
163 | 163 | |
164 | - if ($this->_getOption('show_subpanels') && !empty($_REQUEST['record'])) $this->_displaySubPanels(); |
|
164 | + if ($this->_getOption('show_subpanels') && !empty($_REQUEST['record'])) { |
|
165 | + $this->_displaySubPanels(); |
|
166 | + } |
|
165 | 167 | |
166 | 168 | if ($this->action === 'Login') { |
167 | 169 | //this is needed for a faster loading login page ie won't render unless the tables are closed |
168 | 170 | ob_flush(); |
169 | 171 | } |
170 | - if ($this->_getOption('show_footer')) $this->displayFooter(); |
|
172 | + if ($this->_getOption('show_footer')) { |
|
173 | + $this->displayFooter(); |
|
174 | + } |
|
171 | 175 | $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_footer'); |
172 | 176 | if ($this->_getOption('json_output')) |
173 | 177 | { |
@@ -186,11 +190,13 @@ discard block |
||
186 | 190 | 'favicon' => $this->getFavicon(), |
187 | 191 | ); |
188 | 192 | |
189 | - if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic) |
|
190 | - $ajax_ret['moduleList'] = $this->displayHeader(true); |
|
193 | + if(SugarThemeRegistry::current()->name == 'Classic' || SugarThemeRegistry::current()->classic) { |
|
194 | + $ajax_ret['moduleList'] = $this->displayHeader(true); |
|
195 | + } |
|
191 | 196 | |
192 | - if(empty($this->responseTime)) |
|
193 | - $this->_calculateFooterMetrics(); |
|
197 | + if(empty($this->responseTime)) { |
|
198 | + $this->_calculateFooterMetrics(); |
|
199 | + } |
|
194 | 200 | $ajax_ret['responseTime'] = $this->responseTime; |
195 | 201 | $json = getJSONobj(); |
196 | 202 | echo $json->encode($ajax_ret); |
@@ -214,8 +220,7 @@ discard block |
||
214 | 220 | |
215 | 221 | if ( !$this->suppressDisplayErrors ) { |
216 | 222 | echo $errors; |
217 | - } |
|
218 | - else { |
|
223 | + } else { |
|
219 | 224 | return $errors; |
220 | 225 | } |
221 | 226 | } |
@@ -329,24 +334,26 @@ discard block |
||
329 | 334 | ob_end_clean(); |
330 | 335 | |
331 | 336 | // get favicon |
332 | - if(isset($GLOBALS['sugar_config']['default_module_favicon'])) |
|
333 | - $module_favicon = $GLOBALS['sugar_config']['default_module_favicon']; |
|
334 | - else |
|
335 | - $module_favicon = false; |
|
337 | + if(isset($GLOBALS['sugar_config']['default_module_favicon'])) { |
|
338 | + $module_favicon = $GLOBALS['sugar_config']['default_module_favicon']; |
|
339 | + } else { |
|
340 | + $module_favicon = false; |
|
341 | + } |
|
336 | 342 | |
337 | 343 | $favicon = $this->getFavicon(); |
338 | 344 | $ss->assign('FAVICON_URL', $favicon['url']); |
339 | 345 | |
340 | 346 | // build the shortcut menu |
341 | 347 | $shortcut_menu = array(); |
342 | - foreach ( $this->getMenu() as $key => $menu_item ) |
|
343 | - $shortcut_menu[$key] = array( |
|
348 | + foreach ( $this->getMenu() as $key => $menu_item ) { |
|
349 | + $shortcut_menu[$key] = array( |
|
344 | 350 | "URL" => $menu_item[0], |
345 | 351 | "LABEL" => $menu_item[1], |
346 | 352 | "MODULE_NAME" => $menu_item[2], |
347 | 353 | "IMAGE" => $themeObject |
348 | 354 | ->getImage($menu_item[2],"border='0' align='absmiddle'",null,null,'.gif',$menu_item[1]), |
349 | 355 | ); |
356 | + } |
|
350 | 357 | $ss->assign("SHORTCUT_MENU",$shortcut_menu); |
351 | 358 | |
352 | 359 | // handle rtl text direction |
@@ -370,8 +377,7 @@ discard block |
||
370 | 377 | $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]); |
371 | 378 | $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]); |
372 | 379 | $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]); |
373 | - } |
|
374 | - else { |
|
380 | + } else { |
|
375 | 381 | // Always need to md5 the file |
376 | 382 | $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL)); |
377 | 383 | |
@@ -379,14 +385,14 @@ discard block |
||
379 | 385 | if ( $width > 212 || $height > 40 ) { |
380 | 386 | $resizePctWidth = ($width - 212)/212; |
381 | 387 | $resizePctHeight = ($height - 40)/40; |
382 | - if ( $resizePctWidth > $resizePctHeight ) |
|
383 | - $resizeAmount = $width / 212; |
|
384 | - else |
|
385 | - $resizeAmount = $height / 40; |
|
388 | + if ( $resizePctWidth > $resizePctHeight ) { |
|
389 | + $resizeAmount = $width / 212; |
|
390 | + } else { |
|
391 | + $resizeAmount = $height / 40; |
|
392 | + } |
|
386 | 393 | $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount))); |
387 | 394 | $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount))); |
388 | - } |
|
389 | - else { |
|
395 | + } else { |
|
390 | 396 | $ss->assign("COMPANY_LOGO_WIDTH", $width); |
391 | 397 | $ss->assign("COMPANY_LOGO_HEIGHT", $height); |
392 | 398 | } |
@@ -429,11 +435,12 @@ discard block |
||
429 | 435 | } |
430 | 436 | // and now the sublinks |
431 | 437 | if ( $linkattribute == 'submenu' && is_array($attributevalue) ) { |
432 | - foreach ($attributevalue as $submenulinkkey => $submenulinkinfo) |
|
433 | - $gcls[$key]['SUBMENU'][$submenulinkkey] = array( |
|
438 | + foreach ($attributevalue as $submenulinkkey => $submenulinkinfo) { |
|
439 | + $gcls[$key]['SUBMENU'][$submenulinkkey] = array( |
|
434 | 440 | "LABEL" => key($submenulinkinfo), |
435 | 441 | "URL" => current($submenulinkinfo), |
436 | 442 | ); |
443 | + } |
|
437 | 444 | if(substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") { |
438 | 445 | $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"],11); |
439 | 446 | $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)"; |
@@ -445,8 +452,9 @@ discard block |
||
445 | 452 | |
446 | 453 | $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : ''); |
447 | 454 | |
448 | - if ($this->action == "EditView" || $this->action == "Login") |
|
449 | - $ss->assign("ONLOAD", 'onload="set_focus()"'); |
|
455 | + if ($this->action == "EditView" || $this->action == "Login") { |
|
456 | + $ss->assign("ONLOAD", 'onload="set_focus()"'); |
|
457 | + } |
|
450 | 458 | |
451 | 459 | $ss->assign("AUTHENTICATED",isset($_SESSION["authenticated_user_id"])); |
452 | 460 | |
@@ -506,8 +514,7 @@ discard block |
||
506 | 514 | foreach($frames as $key => $values){ |
507 | 515 | $fullModuleList[$key] = $values; |
508 | 516 | } |
509 | - } |
|
510 | - elseif (isset($fullModuleList['iFrames'])) { |
|
517 | + } elseif (isset($fullModuleList['iFrames'])) { |
|
511 | 518 | unset($fullModuleList['iFrames']); |
512 | 519 | } |
513 | 520 | |
@@ -523,8 +530,7 @@ discard block |
||
523 | 530 | // We have a default value. Use it |
524 | 531 | if(isset($GLOBALS['sugar_config']['default_max_tabs'])){ |
525 | 532 | $max_tabs = $GLOBALS['sugar_config']['default_max_tabs']; |
526 | - } |
|
527 | - else{ |
|
533 | + } else{ |
|
528 | 534 | $max_tabs = 8; |
529 | 535 | } |
530 | 536 | } |
@@ -633,7 +639,9 @@ discard block |
||
633 | 639 | ); |
634 | 640 | } |
635 | 641 | } |
636 | - if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $ss->assign('lock_homepage', true); |
|
642 | + if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) { |
|
643 | + $ss->assign('lock_homepage', true); |
|
644 | + } |
|
637 | 645 | $ss->assign("groupTabs",$groupTabs); |
638 | 646 | $ss->assign("shortcutTopMenu",$shortcutTopMenu); |
639 | 647 | $ss->assign('USE_GROUP_TABS',$usingGroupTabs); |
@@ -676,8 +684,9 @@ discard block |
||
676 | 684 | global $mod_strings; |
677 | 685 | $mod_strings = $bakModStrings; |
678 | 686 | $headerTpl = $themeObject->getTemplate('header.tpl'); |
679 | - if (inDeveloperMode() ) |
|
680 | - $ss->clear_compiled_tpl($headerTpl); |
|
687 | + if (inDeveloperMode() ) { |
|
688 | + $ss->clear_compiled_tpl($headerTpl); |
|
689 | + } |
|
681 | 690 | |
682 | 691 | if ($retModTabs) |
683 | 692 | { |
@@ -716,8 +725,9 @@ discard block |
||
716 | 725 | global $gridline, $request_string, $modListHeader, $dashletData, $authController, $locale, $currentModule, $import_bean_map, $image_path, $license; |
717 | 726 | global $user_unique_key, $server_unique_key, $barChartColors, $modules_exempt_from_availability_check, $dictionary, $current_language, $beanList, $beanFiles, $sugar_build, $sugar_codename; |
718 | 727 | global $timedate, $login_error; // cn: bug 13855 - timedate not available to classic views. |
719 | - if (!empty($this->module)) |
|
720 | - $currentModule = $this->module; |
|
728 | + if (!empty($this->module)) { |
|
729 | + $currentModule = $this->module; |
|
730 | + } |
|
721 | 731 | require_once ($file); |
722 | 732 | } |
723 | 733 | |
@@ -747,8 +757,9 @@ discard block |
||
747 | 757 | if ( typeof(SUGAR.themes) == 'undefined' ) SUGAR.themes = {}; |
748 | 758 | </script> |
749 | 759 | EOQ; |
750 | - if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client']) |
|
751 | - echo getVersionedScript('modules/Sync/headersync.js'); |
|
760 | + if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client']) { |
|
761 | + echo getVersionedScript('modules/Sync/headersync.js'); |
|
762 | + } |
|
752 | 763 | } |
753 | 764 | |
754 | 765 | /** |
@@ -849,8 +860,9 @@ discard block |
||
849 | 860 | |
850 | 861 | echo $this->_getModLanguageJS(); |
851 | 862 | |
852 | - if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client']) |
|
853 | - echo getVersionedScript('modules/Sync/headersync.js'); |
|
863 | + if(isset( $sugar_config['disc_client']) && $sugar_config['disc_client']) { |
|
864 | + echo getVersionedScript('modules/Sync/headersync.js'); |
|
865 | + } |
|
854 | 866 | |
855 | 867 | |
856 | 868 | //echo out the $js_vars variables as javascript variables |
@@ -917,8 +929,9 @@ discard block |
||
917 | 929 | } |
918 | 930 | } |
919 | 931 | $ss->assign("BOTTOMLINKS",$bottomLinksStr); |
920 | - if (SugarConfig::getInstance()->get('calculate_response_time', false)) |
|
921 | - $ss->assign('STATISTICS',$this->_getStatistics()); |
|
932 | + if (SugarConfig::getInstance()->get('calculate_response_time', false)) { |
|
933 | + $ss->assign('STATISTICS',$this->_getStatistics()); |
|
934 | + } |
|
922 | 935 | |
923 | 936 | // Under the License referenced above, you are required to leave in all copyright statements in both |
924 | 937 | // the code and end-user application. |
@@ -956,8 +969,7 @@ discard block |
||
956 | 969 | $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]); |
957 | 970 | $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]); |
958 | 971 | $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]); |
959 | - } |
|
960 | - else { |
|
972 | + } else { |
|
961 | 973 | // Always need to md5 the file |
962 | 974 | $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL)); |
963 | 975 | |
@@ -965,14 +977,14 @@ discard block |
||
965 | 977 | if ( $width > 212 || $height > 40 ) { |
966 | 978 | $resizePctWidth = ($width - 212)/212; |
967 | 979 | $resizePctHeight = ($height - 40)/40; |
968 | - if ( $resizePctWidth > $resizePctHeight ) |
|
969 | - $resizeAmount = $width / 212; |
|
970 | - else |
|
971 | - $resizeAmount = $height / 40; |
|
980 | + if ( $resizePctWidth > $resizePctHeight ) { |
|
981 | + $resizeAmount = $width / 212; |
|
982 | + } else { |
|
983 | + $resizeAmount = $height / 40; |
|
984 | + } |
|
972 | 985 | $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1/$resizeAmount))); |
973 | 986 | $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1/$resizeAmount))); |
974 | - } |
|
975 | - else { |
|
987 | + } else { |
|
976 | 988 | $ss->assign("COMPANY_LOGO_WIDTH", $width); |
977 | 989 | $ss->assign("COMPANY_LOGO_HEIGHT", $height); |
978 | 990 | } |
@@ -1030,8 +1042,9 @@ discard block |
||
1030 | 1042 | |
1031 | 1043 | protected function _buildModuleList() |
1032 | 1044 | { |
1033 | - if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader'])) |
|
1034 | - $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']); |
|
1045 | + if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader'])) { |
|
1046 | + $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']); |
|
1047 | + } |
|
1035 | 1048 | } |
1036 | 1049 | |
1037 | 1050 | /** |
@@ -1051,7 +1064,9 @@ discard block |
||
1051 | 1064 | return $this->options['show_all']; |
1052 | 1065 | } elseif (!empty($this->options) && isset($this->options[$option])) { |
1053 | 1066 | return $this->options[$option]; |
1054 | - } else return $default; |
|
1067 | + } else { |
|
1068 | + return $default; |
|
1069 | + } |
|
1055 | 1070 | } |
1056 | 1071 | |
1057 | 1072 | /** |
@@ -1088,10 +1103,11 @@ discard block |
||
1088 | 1103 | |
1089 | 1104 | public function renderJavascript() |
1090 | 1105 | { |
1091 | - if ($this->action !== 'Login') |
|
1092 | - $this->_displayJavascript(); |
|
1093 | - else |
|
1094 | - $this->_displayLoginJS(); |
|
1106 | + if ($this->action !== 'Login') { |
|
1107 | + $this->_displayJavascript(); |
|
1108 | + } else { |
|
1109 | + $this->_displayLoginJS(); |
|
1110 | + } |
|
1095 | 1111 | } |
1096 | 1112 | |
1097 | 1113 | private function _calculateFooterMetrics() |
@@ -1198,8 +1214,9 @@ discard block |
||
1198 | 1214 | { |
1199 | 1215 | global $current_language, $current_user, $mod_strings, $app_strings, $module_menu; |
1200 | 1216 | |
1201 | - if ( empty($module) ) |
|
1202 | - $module = $this->module; |
|
1217 | + if ( empty($module) ) { |
|
1218 | + $module = $this->module; |
|
1219 | + } |
|
1203 | 1220 | |
1204 | 1221 | //Need to make sure the mod_strings match the requested module or Menus may fail |
1205 | 1222 | $curr_mod_strings = $mod_strings; |
@@ -1220,13 +1237,14 @@ discard block |
||
1220 | 1237 | $GLOBALS['mod_strings']['LNK_NEW_RECORD'],"{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$module" ,$module ); |
1221 | 1238 | $module_menu[] = array("index.php?module=$module&action=index", $GLOBALS['mod_strings']['LNK_LIST'], |
1222 | 1239 | $module, $module); |
1223 | - if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) ) |
|
1224 | - if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) ) |
|
1240 | + if ( ($this->bean instanceOf SugarBean) && !empty($this->bean->importable) ) { |
|
1241 | + if ( !empty($mod_strings['LNK_IMPORT_'.strtoupper($module)]) ) |
|
1225 | 1242 | $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index", |
1226 | 1243 | $mod_strings['LNK_IMPORT_'.strtoupper($module)], "Import", $module); |
1227 | - else |
|
1228 | - $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index", |
|
1244 | + } else { |
|
1245 | + $module_menu[] = array("index.php?module=Import&action=Step1&import_module=$module&return_module=$module&return_action=index", |
|
1229 | 1246 | $app_strings['LBL_IMPORT'], "Import", $module); |
1247 | + } |
|
1230 | 1248 | } |
1231 | 1249 | if (file_exists('custom/application/Ext/Menus/menu.ext.php')) { |
1232 | 1250 | require('custom/application/Ext/Menus/menu.ext.php'); |
@@ -1251,22 +1269,25 @@ discard block |
||
1251 | 1269 | $defaultTab = (in_array("Home",$userTabs)) ? "Home" : key($userTabs); |
1252 | 1270 | |
1253 | 1271 | // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions. |
1254 | - if ( !empty($_REQUEST['module_tab']) ) |
|
1255 | - return $_REQUEST['module_tab']; |
|
1256 | - elseif ( isset($moduleTabMap[$this->module]) ) |
|
1257 | - return $moduleTabMap[$this->module]; |
|
1272 | + if ( !empty($_REQUEST['module_tab']) ) { |
|
1273 | + return $_REQUEST['module_tab']; |
|
1274 | + } elseif ( isset($moduleTabMap[$this->module]) ) { |
|
1275 | + return $moduleTabMap[$this->module]; |
|
1276 | + } |
|
1258 | 1277 | // Special cases |
1259 | - elseif ( $this->module == 'MergeRecords' ) |
|
1260 | - return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module']; |
|
1261 | - elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' ) |
|
1262 | - return $defaultTab; |
|
1278 | + elseif ( $this->module == 'MergeRecords' ) { |
|
1279 | + return !empty($_REQUEST['merge_module']) ? $_REQUEST['merge_module'] : $_REQUEST['return_module']; |
|
1280 | + } elseif ( $this->module == 'Users' && $this->action == 'SetTimezone' ) { |
|
1281 | + return $defaultTab; |
|
1282 | + } |
|
1263 | 1283 | // Default anonymous pages to be under Home |
1264 | - elseif ( !isset($app_list_strings['moduleList'][$this->module]) ) |
|
1265 | - return $defaultTab; |
|
1266 | - elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" ) |
|
1267 | - return $defaultTab; |
|
1268 | - else |
|
1269 | - return $this->module; |
|
1284 | + elseif ( !isset($app_list_strings['moduleList'][$this->module]) ) { |
|
1285 | + return $defaultTab; |
|
1286 | + } elseif ( isset($_REQUEST['action']) && $_REQUEST['action'] == "ajaxui" ) { |
|
1287 | + return $defaultTab; |
|
1288 | + } else { |
|
1289 | + return $this->module; |
|
1290 | + } |
|
1270 | 1291 | } |
1271 | 1292 | |
1272 | 1293 | /** |
@@ -1317,7 +1338,10 @@ discard block |
||
1317 | 1338 | if($show_help || $this->type == 'list') { |
1318 | 1339 | $theTitle .= "<span class='utils'>"; |
1319 | 1340 | $createImageURL = SugarThemeRegistry::current()->getImageURL('create-record.gif'); |
1320 | - 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"); |
|
1341 | + if($this->type == 'list') { |
|
1342 | + $theTitle .= '<a href="#" class="btn btn-success showsearch"><span class=" glyphicon glyphicon-search" aria-hidden="true"></span></a>'; |
|
1343 | + } |
|
1344 | + $url = ajaxLink("index.php?module=$module&action=EditView&return_module=$module&return_action=DetailView"); |
|
1321 | 1345 | if($show_help) { |
1322 | 1346 | $theTitle .= <<<EOHTML |
1323 | 1347 | |
@@ -1349,14 +1373,14 @@ discard block |
||
1349 | 1373 | if(file_exists('custom/' .$coreMetaPath )){ |
1350 | 1374 | $metadataFile = 'custom/' . $coreMetaPath; |
1351 | 1375 | $foundViewDefs = true; |
1352 | - }else{ |
|
1376 | + } else{ |
|
1353 | 1377 | if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){ |
1354 | 1378 | require_once('custom/modules/'.$this->module.'/metadata/metafiles.php'); |
1355 | 1379 | if(!empty($metafiles[$this->module][$viewDef])){ |
1356 | 1380 | $metadataFile = $metafiles[$this->module][$viewDef]; |
1357 | 1381 | $foundViewDefs = true; |
1358 | 1382 | } |
1359 | - }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){ |
|
1383 | + } elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){ |
|
1360 | 1384 | require_once('modules/'.$this->module.'/metadata/metafiles.php'); |
1361 | 1385 | if(!empty($metafiles[$this->module][$viewDef])){ |
1362 | 1386 | $metadataFile = $metafiles[$this->module][$viewDef]; |
@@ -1391,9 +1415,9 @@ discard block |
||
1391 | 1415 | if(!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) { |
1392 | 1416 | $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->get_summary_text()."</a>"; |
1393 | 1417 | $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL']; |
1418 | + } else { |
|
1419 | + $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']; |
|
1394 | 1420 | } |
1395 | - else |
|
1396 | - $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']; |
|
1397 | 1421 | break; |
1398 | 1422 | case 'DetailView': |
1399 | 1423 | $beanName = $this->bean->get_summary_text(); |
@@ -1417,10 +1441,11 @@ discard block |
||
1417 | 1441 | global $current_user; |
1418 | 1442 | global $app_strings; |
1419 | 1443 | |
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; |
|
1444 | + if(!empty($GLOBALS['app_list_strings']['moduleList'][$this->module])) { |
|
1445 | + $firstParam = $GLOBALS['app_list_strings']['moduleList'][$this->module]; |
|
1446 | + } else { |
|
1447 | + $firstParam = $this->module; |
|
1448 | + } |
|
1424 | 1449 | |
1425 | 1450 | $iconPath = $this->getModuleTitleIconPath($this->module); |
1426 | 1451 | if($this->action == "ListView" || $this->action == "index") { |
@@ -1436,8 +1461,7 @@ discard block |
||
1436 | 1461 | } else { |
1437 | 1462 | return $firstParam; |
1438 | 1463 | } |
1439 | - } |
|
1440 | - else { |
|
1464 | + } else { |
|
1441 | 1465 | if (!empty($iconPath) && !$browserTitle) { |
1442 | 1466 | //return "<a href='index.php?module={$this->module}&action=index'>$this->module</a>"; |
1443 | 1467 | } else { |
@@ -1451,8 +1475,7 @@ discard block |
||
1451 | 1475 | $iconPath = ""; |
1452 | 1476 | if(is_file(SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png',false))) { |
1453 | 1477 | $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.$module.'_32.png'); |
1454 | - } |
|
1455 | - else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) { |
|
1478 | + } else if (is_file(SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png',false))) { |
|
1456 | 1479 | $iconPath = SugarThemeRegistry::current()->getImageURL('icon_'.ucfirst($module).'_32.png'); |
1457 | 1480 | } |
1458 | 1481 | return $iconPath; |
@@ -1469,11 +1492,13 @@ discard block |
||
1469 | 1492 | global $app_strings; |
1470 | 1493 | |
1471 | 1494 | $browserTitle = $app_strings['LBL_BROWSER_TITLE']; |
1472 | - if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') ) |
|
1473 | - return $browserTitle; |
|
1495 | + if ( $this->module == 'Users' && ($this->action == 'SetTimezone' || $this->action == 'Login') ) { |
|
1496 | + return $browserTitle; |
|
1497 | + } |
|
1474 | 1498 | $params = $this->_getModuleTitleParams(true); |
1475 | - foreach ($params as $value ) |
|
1476 | - $browserTitle = strip_tags($value) . ' » ' . $browserTitle; |
|
1499 | + foreach ($params as $value ) { |
|
1500 | + $browserTitle = strip_tags($value) . ' » ' . $browserTitle; |
|
1501 | + } |
|
1477 | 1502 | |
1478 | 1503 | return $browserTitle; |
1479 | 1504 | } |
@@ -1487,8 +1512,7 @@ discard block |
||
1487 | 1512 | { |
1488 | 1513 | if(SugarThemeRegistry::current()->directionality == "ltr") { |
1489 | 1514 | return "<span class='pointer'>»</span>"; |
1490 | - } |
|
1491 | - else { |
|
1515 | + } else { |
|
1492 | 1516 | return "<span class='pointer'>«</span>"; |
1493 | 1517 | } |
1494 | 1518 | } |
@@ -1510,8 +1534,7 @@ discard block |
||
1510 | 1534 | } |
1511 | 1535 | if ( empty($sugar_config['disableAjaxUI']) ) { |
1512 | 1536 | $config_js[] = "SUGAR.config.disableAjaxUI = false;"; |
1513 | - } |
|
1514 | - else{ |
|
1537 | + } else{ |
|
1515 | 1538 | $config_js[] = "SUGAR.config.disableAjaxUI = true;"; |
1516 | 1539 | } |
1517 | 1540 | if ( !empty($sugar_config['addAjaxBannedModules']) ){ |
@@ -1581,18 +1604,21 @@ discard block |
||
1581 | 1604 | protected function getFavicon() |
1582 | 1605 | { |
1583 | 1606 | // get favicon |
1584 | - if(isset($GLOBALS['sugar_config']['default_module_favicon'])) |
|
1585 | - $module_favicon = $GLOBALS['sugar_config']['default_module_favicon']; |
|
1586 | - else |
|
1587 | - $module_favicon = false; |
|
1607 | + if(isset($GLOBALS['sugar_config']['default_module_favicon'])) { |
|
1608 | + $module_favicon = $GLOBALS['sugar_config']['default_module_favicon']; |
|
1609 | + } else { |
|
1610 | + $module_favicon = false; |
|
1611 | + } |
|
1588 | 1612 | |
1589 | 1613 | $themeObject = SugarThemeRegistry::current(); |
1590 | 1614 | |
1591 | 1615 | $favicon = ''; |
1592 | - if ( $module_favicon ) |
|
1593 | - $favicon = $themeObject->getImageURL($this->module.'.gif',false); |
|
1594 | - if ( !sugar_is_file($favicon) || !$module_favicon ) |
|
1595 | - $favicon = $themeObject->getImageURL('sugar_icon.ico',false); |
|
1616 | + if ( $module_favicon ) { |
|
1617 | + $favicon = $themeObject->getImageURL($this->module.'.gif',false); |
|
1618 | + } |
|
1619 | + if ( !sugar_is_file($favicon) || !$module_favicon ) { |
|
1620 | + $favicon = $themeObject->getImageURL('sugar_icon.ico',false); |
|
1621 | + } |
|
1596 | 1622 | |
1597 | 1623 | $extension = pathinfo($favicon, PATHINFO_EXTENSION); |
1598 | 1624 | switch ($extension) |