@@ -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. |
@@ -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 | |
@@ -57,23 +57,23 @@ |
||
| 57 | 57 | require_once('custom/modules/'.$module.'/controller.php'); |
| 58 | 58 | if(class_exists($customClass)){ |
| 59 | 59 | $controller = new $customClass(); |
| 60 | - }else if(class_exists($class)){ |
|
| 60 | + } else if(class_exists($class)){ |
|
| 61 | 61 | $controller = new $class(); |
| 62 | 62 | } |
| 63 | - }elseif(file_exists('modules/'.$module.'/controller.php')){ |
|
| 63 | + } elseif(file_exists('modules/'.$module.'/controller.php')){ |
|
| 64 | 64 | require_once('modules/'.$module.'/controller.php'); |
| 65 | 65 | if(class_exists($customClass)){ |
| 66 | 66 | $controller = new $customClass(); |
| 67 | - }else if(class_exists($class)){ |
|
| 67 | + } else if(class_exists($class)){ |
|
| 68 | 68 | $controller = new $class(); |
| 69 | 69 | } |
| 70 | - }else{ |
|
| 70 | + } else{ |
|
| 71 | 71 | if(file_exists('custom/include/MVC/Controller/SugarController.php')){ |
| 72 | 72 | require_once('custom/include/MVC/Controller/SugarController.php'); |
| 73 | 73 | } |
| 74 | 74 | if(class_exists('CustomSugarController')){ |
| 75 | 75 | $controller = new CustomSugarController(); |
| 76 | - }else{ |
|
| 76 | + } else{ |
|
| 77 | 77 | $controller = new SugarController(); |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -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. |
@@ -38,7 +40,9 @@ discard block |
||
| 38 | 40 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
| 39 | 41 | ********************************************************************************/ |
| 40 | 42 | |
| 41 | -if (empty($_REQUEST)) die(); |
|
| 43 | +if (empty($_REQUEST)) { |
|
| 44 | + die(); |
|
| 45 | +} |
|
| 42 | 46 | |
| 43 | 47 | $yui_path = array( |
| 44 | 48 | "2.9.0" => "include/javascript/yui", |
@@ -58,20 +62,24 @@ discard block |
||
| 58 | 62 | foreach ($_REQUEST as $param => $val) |
| 59 | 63 | { |
| 60 | 64 | //No backtracking in the path |
| 61 | - if (strpos($param, "..") !== false) |
|
| 62 | - continue; |
|
| 65 | + if (strpos($param, "..") !== false) { |
|
| 66 | + continue; |
|
| 67 | + } |
|
| 63 | 68 | |
| 64 | 69 | $version = explode("/", $param); |
| 65 | 70 | $version = $version[0]; |
| 66 | - if (empty($yui_path[$version])) continue; |
|
| 71 | + if (empty($yui_path[$version])) { |
|
| 72 | + continue; |
|
| 73 | + } |
|
| 67 | 74 | |
| 68 | 75 | $path = $yui_path[$version] . substr($param, strlen($version)); |
| 69 | 76 | |
| 70 | 77 | $extension = substr($path, strrpos($path, "_") + 1); |
| 71 | 78 | |
| 72 | 79 | //Only allowed file extensions |
| 73 | - if (empty($types[$extension])) |
|
| 74 | - continue; |
|
| 80 | + if (empty($types[$extension])) { |
|
| 81 | + continue; |
|
| 82 | + } |
|
| 75 | 83 | |
| 76 | 84 | if (empty($contentType)) |
| 77 | 85 | { |
@@ -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. |
@@ -121,10 +123,12 @@ discard block |
||
| 121 | 123 | // load language files |
| 122 | 124 | $this->loadLanguage($classname, 'modules/Charts/Dashlets/'); |
| 123 | 125 | |
| 124 | - if ( empty($options['title']) ) |
|
| 125 | - $this->title = $this->dashletStrings['LBL_TITLE']; |
|
| 126 | - if ( isset($options['autoRefresh']) ) |
|
| 127 | - $this->autoRefresh = $options['autoRefresh']; |
|
| 126 | + if ( empty($options['title']) ) { |
|
| 127 | + $this->title = $this->dashletStrings['LBL_TITLE']; |
|
| 128 | + } |
|
| 129 | + if ( isset($options['autoRefresh']) ) { |
|
| 130 | + $this->autoRefresh = $options['autoRefresh']; |
|
| 131 | + } |
|
| 128 | 132 | |
| 129 | 133 | $this->layoutManager = new LayoutManager(); |
| 130 | 134 | $this->layoutManager->setAttribute('context', 'Report'); |
@@ -140,8 +144,8 @@ discard block |
||
| 140 | 144 | public function setRefreshIcon() |
| 141 | 145 | { |
| 142 | 146 | $additionalTitle = ''; |
| 143 | - if($this->isRefreshable) |
|
| 144 | - |
|
| 147 | + if($this->isRefreshable) { |
|
| 148 | + |
|
| 145 | 149 | $additionalTitle .= '<a href="#" onclick="SUGAR.mySugar.retrieveDashlet(\'' |
| 146 | 150 | . $this->id |
| 147 | 151 | . '\',\'predefined_chart\'); return false;"><!--not_in_theme!-->' |
@@ -154,6 +158,7 @@ discard block |
||
| 154 | 158 | translate('LBL_DASHLET_REFRESH', 'Home') |
| 155 | 159 | ) |
| 156 | 160 | . '</a>'; |
| 161 | + } |
|
| 157 | 162 | return $additionalTitle; |
| 158 | 163 | } |
| 159 | 164 | |
@@ -200,25 +205,32 @@ discard block |
||
| 200 | 205 | |
| 201 | 206 | $options = array(); |
| 202 | 207 | |
| 203 | - foreach($req as $name => $value) |
|
| 204 | - if(!is_array($value)) $req[$name] = trim($value); |
|
| 208 | + foreach($req as $name => $value) { |
|
| 209 | + if(!is_array($value)) $req[$name] = trim($value); |
|
| 210 | + } |
|
| 205 | 211 | |
| 206 | 212 | foreach($this->_searchFields as $name => $params) { |
| 207 | 213 | $widgetDef = $params; |
| 208 | - if ( isset($this->getSeedBean()->field_defs[$name]) ) |
|
| 209 | - $widgetDef = $this->getSeedBean()->field_defs[$name]; |
|
| 210 | - if ( $widgetDef['type'] == 'date') // special case date types |
|
| 214 | + if ( isset($this->getSeedBean()->field_defs[$name]) ) { |
|
| 215 | + $widgetDef = $this->getSeedBean()->field_defs[$name]; |
|
| 216 | + } |
|
| 217 | + if ( $widgetDef['type'] == 'date') { |
|
| 218 | + // special case date types |
|
| 211 | 219 | $options[$widgetDef['name']] = $timedate->swap_formats($req['type_'.$widgetDef['name']], $timedate->get_date_format(), $timedate->dbDayFormat); |
| 212 | - elseif ( $widgetDef['type'] == 'time') // special case time types |
|
| 220 | + } elseif ( $widgetDef['type'] == 'time') { |
|
| 221 | + // special case time types |
|
| 213 | 222 | $options[$widgetDef['name']] = $timedate->swap_formats($req['type_'.$widgetDef['name']], $timedate->get_time_format(), $timedate->dbTimeFormat); |
| 214 | - elseif ( $widgetDef['type'] == 'datepicker') // special case datepicker types |
|
| 223 | + } elseif ( $widgetDef['type'] == 'datepicker') { |
|
| 224 | + // special case datepicker types |
|
| 215 | 225 | $options[$widgetDef['name']] = $timedate->swap_formats($req[$widgetDef['name']], $timedate->get_date_format(), $timedate->dbDayFormat); |
| 216 | - elseif (!empty($req[$widgetDef['name']])) |
|
| 217 | - $options[$widgetDef['name']] = $req[$widgetDef['name']]; |
|
| 226 | + } elseif (!empty($req[$widgetDef['name']])) { |
|
| 227 | + $options[$widgetDef['name']] = $req[$widgetDef['name']]; |
|
| 228 | + } |
|
| 218 | 229 | } |
| 219 | 230 | |
| 220 | - if (!empty($req['dashletTitle'])) |
|
| 221 | - $options['title'] = $req['dashletTitle']; |
|
| 231 | + if (!empty($req['dashletTitle'])) { |
|
| 232 | + $options['title'] = $req['dashletTitle']; |
|
| 233 | + } |
|
| 222 | 234 | |
| 223 | 235 | $options['autoRefresh'] = empty($req['autoRefresh']) ? '0' : $req['autoRefresh']; |
| 224 | 236 | |
@@ -241,19 +253,24 @@ discard block |
||
| 241 | 253 | $currentSearchFields[$name] = array(); |
| 242 | 254 | |
| 243 | 255 | $widgetDef = $params; |
| 244 | - if ( isset($this->getSeedBean()->field_defs[$name]) ) |
|
| 245 | - $widgetDef = $this->getSeedBean()->field_defs[$name]; |
|
| 256 | + if ( isset($this->getSeedBean()->field_defs[$name]) ) { |
|
| 257 | + $widgetDef = $this->getSeedBean()->field_defs[$name]; |
|
| 258 | + } |
|
| 246 | 259 | |
| 247 | - if($widgetDef['type'] == 'enum' || $widgetDef['type'] == 'singleenum') $widgetDef['remove_blank'] = true; // remove the blank option for the dropdown |
|
| 260 | + if($widgetDef['type'] == 'enum' || $widgetDef['type'] == 'singleenum') { |
|
| 261 | + $widgetDef['remove_blank'] = true; |
|
| 262 | + } |
|
| 263 | + // remove the blank option for the dropdown |
|
| 248 | 264 | |
| 249 | - if ( empty($widgetDef['input_name0']) ) |
|
| 250 | - $widgetDef['input_name0'] = empty($this->$name) ? '' : $this->$name; |
|
| 265 | + if ( empty($widgetDef['input_name0']) ) { |
|
| 266 | + $widgetDef['input_name0'] = empty($this->$name) ? '' : $this->$name; |
|
| 267 | + } |
|
| 251 | 268 | $currentSearchFields[$name]['label'] = translate($widgetDef['vname'], $this->getSeedBean()->module_dir); |
| 252 | - if ( $currentSearchFields[$name]['label'] == $widgetDef['vname'] ) |
|
| 253 | - $currentSearchFields[$name]['label'] = translate($widgetDef['vname'], 'Charts'); |
|
| 269 | + if ( $currentSearchFields[$name]['label'] == $widgetDef['vname'] ) { |
|
| 270 | + $currentSearchFields[$name]['label'] = translate($widgetDef['vname'], 'Charts'); |
|
| 271 | + } |
|
| 254 | 272 | $currentSearchFields[$name]['input'] = $this->layoutManager->widgetDisplayInput($widgetDef, true, (empty($this->$name) ? '' : $this->$name)); |
| 255 | - } |
|
| 256 | - else { // ability to create spacers in input fields |
|
| 273 | + } else { // ability to create spacers in input fields |
|
| 257 | 274 | $currentSearchFields['blank' + $count]['label'] = ''; |
| 258 | 275 | $currentSearchFields['blank' + $count]['input'] = ''; |
| 259 | 276 | $count++; |
@@ -289,8 +306,9 @@ discard block |
||
| 289 | 306 | */ |
| 290 | 307 | protected function getSeedBean() |
| 291 | 308 | { |
| 292 | - if ( !($this->_seedBean instanceof SugarBean) ) |
|
| 293 | - $this->_seedBean = SugarModule::get($this->_seedName)->loadBean(); |
|
| 309 | + if ( !($this->_seedBean instanceof SugarBean) ) { |
|
| 310 | + $this->_seedBean = SugarModule::get($this->_seedName)->loadBean(); |
|
| 311 | + } |
|
| 294 | 312 | |
| 295 | 313 | return $this->_seedBean; |
| 296 | 314 | } |
@@ -412,9 +430,14 @@ discard block |
||
| 412 | 430 | } |
| 413 | 431 | |
| 414 | 432 | //if(isset($sortby1[0]) && $sortby1[0]=='') unset($sortby1[0]);//the beginning of lead_source_dom is blank. |
| 415 | - if(isset($sortby1[0]) && $sortby1[0]==array()) unset($sortby1[0]);//the beginning of month after search is blank. |
|
| 433 | + if(isset($sortby1[0]) && $sortby1[0]==array()) { |
|
| 434 | + unset($sortby1[0]); |
|
| 435 | + } |
|
| 436 | + //the beginning of month after search is blank. |
|
| 416 | 437 | |
| 417 | - if($ifsort2==false) $sortby2=array(0); |
|
| 438 | + if($ifsort2==false) { |
|
| 439 | + $sortby2=array(0); |
|
| 440 | + } |
|
| 418 | 441 | |
| 419 | 442 | if($keycolname2!=null) { |
| 420 | 443 | $sortby2 = array(); |
@@ -438,7 +461,9 @@ discard block |
||
| 438 | 461 | |
| 439 | 462 | foreach($sortby1 as $sort1) { |
| 440 | 463 | foreach($sortby2 as $sort2) { |
| 441 | - if($ifsort2) $a=0; |
|
| 464 | + if($ifsort2) { |
|
| 465 | + $a=0; |
|
| 466 | + } |
|
| 442 | 467 | foreach($data_set as $key => $value){ |
| 443 | 468 | if($value[$keycolname1] == $sort1 && (!$ifsort2 || $value[$keycolname2]== $sort2)) { |
| 444 | 469 | if($translate1) { |
@@ -461,15 +486,13 @@ discard block |
||
| 461 | 486 | if($translate1) { |
| 462 | 487 | $val[$keycolname1] = $app_list_strings[$keycolname1.'_dom'][$sort1]; |
| 463 | 488 | $val[$keycolname1.'_dom_option'] = $sort1; |
| 464 | - } |
|
| 465 | - else { |
|
| 489 | + } else { |
|
| 466 | 490 | $val[$keycolname1] = $sort1; |
| 467 | 491 | } |
| 468 | 492 | if($translate2) { |
| 469 | 493 | $val[$keycolname2] = $app_list_strings[$keycolname2.'_dom'][$sort2]; |
| 470 | 494 | $val[$keycolname2.'_dom_option'] = $sort2; |
| 471 | - } |
|
| 472 | - elseif($keycolname2!=null) { |
|
| 495 | + } elseif($keycolname2!=null) { |
|
| 473 | 496 | $val[$keycolname2] = $sort2; |
| 474 | 497 | } |
| 475 | 498 | array_push($data, $val); |
@@ -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. |
@@ -73,8 +75,9 @@ discard block |
||
| 73 | 75 | if(is_file(preg_replace('/(.*\/.*)(\.php)/Uis', '$1.meta$2', $file))) { // is there an associated meta data file? |
| 74 | 76 | $dashletFiles[$class]['meta'] = preg_replace('/(.*\/.*)(\.php)/Uis', '$1.meta$2', $file); |
| 75 | 77 | require($dashletFiles[$class]['meta']); |
| 76 | - if ( isset($dashletMeta[$class]['module']) ) |
|
| 77 | - $dashletFiles[$class]['module'] = $dashletMeta[$class]['module']; |
|
| 78 | + if ( isset($dashletMeta[$class]['module']) ) { |
|
| 79 | + $dashletFiles[$class]['module'] = $dashletMeta[$class]['module']; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | $filesInDirectory = array(); |
@@ -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. |
@@ -94,8 +96,7 @@ discard block |
||
| 94 | 96 | $old_dashlets = array(); |
| 95 | 97 | $current_user->setPreference('columns', $old_columns, 0, 'home'); |
| 96 | 98 | $current_user->setPreference('dashlets', $old_dashlets, 0, 'home'); |
| 97 | - } |
|
| 98 | - else{ |
|
| 99 | + } else{ |
|
| 99 | 100 | // This is here to get Sugar dashlets added above the rest |
| 100 | 101 | $dashlets[create_guid()] = array('className' => 'iFrameDashlet', |
| 101 | 102 | 'module' => 'Home', |
@@ -150,8 +151,11 @@ discard block |
||
| 150 | 151 | $columns[1]['dashlets'] = array(); |
| 151 | 152 | |
| 152 | 153 | foreach($dashlets as $guid=>$dashlet) { |
| 153 | - if( $dashlet['forceColumn'] == 0 ) array_push($columns[0]['dashlets'], $guid); |
|
| 154 | - else array_push($columns[1]['dashlets'], $guid); |
|
| 154 | + if( $dashlet['forceColumn'] == 0 ) { |
|
| 155 | + array_push($columns[0]['dashlets'], $guid); |
|
| 156 | + } else { |
|
| 157 | + array_push($columns[1]['dashlets'], $guid); |
|
| 158 | + } |
|
| 155 | 159 | $count++; |
| 156 | 160 | } |
| 157 | 161 | } |
@@ -179,8 +183,9 @@ discard block |
||
| 179 | 183 | $dashlets = array_merge($dashlets,$dashletsDashboard); |
| 180 | 184 | $current_user->setPreference('dashlets', $dashlets, 0, 'Home'); |
| 181 | 185 | } |
| 182 | -if ( !empty($pagesDashboard) || !empty($dashletsDashboard) ) |
|
| 186 | +if ( !empty($pagesDashboard) || !empty($dashletsDashboard) ) { |
|
| 183 | 187 | $current_user->resetPreferences('Dashboard'); |
| 188 | +} |
|
| 184 | 189 | |
| 185 | 190 | if (empty($pages)){ |
| 186 | 191 | $pages = array(); |
@@ -217,12 +222,14 @@ discard block |
||
| 217 | 222 | // only display dashlets that are from visibile modules and that the user has permission to list |
| 218 | 223 | if(!empty($id) && isset($dashlets[$id]) && is_file($dashlets[$id]['fileLocation'])) { |
| 219 | 224 | $module = 'Home'; |
| 220 | - if ( !empty($dashletsFiles[$dashlets[$id]['className']]['module']) ) |
|
| 221 | - $module = $dashletsFiles[$dashlets[$id]['className']]['module']; |
|
| 225 | + if ( !empty($dashletsFiles[$dashlets[$id]['className']]['module']) ) { |
|
| 226 | + $module = $dashletsFiles[$dashlets[$id]['className']]['module']; |
|
| 227 | + } |
|
| 222 | 228 | // Bug 24772 - Look into the user preference for the module the dashlet is a part of in case |
| 223 | 229 | // of the Report Chart dashlets. |
| 224 | - elseif ( !empty($dashlets[$id]['module']) ) |
|
| 225 | - $module = $dashlets[$id]['module']; |
|
| 230 | + elseif ( !empty($dashlets[$id]['module']) ) { |
|
| 231 | + $module = $dashlets[$id]['module']; |
|
| 232 | + } |
|
| 226 | 233 | |
| 227 | 234 | $myDashlet = new MySugar($module); |
| 228 | 235 | |
@@ -267,7 +274,9 @@ discard block |
||
| 267 | 274 | $_SESSION['current_tab'] = $activePage; |
| 268 | 275 | |
| 269 | 276 | |
| 270 | -if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) $sugar_smarty->assign('lock_homepage', true); |
|
| 277 | +if(!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) { |
|
| 278 | + $sugar_smarty->assign('lock_homepage', true); |
|
| 279 | +} |
|
| 271 | 280 | |
| 272 | 281 | |
| 273 | 282 | $sugar_smarty->assign('sugarVersion', $sugar_version); |