@@ -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. |
@@ -403,13 +405,15 @@ discard block |
||
| 403 | 405 | $match = array(); |
| 404 | 406 | preg_match_all("'.* FROM ([^ ]*).* ORDER BY (.*)'is", $sql, $match); |
| 405 | 407 | $indices = false; |
| 406 | - if (!empty($match[1][0])) |
|
| 407 | - $table = $match[1][0]; |
|
| 408 | - else |
|
| 409 | - return false; |
|
| 408 | + if (!empty($match[1][0])) { |
|
| 409 | + $table = $match[1][0]; |
|
| 410 | + } else { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 410 | 413 | |
| 411 | - if (!empty($object_name) && !empty($GLOBALS['dictionary'][$object_name])) |
|
| 412 | - $indices = $GLOBALS['dictionary'][$object_name]['indices']; |
|
| 414 | + if (!empty($object_name) && !empty($GLOBALS['dictionary'][$object_name])) { |
|
| 415 | + $indices = $GLOBALS['dictionary'][$object_name]['indices']; |
|
| 416 | + } |
|
| 413 | 417 | |
| 414 | 418 | if (empty($indices)) { |
| 415 | 419 | foreach ( $GLOBALS['dictionary'] as $current ) { |
@@ -427,25 +431,29 @@ discard block |
||
| 427 | 431 | $orderBys = explode(' ', $match[2][0]); |
| 428 | 432 | foreach ($orderBys as $orderBy){ |
| 429 | 433 | $orderBy = trim($orderBy); |
| 430 | - if (empty($orderBy)) |
|
| 431 | - continue; |
|
| 434 | + if (empty($orderBy)) { |
|
| 435 | + continue; |
|
| 436 | + } |
|
| 432 | 437 | $orderBy = strtolower($orderBy); |
| 433 | - if ($orderBy == 'asc' || $orderBy == 'desc') |
|
| 434 | - continue; |
|
| 438 | + if ($orderBy == 'asc' || $orderBy == 'desc') { |
|
| 439 | + continue; |
|
| 440 | + } |
|
| 435 | 441 | |
| 436 | 442 | $orderBy = str_replace(array($table . '.', ','), '', $orderBy); |
| 437 | 443 | |
| 438 | - foreach ($indices as $index) |
|
| 439 | - if (empty($index['db']) || $index['db'] == $this->dbType) |
|
| 444 | + foreach ($indices as $index) { |
|
| 445 | + if (empty($index['db']) || $index['db'] == $this->dbType) |
|
| 440 | 446 | foreach ($index['fields'] as $field) |
| 441 | 447 | if ($field == $orderBy) |
| 442 | 448 | return true; |
| 449 | + } |
|
| 443 | 450 | |
| 444 | 451 | $warning = 'Missing Index For Order By Table: ' . $table . ' Order By:' . $orderBy ; |
| 445 | - if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) |
|
| 446 | - $this->log->fatal('CHECK QUERY:' .$warning); |
|
| 447 | - else |
|
| 448 | - $this->log->warn('CHECK QUERY:' .$warning); |
|
| 452 | + if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) { |
|
| 453 | + $this->log->fatal('CHECK QUERY:' .$warning); |
|
| 454 | + } else { |
|
| 455 | + $this->log->warn('CHECK QUERY:' .$warning); |
|
| 456 | + } |
|
| 449 | 457 | } |
| 450 | 458 | } |
| 451 | 459 | return false; |
@@ -467,8 +475,9 @@ discard block |
||
| 467 | 475 | public function checkConnection() |
| 468 | 476 | { |
| 469 | 477 | $this->last_error = ''; |
| 470 | - if (!isset($this->database)) |
|
| 471 | - $this->connect(); |
|
| 478 | + if (!isset($this->database)) { |
|
| 479 | + $this->connect(); |
|
| 480 | + } |
|
| 472 | 481 | } |
| 473 | 482 | |
| 474 | 483 | /** |
@@ -510,9 +519,13 @@ discard block |
||
| 510 | 519 | $values = array(); |
| 511 | 520 | foreach ($field_defs as $field => $fieldDef) |
| 512 | 521 | { |
| 513 | - if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
|
| 522 | + if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') { |
|
| 523 | + continue; |
|
| 524 | + } |
|
| 514 | 525 | //custom fields handle there save seperatley |
| 515 | - if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue; |
|
| 526 | + if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) { |
|
| 527 | + continue; |
|
| 528 | + } |
|
| 516 | 529 | |
| 517 | 530 | if(isset($data[$field])) { |
| 518 | 531 | // clean the incoming value.. |
@@ -541,8 +554,10 @@ discard block |
||
| 541 | 554 | } |
| 542 | 555 | } |
| 543 | 556 | |
| 544 | - if (empty($values)) |
|
| 545 | - return $execute?true:''; // no columns set |
|
| 557 | + if (empty($values)) { |
|
| 558 | + return $execute?true:''; |
|
| 559 | + } |
|
| 560 | + // no columns set |
|
| 546 | 561 | |
| 547 | 562 | // get the entire sql |
| 548 | 563 | $query = "INSERT INTO $table (".implode(",", array_keys($values)).") |
@@ -642,9 +657,10 @@ discard block |
||
| 642 | 657 | if(!$this->supports("inline_keys")) { |
| 643 | 658 | // handle constraints and indices |
| 644 | 659 | $indicesArr = $this->createConstraintSql($bean); |
| 645 | - if (count($indicesArr) > 0) |
|
| 646 | - foreach ($indicesArr as $indexSql) |
|
| 660 | + if (count($indicesArr) > 0) { |
|
| 661 | + foreach ($indicesArr as $indexSql) |
|
| 647 | 662 | $this->query($indexSql, true, $msg); |
| 663 | + } |
|
| 648 | 664 | } |
| 649 | 665 | } |
| 650 | 666 | |
@@ -681,9 +697,10 @@ discard block |
||
| 681 | 697 | if(!$this->supports("inline_keys")) { |
| 682 | 698 | // handle constraints and indices |
| 683 | 699 | $indicesArr = $this->getConstraintSql($indices, $tablename); |
| 684 | - if (count($indicesArr) > 0) |
|
| 685 | - foreach ($indicesArr as $indexSql) |
|
| 700 | + if (count($indicesArr) > 0) { |
|
| 701 | + foreach ($indicesArr as $indexSql) |
|
| 686 | 702 | $res = ($res and $this->query($indexSql, true, "Error creating indexes")); |
| 703 | + } |
|
| 687 | 704 | } |
| 688 | 705 | return $res; |
| 689 | 706 | } |
@@ -710,13 +727,15 @@ discard block |
||
| 710 | 727 | } |
| 711 | 728 | //jc: added this for beans that do not actually have a table, namely |
| 712 | 729 | //ForecastOpportunities |
| 713 | - if($tablename == 'does_not_exist' || $tablename == '') |
|
| 714 | - return ''; |
|
| 730 | + if($tablename == 'does_not_exist' || $tablename == '') { |
|
| 731 | + return ''; |
|
| 732 | + } |
|
| 715 | 733 | |
| 716 | 734 | global $dictionary; |
| 717 | 735 | $engine=null; |
| 718 | - if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) |
|
| 719 | - $engine = $dictionary[$bean->getObjectName()]['engine']; |
|
| 736 | + if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) { |
|
| 737 | + $engine = $dictionary[$bean->getObjectName()]['engine']; |
|
| 738 | + } |
|
| 720 | 739 | |
| 721 | 740 | return $this->repairTableParams($tablename, $fielddefs,$new_index,$execute,$engine); |
| 722 | 741 | } |
@@ -760,8 +779,9 @@ discard block |
||
| 760 | 779 | { |
| 761 | 780 | //jc: had a bug when running the repair if the tablename is blank the repair will |
| 762 | 781 | //fail when it tries to create a repair table |
| 763 | - if ($tablename == '' || empty($fielddefs)) |
|
| 764 | - return ''; |
|
| 782 | + if ($tablename == '' || empty($fielddefs)) { |
|
| 783 | + return ''; |
|
| 784 | + } |
|
| 765 | 785 | |
| 766 | 786 | //if the table does not exist create it and we are done |
| 767 | 787 | $sql = "/* Table : $tablename */\n"; |
@@ -784,16 +804,16 @@ discard block |
||
| 784 | 804 | // do column comparisons |
| 785 | 805 | $sql .= "/*COLUMNS*/\n"; |
| 786 | 806 | foreach ($fielddefs as $name => $value) { |
| 787 | - if (isset($value['source']) && $value['source'] != 'db') |
|
| 788 | - continue; |
|
| 807 | + if (isset($value['source']) && $value['source'] != 'db') { |
|
| 808 | + continue; |
|
| 809 | + } |
|
| 789 | 810 | |
| 790 | 811 | // Bug #42406. Skipping breaked vardef without type or name |
| 791 | 812 | if (isset($value['name']) == false || $value['name'] == false) |
| 792 | 813 | { |
| 793 | 814 | $sql .= "/* NAME IS MISSING IN VARDEF $tablename::$name */\n"; |
| 794 | 815 | continue; |
| 795 | - } |
|
| 796 | - else if (isset($value['type']) == false || $value['type'] == false) |
|
| 816 | + } else if (isset($value['type']) == false || $value['type'] == false) |
|
| 797 | 817 | { |
| 798 | 818 | $sql .= "/* TYPE IS MISSING IN VARDEF $tablename::$name */\n"; |
| 799 | 819 | continue; |
@@ -823,8 +843,9 @@ discard block |
||
| 823 | 843 | // ok we need this field lets create it |
| 824 | 844 | $sql .= "/*MISSING IN DATABASE - $name - ROW*/\n"; |
| 825 | 845 | $sql .= $this->addColumnSQL($tablename, $value) . "\n"; |
| 826 | - if ($execute) |
|
| 827 | - $this->addColumn($tablename, $value); |
|
| 846 | + if ($execute) { |
|
| 847 | + $this->addColumn($tablename, $value); |
|
| 848 | + } |
|
| 828 | 849 | $take_action = true; |
| 829 | 850 | } elseif ( !$this->compareVarDefs($compareFieldDefs[$name],$value)) { |
| 830 | 851 | //fields are different lets alter it |
@@ -880,8 +901,9 @@ discard block |
||
| 880 | 901 | unset($compareIndices_case_insensitive); |
| 881 | 902 | |
| 882 | 903 | foreach ($indices as $value) { |
| 883 | - if (isset($value['source']) && $value['source'] != 'db') |
|
| 884 | - continue; |
|
| 904 | + if (isset($value['source']) && $value['source'] != 'db') { |
|
| 905 | + continue; |
|
| 906 | + } |
|
| 885 | 907 | |
| 886 | 908 | |
| 887 | 909 | $validDBName = $this->getValidDBName($value['name'], true, 'index', true); |
@@ -891,19 +913,23 @@ discard block |
||
| 891 | 913 | $name = strtolower($value['name']); |
| 892 | 914 | |
| 893 | 915 | //Don't attempt to fix the same index twice in one pass; |
| 894 | - if (isset($correctedIndexs[$name])) |
|
| 895 | - continue; |
|
| 916 | + if (isset($correctedIndexs[$name])) { |
|
| 917 | + continue; |
|
| 918 | + } |
|
| 896 | 919 | |
| 897 | 920 | //don't bother checking primary nothing we can do about them |
| 898 | - if (isset($value['type']) && $value['type'] == 'primary') |
|
| 899 | - continue; |
|
| 921 | + if (isset($value['type']) && $value['type'] == 'primary') { |
|
| 922 | + continue; |
|
| 923 | + } |
|
| 900 | 924 | |
| 901 | 925 | //database helpers do not know how to handle full text indices |
| 902 | - if ($value['type']=='fulltext') |
|
| 903 | - continue; |
|
| 926 | + if ($value['type']=='fulltext') { |
|
| 927 | + continue; |
|
| 928 | + } |
|
| 904 | 929 | |
| 905 | - if ( in_array($value['type'],array('alternate_key','foreign')) ) |
|
| 906 | - $value['type'] = 'index'; |
|
| 930 | + if ( in_array($value['type'],array('alternate_key','foreign')) ) { |
|
| 931 | + $value['type'] = 'index'; |
|
| 932 | + } |
|
| 907 | 933 | |
| 908 | 934 | if ( !isset($compareIndices[$name]) ) { |
| 909 | 935 | //First check if an index exists that doesn't match our name, if so, try to rename it |
@@ -934,21 +960,23 @@ discard block |
||
| 934 | 960 | $sql .= "/*INDEX MISMATCH WITH DATABASE - $name - ROW "; |
| 935 | 961 | foreach ($compareIndices[$name] as $n1 => $t1) { |
| 936 | 962 | $sql .= "<$n1>"; |
| 937 | - if ( $n1 == 'fields' ) |
|
| 938 | - foreach($t1 as $rKey => $rValue) |
|
| 963 | + if ( $n1 == 'fields' ) { |
|
| 964 | + foreach($t1 as $rKey => $rValue) |
|
| 939 | 965 | $sql .= "[$rKey] => '$rValue' "; |
| 940 | - else |
|
| 941 | - $sql .= " $t1 "; |
|
| 966 | + } else { |
|
| 967 | + $sql .= " $t1 "; |
|
| 968 | + } |
|
| 942 | 969 | } |
| 943 | 970 | $sql .= "*/\n"; |
| 944 | 971 | $sql .= "/* VARDEF - $name - ROW"; |
| 945 | 972 | foreach ($value as $n1 => $t1) { |
| 946 | 973 | $sql .= "<$n1>"; |
| 947 | - if ( $n1 == 'fields' ) |
|
| 948 | - foreach ($t1 as $rKey => $rValue) |
|
| 974 | + if ( $n1 == 'fields' ) { |
|
| 975 | + foreach ($t1 as $rKey => $rValue) |
|
| 949 | 976 | $sql .= "[$rKey] => '$rValue' "; |
| 950 | - else |
|
| 951 | - $sql .= " $t1 "; |
|
| 977 | + } else { |
|
| 978 | + $sql .= " $t1 "; |
|
| 979 | + } |
|
| 952 | 980 | } |
| 953 | 981 | $sql .= "*/\n"; |
| 954 | 982 | $sql .= $this->modifyIndexes($tablename,array($value), $execute) . "\n"; |
@@ -971,8 +999,9 @@ discard block |
||
| 971 | 999 | public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false) |
| 972 | 1000 | { |
| 973 | 1001 | foreach ( $fielddef1 as $key => $value ) { |
| 974 | - if ($key == 'name' && $ignoreName) |
|
| 975 | - continue; |
|
| 1002 | + if ($key == 'name' && $ignoreName) { |
|
| 1003 | + continue; |
|
| 1004 | + } |
|
| 976 | 1005 | if (isset($fielddef2[$key])) |
| 977 | 1006 | { |
| 978 | 1007 | if (!is_array($fielddef1[$key]) && !is_array($fielddef2[$key])) |
@@ -981,8 +1010,7 @@ discard block |
||
| 981 | 1010 | { |
| 982 | 1011 | continue; |
| 983 | 1012 | } |
| 984 | - } |
|
| 985 | - else |
|
| 1013 | + } else |
|
| 986 | 1014 | { |
| 987 | 1015 | if (array_map('strtolower', $fielddef1[$key]) == array_map('strtolower',$fielddef2[$key])) |
| 988 | 1016 | { |
@@ -991,8 +1019,9 @@ discard block |
||
| 991 | 1019 | } |
| 992 | 1020 | } |
| 993 | 1021 | //Ignore len if its not set in the vardef |
| 994 | - if ($key == 'len' && empty($fielddef2[$key])) |
|
| 995 | - continue; |
|
| 1022 | + if ($key == 'len' && empty($fielddef2[$key])) { |
|
| 1023 | + continue; |
|
| 1024 | + } |
|
| 996 | 1025 | // if the length in db is greather than the vardef, ignore it |
| 997 | 1026 | if ($key == 'len' && ($fielddef1[$key] >= $fielddef2[$key])) { |
| 998 | 1027 | continue; |
@@ -1026,12 +1055,10 @@ discard block |
||
| 1026 | 1055 | if (!$row2) { |
| 1027 | 1056 | // Exists on table1 but not table2 |
| 1028 | 1057 | $returnArray['msg'] = 'not_exists_table2'; |
| 1029 | - } |
|
| 1030 | - else { |
|
| 1058 | + } else { |
|
| 1031 | 1059 | if (sizeof($row1) != sizeof($row2)) { |
| 1032 | 1060 | $returnArray['msg'] = 'no_match'; |
| 1033 | - } |
|
| 1034 | - else { |
|
| 1061 | + } else { |
|
| 1035 | 1062 | $returnArray['msg'] = 'match'; |
| 1036 | 1063 | foreach($row1 as $key => $value){ |
| 1037 | 1064 | //ignore keys when checking we will check them when we do the index check |
@@ -1041,8 +1068,7 @@ discard block |
||
| 1041 | 1068 | } |
| 1042 | 1069 | } |
| 1043 | 1070 | } |
| 1044 | - } |
|
| 1045 | - else { |
|
| 1071 | + } else { |
|
| 1046 | 1072 | $returnArray['msg'] = 'not_exists_table1'; |
| 1047 | 1073 | } |
| 1048 | 1074 | |
@@ -1122,16 +1148,19 @@ discard block |
||
| 1122 | 1148 | */ |
| 1123 | 1149 | public function getConstraintSql($indices, $table) |
| 1124 | 1150 | { |
| 1125 | - if (!$this->isFieldArray($indices)) |
|
| 1126 | - $indices = array($indices); |
|
| 1151 | + if (!$this->isFieldArray($indices)) { |
|
| 1152 | + $indices = array($indices); |
|
| 1153 | + } |
|
| 1127 | 1154 | |
| 1128 | 1155 | $columns = array(); |
| 1129 | 1156 | |
| 1130 | 1157 | foreach ($indices as $index) { |
| 1131 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
| 1132 | - continue; |
|
| 1133 | - if (isset($index['source']) && $index['source'] != 'db') |
|
| 1134 | - continue; |
|
| 1158 | + if(!empty($index['db']) && $index['db'] != $this->dbType) { |
|
| 1159 | + continue; |
|
| 1160 | + } |
|
| 1161 | + if (isset($index['source']) && $index['source'] != 'db') { |
|
| 1162 | + continue; |
|
| 1163 | + } |
|
| 1135 | 1164 | |
| 1136 | 1165 | $sql = $this->add_drop_constraint($table, $index); |
| 1137 | 1166 | |
@@ -1221,11 +1250,11 @@ discard block |
||
| 1221 | 1250 | $sql = $this->addColumnSQL($tablename, $fieldDefs); |
| 1222 | 1251 | if ($this->isFieldArray($fieldDefs)){ |
| 1223 | 1252 | $columns = array(); |
| 1224 | - foreach ($fieldDefs as $fieldDef) |
|
| 1225 | - $columns[] = $fieldDef['name']; |
|
| 1253 | + foreach ($fieldDefs as $fieldDef) { |
|
| 1254 | + $columns[] = $fieldDef['name']; |
|
| 1255 | + } |
|
| 1226 | 1256 | $columns = implode(",", $columns); |
| 1227 | - } |
|
| 1228 | - else { |
|
| 1257 | + } else { |
|
| 1229 | 1258 | $columns = $fieldDefs['name']; |
| 1230 | 1259 | } |
| 1231 | 1260 | $msg = "Error adding column(s) $columns on table: $tablename:"; |
@@ -1249,8 +1278,7 @@ discard block |
||
| 1249 | 1278 | $columns[] = $fieldDef['name']; |
| 1250 | 1279 | } |
| 1251 | 1280 | $columns = implode(",", $columns); |
| 1252 | - } |
|
| 1253 | - else { |
|
| 1281 | + } else { |
|
| 1254 | 1282 | $columns = $newFieldDef['name']; |
| 1255 | 1283 | } |
| 1256 | 1284 | |
@@ -1370,7 +1398,9 @@ discard block |
||
| 1370 | 1398 | if(!$is_related_query){ |
| 1371 | 1399 | foreach ($fields as $fieldDef) |
| 1372 | 1400 | { |
| 1373 | - if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue; |
|
| 1401 | + if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') { |
|
| 1402 | + continue; |
|
| 1403 | + } |
|
| 1374 | 1404 | $val = $row[$fieldDef['name']]; |
| 1375 | 1405 | |
| 1376 | 1406 | //handle auto increment values here only need to do this on insert not create |
@@ -1379,8 +1409,7 @@ discard block |
||
| 1379 | 1409 | if(!$built_columns){ |
| 1380 | 1410 | $columns[] = 'deleted'; |
| 1381 | 1411 | } |
| 1382 | - } |
|
| 1383 | - else |
|
| 1412 | + } else |
|
| 1384 | 1413 | { |
| 1385 | 1414 | $type = $fieldDef['type']; |
| 1386 | 1415 | if(!empty($fieldDef['custom_type'])){ |
@@ -1388,28 +1417,32 @@ discard block |
||
| 1388 | 1417 | } |
| 1389 | 1418 | // need to do some thing about types of values |
| 1390 | 1419 | if($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')){ |
| 1391 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1392 | - $cstm_values[$fieldDef['name']] = 'null'; |
|
| 1393 | - else |
|
| 1394 | - $values[$fieldDef['name']] = 'null'; |
|
| 1395 | - }else{ |
|
| 1420 | + if(!empty($custom_fields[$fieldDef['name']])) { |
|
| 1421 | + $cstm_values[$fieldDef['name']] = 'null'; |
|
| 1422 | + } else { |
|
| 1423 | + $values[$fieldDef['name']] = 'null'; |
|
| 1424 | + } |
|
| 1425 | + } else{ |
|
| 1396 | 1426 | if(isset($type) && $type=='int') { |
| 1397 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1398 | - $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1399 | - else |
|
| 1400 | - $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1427 | + if(!empty($custom_fields[$fieldDef['name']])) { |
|
| 1428 | + $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1429 | + } else { |
|
| 1430 | + $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
|
| 1431 | + } |
|
| 1401 | 1432 | } else { |
| 1402 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1403 | - $cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1404 | - else |
|
| 1405 | - $values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1433 | + if(!empty($custom_fields[$fieldDef['name']])) { |
|
| 1434 | + $cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1435 | + } else { |
|
| 1436 | + $values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
|
| 1437 | + } |
|
| 1406 | 1438 | } |
| 1407 | 1439 | } |
| 1408 | 1440 | if(!$built_columns){ |
| 1409 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1410 | - $cstm_columns[] = $fieldDef['name']; |
|
| 1411 | - else |
|
| 1412 | - $columns[] = $fieldDef['name']; |
|
| 1441 | + if(!empty($custom_fields[$fieldDef['name']])) { |
|
| 1442 | + $cstm_columns[] = $fieldDef['name']; |
|
| 1443 | + } else { |
|
| 1444 | + $columns[] = $fieldDef['name']; |
|
| 1445 | + } |
|
| 1413 | 1446 | } |
| 1414 | 1447 | } |
| 1415 | 1448 | |
@@ -1624,7 +1657,9 @@ discard block |
||
| 1624 | 1657 | $queryresult = $this->query($sql, $dieOnError, $msg); |
| 1625 | 1658 | } |
| 1626 | 1659 | $this->checkError($msg.' Get One Failed:' . $sql, $dieOnError); |
| 1627 | - if (!$queryresult) return false; |
|
| 1660 | + if (!$queryresult) { |
|
| 1661 | + return false; |
|
| 1662 | + } |
|
| 1628 | 1663 | $row = $this->fetchByAssoc($queryresult); |
| 1629 | 1664 | if(!empty($row)) { |
| 1630 | 1665 | return array_shift($row); |
@@ -1648,10 +1683,14 @@ discard block |
||
| 1648 | 1683 | $queryresult = $this->query($sql, $dieOnError, $msg); |
| 1649 | 1684 | $this->checkError($msg.' Fetch One Failed:' . $sql, $dieOnError); |
| 1650 | 1685 | |
| 1651 | - if (!$queryresult) return false; |
|
| 1686 | + if (!$queryresult) { |
|
| 1687 | + return false; |
|
| 1688 | + } |
|
| 1652 | 1689 | |
| 1653 | 1690 | $row = $this->fetchByAssoc($queryresult); |
| 1654 | - if ( !$row ) return false; |
|
| 1691 | + if ( !$row ) { |
|
| 1692 | + return false; |
|
| 1693 | + } |
|
| 1655 | 1694 | |
| 1656 | 1695 | $this->freeResult($queryresult); |
| 1657 | 1696 | return $row; |
@@ -1708,13 +1747,15 @@ discard block |
||
| 1708 | 1747 | protected function describeField($name, $tablename) |
| 1709 | 1748 | { |
| 1710 | 1749 | $table = $this->getTableDescription($tablename); |
| 1711 | - if(!empty($table) && isset($table[$name])) |
|
| 1712 | - return $table[$name]; |
|
| 1750 | + if(!empty($table) && isset($table[$name])) { |
|
| 1751 | + return $table[$name]; |
|
| 1752 | + } |
|
| 1713 | 1753 | |
| 1714 | 1754 | $table = $this->getTableDescription($tablename, true); |
| 1715 | 1755 | |
| 1716 | - if(isset($table[$name])) |
|
| 1717 | - return $table[$name]; |
|
| 1756 | + if(isset($table[$name])) { |
|
| 1757 | + return $table[$name]; |
|
| 1758 | + } |
|
| 1718 | 1759 | |
| 1719 | 1760 | return array(); |
| 1720 | 1761 | } |
@@ -1768,11 +1809,15 @@ discard block |
||
| 1768 | 1809 | */ |
| 1769 | 1810 | public function concat($table, array $fields, $space = ' ') |
| 1770 | 1811 | { |
| 1771 | - if(empty($fields)) return ''; |
|
| 1812 | + if(empty($fields)) { |
|
| 1813 | + return ''; |
|
| 1814 | + } |
|
| 1772 | 1815 | $elems = array(); |
| 1773 | 1816 | $space = $this->quoted($space); |
| 1774 | 1817 | foreach ( $fields as $field ) { |
| 1775 | - if(!empty($elems)) $elems[] = $space; |
|
| 1818 | + if(!empty($elems)) { |
|
| 1819 | + $elems[] = $space; |
|
| 1820 | + } |
|
| 1776 | 1821 | $elems[] = $this->convert("$table.$field", 'IFNULL', array("''")); |
| 1777 | 1822 | } |
| 1778 | 1823 | $first = array_shift($elems); |
@@ -1864,7 +1909,7 @@ discard block |
||
| 1864 | 1909 | }//switch |
| 1865 | 1910 | }//foreach |
| 1866 | 1911 | return $this->query($query); |
| 1867 | - }else{ |
|
| 1912 | + } else{ |
|
| 1868 | 1913 | return false; |
| 1869 | 1914 | } |
| 1870 | 1915 | } |
@@ -1926,20 +1971,30 @@ discard block |
||
| 1926 | 1971 | $fields = $bean->getFieldDefinitions(); |
| 1927 | 1972 | // get column names and values |
| 1928 | 1973 | foreach ($fields as $field => $fieldDef) { |
| 1929 | - if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
|
| 1974 | + if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') { |
|
| 1975 | + continue; |
|
| 1976 | + } |
|
| 1930 | 1977 | // Do not write out the id field on the update statement. |
| 1931 | 1978 | // We are not allowed to change ids. |
| 1932 | - if (empty($fieldDef['name']) || $fieldDef['name'] == $primaryField['name']) continue; |
|
| 1979 | + if (empty($fieldDef['name']) || $fieldDef['name'] == $primaryField['name']) { |
|
| 1980 | + continue; |
|
| 1981 | + } |
|
| 1933 | 1982 | |
| 1934 | 1983 | // If the field is an auto_increment field, then we shouldn't be setting it. This was added |
| 1935 | 1984 | // specially for Bugs and Cases which have a number associated with them. |
| 1936 | - if (!empty($bean->field_name_map[$field]['auto_increment'])) continue; |
|
| 1985 | + if (!empty($bean->field_name_map[$field]['auto_increment'])) { |
|
| 1986 | + continue; |
|
| 1987 | + } |
|
| 1937 | 1988 | |
| 1938 | 1989 | //custom fields handle their save separately |
| 1939 | - if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) continue; |
|
| 1990 | + if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) { |
|
| 1991 | + continue; |
|
| 1992 | + } |
|
| 1940 | 1993 | |
| 1941 | 1994 | // no need to clear deleted since we only update not deleted records anyway |
| 1942 | - if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue; |
|
| 1995 | + if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) { |
|
| 1996 | + continue; |
|
| 1997 | + } |
|
| 1943 | 1998 | |
| 1944 | 1999 | if(isset($bean->$field)) { |
| 1945 | 2000 | $val = from_html($bean->$field); |
@@ -1972,8 +2027,10 @@ discard block |
||
| 1972 | 2027 | } |
| 1973 | 2028 | } |
| 1974 | 2029 | |
| 1975 | - if ( sizeof($columns) == 0 ) |
|
| 1976 | - return ""; // no columns set |
|
| 2030 | + if ( sizeof($columns) == 0 ) { |
|
| 2031 | + return ""; |
|
| 2032 | + } |
|
| 2033 | + // no columns set |
|
| 1977 | 2034 | |
| 1978 | 2035 | // build where clause |
| 1979 | 2036 | $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
@@ -2039,8 +2096,9 @@ discard block |
||
| 2039 | 2096 | $where[] = " $table.$name $op $val"; |
| 2040 | 2097 | } |
| 2041 | 2098 | |
| 2042 | - if (!empty($where)) |
|
| 2043 | - return implode(" AND ", $where); |
|
| 2099 | + if (!empty($where)) { |
|
| 2100 | + return implode(" AND ", $where); |
|
| 2101 | + } |
|
| 2044 | 2102 | |
| 2045 | 2103 | return ''; |
| 2046 | 2104 | } |
@@ -2144,21 +2202,25 @@ discard block |
||
| 2144 | 2202 | public function massageFieldDef(&$fieldDef, $tablename) |
| 2145 | 2203 | { |
| 2146 | 2204 | if ( !isset($fieldDef['dbType']) ) { |
| 2147 | - if ( isset($fieldDef['dbtype']) ) |
|
| 2148 | - $fieldDef['dbType'] = $fieldDef['dbtype']; |
|
| 2149 | - else |
|
| 2150 | - $fieldDef['dbType'] = $fieldDef['type']; |
|
| 2205 | + if ( isset($fieldDef['dbtype']) ) { |
|
| 2206 | + $fieldDef['dbType'] = $fieldDef['dbtype']; |
|
| 2207 | + } else { |
|
| 2208 | + $fieldDef['dbType'] = $fieldDef['type']; |
|
| 2209 | + } |
|
| 2151 | 2210 | } |
| 2152 | 2211 | $type = $this->getColumnType($fieldDef['dbType'],$fieldDef['name'],$tablename); |
| 2153 | 2212 | $matches = array(); |
| 2154 | 2213 | // len can be a number or a string like 'max', for example, nvarchar(max) |
| 2155 | 2214 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*|\w+)\)|)/i', $type, $matches); |
| 2156 | - if ( isset($matches[1][0]) ) |
|
| 2157 | - $fieldDef['type'] = $matches[1][0]; |
|
| 2158 | - if ( isset($matches[2][0]) && empty($fieldDef['len']) ) |
|
| 2159 | - $fieldDef['len'] = $matches[2][0]; |
|
| 2160 | - if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) |
|
| 2161 | - $fieldDef['len'] .= ",{$fieldDef['precision']}"; |
|
| 2215 | + if ( isset($matches[1][0]) ) { |
|
| 2216 | + $fieldDef['type'] = $matches[1][0]; |
|
| 2217 | + } |
|
| 2218 | + if ( isset($matches[2][0]) && empty($fieldDef['len']) ) { |
|
| 2219 | + $fieldDef['len'] = $matches[2][0]; |
|
| 2220 | + } |
|
| 2221 | + if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) { |
|
| 2222 | + $fieldDef['len'] .= ",{$fieldDef['precision']}"; |
|
| 2223 | + } |
|
| 2162 | 2224 | if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required'])) ) { |
| 2163 | 2225 | $fieldDef['required'] = 'true'; |
| 2164 | 2226 | } |
@@ -2172,8 +2234,9 @@ discard block |
||
| 2172 | 2234 | public function getSelectFieldsFromQuery($selectStatement) |
| 2173 | 2235 | { |
| 2174 | 2236 | $selectStatement = trim($selectStatement); |
| 2175 | - if (strtoupper(substr($selectStatement, 0, 6)) == "SELECT") |
|
| 2176 | - $selectStatement = trim(substr($selectStatement, 6)); |
|
| 2237 | + if (strtoupper(substr($selectStatement, 0, 6)) == "SELECT") { |
|
| 2238 | + $selectStatement = trim(substr($selectStatement, 6)); |
|
| 2239 | + } |
|
| 2177 | 2240 | |
| 2178 | 2241 | //Due to sql functions existing in many selects, we can't use php explode |
| 2179 | 2242 | $fields = array(); |
@@ -2189,17 +2252,15 @@ discard block |
||
| 2189 | 2252 | $field = $this->getFieldNameFromSelect(trim($selectField)); |
| 2190 | 2253 | $fields[$field] = $selectField; |
| 2191 | 2254 | $selectField = ""; |
| 2192 | - } |
|
| 2193 | - else if ($char == "("){ |
|
| 2255 | + } else if ($char == "("){ |
|
| 2194 | 2256 | $level++; |
| 2195 | 2257 | $selectField .= $char; |
| 2196 | - } |
|
| 2197 | - else if($char == ")"){ |
|
| 2258 | + } else if($char == ")"){ |
|
| 2198 | 2259 | $level--; |
| 2199 | 2260 | $selectField .= $char; |
| 2200 | 2261 | |
| 2201 | 2262 | |
| 2202 | - }else{ |
|
| 2263 | + } else{ |
|
| 2203 | 2264 | $selectField .= $char; |
| 2204 | 2265 | } |
| 2205 | 2266 | |
@@ -2218,18 +2279,19 @@ discard block |
||
| 2218 | 2279 | if(strncasecmp($string, "DISTINCT ", 9) == 0) { |
| 2219 | 2280 | $string = substr($string, 9); |
| 2220 | 2281 | } |
| 2221 | - if (stripos($string, " as ") !== false) |
|
| 2222 | - //"as" used for an alias |
|
| 2282 | + if (stripos($string, " as ") !== false) { |
|
| 2283 | + //"as" used for an alias |
|
| 2223 | 2284 | return trim(substr($string, strripos($string, " as ") + 4)); |
| 2224 | - else if (strrpos($string, " ") != 0) |
|
| 2225 | - //Space used as a delimiter for an alias |
|
| 2285 | + } else if (strrpos($string, " ") != 0) { |
|
| 2286 | + //Space used as a delimiter for an alias |
|
| 2226 | 2287 | return trim(substr($string, strrpos($string, " "))); |
| 2227 | - else if (strpos($string, ".") !== false) |
|
| 2228 | - //No alias, but a table.field format was used |
|
| 2288 | + } else if (strpos($string, ".") !== false) { |
|
| 2289 | + //No alias, but a table.field format was used |
|
| 2229 | 2290 | return substr($string, strpos($string, ".") + 1); |
| 2230 | - else |
|
| 2231 | - //Give up and assume the whole thing is the field name |
|
| 2291 | + } else { |
|
| 2292 | + //Give up and assume the whole thing is the field name |
|
| 2232 | 2293 | return $string; |
| 2294 | + } |
|
| 2233 | 2295 | } |
| 2234 | 2296 | |
| 2235 | 2297 | /** |
@@ -2289,8 +2351,9 @@ discard block |
||
| 2289 | 2351 | $aliases[$tableName][] = $table; |
| 2290 | 2352 | |
| 2291 | 2353 | // build part of select for this table |
| 2292 | - if (is_array($cols[$beanID])) |
|
| 2293 | - foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name']; |
|
| 2354 | + if (is_array($cols[$beanID])) { |
|
| 2355 | + foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name']; |
|
| 2356 | + } |
|
| 2294 | 2357 | |
| 2295 | 2358 | // build part of where clause |
| 2296 | 2359 | if (is_array($whereClause[$beanID])){ |
@@ -2322,7 +2385,10 @@ discard block |
||
| 2322 | 2385 | $separator = ""; |
| 2323 | 2386 | $from = ''; $table_used_in_from = array(); |
| 2324 | 2387 | foreach ($relations as $table1 => $rightsidearray){ |
| 2325 | - if ($table_used_in_from[$table1]) continue; // table has been joined |
|
| 2388 | + if ($table_used_in_from[$table1]) { |
|
| 2389 | + continue; |
|
| 2390 | + } |
|
| 2391 | + // table has been joined |
|
| 2326 | 2392 | |
| 2327 | 2393 | $from .= $separator." ".$table1; |
| 2328 | 2394 | $table_used_in_from[$table1] = true; |
@@ -2333,7 +2399,9 @@ discard block |
||
| 2333 | 2399 | //choose first alias that does not match |
| 2334 | 2400 | // we are doing this because of self joins. |
| 2335 | 2401 | // in case of self joins, the same table will have many aliases. |
| 2336 | - if ($table2 != $table1) break; |
|
| 2402 | + if ($table2 != $table1) { |
|
| 2403 | + break; |
|
| 2404 | + } |
|
| 2337 | 2405 | } |
| 2338 | 2406 | |
| 2339 | 2407 | $col = $tablearray['foreingColumn']; |
@@ -2362,11 +2430,13 @@ discard block |
||
| 2362 | 2430 | $tablename = $bean->getTableName(); |
| 2363 | 2431 | $columns = array(); |
| 2364 | 2432 | // get column names |
| 2365 | - foreach ($fields as $fieldDef) |
|
| 2366 | - $columns[] = $fieldDef['name']; |
|
| 2433 | + foreach ($fields as $fieldDef) { |
|
| 2434 | + $columns[] = $fieldDef['name']; |
|
| 2435 | + } |
|
| 2367 | 2436 | |
| 2368 | - if (empty($columns)) |
|
| 2369 | - return ""; |
|
| 2437 | + if (empty($columns)) { |
|
| 2438 | + return ""; |
|
| 2439 | + } |
|
| 2370 | 2440 | |
| 2371 | 2441 | $columns = implode(",", $columns); |
| 2372 | 2442 | |
@@ -2386,16 +2456,21 @@ discard block |
||
| 2386 | 2456 | // we do not have change a lot of existing code |
| 2387 | 2457 | // and add dbtype where type is being used for some special |
| 2388 | 2458 | // purposes like referring to foreign table etc. |
| 2389 | - if(!empty($fieldDef['dbType'])) |
|
| 2390 | - return $fieldDef['dbType']; |
|
| 2391 | - if(!empty($fieldDef['dbtype'])) |
|
| 2392 | - return $fieldDef['dbtype']; |
|
| 2393 | - if (!empty($fieldDef['type'])) |
|
| 2394 | - return $fieldDef['type']; |
|
| 2395 | - if (!empty($fieldDef['Type'])) |
|
| 2396 | - return $fieldDef['Type']; |
|
| 2397 | - if (!empty($fieldDef['data_type'])) |
|
| 2398 | - return $fieldDef['data_type']; |
|
| 2459 | + if(!empty($fieldDef['dbType'])) { |
|
| 2460 | + return $fieldDef['dbType']; |
|
| 2461 | + } |
|
| 2462 | + if(!empty($fieldDef['dbtype'])) { |
|
| 2463 | + return $fieldDef['dbtype']; |
|
| 2464 | + } |
|
| 2465 | + if (!empty($fieldDef['type'])) { |
|
| 2466 | + return $fieldDef['type']; |
|
| 2467 | + } |
|
| 2468 | + if (!empty($fieldDef['Type'])) { |
|
| 2469 | + return $fieldDef['Type']; |
|
| 2470 | + } |
|
| 2471 | + if (!empty($fieldDef['data_type'])) { |
|
| 2472 | + return $fieldDef['data_type']; |
|
| 2473 | + } |
|
| 2399 | 2474 | |
| 2400 | 2475 | return null; |
| 2401 | 2476 | } |
@@ -2453,14 +2528,15 @@ discard block |
||
| 2453 | 2528 | 'clob', 'blob', 'text'))) { |
| 2454 | 2529 | $colType = "$colBaseType(${fieldDef['len']})"; |
| 2455 | 2530 | } elseif(($colBaseType == 'decimal' || $colBaseType == 'float')){ |
| 2456 | - if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) |
|
| 2457 | - if(strpos($fieldDef['len'],',') === false){ |
|
| 2531 | + if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) { |
|
| 2532 | + if(strpos($fieldDef['len'],',') === false){ |
|
| 2458 | 2533 | $colType = $colBaseType . "(".$fieldDef['len'].",".$fieldDef['precision'].")"; |
| 2459 | - }else{ |
|
| 2460 | - $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2461 | - } |
|
| 2462 | - else |
|
| 2534 | + } |
|
| 2535 | + } else{ |
|
| 2463 | 2536 | $colType = $colBaseType . "(".$fieldDef['len'].")"; |
| 2537 | + } else { |
|
| 2538 | + $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2539 | + } |
|
| 2464 | 2540 | } |
| 2465 | 2541 | } else { |
| 2466 | 2542 | if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) { |
@@ -2474,19 +2550,18 @@ discard block |
||
| 2474 | 2550 | if (!empty($fieldDef['no_default'])) |
| 2475 | 2551 | { |
| 2476 | 2552 | // nothing to do |
| 2477 | - } |
|
| 2478 | - elseif (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) |
|
| 2553 | + } elseif (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) |
|
| 2479 | 2554 | { |
| 2480 | 2555 | $default = " DEFAULT ".$this->quoted($fieldDef['default']); |
| 2481 | - } |
|
| 2482 | - elseif (!isset($default) && $type == 'bool') |
|
| 2556 | + } elseif (!isset($default) && $type == 'bool') |
|
| 2483 | 2557 | { |
| 2484 | 2558 | $default = " DEFAULT 0 "; |
| 2485 | 2559 | } |
| 2486 | 2560 | |
| 2487 | 2561 | $auto_increment = ''; |
| 2488 | - if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) |
|
| 2489 | - $auto_increment = $this->setAutoIncrement($table , $fieldDef['name']); |
|
| 2562 | + if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) { |
|
| 2563 | + $auto_increment = $this->setAutoIncrement($table , $fieldDef['name']); |
|
| 2564 | + } |
|
| 2490 | 2565 | |
| 2491 | 2566 | $required = 'NULL'; // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify |
| 2492 | 2567 | //Starting in 6.0, only ID and auto_increment fields will be NOT NULL in the DB. |
@@ -2500,8 +2575,9 @@ discard block |
||
| 2500 | 2575 | && !empty($fieldDef['required'])) { |
| 2501 | 2576 | $required = "NOT NULL"; |
| 2502 | 2577 | } |
| 2503 | - if ($ignoreRequired) |
|
| 2504 | - $required = ""; |
|
| 2578 | + if ($ignoreRequired) { |
|
| 2579 | + $required = ""; |
|
| 2580 | + } |
|
| 2505 | 2581 | |
| 2506 | 2582 | if ( $return_as_array ) { |
| 2507 | 2583 | return array( |
@@ -2537,8 +2613,7 @@ discard block |
||
| 2537 | 2613 | } |
| 2538 | 2614 | } |
| 2539 | 2615 | $columns = implode(",", $columns); |
| 2540 | - } |
|
| 2541 | - else { |
|
| 2616 | + } else { |
|
| 2542 | 2617 | $columns = $this->oneColumnSQLRep($fieldDefs,$ignoreRequired, $tablename); |
| 2543 | 2618 | } |
| 2544 | 2619 | |
@@ -2760,8 +2835,9 @@ discard block |
||
| 2760 | 2835 | */ |
| 2761 | 2836 | public function isFieldArray($defArray) |
| 2762 | 2837 | { |
| 2763 | - if ( !is_array($defArray) ) |
|
| 2764 | - return false; |
|
| 2838 | + if ( !is_array($defArray) ) { |
|
| 2839 | + return false; |
|
| 2840 | + } |
|
| 2765 | 2841 | |
| 2766 | 2842 | if ( isset($defArray['type']) ){ |
| 2767 | 2843 | // type key exists. May be an array of defs or a simple definition |
@@ -2872,11 +2948,9 @@ discard block |
||
| 2872 | 2948 | } else { |
| 2873 | 2949 | if (isset($properties['dbType'])) { |
| 2874 | 2950 | $field_type=$properties['dbType']; |
| 2875 | - } |
|
| 2876 | - else if(isset($properties['data_type'])) { |
|
| 2951 | + } else if(isset($properties['data_type'])) { |
|
| 2877 | 2952 | $field_type=$properties['data_type']; |
| 2878 | - } |
|
| 2879 | - else { |
|
| 2953 | + } else { |
|
| 2880 | 2954 | $field_type=$properties['dbtype']; |
| 2881 | 2955 | } |
| 2882 | 2956 | } |
@@ -2901,13 +2975,11 @@ discard block |
||
| 2901 | 2975 | if ($error >= 0.0000000001) { // Smaller than 10E-10 |
| 2902 | 2976 | $change = true; |
| 2903 | 2977 | } |
| 2904 | - } |
|
| 2905 | - else if ($this->isBooleanType($field_type)) { |
|
| 2978 | + } else if ($this->isBooleanType($field_type)) { |
|
| 2906 | 2979 | if ($this->_getBooleanValue($before_value) != $this->_getBooleanValue($after_value)) { |
| 2907 | 2980 | $change = true; |
| 2908 | 2981 | } |
| 2909 | - } |
|
| 2910 | - else { |
|
| 2982 | + } else { |
|
| 2911 | 2983 | $change = true; |
| 2912 | 2984 | } |
| 2913 | 2985 | if ($change) { |
@@ -3005,8 +3077,9 @@ discard block |
||
| 3005 | 3077 | protected function _getBooleanValue($val) |
| 3006 | 3078 | { |
| 3007 | 3079 | //need to put the === sign here otherwise true == 'non empty string' |
| 3008 | - if (empty($val) or $val==='off') |
|
| 3009 | - return false; |
|
| 3080 | + if (empty($val) or $val==='off') { |
|
| 3081 | + return false; |
|
| 3082 | + } |
|
| 3010 | 3083 | |
| 3011 | 3084 | return true; |
| 3012 | 3085 | } |
@@ -3032,8 +3105,9 @@ discard block |
||
| 3032 | 3105 | */ |
| 3033 | 3106 | protected function _emptyValue($val, $type) |
| 3034 | 3107 | { |
| 3035 | - if (empty($val)) |
|
| 3036 | - return true; |
|
| 3108 | + if (empty($val)) { |
|
| 3109 | + return true; |
|
| 3110 | + } |
|
| 3037 | 3111 | |
| 3038 | 3112 | if($this->emptyValue($type) == $val) { |
| 3039 | 3113 | return true; |
@@ -3050,10 +3124,12 @@ discard block |
||
| 3050 | 3124 | case 'short': |
| 3051 | 3125 | return ($val == 0); |
| 3052 | 3126 | case 'date': |
| 3053 | - if ($val == '0000-00-00') |
|
| 3054 | - return true; |
|
| 3055 | - if ($val == 'NULL') |
|
| 3056 | - return true; |
|
| 3127 | + if ($val == '0000-00-00') { |
|
| 3128 | + return true; |
|
| 3129 | + } |
|
| 3130 | + if ($val == 'NULL') { |
|
| 3131 | + return true; |
|
| 3132 | + } |
|
| 3057 | 3133 | return false; |
| 3058 | 3134 | } |
| 3059 | 3135 | |
@@ -3407,7 +3483,9 @@ discard block |
||
| 3407 | 3483 | */ |
| 3408 | 3484 | public function fetchByAssoc($result, $encode = true) |
| 3409 | 3485 | { |
| 3410 | - if (empty($result)) return false; |
|
| 3486 | + if (empty($result)) { |
|
| 3487 | + return false; |
|
| 3488 | + } |
|
| 3411 | 3489 | |
| 3412 | 3490 | if(is_int($encode) && func_num_args() == 3) { |
| 3413 | 3491 | // old API: $result, $rowNum, $encode |
@@ -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 | function handleAttachmentForRemove() { |
| 5 | 7 | if(!empty($_REQUEST['attachmentsRemove'])) { |
@@ -60,8 +62,7 @@ discard block |
||
| 60 | 62 | $marketing = BeanFactory::getBean('EmailMarketing', $marketingId); |
| 61 | 63 | $marketing->template_id = $emailTemplateId; |
| 62 | 64 | $marketing->save(); |
| 63 | - } |
|
| 64 | - else { |
|
| 65 | + } else { |
|
| 65 | 66 | // TODO something is not OK, the selected campaign isn't related to this marketing!! |
| 66 | 67 | $GLOBALS['log']->debug('Selected marketing not found!'); |
| 67 | 68 | } |
@@ -75,8 +76,7 @@ discard block |
||
| 75 | 76 | foreach($bean as $key => $value) { |
| 76 | 77 | if(in_array($key, $fields)) { |
| 77 | 78 | $newBean->$key = $_POST[$key]; |
| 78 | - } |
|
| 79 | - else if(in_array($key, $fieldsForCopy)) { |
|
| 79 | + } else if(in_array($key, $fieldsForCopy)) { |
|
| 80 | 80 | $newBean->$key = $bean->$key; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -125,16 +125,14 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | $data['attachments'] = $attachments; |
| 127 | 127 | } |
| 128 | - } |
|
| 129 | - else { |
|
| 128 | + } else { |
|
| 130 | 129 | $error = 'Email Template not found.'; |
| 131 | 130 | } |
| 132 | 131 | break; |
| 133 | 132 | } |
| 134 | 133 | |
| 135 | 134 | |
| 136 | -} |
|
| 137 | -else { |
|
| 135 | +} else { |
|
| 138 | 136 | $error = 'Illegal GUID format.'; |
| 139 | 137 | } |
| 140 | 138 | |
@@ -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. |
@@ -53,8 +55,7 @@ discard block |
||
| 53 | 55 | $campaign_focus = new Campaign(); |
| 54 | 56 | if(isset($_REQUEST['record']) && $_REQUEST['record'] && !(isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id'])) { |
| 55 | 57 | $campaign_focus->retrieve($_REQUEST['record']); |
| 56 | - } |
|
| 57 | - else if(isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id']) { |
|
| 58 | + } else if(isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id']) { |
|
| 58 | 59 | $campaign_focus->retrieve($_REQUEST['campaign_id']); |
| 59 | 60 | } |
| 60 | 61 | |
@@ -230,7 +231,7 @@ discard block |
||
| 230 | 231 | $action = 'WizardMarketing'; |
| 231 | 232 | break; |
| 232 | 233 | } |
| 233 | - }else{ |
|
| 234 | + } else{ |
|
| 234 | 235 | $action = 'WizardHome&record='.$campaign_focus->id; |
| 235 | 236 | } |
| 236 | 237 | //require_once('modules/Campaigns/WizardMarketing.php'); |
@@ -240,8 +241,7 @@ discard block |
||
| 240 | 241 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 241 | 242 | $href = $matches[1]; |
| 242 | 243 | SugarApplication::redirect($href); |
| 243 | - } |
|
| 244 | - else { |
|
| 244 | + } else { |
|
| 245 | 245 | header($header_URL); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $action = 'WizardHome'; |
| 403 | 403 | break; |
| 404 | 404 | } |
| 405 | - }else{ |
|
| 405 | + } else{ |
|
| 406 | 406 | $action = 'WizardHome&record='.$campaign_focus->id; |
| 407 | 407 | } |
| 408 | 408 | //require_once('modules/Campaigns/WizardMarketing.php'); |
@@ -411,8 +411,7 @@ discard block |
||
| 411 | 411 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 412 | 412 | $href = $matches[1]; |
| 413 | 413 | SugarApplication::redirect($href); |
| 414 | - } |
|
| 415 | - else { |
|
| 414 | + } else { |
|
| 416 | 415 | header($header_URL); |
| 417 | 416 | } |
| 418 | 417 | |
@@ -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. |
@@ -157,8 +159,7 @@ discard block |
||
| 157 | 159 | $lead->campaigns->add($camplog->id); |
| 158 | 160 | if(!empty($GLOBALS['check_notify'])) { |
| 159 | 161 | $lead->save($GLOBALS['check_notify']); |
| 160 | - } |
|
| 161 | - else { |
|
| 162 | + } else { |
|
| 162 | 163 | $lead->save(FALSE); |
| 163 | 164 | } |
| 164 | 165 | } |
@@ -188,14 +189,14 @@ discard block |
||
| 188 | 189 | $get_and_post = array_merge($_GET, $_POST); |
| 189 | 190 | foreach($get_and_post as $param => $value) { |
| 190 | 191 | |
| 191 | - if($param == 'redirect_url' && $param == 'submit') |
|
| 192 | - continue; |
|
| 192 | + if($param == 'redirect_url' && $param == 'submit') { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 193 | 195 | |
| 194 | 196 | if($first_iteration){ |
| 195 | 197 | $first_iteration = false; |
| 196 | 198 | $query_string .= $first_char; |
| 197 | - } |
|
| 198 | - else{ |
|
| 199 | + } else{ |
|
| 199 | 200 | $query_string .= "&"; |
| 200 | 201 | } |
| 201 | 202 | $query_string .= "{$param}=".urlencode($value); |
@@ -203,8 +204,7 @@ discard block |
||
| 203 | 204 | if(empty($lead)) { |
| 204 | 205 | if($first_iteration){ |
| 205 | 206 | $query_string .= $first_char; |
| 206 | - } |
|
| 207 | - else{ |
|
| 207 | + } else{ |
|
| 208 | 208 | $query_string .= "&"; |
| 209 | 209 | } |
| 210 | 210 | $query_string .= "error=1"; |
@@ -229,29 +229,25 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>'; |
| 231 | 231 | echo '</body></html>'; |
| 232 | - } |
|
| 233 | - else{ |
|
| 232 | + } else{ |
|
| 234 | 233 | $header_URL = "Location: {$redirect_url}"; |
| 235 | 234 | |
| 236 | 235 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 237 | 236 | $href = $matches[1]; |
| 238 | 237 | SugarApplication::redirect($href); |
| 239 | - } |
|
| 240 | - else { |
|
| 238 | + } else { |
|
| 241 | 239 | header($header_URL); |
| 242 | 240 | } |
| 243 | 241 | |
| 244 | 242 | die(); |
| 245 | 243 | } |
| 246 | - } |
|
| 247 | - else{ |
|
| 244 | + } else{ |
|
| 248 | 245 | echo $mod_strings['LBL_THANKS_FOR_SUBMITTING']; |
| 249 | 246 | } |
| 250 | 247 | sugar_cleanup(); |
| 251 | 248 | // die to keep code from running into redirect case below |
| 252 | 249 | die(); |
| 253 | - } |
|
| 254 | - else{ |
|
| 250 | + } else{ |
|
| 255 | 251 | echo $mod_strings['LBL_SERVER_IS_CURRENTLY_UNAVAILABLE']; |
| 256 | 252 | } |
| 257 | 253 | } |
@@ -262,15 +258,13 @@ discard block |
||
| 262 | 258 | echo '<form name="redirect" action="' .$_POST['redirect']. '" method="GET">'; |
| 263 | 259 | echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>'; |
| 264 | 260 | echo '</body></html>'; |
| 265 | - } |
|
| 266 | - else{ |
|
| 261 | + } else{ |
|
| 267 | 262 | $header_URL = "Location: {$_POST['redirect']}"; |
| 268 | 263 | |
| 269 | 264 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 270 | 265 | $href = $matches[1]; |
| 271 | 266 | SugarApplication::redirect($href); |
| 272 | - } |
|
| 273 | - else { |
|
| 267 | + } else { |
|
| 274 | 268 | header($header_URL); |
| 275 | 269 | } |
| 276 | 270 | |
@@ -240,8 +240,7 @@ discard block |
||
| 240 | 240 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 241 | 241 | $href = $matches[1]; |
| 242 | 242 | SugarApplication::redirect($href); |
| 243 | - } |
|
| 244 | - else { |
|
| 243 | + } else { |
|
| 245 | 244 | header($header_URL); |
| 246 | 245 | } |
| 247 | 246 | |
@@ -276,8 +275,7 @@ discard block |
||
| 276 | 275 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 277 | 276 | $href = $matches[1]; |
| 278 | 277 | SugarApplication::redirect($href); |
| 279 | - } |
|
| 280 | - else { |
|
| 278 | + } else { |
|
| 281 | 279 | header($header_URL); |
| 282 | 280 | } |
| 283 | 281 | |
@@ -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. |
@@ -44,8 +46,7 @@ discard block |
||
| 44 | 46 | $msgs = array(); |
| 45 | 47 | if(!$templateId) { |
| 46 | 48 | $msgs[] = 'LBL_NO_SELECTED_TEMPLATE'; |
| 47 | - } |
|
| 48 | - else { |
|
| 49 | + } else { |
|
| 49 | 50 | $template = new EmailTemplate(); |
| 50 | 51 | $template->retrieve($templateId); |
| 51 | 52 | if (!$template->subject) { |
@@ -67,8 +68,7 @@ discard block |
||
| 67 | 68 | if($func == 'getTemplateValidation') { |
| 68 | 69 | if (!empty($_POST['templateId'])) { |
| 69 | 70 | $templateId = $db->quote($_POST['templateId']); |
| 70 | - } |
|
| 71 | - else { |
|
| 71 | + } else { |
|
| 72 | 72 | if (!$marketingId) { |
| 73 | 73 | if (!empty($_SESSION['campaignWizard'][$campaignId]['defaultSelectedMarketingId']) && $func != 'createEmailMarketing') { |
| 74 | 74 | $marketingId = $_SESSION['campaignWizard'][$campaignId]['defaultSelectedMarketingId']; |
@@ -83,8 +83,7 @@ discard block |
||
| 83 | 83 | $return['marketingValidationMessages'] = $marketing->validate(); |
| 84 | 84 | |
| 85 | 85 | echo json_encode($return); |
| 86 | -} |
|
| 87 | -else { |
|
| 86 | +} else { |
|
| 88 | 87 | if (!$marketingId) { |
| 89 | 88 | if (!empty($_SESSION['campaignWizard'][$campaignId]['defaultSelectedMarketingId']) && $func != 'createEmailMarketing') { |
| 90 | 89 | $marketingId = $_SESSION['campaignWizard'][$campaignId]['defaultSelectedMarketingId']; |
@@ -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. |
@@ -97,8 +99,7 @@ discard block |
||
| 97 | 99 | $personTypeList.="<option value='".$count."'>".$b->name."</option>"; |
| 98 | 100 | $count++; |
| 99 | 101 | } |
| 100 | -} |
|
| 101 | -else |
|
| 102 | +} else |
|
| 102 | 103 | { |
| 103 | 104 | $personTypeList.="<option value='noPerson'>No matching types</option>"; |
| 104 | 105 | } |
@@ -133,8 +134,12 @@ discard block |
||
| 133 | 134 | |
| 134 | 135 | $xtpl->assign("WEB_POST_URL",$web_post_url); |
| 135 | 136 | |
| 136 | -if (empty($focus->assigned_user_id) && empty($focus->id)) $focus->assigned_user_id = $current_user->id; |
|
| 137 | -if (empty($focus->assigned_name) && empty($focus->id)) $focus->assigned_user_name = $current_user->user_name; |
|
| 137 | +if (empty($focus->assigned_user_id) && empty($focus->id)) { |
|
| 138 | + $focus->assigned_user_id = $current_user->id; |
|
| 139 | +} |
|
| 140 | +if (empty($focus->assigned_name) && empty($focus->id)) { |
|
| 141 | + $focus->assigned_user_name = $current_user->user_name; |
|
| 142 | +} |
|
| 138 | 143 | $xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name); |
| 139 | 144 | $xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id ); |
| 140 | 145 | |
@@ -197,8 +202,7 @@ discard block |
||
| 197 | 202 | $col_arr[0]=$cols_name; |
| 198 | 203 | $col_arr[1]=$field_def['name']; |
| 199 | 204 | $col_arr[2]=true; |
| 200 | - } |
|
| 201 | - else{ |
|
| 205 | + } else{ |
|
| 202 | 206 | $cols_name=$field_def['vname']; |
| 203 | 207 | $col_arr[0]=$cols_name; |
| 204 | 208 | $col_arr[1]=$field_def['name']; |
@@ -232,8 +236,9 @@ discard block |
||
| 232 | 236 | foreach($GLOBALS['moduleList'] as $mod) |
| 233 | 237 | { |
| 234 | 238 | $item = BeanFactory::getBean($mod); |
| 235 | - if($item && is_subclass_of($item,$superclass)) |
|
| 236 | - $subclasses[] = $item; |
|
| 239 | + if($item && is_subclass_of($item,$superclass)) { |
|
| 240 | + $subclasses[] = $item; |
|
| 241 | + } |
|
| 237 | 242 | } |
| 238 | 243 | return $subclasses; |
| 239 | 244 | } |
@@ -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. |
@@ -104,20 +106,18 @@ discard block |
||
| 104 | 106 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 105 | 107 | $href = $matches[1]; |
| 106 | 108 | SugarApplication::redirect($href); |
| 107 | - } |
|
| 108 | - else { |
|
| 109 | + } else { |
|
| 109 | 110 | header($headers); |
| 110 | 111 | } |
| 111 | 112 | |
| 112 | - }else{ |
|
| 113 | + } else{ |
|
| 113 | 114 | //set navigation details |
| 114 | 115 | $header_URL = "Location: index.php?action=index&module=Campaigns"; |
| 115 | 116 | |
| 116 | 117 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 117 | 118 | $href = $matches[1]; |
| 118 | 119 | SugarApplication::redirect($href); |
| 119 | - } |
|
| 120 | - else { |
|
| 120 | + } else { |
|
| 121 | 121 | header($header_URL); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -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,15 +58,15 @@ discard block |
||
| 56 | 58 | if($_REQUEST['wiz_home_next_step']==3){ |
| 57 | 59 | //user has chosen to save and schedule this campaign for email |
| 58 | 60 | $master = 'send'; |
| 59 | - }elseif($_REQUEST['wiz_home_next_step']==2){ |
|
| 61 | + } elseif($_REQUEST['wiz_home_next_step']==2){ |
|
| 60 | 62 | //user has chosen to save and send this campaign in test mode |
| 61 | 63 | $master = 'test'; |
| 62 | - }else{ |
|
| 64 | + } else{ |
|
| 63 | 65 | //user has chosen to simply save |
| 64 | 66 | $master = 'save'; |
| 65 | 67 | } |
| 66 | 68 | |
| 67 | -}else{ |
|
| 69 | +} else{ |
|
| 68 | 70 | //default to just saving and exiting wizard |
| 69 | 71 | $master = 'save'; |
| 70 | 72 | } |
@@ -76,8 +78,7 @@ discard block |
||
| 76 | 78 | $marketing = new EmailMarketing(); |
| 77 | 79 | if (isset($_REQUEST['record']) && !empty($_REQUEST['record'])) { |
| 78 | 80 | $marketing->retrieve($_REQUEST['record']); |
| 79 | -} |
|
| 80 | -else { |
|
| 81 | +} else { |
|
| 81 | 82 | if(!empty($_SESSION['campaignWizard'][$_REQUEST['campaign_id']]['defaultSelectedMarketingId'])) { |
| 82 | 83 | $marketing->retrieve($_SESSION['campaignWizard'][$_REQUEST['campaign_id']]['defaultSelectedMarketingId']); |
| 83 | 84 | } |
@@ -89,8 +90,7 @@ discard block |
||
| 89 | 90 | |
| 90 | 91 | if (!empty($_REQUEST['assigned_user_id']) && ($marketing->assigned_user_id != $_REQUEST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) { |
| 91 | 92 | $check_notify = TRUE; |
| 92 | -} |
|
| 93 | -else { |
|
| 93 | +} else { |
|
| 94 | 94 | $check_notify = FALSE; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } else { |
| 128 | 128 | $marketing->$field = 0; |
| 129 | 129 | } |
| 130 | - }else { |
|
| 130 | + } else { |
|
| 131 | 131 | if(isset($_REQUEST[$field])) |
| 132 | 132 | { |
| 133 | 133 | $value = $_REQUEST[$field]; |
@@ -207,12 +207,10 @@ discard block |
||
| 207 | 207 | $_POST['wiz_mass'] = $marketing->id; |
| 208 | 208 | if(isset($_REQUEST['sendMarketingEmailTest']) && $_REQUEST['sendMarketingEmailTest']) { |
| 209 | 209 | $_POST['mode'] = 'test'; |
| 210 | - } |
|
| 211 | - else if(isset($_REQUEST['sendMarketingEmailSchedule']) && $_REQUEST['sendMarketingEmailSchedule']) { |
|
| 210 | + } else if(isset($_REQUEST['sendMarketingEmailSchedule']) && $_REQUEST['sendMarketingEmailSchedule']) { |
|
| 212 | 211 | $_POST['mode'] = 'send'; |
| 213 | 212 | $_SESSION['msg'] = 'LBL_EMAILS_SCHEDULED'; |
| 214 | - } |
|
| 215 | - else { |
|
| 213 | + } else { |
|
| 216 | 214 | throw new Exception('request error'); |
| 217 | 215 | } |
| 218 | 216 | |
@@ -223,8 +221,7 @@ discard block |
||
| 223 | 221 | } |
| 224 | 222 | |
| 225 | 223 | $header_URL = "Location: index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome&return_id=" . $marketing->campaign_id . "&campaign_id=" . $marketing->campaign_id . "&jump=3&marketing_id=" . $marketing->id; |
| 226 | -} |
|
| 227 | -else { |
|
| 224 | +} else { |
|
| 228 | 225 | $header_URL = "Location: index.php?action=WizardHome&module=Campaigns&record=".$marketing->campaign_id; |
| 229 | 226 | } |
| 230 | 227 | |
@@ -233,8 +230,7 @@ discard block |
||
| 233 | 230 | if(preg_match('/\s*Location:\s*(.*)$/', $header_URL, $matches)) { |
| 234 | 231 | $href = $matches[1]; |
| 235 | 232 | SugarApplication::redirect($href); |
| 236 | -} |
|
| 237 | -else { |
|
| 233 | +} else { |
|
| 238 | 234 | header($header_URL); |
| 239 | 235 | } |
| 240 | 236 | |