@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | $dberror = $this->lastDbError(); |
| 317 | - if($dberror === false) { |
|
| 317 | + if ($dberror === false) { |
|
| 318 | 318 | $this->last_error = false; |
| 319 | 319 | return false; |
| 320 | 320 | } |
@@ -332,16 +332,16 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | protected function registerError($userMessage, $message, $dieOnError = false) |
| 334 | 334 | { |
| 335 | - if(!empty($message)) { |
|
| 336 | - if(!empty($userMessage)) { |
|
| 335 | + if (!empty($message)) { |
|
| 336 | + if (!empty($userMessage)) { |
|
| 337 | 337 | $message = "$userMessage: $message"; |
| 338 | 338 | } |
| 339 | - if(empty($message)) { |
|
| 339 | + if (empty($message)) { |
|
| 340 | 340 | $message = "Database error"; |
| 341 | 341 | } |
| 342 | 342 | $this->log->fatal($message); |
| 343 | 343 | if ($dieOnError || $this->dieOnError) { |
| 344 | - if(isset($GLOBALS['app_strings']['ERR_DB_FAIL'])) { |
|
| 344 | + if (isset($GLOBALS['app_strings']['ERR_DB_FAIL'])) { |
|
| 345 | 345 | sugar_die($GLOBALS['app_strings']['ERR_DB_FAIL']); |
| 346 | 346 | } else { |
| 347 | 347 | sugar_die("Database error. Please check suitecrm.log for details."); |
@@ -379,8 +379,8 @@ discard block |
||
| 379 | 379 | $slow_query_time_msec = isset($sugar_config['slow_query_time_msec']) |
| 380 | 380 | ? $sugar_config['slow_query_time_msec'] : 5000; |
| 381 | 381 | |
| 382 | - if($do_the_dump) { |
|
| 383 | - if($slow_query_time_msec < ($this->query_time * 1000)) { |
|
| 382 | + if ($do_the_dump) { |
|
| 383 | + if ($slow_query_time_msec < ($this->query_time * 1000)) { |
|
| 384 | 384 | // Then log both the query and the query time |
| 385 | 385 | $this->log->fatal('Slow Query (time:'.$this->query_time."\n".$query); |
| 386 | 386 | return true; |
@@ -412,20 +412,20 @@ discard block |
||
| 412 | 412 | $indices = $GLOBALS['dictionary'][$object_name]['indices']; |
| 413 | 413 | |
| 414 | 414 | if (empty($indices)) { |
| 415 | - foreach ( $GLOBALS['dictionary'] as $current ) { |
|
| 416 | - if ($current['table'] == $table){ |
|
| 415 | + foreach ($GLOBALS['dictionary'] as $current) { |
|
| 416 | + if ($current['table'] == $table) { |
|
| 417 | 417 | $indices = $current['indices']; |
| 418 | 418 | break; |
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | if (empty($indices)) { |
| 423 | - $this->log->warn('CHECK QUERY: Could not find index definitions for table ' . $table); |
|
| 423 | + $this->log->warn('CHECK QUERY: Could not find index definitions for table '.$table); |
|
| 424 | 424 | return false; |
| 425 | 425 | } |
| 426 | 426 | if (!empty($match[2][0])) { |
| 427 | 427 | $orderBys = explode(' ', $match[2][0]); |
| 428 | - foreach ($orderBys as $orderBy){ |
|
| 428 | + foreach ($orderBys as $orderBy) { |
|
| 429 | 429 | $orderBy = trim($orderBy); |
| 430 | 430 | if (empty($orderBy)) |
| 431 | 431 | continue; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | if ($orderBy == 'asc' || $orderBy == 'desc') |
| 434 | 434 | continue; |
| 435 | 435 | |
| 436 | - $orderBy = str_replace(array($table . '.', ','), '', $orderBy); |
|
| 436 | + $orderBy = str_replace(array($table.'.', ','), '', $orderBy); |
|
| 437 | 437 | |
| 438 | 438 | foreach ($indices as $index) |
| 439 | 439 | if (empty($index['db']) || $index['db'] == $this->dbType) |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | if ($field == $orderBy) |
| 442 | 442 | return true; |
| 443 | 443 | |
| 444 | - $warning = 'Missing Index For Order By Table: ' . $table . ' Order By:' . $orderBy ; |
|
| 444 | + $warning = 'Missing Index For Order By Table: '.$table.' Order By:'.$orderBy; |
|
| 445 | 445 | if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) |
| 446 | - $this->log->fatal('CHECK QUERY:' .$warning); |
|
| 446 | + $this->log->fatal('CHECK QUERY:'.$warning); |
|
| 447 | 447 | else |
| 448 | - $this->log->warn('CHECK QUERY:' .$warning); |
|
| 448 | + $this->log->warn('CHECK QUERY:'.$warning); |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | return false; |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | public function insert(SugarBean $bean) |
| 492 | 492 | { |
| 493 | 493 | $sql = $this->insertSQL($bean); |
| 494 | - $tablename = $bean->getTableName(); |
|
| 494 | + $tablename = $bean->getTableName(); |
|
| 495 | 495 | $msg = "Error inserting into table: $tablename:"; |
| 496 | - return $this->query($sql,true,$msg); |
|
| 496 | + return $this->query($sql, true, $msg); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | /** |
@@ -512,13 +512,13 @@ discard block |
||
| 512 | 512 | { |
| 513 | 513 | if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') continue; |
| 514 | 514 | //custom fields handle there save seperatley |
| 515 | - if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue; |
|
| 515 | + if (!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue; |
|
| 516 | 516 | |
| 517 | - if(isset($data[$field])) { |
|
| 517 | + if (isset($data[$field])) { |
|
| 518 | 518 | // clean the incoming value.. |
| 519 | 519 | $val = from_html($data[$field]); |
| 520 | 520 | } else { |
| 521 | - if(isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 521 | + if (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 522 | 522 | $val = $fieldDef['default']; |
| 523 | 523 | } else { |
| 524 | 524 | $val = null; |
@@ -528,26 +528,26 @@ discard block |
||
| 528 | 528 | //handle auto increment values here - we may have to do something like nextval for oracle |
| 529 | 529 | if (!empty($fieldDef['auto_increment'])) { |
| 530 | 530 | $auto = $this->getAutoIncrementSQL($table, $fieldDef['name']); |
| 531 | - if(!empty($auto)) { |
|
| 531 | + if (!empty($auto)) { |
|
| 532 | 532 | $values[$field] = $auto; |
| 533 | 533 | } |
| 534 | 534 | } elseif ($fieldDef['name'] == 'deleted') { |
| 535 | 535 | $values['deleted'] = (int)$val; |
| 536 | 536 | } else { |
| 537 | 537 | // need to do some thing about types of values |
| 538 | - if(!is_null($val) || !empty($fieldDef['required'])) { |
|
| 538 | + if (!is_null($val) || !empty($fieldDef['required'])) { |
|
| 539 | 539 | $values[$field] = $this->massageValue($val, $fieldDef); |
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | if (empty($values)) |
| 545 | - return $execute?true:''; // no columns set |
|
| 545 | + return $execute ? true : ''; // no columns set |
|
| 546 | 546 | |
| 547 | 547 | // get the entire sql |
| 548 | 548 | $query = "INSERT INTO $table (".implode(",", array_keys($values)).") |
| 549 | 549 | VALUES (".implode(",", $values).")"; |
| 550 | - return $execute?$this->query($query):$query; |
|
| 550 | + return $execute ? $this->query($query) : $query; |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | $sql = $this->updateSQL($bean, $where); |
| 566 | 566 | $tablename = $bean->getTableName(); |
| 567 | 567 | $msg = "Error updating table: $tablename:"; |
| 568 | - return $this->query($sql,true,$msg); |
|
| 568 | + return $this->query($sql, true, $msg); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -581,8 +581,8 @@ discard block |
||
| 581 | 581 | { |
| 582 | 582 | $sql = $this->deleteSQL($bean, $where); |
| 583 | 583 | $tableName = $bean->getTableName(); |
| 584 | - $msg = "Error deleting from table: ".$tableName. ":"; |
|
| 585 | - return $this->query($sql,true,$msg); |
|
| 584 | + $msg = "Error deleting from table: ".$tableName.":"; |
|
| 585 | + return $this->query($sql, true, $msg); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -599,8 +599,8 @@ discard block |
||
| 599 | 599 | { |
| 600 | 600 | $sql = $this->retrieveSQL($bean, $where); |
| 601 | 601 | $tableName = $bean->getTableName(); |
| 602 | - $msg = "Error retriving values from table:".$tableName. ":"; |
|
| 603 | - return $this->query($sql,true,$msg); |
|
| 602 | + $msg = "Error retriving values from table:".$tableName.":"; |
|
| 603 | + return $this->query($sql, true, $msg); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | { |
| 624 | 624 | $sql = $this->retrieveViewSQL($beans, $cols, $where); |
| 625 | 625 | $msg = "Error retriving values from View Collection:"; |
| 626 | - return $this->query($sql,true,$msg); |
|
| 626 | + return $this->query($sql, true, $msg); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | |
@@ -638,8 +638,8 @@ discard block |
||
| 638 | 638 | $sql = $this->createTableSQL($bean); |
| 639 | 639 | $tablename = $bean->getTableName(); |
| 640 | 640 | $msg = "Error creating table: $tablename:"; |
| 641 | - $this->query($sql,true,$msg); |
|
| 642 | - if(!$this->supports("inline_keys")) { |
|
| 641 | + $this->query($sql, true, $msg); |
|
| 642 | + if (!$this->supports("inline_keys")) { |
|
| 643 | 643 | // handle constraints and indices |
| 644 | 644 | $indicesArr = $this->createConstraintSql($bean); |
| 645 | 645 | if (count($indicesArr) > 0) |
@@ -676,9 +676,9 @@ discard block |
||
| 676 | 676 | $res = true; |
| 677 | 677 | if ($sql) { |
| 678 | 678 | $msg = "Error creating table: $tablename"; |
| 679 | - $res = ($res and $this->query($sql,true,$msg)); |
|
| 679 | + $res = ($res and $this->query($sql, true, $msg)); |
|
| 680 | 680 | } |
| 681 | - if(!$this->supports("inline_keys")) { |
|
| 681 | + if (!$this->supports("inline_keys")) { |
|
| 682 | 682 | // handle constraints and indices |
| 683 | 683 | $indicesArr = $this->getConstraintSql($indices, $tablename); |
| 684 | 684 | if (count($indicesArr) > 0) |
@@ -705,20 +705,20 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | //Clean the indexes to prevent duplicate definitions |
| 707 | 707 | $new_index = array(); |
| 708 | - foreach($indices as $ind_def){ |
|
| 708 | + foreach ($indices as $ind_def) { |
|
| 709 | 709 | $new_index[$ind_def['name']] = $ind_def; |
| 710 | 710 | } |
| 711 | 711 | //jc: added this for beans that do not actually have a table, namely |
| 712 | 712 | //ForecastOpportunities |
| 713 | - if($tablename == 'does_not_exist' || $tablename == '') |
|
| 713 | + if ($tablename == 'does_not_exist' || $tablename == '') |
|
| 714 | 714 | return ''; |
| 715 | 715 | |
| 716 | 716 | global $dictionary; |
| 717 | - $engine=null; |
|
| 718 | - if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) |
|
| 717 | + $engine = null; |
|
| 718 | + if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine'])) |
|
| 719 | 719 | $engine = $dictionary[$bean->getObjectName()]['engine']; |
| 720 | 720 | |
| 721 | - return $this->repairTableParams($tablename, $fielddefs,$new_index,$execute,$engine); |
|
| 721 | + return $this->repairTableParams($tablename, $fielddefs, $new_index, $execute, $engine); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -730,12 +730,12 @@ discard block |
||
| 730 | 730 | protected function isNullable($vardef) |
| 731 | 731 | { |
| 732 | 732 | |
| 733 | - if(isset($vardef['isnull']) && (strtolower($vardef['isnull']) == 'false' || $vardef['isnull'] === false) |
|
| 733 | + if (isset($vardef['isnull']) && (strtolower($vardef['isnull']) == 'false' || $vardef['isnull'] === false) |
|
| 734 | 734 | && !empty($vardef['required'])) { |
| 735 | 735 | /* required + is_null=false => not null */ |
| 736 | 736 | return false; |
| 737 | 737 | } |
| 738 | - if(empty($vardef['auto_increment']) && (empty($vardef['type']) || $vardef['type'] != 'id') |
|
| 738 | + if (empty($vardef['auto_increment']) && (empty($vardef['type']) || $vardef['type'] != 'id') |
|
| 739 | 739 | && (empty($vardef['dbType']) || $vardef['dbType'] != 'id') |
| 740 | 740 | && (empty($vardef['name']) || ($vardef['name'] != 'id' && $vardef['name'] != 'deleted')) |
| 741 | 741 | ) { |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | * @todo: refactor engine param to be more generic |
| 757 | 757 | * @return string |
| 758 | 758 | */ |
| 759 | - public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
|
| 759 | + public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
|
| 760 | 760 | { |
| 761 | 761 | //jc: had a bug when running the repair if the tablename is blank the repair will |
| 762 | 762 | //fail when it tries to create a repair table |
@@ -766,13 +766,13 @@ discard block |
||
| 766 | 766 | //if the table does not exist create it and we are done |
| 767 | 767 | $sql = "/* Table : $tablename */\n"; |
| 768 | 768 | if (!$this->tableExists($tablename)) { |
| 769 | - $createtablesql = $this->createTableSQLParams($tablename,$fielddefs,$indices,$engine); |
|
| 770 | - if($execute && $createtablesql){ |
|
| 771 | - $this->createTableParams($tablename,$fielddefs,$indices,$engine); |
|
| 769 | + $createtablesql = $this->createTableSQLParams($tablename, $fielddefs, $indices, $engine); |
|
| 770 | + if ($execute && $createtablesql) { |
|
| 771 | + $this->createTableParams($tablename, $fielddefs, $indices, $engine); |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | $sql .= "/* MISSING TABLE: {$tablename} */\n"; |
| 775 | - $sql .= $createtablesql . "\n"; |
|
| 775 | + $sql .= $createtablesql."\n"; |
|
| 776 | 776 | return $sql; |
| 777 | 777 | } |
| 778 | 778 | |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | $take_action = false; |
| 783 | 783 | |
| 784 | 784 | // do column comparisons |
| 785 | - $sql .= "/*COLUMNS*/\n"; |
|
| 785 | + $sql .= "/*COLUMNS*/\n"; |
|
| 786 | 786 | foreach ($fielddefs as $name => $value) { |
| 787 | 787 | if (isset($value['source']) && $value['source'] != 'db') |
| 788 | 788 | continue; |
@@ -801,9 +801,9 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | $name = strtolower($value['name']); |
| 803 | 803 | // add or fix the field defs per what the DB is expected to give us back |
| 804 | - $this->massageFieldDef($value,$tablename); |
|
| 804 | + $this->massageFieldDef($value, $tablename); |
|
| 805 | 805 | |
| 806 | - $ignorerequired=false; |
|
| 806 | + $ignorerequired = false; |
|
| 807 | 807 | |
| 808 | 808 | //Do not track requiredness in the DB, auto_increment, ID, |
| 809 | 809 | // and deleted fields are always required in the DB, so don't force those |
@@ -819,32 +819,32 @@ discard block |
||
| 819 | 819 | $value['required'] = $compareFieldDefs[$name]['required']; |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - if ( !isset($compareFieldDefs[$name]) ) { |
|
| 822 | + if (!isset($compareFieldDefs[$name])) { |
|
| 823 | 823 | // ok we need this field lets create it |
| 824 | - $sql .= "/*MISSING IN DATABASE - $name - ROW*/\n"; |
|
| 825 | - $sql .= $this->addColumnSQL($tablename, $value) . "\n"; |
|
| 824 | + $sql .= "/*MISSING IN DATABASE - $name - ROW*/\n"; |
|
| 825 | + $sql .= $this->addColumnSQL($tablename, $value)."\n"; |
|
| 826 | 826 | if ($execute) |
| 827 | 827 | $this->addColumn($tablename, $value); |
| 828 | 828 | $take_action = true; |
| 829 | - } elseif ( !$this->compareVarDefs($compareFieldDefs[$name],$value)) { |
|
| 829 | + } elseif (!$this->compareVarDefs($compareFieldDefs[$name], $value)) { |
|
| 830 | 830 | //fields are different lets alter it |
| 831 | - $sql .= "/*MISMATCH WITH DATABASE - $name - ROW "; |
|
| 832 | - foreach($compareFieldDefs[$name] as $rKey => $rValue) { |
|
| 833 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 831 | + $sql .= "/*MISMATCH WITH DATABASE - $name - ROW "; |
|
| 832 | + foreach ($compareFieldDefs[$name] as $rKey => $rValue) { |
|
| 833 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 834 | 834 | } |
| 835 | - $sql .= "*/\n"; |
|
| 836 | - $sql .= "/* VARDEF - $name - ROW"; |
|
| 837 | - foreach($value as $rKey => $rValue) { |
|
| 838 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 835 | + $sql .= "*/\n"; |
|
| 836 | + $sql .= "/* VARDEF - $name - ROW"; |
|
| 837 | + foreach ($value as $rKey => $rValue) { |
|
| 838 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 839 | 839 | } |
| 840 | - $sql .= "*/\n"; |
|
| 840 | + $sql .= "*/\n"; |
|
| 841 | 841 | |
| 842 | 842 | //jc: oracle will complain if you try to execute a statement that sets a column to (not) null |
| 843 | 843 | //when it is already (not) null |
| 844 | - if ( isset($value['isnull']) && isset($compareFieldDefs[$name]['isnull']) && |
|
| 844 | + if (isset($value['isnull']) && isset($compareFieldDefs[$name]['isnull']) && |
|
| 845 | 845 | $value['isnull'] === $compareFieldDefs[$name]['isnull']) { |
| 846 | 846 | unset($value['required']); |
| 847 | - $ignorerequired=true; |
|
| 847 | + $ignorerequired = true; |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | //dwheeler: Once a column has been defined as null, we cannot try to force it back to !null |
@@ -853,12 +853,12 @@ discard block |
||
| 853 | 853 | { |
| 854 | 854 | $ignorerequired = true; |
| 855 | 855 | } |
| 856 | - $altersql = $this->alterColumnSQL($tablename, $value,$ignorerequired); |
|
| 857 | - if(is_array($altersql)) { |
|
| 856 | + $altersql = $this->alterColumnSQL($tablename, $value, $ignorerequired); |
|
| 857 | + if (is_array($altersql)) { |
|
| 858 | 858 | $altersql = join("\n", $altersql); |
| 859 | 859 | } |
| 860 | - $sql .= $altersql . "\n"; |
|
| 861 | - if($execute){ |
|
| 860 | + $sql .= $altersql."\n"; |
|
| 861 | + if ($execute) { |
|
| 862 | 862 | $this->alterColumn($tablename, $value, $ignorerequired); |
| 863 | 863 | } |
| 864 | 864 | $take_action = true; |
@@ -866,13 +866,13 @@ discard block |
||
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | // do index comparisons |
| 869 | - $sql .= "/* INDEXES */\n"; |
|
| 869 | + $sql .= "/* INDEXES */\n"; |
|
| 870 | 870 | $correctedIndexs = array(); |
| 871 | 871 | |
| 872 | 872 | $compareIndices_case_insensitive = array(); |
| 873 | 873 | |
| 874 | 874 | // do indices comparisons case-insensitive |
| 875 | - foreach($compareIndices as $k => $value){ |
|
| 875 | + foreach ($compareIndices as $k => $value) { |
|
| 876 | 876 | $value['name'] = strtolower($value['name']); |
| 877 | 877 | $compareIndices_case_insensitive[strtolower($k)] = $value; |
| 878 | 878 | } |
@@ -899,59 +899,59 @@ discard block |
||
| 899 | 899 | continue; |
| 900 | 900 | |
| 901 | 901 | //database helpers do not know how to handle full text indices |
| 902 | - if ($value['type']=='fulltext') |
|
| 902 | + if ($value['type'] == 'fulltext') |
|
| 903 | 903 | continue; |
| 904 | 904 | |
| 905 | - if ( in_array($value['type'],array('alternate_key','foreign')) ) |
|
| 905 | + if (in_array($value['type'], array('alternate_key', 'foreign'))) |
|
| 906 | 906 | $value['type'] = 'index'; |
| 907 | 907 | |
| 908 | - if ( !isset($compareIndices[$name]) ) { |
|
| 908 | + if (!isset($compareIndices[$name])) { |
|
| 909 | 909 | //First check if an index exists that doesn't match our name, if so, try to rename it |
| 910 | 910 | $found = false; |
| 911 | 911 | foreach ($compareIndices as $ex_name => $ex_value) { |
| 912 | - if($this->compareVarDefs($ex_value, $value, true)) { |
|
| 912 | + if ($this->compareVarDefs($ex_value, $value, true)) { |
|
| 913 | 913 | $found = $ex_name; |
| 914 | 914 | break; |
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | if ($found) { |
| 918 | - $sql .= "/*MISSNAMED INDEX IN DATABASE - $name - $ex_name */\n"; |
|
| 918 | + $sql .= "/*MISSNAMED INDEX IN DATABASE - $name - $ex_name */\n"; |
|
| 919 | 919 | $rename = $this->renameIndexDefs($ex_value, $value, $tablename); |
| 920 | - if($execute) { |
|
| 920 | + if ($execute) { |
|
| 921 | 921 | $this->query($rename, true, "Cannot rename index"); |
| 922 | 922 | } |
| 923 | - $sql .= is_array($rename)?join("\n", $rename). "\n":$rename."\n"; |
|
| 923 | + $sql .= is_array($rename) ? join("\n", $rename)."\n" : $rename."\n"; |
|
| 924 | 924 | |
| 925 | 925 | } else { |
| 926 | 926 | // ok we need this field lets create it |
| 927 | - $sql .= "/*MISSING INDEX IN DATABASE - $name -{$value['type']} ROW */\n"; |
|
| 928 | - $sql .= $this->addIndexes($tablename,array($value), $execute) . "\n"; |
|
| 927 | + $sql .= "/*MISSING INDEX IN DATABASE - $name -{$value['type']} ROW */\n"; |
|
| 928 | + $sql .= $this->addIndexes($tablename, array($value), $execute)."\n"; |
|
| 929 | 929 | } |
| 930 | 930 | $take_action = true; |
| 931 | 931 | $correctedIndexs[$name] = true; |
| 932 | - } elseif ( !$this->compareVarDefs($compareIndices[$name],$value) ) { |
|
| 932 | + } elseif (!$this->compareVarDefs($compareIndices[$name], $value)) { |
|
| 933 | 933 | // fields are different lets alter it |
| 934 | - $sql .= "/*INDEX MISMATCH WITH DATABASE - $name - ROW "; |
|
| 934 | + $sql .= "/*INDEX MISMATCH WITH DATABASE - $name - ROW "; |
|
| 935 | 935 | foreach ($compareIndices[$name] as $n1 => $t1) { |
| 936 | - $sql .= "<$n1>"; |
|
| 937 | - if ( $n1 == 'fields' ) |
|
| 938 | - foreach($t1 as $rKey => $rValue) |
|
| 936 | + $sql .= "<$n1>"; |
|
| 937 | + if ($n1 == 'fields') |
|
| 938 | + foreach ($t1 as $rKey => $rValue) |
|
| 939 | 939 | $sql .= "[$rKey] => '$rValue' "; |
| 940 | 940 | else |
| 941 | 941 | $sql .= " $t1 "; |
| 942 | 942 | } |
| 943 | - $sql .= "*/\n"; |
|
| 944 | - $sql .= "/* VARDEF - $name - ROW"; |
|
| 943 | + $sql .= "*/\n"; |
|
| 944 | + $sql .= "/* VARDEF - $name - ROW"; |
|
| 945 | 945 | foreach ($value as $n1 => $t1) { |
| 946 | - $sql .= "<$n1>"; |
|
| 947 | - if ( $n1 == 'fields' ) |
|
| 946 | + $sql .= "<$n1>"; |
|
| 947 | + if ($n1 == 'fields') |
|
| 948 | 948 | foreach ($t1 as $rKey => $rValue) |
| 949 | - $sql .= "[$rKey] => '$rValue' "; |
|
| 949 | + $sql .= "[$rKey] => '$rValue' "; |
|
| 950 | 950 | else |
| 951 | 951 | $sql .= " $t1 "; |
| 952 | 952 | } |
| 953 | - $sql .= "*/\n"; |
|
| 954 | - $sql .= $this->modifyIndexes($tablename,array($value), $execute) . "\n"; |
|
| 953 | + $sql .= "*/\n"; |
|
| 954 | + $sql .= $this->modifyIndexes($tablename, array($value), $execute)."\n"; |
|
| 955 | 955 | $take_action = true; |
| 956 | 956 | $correctedIndexs[$name] = true; |
| 957 | 957 | } |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | */ |
| 971 | 971 | public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false) |
| 972 | 972 | { |
| 973 | - foreach ( $fielddef1 as $key => $value ) { |
|
| 973 | + foreach ($fielddef1 as $key => $value) { |
|
| 974 | 974 | if ($key == 'name' && $ignoreName) |
| 975 | 975 | continue; |
| 976 | 976 | if (isset($fielddef2[$key])) |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | } |
| 985 | 985 | else |
| 986 | 986 | { |
| 987 | - if (array_map('strtolower', $fielddef1[$key]) == array_map('strtolower',$fielddef2[$key])) |
|
| 987 | + if (array_map('strtolower', $fielddef1[$key]) == array_map('strtolower', $fielddef2[$key])) |
|
| 988 | 988 | { |
| 989 | 989 | continue; |
| 990 | 990 | } |
@@ -1033,9 +1033,9 @@ discard block |
||
| 1033 | 1033 | } |
| 1034 | 1034 | else { |
| 1035 | 1035 | $returnArray['msg'] = 'match'; |
| 1036 | - foreach($row1 as $key => $value){ |
|
| 1036 | + foreach ($row1 as $key => $value) { |
|
| 1037 | 1037 | //ignore keys when checking we will check them when we do the index check |
| 1038 | - if( !isset($ignore_filter[$key]) && (!isset($row2[$key]) || $row1[$key] !== $row2[$key])){ |
|
| 1038 | + if (!isset($ignore_filter[$key]) && (!isset($row2[$key]) || $row1[$key] !== $row2[$key])) { |
|
| 1039 | 1039 | $returnArray['msg'] = 'no_match'; |
| 1040 | 1040 | } |
| 1041 | 1041 | } |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | $sql = $this->createIndexSQL($bean, $fieldDefs, $name, $unique); |
| 1112 | 1112 | $tablename = $bean->getTableName(); |
| 1113 | 1113 | $msg = "Error creating index $name on table: $tablename:"; |
| 1114 | - return $this->query($sql,true,$msg); |
|
| 1114 | + return $this->query($sql, true, $msg); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | /** |
@@ -1128,14 +1128,14 @@ discard block |
||
| 1128 | 1128 | $columns = array(); |
| 1129 | 1129 | |
| 1130 | 1130 | foreach ($indices as $index) { |
| 1131 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
| 1131 | + if (!empty($index['db']) && $index['db'] != $this->dbType) |
|
| 1132 | 1132 | continue; |
| 1133 | 1133 | if (isset($index['source']) && $index['source'] != 'db') |
| 1134 | 1134 | continue; |
| 1135 | 1135 | |
| 1136 | 1136 | $sql = $this->add_drop_constraint($table, $index); |
| 1137 | 1137 | |
| 1138 | - if(!empty($sql)) { |
|
| 1138 | + if (!empty($sql)) { |
|
| 1139 | 1139 | $columns[] = $sql; |
| 1140 | 1140 | } |
| 1141 | 1141 | } |
@@ -1155,11 +1155,11 @@ discard block |
||
| 1155 | 1155 | { |
| 1156 | 1156 | $alters = $this->getConstraintSql($indexes, $tablename); |
| 1157 | 1157 | if ($execute) { |
| 1158 | - foreach($alters as $sql) { |
|
| 1158 | + foreach ($alters as $sql) { |
|
| 1159 | 1159 | $this->query($sql, true, "Error adding index: "); |
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | - if(!empty($alters)) { |
|
| 1162 | + if (!empty($alters)) { |
|
| 1163 | 1163 | $sql = join(";\n", $alters).";\n"; |
| 1164 | 1164 | } else { |
| 1165 | 1165 | $sql = ''; |
@@ -1179,17 +1179,17 @@ discard block |
||
| 1179 | 1179 | { |
| 1180 | 1180 | $sqls = array(); |
| 1181 | 1181 | foreach ($indexes as $index) { |
| 1182 | - $name =$index['name']; |
|
| 1183 | - $sqls[$name] = $this->add_drop_constraint($tablename,$index,true); |
|
| 1182 | + $name = $index['name']; |
|
| 1183 | + $sqls[$name] = $this->add_drop_constraint($tablename, $index, true); |
|
| 1184 | 1184 | } |
| 1185 | 1185 | if (!empty($sqls) && $execute) { |
| 1186 | - foreach($sqls as $name => $sql) { |
|
| 1186 | + foreach ($sqls as $name => $sql) { |
|
| 1187 | 1187 | unset(self::$index_descriptions[$tablename][$name]); |
| 1188 | 1188 | $this->query($sql); |
| 1189 | 1189 | } |
| 1190 | 1190 | } |
| 1191 | - if(!empty($sqls)) { |
|
| 1192 | - return join(";\n",$sqls).";"; |
|
| 1191 | + if (!empty($sqls)) { |
|
| 1192 | + return join(";\n", $sqls).";"; |
|
| 1193 | 1193 | } else { |
| 1194 | 1194 | return ''; |
| 1195 | 1195 | } |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | public function addColumn($tablename, $fieldDefs) |
| 1220 | 1220 | { |
| 1221 | 1221 | $sql = $this->addColumnSQL($tablename, $fieldDefs); |
| 1222 | - if ($this->isFieldArray($fieldDefs)){ |
|
| 1222 | + if ($this->isFieldArray($fieldDefs)) { |
|
| 1223 | 1223 | $columns = array(); |
| 1224 | 1224 | foreach ($fieldDefs as $fieldDef) |
| 1225 | 1225 | $columns[] = $fieldDef['name']; |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | $columns = $fieldDefs['name']; |
| 1230 | 1230 | } |
| 1231 | 1231 | $msg = "Error adding column(s) $columns on table: $tablename:"; |
| 1232 | - return $this->query($sql,true,$msg); |
|
| 1232 | + return $this->query($sql, true, $msg); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | /** |
@@ -1242,8 +1242,8 @@ discard block |
||
| 1242 | 1242 | */ |
| 1243 | 1243 | public function alterColumn($tablename, $newFieldDef, $ignoreRequired = false) |
| 1244 | 1244 | { |
| 1245 | - $sql = $this->alterColumnSQL($tablename, $newFieldDef,$ignoreRequired); |
|
| 1246 | - if ($this->isFieldArray($newFieldDef)){ |
|
| 1245 | + $sql = $this->alterColumnSQL($tablename, $newFieldDef, $ignoreRequired); |
|
| 1246 | + if ($this->isFieldArray($newFieldDef)) { |
|
| 1247 | 1247 | $columns = array(); |
| 1248 | 1248 | foreach ($newFieldDef as $fieldDef) { |
| 1249 | 1249 | $columns[] = $fieldDef['name']; |
@@ -1255,8 +1255,8 @@ discard block |
||
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | $msg = "Error altering column(s) $columns on table: $tablename:"; |
| 1258 | - $res = $this->query($sql,true,$msg); |
|
| 1259 | - if($res) { |
|
| 1258 | + $res = $this->query($sql, true, $msg); |
|
| 1259 | + if ($res) { |
|
| 1260 | 1260 | $this->getTableDescription($tablename, true); // reload table description after altering |
| 1261 | 1261 | } |
| 1262 | 1262 | return $res; |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | public function dropTableName($name) |
| 1283 | 1283 | { |
| 1284 | 1284 | $sql = $this->dropTableNameSQL($name); |
| 1285 | - return $this->query($sql,true,"Error dropping table $name:"); |
|
| 1285 | + return $this->query($sql, true, "Error dropping table $name:"); |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | /** |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | $tablename = $bean->getTableName(); |
| 1298 | 1298 | $sql = $this->dropColumnSQL($tablename, $fieldDefs); |
| 1299 | 1299 | $msg = "Error deleting column(s) on table: $tablename:"; |
| 1300 | - return $this->query($sql,true,$msg); |
|
| 1300 | + return $this->query($sql, true, $msg); |
|
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | /** |
@@ -1320,18 +1320,18 @@ discard block |
||
| 1320 | 1320 | |
| 1321 | 1321 | $rows_found = 0; |
| 1322 | 1322 | $count_query = $bean->create_list_count_query($select_query); |
| 1323 | - if(!empty($count_query)) |
|
| 1323 | + if (!empty($count_query)) |
|
| 1324 | 1324 | { |
| 1325 | 1325 | // We have a count query. Run it and get the results. |
| 1326 | 1326 | $result = $this->query($count_query, true, "Error running count query for $this->object_name List: "); |
| 1327 | 1327 | $assoc = $this->fetchByAssoc($result); |
| 1328 | - if(!empty($assoc['c'])) |
|
| 1328 | + if (!empty($assoc['c'])) |
|
| 1329 | 1329 | { |
| 1330 | 1330 | $rows_found = $assoc['c']; |
| 1331 | 1331 | } |
| 1332 | 1332 | } |
| 1333 | - if($count == -1){ |
|
| 1334 | - $count = $sugar_config['list_max_entries_per_page']; |
|
| 1333 | + if ($count == -1) { |
|
| 1334 | + $count = $sugar_config['list_max_entries_per_page']; |
|
| 1335 | 1335 | } |
| 1336 | 1336 | $next_offset = $start + $count; |
| 1337 | 1337 | |
@@ -1344,13 +1344,13 @@ discard block |
||
| 1344 | 1344 | $fields = $bean->getFieldDefinitions(); |
| 1345 | 1345 | $custom_fields = array(); |
| 1346 | 1346 | |
| 1347 | - if($bean->hasCustomFields()){ |
|
| 1348 | - foreach ($fields as $fieldDef){ |
|
| 1349 | - if($fieldDef['source'] == 'custom_fields'){ |
|
| 1347 | + if ($bean->hasCustomFields()) { |
|
| 1348 | + foreach ($fields as $fieldDef) { |
|
| 1349 | + if ($fieldDef['source'] == 'custom_fields') { |
|
| 1350 | 1350 | $custom_fields[$fieldDef['name']] = $fieldDef['name']; |
| 1351 | 1351 | } |
| 1352 | 1352 | } |
| 1353 | - if(!empty($custom_fields)){ |
|
| 1353 | + if (!empty($custom_fields)) { |
|
| 1354 | 1354 | $custom_fields['id_c'] = 'id_c'; |
| 1355 | 1355 | $id_field = array('name' => 'id_c', 'custom_type' => 'id',); |
| 1356 | 1356 | $fields[] = $id_field; |
@@ -1363,50 +1363,50 @@ discard block |
||
| 1363 | 1363 | $cstm_row_array = array(); |
| 1364 | 1364 | $cstm_columns = array(); |
| 1365 | 1365 | $built_columns = false; |
| 1366 | - while(($row = $this->fetchByAssoc($result)) != null) |
|
| 1366 | + while (($row = $this->fetchByAssoc($result)) != null) |
|
| 1367 | 1367 | { |
| 1368 | 1368 | $values = array(); |
| 1369 | 1369 | $cstm_values = array(); |
| 1370 | - if(!$is_related_query){ |
|
| 1370 | + if (!$is_related_query) { |
|
| 1371 | 1371 | foreach ($fields as $fieldDef) |
| 1372 | 1372 | { |
| 1373 | - if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue; |
|
| 1373 | + if (isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue; |
|
| 1374 | 1374 | $val = $row[$fieldDef['name']]; |
| 1375 | 1375 | |
| 1376 | 1376 | //handle auto increment values here only need to do this on insert not create |
| 1377 | - if ($fieldDef['name'] == 'deleted'){ |
|
| 1377 | + if ($fieldDef['name'] == 'deleted') { |
|
| 1378 | 1378 | $values['deleted'] = $val; |
| 1379 | - if(!$built_columns){ |
|
| 1379 | + if (!$built_columns) { |
|
| 1380 | 1380 | $columns[] = 'deleted'; |
| 1381 | 1381 | } |
| 1382 | 1382 | } |
| 1383 | 1383 | else |
| 1384 | 1384 | { |
| 1385 | 1385 | $type = $fieldDef['type']; |
| 1386 | - if(!empty($fieldDef['custom_type'])){ |
|
| 1386 | + if (!empty($fieldDef['custom_type'])) { |
|
| 1387 | 1387 | $type = $fieldDef['custom_type']; |
| 1388 | 1388 | } |
| 1389 | 1389 | // need to do some thing about types of values |
| 1390 | - if($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')){ |
|
| 1391 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1390 | + if ($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' || $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')) { |
|
| 1391 | + if (!empty($custom_fields[$fieldDef['name']])) |
|
| 1392 | 1392 | $cstm_values[$fieldDef['name']] = 'null'; |
| 1393 | 1393 | else |
| 1394 | 1394 | $values[$fieldDef['name']] = 'null'; |
| 1395 | - }else{ |
|
| 1396 | - if(isset($type) && $type=='int') { |
|
| 1397 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1395 | + } else { |
|
| 1396 | + if (isset($type) && $type == 'int') { |
|
| 1397 | + if (!empty($custom_fields[$fieldDef['name']])) |
|
| 1398 | 1398 | $cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
| 1399 | 1399 | else |
| 1400 | 1400 | $values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val)); |
| 1401 | 1401 | } else { |
| 1402 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1402 | + if (!empty($custom_fields[$fieldDef['name']])) |
|
| 1403 | 1403 | $cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
| 1404 | 1404 | else |
| 1405 | 1405 | $values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'"; |
| 1406 | 1406 | } |
| 1407 | 1407 | } |
| 1408 | - if(!$built_columns){ |
|
| 1409 | - if(!empty($custom_fields[$fieldDef['name']])) |
|
| 1408 | + if (!$built_columns) { |
|
| 1409 | + if (!empty($custom_fields[$fieldDef['name']])) |
|
| 1410 | 1410 | $cstm_columns[] = $fieldDef['name']; |
| 1411 | 1411 | else |
| 1412 | 1412 | $columns[] = $fieldDef['name']; |
@@ -1417,19 +1417,19 @@ discard block |
||
| 1417 | 1417 | } else { |
| 1418 | 1418 | foreach ($row as $key=>$val) |
| 1419 | 1419 | { |
| 1420 | - if($key != 'orc_row'){ |
|
| 1420 | + if ($key != 'orc_row') { |
|
| 1421 | 1421 | $values[$key] = "'$val'"; |
| 1422 | - if(!$built_columns){ |
|
| 1422 | + if (!$built_columns) { |
|
| 1423 | 1423 | $columns[] = $key; |
| 1424 | 1424 | } |
| 1425 | 1425 | } |
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | $built_columns = true; |
| 1429 | - if(!empty($values)){ |
|
| 1429 | + if (!empty($values)) { |
|
| 1430 | 1430 | $row_array[] = $values; |
| 1431 | 1431 | } |
| 1432 | - if(!empty($cstm_values) && !empty($cstm_values['id_c']) && (strlen($cstm_values['id_c']) > 7)){ |
|
| 1432 | + if (!empty($cstm_values) && !empty($cstm_values['id_c']) && (strlen($cstm_values['id_c']) > 7)) { |
|
| 1433 | 1433 | $cstm_row_array[] = $cstm_values; |
| 1434 | 1434 | } |
| 1435 | 1435 | } |
@@ -1439,9 +1439,9 @@ discard block |
||
| 1439 | 1439 | // get the entire sql |
| 1440 | 1440 | $sql .= "(".implode(",", $columns).") "; |
| 1441 | 1441 | $sql .= "VALUES"; |
| 1442 | - for($i = 0; $i < count($row_array); $i++){ |
|
| 1442 | + for ($i = 0; $i < count($row_array); $i++) { |
|
| 1443 | 1443 | $sql .= " (".implode(",", $row_array[$i]).")"; |
| 1444 | - if($i < (count($row_array) - 1)){ |
|
| 1444 | + if ($i < (count($row_array) - 1)) { |
|
| 1445 | 1445 | $sql .= ", "; |
| 1446 | 1446 | } |
| 1447 | 1447 | } |
@@ -1450,9 +1450,9 @@ discard block |
||
| 1450 | 1450 | $custom_sql .= "(".implode(",", $cstm_columns).") "; |
| 1451 | 1451 | $custom_sql .= "VALUES"; |
| 1452 | 1452 | |
| 1453 | - for($i = 0; $i < count($cstm_row_array); $i++){ |
|
| 1453 | + for ($i = 0; $i < count($cstm_row_array); $i++) { |
|
| 1454 | 1454 | $custom_sql .= " (".implode(",", $cstm_row_array[$i]).")"; |
| 1455 | - if($i < (count($cstm_row_array) - 1)){ |
|
| 1455 | + if ($i < (count($cstm_row_array) - 1)) { |
|
| 1456 | 1456 | $custom_sql .= ", "; |
| 1457 | 1457 | } |
| 1458 | 1458 | } |
@@ -1545,17 +1545,17 @@ discard block |
||
| 1545 | 1545 | */ |
| 1546 | 1546 | public function quoteType($type, $value) |
| 1547 | 1547 | { |
| 1548 | - if($type == 'date') { |
|
| 1548 | + if ($type == 'date') { |
|
| 1549 | 1549 | return $this->convert($this->quoted($value), "date"); |
| 1550 | 1550 | } |
| 1551 | - if($type == 'time') { |
|
| 1551 | + if ($type == 'time') { |
|
| 1552 | 1552 | return $this->convert($this->quoted($value), "time"); |
| 1553 | 1553 | } |
| 1554 | - if(isset($this->type_class[$type]) && $this->type_class[$type] == "date") { |
|
| 1554 | + if (isset($this->type_class[$type]) && $this->type_class[$type] == "date") { |
|
| 1555 | 1555 | return $this->convert($this->quoted($value), "datetime"); |
| 1556 | 1556 | } |
| 1557 | - if($this->isNumericType($type)) { |
|
| 1558 | - return 0+$value; // ensure it's numeric |
|
| 1557 | + if ($this->isNumericType($type)) { |
|
| 1558 | + return 0 + $value; // ensure it's numeric |
|
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | return $this->quoted($value); |
@@ -1571,7 +1571,7 @@ discard block |
||
| 1571 | 1571 | */ |
| 1572 | 1572 | public function arrayQuote(array &$array) |
| 1573 | 1573 | { |
| 1574 | - foreach($array as &$val) { |
|
| 1574 | + foreach ($array as &$val) { |
|
| 1575 | 1575 | $val = $this->quote($val); |
| 1576 | 1576 | } |
| 1577 | 1577 | return $array; |
@@ -1584,10 +1584,10 @@ discard block |
||
| 1584 | 1584 | */ |
| 1585 | 1585 | protected function freeResult($result = false) |
| 1586 | 1586 | { |
| 1587 | - if($result) { |
|
| 1587 | + if ($result) { |
|
| 1588 | 1588 | $this->freeDbResult($result); |
| 1589 | 1589 | } |
| 1590 | - if($this->lastResult) { |
|
| 1590 | + if ($this->lastResult) { |
|
| 1591 | 1591 | $this->freeDbResult($this->lastResult); |
| 1592 | 1592 | $this->lastResult = null; |
| 1593 | 1593 | } |
@@ -1616,17 +1616,17 @@ discard block |
||
| 1616 | 1616 | public function getOne($sql, $dieOnError = false, $msg = '') |
| 1617 | 1617 | { |
| 1618 | 1618 | $this->log->info("Get One: |$sql|"); |
| 1619 | - if(!$this->hasLimit($sql)) { |
|
| 1619 | + if (!$this->hasLimit($sql)) { |
|
| 1620 | 1620 | $queryresult = $this->limitQuery($sql, 0, 1, $dieOnError, $msg); |
| 1621 | 1621 | } else { |
| 1622 | 1622 | // support old code that passes LIMIT to sql |
| 1623 | 1623 | // works only for mysql, so do not rely on this |
| 1624 | 1624 | $queryresult = $this->query($sql, $dieOnError, $msg); |
| 1625 | 1625 | } |
| 1626 | - $this->checkError($msg.' Get One Failed:' . $sql, $dieOnError); |
|
| 1626 | + $this->checkError($msg.' Get One Failed:'.$sql, $dieOnError); |
|
| 1627 | 1627 | if (!$queryresult) return false; |
| 1628 | 1628 | $row = $this->fetchByAssoc($queryresult); |
| 1629 | - if(!empty($row)) { |
|
| 1629 | + if (!empty($row)) { |
|
| 1630 | 1630 | return array_shift($row); |
| 1631 | 1631 | } |
| 1632 | 1632 | return false; |
@@ -1646,12 +1646,12 @@ discard block |
||
| 1646 | 1646 | $this->log->info("Fetch One: |$sql|"); |
| 1647 | 1647 | $this->checkConnection(); |
| 1648 | 1648 | $queryresult = $this->query($sql, $dieOnError, $msg); |
| 1649 | - $this->checkError($msg.' Fetch One Failed:' . $sql, $dieOnError); |
|
| 1649 | + $this->checkError($msg.' Fetch One Failed:'.$sql, $dieOnError); |
|
| 1650 | 1650 | |
| 1651 | 1651 | if (!$queryresult) return false; |
| 1652 | 1652 | |
| 1653 | 1653 | $row = $this->fetchByAssoc($queryresult); |
| 1654 | - if ( !$row ) return false; |
|
| 1654 | + if (!$row) return false; |
|
| 1655 | 1655 | |
| 1656 | 1656 | $this->freeResult($queryresult); |
| 1657 | 1657 | return $row; |
@@ -1692,7 +1692,7 @@ discard block |
||
| 1692 | 1692 | */ |
| 1693 | 1693 | public function getTableDescription($tablename, $reload = false) |
| 1694 | 1694 | { |
| 1695 | - if($reload || empty(self::$table_descriptions[$tablename])) { |
|
| 1695 | + if ($reload || empty(self::$table_descriptions[$tablename])) { |
|
| 1696 | 1696 | self::$table_descriptions[$tablename] = $this->get_columns($tablename); |
| 1697 | 1697 | } |
| 1698 | 1698 | return self::$table_descriptions[$tablename]; |
@@ -1708,12 +1708,12 @@ discard block |
||
| 1708 | 1708 | protected function describeField($name, $tablename) |
| 1709 | 1709 | { |
| 1710 | 1710 | $table = $this->getTableDescription($tablename); |
| 1711 | - if(!empty($table) && isset($table[$name])) |
|
| 1711 | + if (!empty($table) && isset($table[$name])) |
|
| 1712 | 1712 | return $table[$name]; |
| 1713 | 1713 | |
| 1714 | 1714 | $table = $this->getTableDescription($tablename, true); |
| 1715 | 1715 | |
| 1716 | - if(isset($table[$name])) |
|
| 1716 | + if (isset($table[$name])) |
|
| 1717 | 1717 | return $table[$name]; |
| 1718 | 1718 | |
| 1719 | 1719 | return array(); |
@@ -1728,13 +1728,13 @@ discard block |
||
| 1728 | 1728 | */ |
| 1729 | 1729 | protected function describeIndex($name, $tablename) |
| 1730 | 1730 | { |
| 1731 | - if(isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename][$name])){ |
|
| 1731 | + if (isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename]) && isset(self::$index_descriptions[$tablename][$name])) { |
|
| 1732 | 1732 | return self::$index_descriptions[$tablename][$name]; |
| 1733 | 1733 | } |
| 1734 | 1734 | |
| 1735 | 1735 | self::$index_descriptions[$tablename] = $this->get_indices($tablename); |
| 1736 | 1736 | |
| 1737 | - if(isset(self::$index_descriptions[$tablename][$name])){ |
|
| 1737 | + if (isset(self::$index_descriptions[$tablename][$name])) { |
|
| 1738 | 1738 | return self::$index_descriptions[$tablename][$name]; |
| 1739 | 1739 | } |
| 1740 | 1740 | |
@@ -1751,9 +1751,9 @@ discard block |
||
| 1751 | 1751 | */ |
| 1752 | 1752 | public function truncate($string, $len) |
| 1753 | 1753 | { |
| 1754 | - if ( is_numeric($len) && $len > 0) |
|
| 1754 | + if (is_numeric($len) && $len > 0) |
|
| 1755 | 1755 | { |
| 1756 | - $string = mb_substr($string,0,(int) $len, "UTF-8"); |
|
| 1756 | + $string = mb_substr($string, 0, (int)$len, "UTF-8"); |
|
| 1757 | 1757 | } |
| 1758 | 1758 | return $string; |
| 1759 | 1759 | } |
@@ -1768,11 +1768,11 @@ discard block |
||
| 1768 | 1768 | */ |
| 1769 | 1769 | public function concat($table, array $fields, $space = ' ') |
| 1770 | 1770 | { |
| 1771 | - if(empty($fields)) return ''; |
|
| 1771 | + if (empty($fields)) return ''; |
|
| 1772 | 1772 | $elems = array(); |
| 1773 | 1773 | $space = $this->quoted($space); |
| 1774 | - foreach ( $fields as $field ) { |
|
| 1775 | - if(!empty($elems)) $elems[] = $space; |
|
| 1774 | + foreach ($fields as $field) { |
|
| 1775 | + if (!empty($elems)) $elems[] = $space; |
|
| 1776 | 1776 | $elems[] = $this->convert("$table.$field", 'IFNULL', array("''")); |
| 1777 | 1777 | } |
| 1778 | 1778 | $first = array_shift($elems); |
@@ -1829,8 +1829,8 @@ discard block |
||
| 1829 | 1829 | */ |
| 1830 | 1830 | public function executePreparedQuery($stmt, $data = array()) |
| 1831 | 1831 | { |
| 1832 | - if(!empty($this->preparedTokens[$stmt])){ |
|
| 1833 | - if(!is_array($data)){ |
|
| 1832 | + if (!empty($this->preparedTokens[$stmt])) { |
|
| 1833 | + if (!is_array($data)) { |
|
| 1834 | 1834 | $data = array($data); |
| 1835 | 1835 | } |
| 1836 | 1836 | |
@@ -1838,7 +1838,7 @@ discard block |
||
| 1838 | 1838 | |
| 1839 | 1839 | //ensure that the number of data elements matches the number of replacement tokens |
| 1840 | 1840 | //we found in prepare(). |
| 1841 | - if(count($data) != $pTokens['tokenCount']){ |
|
| 1841 | + if (count($data) != $pTokens['tokenCount']) { |
|
| 1842 | 1842 | //error the data count did not match the token count |
| 1843 | 1843 | return false; |
| 1844 | 1844 | } |
@@ -1864,7 +1864,7 @@ discard block |
||
| 1864 | 1864 | }//switch |
| 1865 | 1865 | }//foreach |
| 1866 | 1866 | return $this->query($query); |
| 1867 | - }else{ |
|
| 1867 | + } else { |
|
| 1868 | 1868 | return false; |
| 1869 | 1869 | } |
| 1870 | 1870 | } |
@@ -1908,7 +1908,7 @@ discard block |
||
| 1908 | 1908 | { |
| 1909 | 1909 | // get column names and values |
| 1910 | 1910 | $sql = $this->insertParams($bean->getTableName(), $bean->getFieldDefinitions(), get_object_vars($bean), |
| 1911 | - isset($bean->field_name_map)?$bean->field_name_map:null, false); |
|
| 1911 | + isset($bean->field_name_map) ? $bean->field_name_map : null, false); |
|
| 1912 | 1912 | return $sql; |
| 1913 | 1913 | } |
| 1914 | 1914 | |
@@ -1936,48 +1936,48 @@ discard block |
||
| 1936 | 1936 | if (!empty($bean->field_name_map[$field]['auto_increment'])) continue; |
| 1937 | 1937 | |
| 1938 | 1938 | //custom fields handle their save separately |
| 1939 | - if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) continue; |
|
| 1939 | + if (isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) continue; |
|
| 1940 | 1940 | |
| 1941 | 1941 | // no need to clear deleted since we only update not deleted records anyway |
| 1942 | - if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue; |
|
| 1942 | + if ($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue; |
|
| 1943 | 1943 | |
| 1944 | - if(isset($bean->$field)) { |
|
| 1944 | + if (isset($bean->$field)) { |
|
| 1945 | 1945 | $val = from_html($bean->$field); |
| 1946 | 1946 | } else { |
| 1947 | 1947 | continue; |
| 1948 | 1948 | } |
| 1949 | 1949 | |
| 1950 | - if(!empty($fieldDef['type']) && $fieldDef['type'] == 'bool'){ |
|
| 1950 | + if (!empty($fieldDef['type']) && $fieldDef['type'] == 'bool') { |
|
| 1951 | 1951 | $val = $bean->getFieldValue($field); |
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | - if(strlen($val) == 0) { |
|
| 1955 | - if(isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 1954 | + if (strlen($val) == 0) { |
|
| 1955 | + if (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0) { |
|
| 1956 | 1956 | $val = $fieldDef['default']; |
| 1957 | 1957 | } else { |
| 1958 | 1958 | $val = null; |
| 1959 | 1959 | } |
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | - if(!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 1962 | + if (!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 1963 | 1963 | $val = $this->truncate($val, $fieldDef['len']); |
| 1964 | 1964 | } |
| 1965 | 1965 | $columnName = $this->quoteIdentifier($fieldDef['name']); |
| 1966 | - if(!is_null($val) || !empty($fieldDef['required'])) { |
|
| 1966 | + if (!is_null($val) || !empty($fieldDef['required'])) { |
|
| 1967 | 1967 | $columns[] = "{$columnName}=".$this->massageValue($val, $fieldDef); |
| 1968 | - } elseif($this->isNullable($fieldDef)) { |
|
| 1968 | + } elseif ($this->isNullable($fieldDef)) { |
|
| 1969 | 1969 | $columns[] = "{$columnName}=NULL"; |
| 1970 | 1970 | } else { |
| 1971 | 1971 | $columns[] = "{$columnName}=".$this->emptyValue($fieldDef['type']); |
| 1972 | 1972 | } |
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | - if ( sizeof($columns) == 0 ) |
|
| 1975 | + if (sizeof($columns) == 0) |
|
| 1976 | 1976 | return ""; // no columns set |
| 1977 | 1977 | |
| 1978 | 1978 | // build where clause |
| 1979 | 1979 | $where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where)); |
| 1980 | - if(isset($fields['deleted'])) { |
|
| 1980 | + if (isset($fields['deleted'])) { |
|
| 1981 | 1981 | $where .= " AND deleted=0"; |
| 1982 | 1982 | } |
| 1983 | 1983 | |
@@ -2001,7 +2001,7 @@ discard block |
||
| 2001 | 2001 | $primaryColumn = $fieldDef['name']; |
| 2002 | 2002 | |
| 2003 | 2003 | $val = $bean->getFieldValue($fieldDef['name']); |
| 2004 | - if ($val != FALSE){ |
|
| 2004 | + if ($val != FALSE) { |
|
| 2005 | 2005 | $where[$primaryColumn] = $val; |
| 2006 | 2006 | } |
| 2007 | 2007 | } |
@@ -2027,7 +2027,7 @@ discard block |
||
| 2027 | 2027 | if (is_array($val)) { |
| 2028 | 2028 | $op = "IN"; |
| 2029 | 2029 | $temp = array(); |
| 2030 | - foreach ($val as $tval){ |
|
| 2030 | + foreach ($val as $tval) { |
|
| 2031 | 2031 | $temp[] = $this->quoted($tval); |
| 2032 | 2032 | } |
| 2033 | 2033 | $val = implode(",", $temp); |
@@ -2053,9 +2053,9 @@ discard block |
||
| 2053 | 2053 | * @param array $whereArray Optional, where conditions in an array |
| 2054 | 2054 | * @return string |
| 2055 | 2055 | */ |
| 2056 | - protected function getWhereClause(SugarBean $bean, array $whereArray=array()) |
|
| 2056 | + protected function getWhereClause(SugarBean $bean, array $whereArray = array()) |
|
| 2057 | 2057 | { |
| 2058 | - return " WHERE " . $this->getColumnWhereClause($bean->getTableName(), $whereArray); |
|
| 2058 | + return " WHERE ".$this->getColumnWhereClause($bean->getTableName(), $whereArray); |
|
| 2059 | 2059 | } |
| 2060 | 2060 | |
| 2061 | 2061 | /** |
@@ -2069,13 +2069,13 @@ discard block |
||
| 2069 | 2069 | { |
| 2070 | 2070 | $type = $this->getFieldType($fieldDef); |
| 2071 | 2071 | |
| 2072 | - if(isset($this->type_class[$type])) { |
|
| 2072 | + if (isset($this->type_class[$type])) { |
|
| 2073 | 2073 | // handle some known types |
| 2074 | - switch($this->type_class[$type]) { |
|
| 2074 | + switch ($this->type_class[$type]) { |
|
| 2075 | 2075 | case 'bool': |
| 2076 | 2076 | case 'int': |
| 2077 | - if (!empty($fieldDef['required']) && $val == ''){ |
|
| 2078 | - if (isset($fieldDef['default'])){ |
|
| 2077 | + if (!empty($fieldDef['required']) && $val == '') { |
|
| 2078 | + if (isset($fieldDef['default'])) { |
|
| 2079 | 2079 | return $fieldDef['default']; |
| 2080 | 2080 | } |
| 2081 | 2081 | return 0; |
@@ -2083,16 +2083,16 @@ discard block |
||
| 2083 | 2083 | return intval($val); |
| 2084 | 2084 | case 'bigint' : |
| 2085 | 2085 | $val = (float)$val; |
| 2086 | - if (!empty($fieldDef['required']) && $val == false){ |
|
| 2087 | - if (isset($fieldDef['default'])){ |
|
| 2086 | + if (!empty($fieldDef['required']) && $val == false) { |
|
| 2087 | + if (isset($fieldDef['default'])) { |
|
| 2088 | 2088 | return $fieldDef['default']; |
| 2089 | 2089 | } |
| 2090 | 2090 | return 0; |
| 2091 | 2091 | } |
| 2092 | 2092 | return $val; |
| 2093 | 2093 | case 'float': |
| 2094 | - if (!empty($fieldDef['required']) && $val == ''){ |
|
| 2095 | - if (isset($fieldDef['default'])){ |
|
| 2094 | + if (!empty($fieldDef['required']) && $val == '') { |
|
| 2095 | + if (isset($fieldDef['default'])) { |
|
| 2096 | 2096 | return $fieldDef['default']; |
| 2097 | 2097 | } |
| 2098 | 2098 | return 0; |
@@ -2101,7 +2101,7 @@ discard block |
||
| 2101 | 2101 | case 'time': |
| 2102 | 2102 | case 'date': |
| 2103 | 2103 | // empty date can't be '', so convert it to either NULL or empty date value |
| 2104 | - if($val == '') { |
|
| 2104 | + if ($val == '') { |
|
| 2105 | 2105 | if (!empty($fieldDef['required'])) { |
| 2106 | 2106 | if (isset($fieldDef['default'])) { |
| 2107 | 2107 | return $fieldDef['default']; |
@@ -2113,14 +2113,14 @@ discard block |
||
| 2113 | 2113 | break; |
| 2114 | 2114 | } |
| 2115 | 2115 | } else { |
| 2116 | - if(!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 2116 | + if (!empty($val) && !empty($fieldDef['len']) && strlen($val) > $fieldDef['len']) { |
|
| 2117 | 2117 | $val = $this->truncate($val, $fieldDef['len']); |
| 2118 | 2118 | } |
| 2119 | 2119 | } |
| 2120 | 2120 | |
| 2121 | - if ( is_null($val) ) { |
|
| 2122 | - if(!empty($fieldDef['required'])) { |
|
| 2123 | - if (isset($fieldDef['default']) && $fieldDef['default'] != ''){ |
|
| 2121 | + if (is_null($val)) { |
|
| 2122 | + if (!empty($fieldDef['required'])) { |
|
| 2123 | + if (isset($fieldDef['default']) && $fieldDef['default'] != '') { |
|
| 2124 | 2124 | return $fieldDef['default']; |
| 2125 | 2125 | } |
| 2126 | 2126 | return $this->emptyValue($type); |
@@ -2128,7 +2128,7 @@ discard block |
||
| 2128 | 2128 | return "NULL"; |
| 2129 | 2129 | } |
| 2130 | 2130 | } |
| 2131 | - if($type == "datetimecombo") { |
|
| 2131 | + if ($type == "datetimecombo") { |
|
| 2132 | 2132 | $type = "datetime"; |
| 2133 | 2133 | } |
| 2134 | 2134 | return $this->convert($this->quoted($val), $type); |
@@ -2143,23 +2143,23 @@ discard block |
||
| 2143 | 2143 | */ |
| 2144 | 2144 | public function massageFieldDef(&$fieldDef, $tablename) |
| 2145 | 2145 | { |
| 2146 | - if ( !isset($fieldDef['dbType']) ) { |
|
| 2147 | - if ( isset($fieldDef['dbtype']) ) |
|
| 2146 | + if (!isset($fieldDef['dbType'])) { |
|
| 2147 | + if (isset($fieldDef['dbtype'])) |
|
| 2148 | 2148 | $fieldDef['dbType'] = $fieldDef['dbtype']; |
| 2149 | 2149 | else |
| 2150 | 2150 | $fieldDef['dbType'] = $fieldDef['type']; |
| 2151 | 2151 | } |
| 2152 | - $type = $this->getColumnType($fieldDef['dbType'],$fieldDef['name'],$tablename); |
|
| 2152 | + $type = $this->getColumnType($fieldDef['dbType'], $fieldDef['name'], $tablename); |
|
| 2153 | 2153 | $matches = array(); |
| 2154 | 2154 | // len can be a number or a string like 'max', for example, nvarchar(max) |
| 2155 | 2155 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*|\w+)\)|)/i', $type, $matches); |
| 2156 | - if ( isset($matches[1][0]) ) |
|
| 2156 | + if (isset($matches[1][0])) |
|
| 2157 | 2157 | $fieldDef['type'] = $matches[1][0]; |
| 2158 | - if ( isset($matches[2][0]) && empty($fieldDef['len']) ) |
|
| 2158 | + if (isset($matches[2][0]) && empty($fieldDef['len'])) |
|
| 2159 | 2159 | $fieldDef['len'] = $matches[2][0]; |
| 2160 | - if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) |
|
| 2160 | + if (!empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'], ',')) |
|
| 2161 | 2161 | $fieldDef['len'] .= ",{$fieldDef['precision']}"; |
| 2162 | - if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required'])) ) { |
|
| 2162 | + if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required']))) { |
|
| 2163 | 2163 | $fieldDef['required'] = 'true'; |
| 2164 | 2164 | } |
| 2165 | 2165 | } |
@@ -2180,7 +2180,7 @@ discard block |
||
| 2180 | 2180 | $level = 0; |
| 2181 | 2181 | $selectField = ""; |
| 2182 | 2182 | $strLen = strlen($selectStatement); |
| 2183 | - for($i = 0; $i < $strLen; $i++) |
|
| 2183 | + for ($i = 0; $i < $strLen; $i++) |
|
| 2184 | 2184 | { |
| 2185 | 2185 | $char = $selectStatement[$i]; |
| 2186 | 2186 | |
@@ -2190,16 +2190,16 @@ discard block |
||
| 2190 | 2190 | $fields[$field] = $selectField; |
| 2191 | 2191 | $selectField = ""; |
| 2192 | 2192 | } |
| 2193 | - else if ($char == "("){ |
|
| 2193 | + else if ($char == "(") { |
|
| 2194 | 2194 | $level++; |
| 2195 | 2195 | $selectField .= $char; |
| 2196 | 2196 | } |
| 2197 | - else if($char == ")"){ |
|
| 2197 | + else if ($char == ")") { |
|
| 2198 | 2198 | $level--; |
| 2199 | 2199 | $selectField .= $char; |
| 2200 | 2200 | |
| 2201 | 2201 | |
| 2202 | - }else{ |
|
| 2202 | + } else { |
|
| 2203 | 2203 | $selectField .= $char; |
| 2204 | 2204 | } |
| 2205 | 2205 | |
@@ -2215,7 +2215,7 @@ discard block |
||
| 2215 | 2215 | */ |
| 2216 | 2216 | protected function getFieldNameFromSelect($string) |
| 2217 | 2217 | { |
| 2218 | - if(strncasecmp($string, "DISTINCT ", 9) == 0) { |
|
| 2218 | + if (strncasecmp($string, "DISTINCT ", 9) == 0) { |
|
| 2219 | 2219 | $string = substr($string, 9); |
| 2220 | 2220 | } |
| 2221 | 2221 | if (stripos($string, " as ") !== false) |
@@ -2293,14 +2293,14 @@ discard block |
||
| 2293 | 2293 | foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name']; |
| 2294 | 2294 | |
| 2295 | 2295 | // build part of where clause |
| 2296 | - if (is_array($whereClause[$beanID])){ |
|
| 2296 | + if (is_array($whereClause[$beanID])) { |
|
| 2297 | 2297 | $where[] = $this->getColumnWhereClause($table, $whereClause[$beanID]); |
| 2298 | 2298 | } |
| 2299 | 2299 | // initialize so that it can be used properly in form clause generation |
| 2300 | 2300 | $table_used_in_from[$table] = false; |
| 2301 | 2301 | |
| 2302 | 2302 | $indices = $bean->getIndices(); |
| 2303 | - foreach ($indices as $index){ |
|
| 2303 | + foreach ($indices as $index) { |
|
| 2304 | 2304 | if ($index['type'] == 'foreign') { |
| 2305 | 2305 | $relationship[$table][] = array('foreignTable'=> $index['foreignTable'] |
| 2306 | 2306 | ,'foreignColumn'=>$index['foreignField'] |
@@ -2321,12 +2321,12 @@ discard block |
||
| 2321 | 2321 | // table2 is assumed to joining through primary key called id |
| 2322 | 2322 | $separator = ""; |
| 2323 | 2323 | $from = ''; $table_used_in_from = array(); |
| 2324 | - foreach ($relations as $table1 => $rightsidearray){ |
|
| 2324 | + foreach ($relations as $table1 => $rightsidearray) { |
|
| 2325 | 2325 | if ($table_used_in_from[$table1]) continue; // table has been joined |
| 2326 | 2326 | |
| 2327 | 2327 | $from .= $separator." ".$table1; |
| 2328 | 2328 | $table_used_in_from[$table1] = true; |
| 2329 | - foreach ($rightsidearray as $tablearray){ |
|
| 2329 | + foreach ($rightsidearray as $tablearray) { |
|
| 2330 | 2330 | $table2 = $tablearray['foreignTable']; // get foreign table |
| 2331 | 2331 | $tableAlias = $aliases[$table2]; // get a list of aliases for this table |
| 2332 | 2332 | foreach ($tableAlias as $table2) { |
@@ -2386,9 +2386,9 @@ discard block |
||
| 2386 | 2386 | // we do not have change a lot of existing code |
| 2387 | 2387 | // and add dbtype where type is being used for some special |
| 2388 | 2388 | // purposes like referring to foreign table etc. |
| 2389 | - if(!empty($fieldDef['dbType'])) |
|
| 2389 | + if (!empty($fieldDef['dbType'])) |
|
| 2390 | 2390 | return $fieldDef['dbType']; |
| 2391 | - if(!empty($fieldDef['dbtype'])) |
|
| 2391 | + if (!empty($fieldDef['dbtype'])) |
|
| 2392 | 2392 | return $fieldDef['dbtype']; |
| 2393 | 2393 | if (!empty($fieldDef['type'])) |
| 2394 | 2394 | return $fieldDef['type']; |
@@ -2408,17 +2408,17 @@ discard block |
||
| 2408 | 2408 | */ |
| 2409 | 2409 | public function getTypeParts($type) |
| 2410 | 2410 | { |
| 2411 | - if(preg_match("#(?P<type>\w+)\s*(?P<arg>\((?P<len>\w+)\s*(,\s*(?P<scale>\d+))*\))*#", $type, $matches)) |
|
| 2411 | + if (preg_match("#(?P<type>\w+)\s*(?P<arg>\((?P<len>\w+)\s*(,\s*(?P<scale>\d+))*\))*#", $type, $matches)) |
|
| 2412 | 2412 | { |
| 2413 | - $return = array(); // Not returning matches array as such as we don't want to expose the regex make up on the interface |
|
| 2413 | + $return = array(); // Not returning matches array as such as we don't want to expose the regex make up on the interface |
|
| 2414 | 2414 | $return['baseType'] = $matches['type']; |
| 2415 | - if( isset($matches['arg'])) { |
|
| 2415 | + if (isset($matches['arg'])) { |
|
| 2416 | 2416 | $return['arg'] = $matches['arg']; |
| 2417 | 2417 | } |
| 2418 | - if( isset($matches['len'])) { |
|
| 2418 | + if (isset($matches['len'])) { |
|
| 2419 | 2419 | $return['len'] = $matches['len']; |
| 2420 | 2420 | } |
| 2421 | - if( isset($matches['scale'])) { |
|
| 2421 | + if (isset($matches['scale'])) { |
|
| 2422 | 2422 | $return['scale'] = $matches['scale']; |
| 2423 | 2423 | } |
| 2424 | 2424 | return $return; |
@@ -2442,28 +2442,28 @@ discard block |
||
| 2442 | 2442 | $type = $this->getFieldType($fieldDef); |
| 2443 | 2443 | $colType = $this->getColumnType($type); |
| 2444 | 2444 | |
| 2445 | - if($parts = $this->getTypeParts($colType)) |
|
| 2445 | + if ($parts = $this->getTypeParts($colType)) |
|
| 2446 | 2446 | { |
| 2447 | 2447 | $colBaseType = $parts['baseType']; |
| 2448 | - $defLen = isset($parts['len']) ? $parts['len'] : '255'; // Use the mappings length (precision) as default if it exists |
|
| 2448 | + $defLen = isset($parts['len']) ? $parts['len'] : '255'; // Use the mappings length (precision) as default if it exists |
|
| 2449 | 2449 | } |
| 2450 | 2450 | |
| 2451 | - if(!empty($fieldDef['len'])) { |
|
| 2452 | - if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char', |
|
| 2451 | + if (!empty($fieldDef['len'])) { |
|
| 2452 | + if (in_array($colBaseType, array('nvarchar', 'nchar', 'varchar', 'varchar2', 'char', |
|
| 2453 | 2453 | 'clob', 'blob', 'text'))) { |
| 2454 | 2454 | $colType = "$colBaseType(${fieldDef['len']})"; |
| 2455 | - } elseif(($colBaseType == 'decimal' || $colBaseType == 'float')){ |
|
| 2456 | - if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) |
|
| 2457 | - if(strpos($fieldDef['len'],',') === false){ |
|
| 2458 | - $colType = $colBaseType . "(".$fieldDef['len'].",".$fieldDef['precision'].")"; |
|
| 2459 | - }else{ |
|
| 2460 | - $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2455 | + } elseif (($colBaseType == 'decimal' || $colBaseType == 'float')) { |
|
| 2456 | + if (!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) |
|
| 2457 | + if (strpos($fieldDef['len'], ',') === false) { |
|
| 2458 | + $colType = $colBaseType."(".$fieldDef['len'].",".$fieldDef['precision'].")"; |
|
| 2459 | + } else { |
|
| 2460 | + $colType = $colBaseType."(".$fieldDef['len'].")"; |
|
| 2461 | 2461 | } |
| 2462 | 2462 | else |
| 2463 | - $colType = $colBaseType . "(".$fieldDef['len'].")"; |
|
| 2463 | + $colType = $colBaseType."(".$fieldDef['len'].")"; |
|
| 2464 | 2464 | } |
| 2465 | 2465 | } else { |
| 2466 | - if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) { |
|
| 2466 | + if (in_array($colBaseType, array('nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) { |
|
| 2467 | 2467 | $colType = "$colBaseType($defLen)"; |
| 2468 | 2468 | } |
| 2469 | 2469 | } |
@@ -2485,29 +2485,29 @@ discard block |
||
| 2485 | 2485 | } |
| 2486 | 2486 | |
| 2487 | 2487 | $auto_increment = ''; |
| 2488 | - if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) |
|
| 2489 | - $auto_increment = $this->setAutoIncrement($table , $fieldDef['name']); |
|
| 2488 | + if (!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) |
|
| 2489 | + $auto_increment = $this->setAutoIncrement($table, $fieldDef['name']); |
|
| 2490 | 2490 | |
| 2491 | - $required = 'NULL'; // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify |
|
| 2491 | + $required = 'NULL'; // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify |
|
| 2492 | 2492 | //Starting in 6.0, only ID and auto_increment fields will be NOT NULL in the DB. |
| 2493 | 2493 | if ((empty($fieldDef['isnull']) || strtolower($fieldDef['isnull']) == 'false') && |
| 2494 | 2494 | (!empty($auto_increment) || $name == 'id' || ($fieldDef['type'] == 'id' && !empty($fieldDef['required'])))) { |
| 2495 | - $required = "NOT NULL"; |
|
| 2495 | + $required = "NOT NULL"; |
|
| 2496 | 2496 | } |
| 2497 | 2497 | // If the field is marked both required & isnull=>false - alwqys make it not null |
| 2498 | 2498 | // Use this to ensure primary key fields never defined as null |
| 2499 | - if(isset($fieldDef['isnull']) && (strtolower($fieldDef['isnull']) == 'false' || $fieldDef['isnull'] === false) |
|
| 2499 | + if (isset($fieldDef['isnull']) && (strtolower($fieldDef['isnull']) == 'false' || $fieldDef['isnull'] === false) |
|
| 2500 | 2500 | && !empty($fieldDef['required'])) { |
| 2501 | - $required = "NOT NULL"; |
|
| 2501 | + $required = "NOT NULL"; |
|
| 2502 | 2502 | } |
| 2503 | 2503 | if ($ignoreRequired) |
| 2504 | 2504 | $required = ""; |
| 2505 | 2505 | |
| 2506 | - if ( $return_as_array ) { |
|
| 2506 | + if ($return_as_array) { |
|
| 2507 | 2507 | return array( |
| 2508 | 2508 | 'name' => $name, |
| 2509 | 2509 | 'colType' => $colType, |
| 2510 | - 'colBaseType' => $colBaseType, // Adding base type for easier processing in derived classes |
|
| 2510 | + 'colBaseType' => $colBaseType, // Adding base type for easier processing in derived classes |
|
| 2511 | 2511 | 'default' => $default, |
| 2512 | 2512 | 'required' => $required, |
| 2513 | 2513 | 'auto_increment' => $auto_increment, |
@@ -2532,14 +2532,14 @@ discard block |
||
| 2532 | 2532 | |
| 2533 | 2533 | if ($this->isFieldArray($fieldDefs)) { |
| 2534 | 2534 | foreach ($fieldDefs as $fieldDef) { |
| 2535 | - if(!isset($fieldDef['source']) || $fieldDef['source'] == 'db') { |
|
| 2536 | - $columns[] = $this->oneColumnSQLRep($fieldDef,false, $tablename); |
|
| 2535 | + if (!isset($fieldDef['source']) || $fieldDef['source'] == 'db') { |
|
| 2536 | + $columns[] = $this->oneColumnSQLRep($fieldDef, false, $tablename); |
|
| 2537 | 2537 | } |
| 2538 | 2538 | } |
| 2539 | 2539 | $columns = implode(",", $columns); |
| 2540 | 2540 | } |
| 2541 | 2541 | else { |
| 2542 | - $columns = $this->oneColumnSQLRep($fieldDefs,$ignoreRequired, $tablename); |
|
| 2542 | + $columns = $this->oneColumnSQLRep($fieldDefs, $ignoreRequired, $tablename); |
|
| 2543 | 2543 | } |
| 2544 | 2544 | |
| 2545 | 2545 | return $columns; |
@@ -2701,40 +2701,40 @@ discard block |
||
| 2701 | 2701 | */ |
| 2702 | 2702 | public function getValidDBName($name, $ensureUnique = false, $type = 'column', $force = false) |
| 2703 | 2703 | { |
| 2704 | - if(is_array($name)) { |
|
| 2704 | + if (is_array($name)) { |
|
| 2705 | 2705 | $result = array(); |
| 2706 | - foreach($name as $field) { |
|
| 2706 | + foreach ($name as $field) { |
|
| 2707 | 2707 | $result[] = $this->getValidDBName($field, $ensureUnique, $type); |
| 2708 | 2708 | } |
| 2709 | 2709 | return $result; |
| 2710 | 2710 | } else { |
| 2711 | - if(strchr($name, ".")) { |
|
| 2711 | + if (strchr($name, ".")) { |
|
| 2712 | 2712 | // this is a compound name with dots, handle separately |
| 2713 | 2713 | $parts = explode(".", $name); |
| 2714 | - if(count($parts) > 2) { |
|
| 2714 | + if (count($parts) > 2) { |
|
| 2715 | 2715 | // some weird name, cut to table.name |
| 2716 | - array_splice($parts, 0, count($parts)-2); |
|
| 2716 | + array_splice($parts, 0, count($parts) - 2); |
|
| 2717 | 2717 | } |
| 2718 | 2718 | $parts = $this->getValidDBName($parts, $ensureUnique, $type, $force); |
| 2719 | 2719 | return join(".", $parts); |
| 2720 | 2720 | } |
| 2721 | 2721 | // first strip any invalid characters - all but word chars (which is alphanumeric and _) |
| 2722 | - $name = preg_replace( '/[^\w]+/i', '', $name ) ; |
|
| 2723 | - $len = strlen( $name ) ; |
|
| 2722 | + $name = preg_replace('/[^\w]+/i', '', $name); |
|
| 2723 | + $len = strlen($name); |
|
| 2724 | 2724 | $maxLen = empty($this->maxNameLengths[$type]) ? $this->maxNameLengths[$type]['column'] : $this->maxNameLengths[$type]; |
| 2725 | 2725 | if ($len <= $maxLen && !$force) { |
| 2726 | 2726 | return strtolower($name); |
| 2727 | 2727 | } |
| 2728 | 2728 | if ($ensureUnique) { |
| 2729 | 2729 | $md5str = md5($name); |
| 2730 | - $tail = substr ( $name, -11) ; |
|
| 2731 | - $temp = substr($md5str , strlen($md5str)-4 ); |
|
| 2732 | - $result = substr( $name, 0, 10) . $temp . $tail ; |
|
| 2730 | + $tail = substr($name, -11); |
|
| 2731 | + $temp = substr($md5str, strlen($md5str) - 4); |
|
| 2732 | + $result = substr($name, 0, 10).$temp.$tail; |
|
| 2733 | 2733 | } else { |
| 2734 | - $result = substr( $name, 0, 11) . substr( $name, 11 - $maxLen); |
|
| 2734 | + $result = substr($name, 0, 11).substr($name, 11 - $maxLen); |
|
| 2735 | 2735 | } |
| 2736 | 2736 | |
| 2737 | - return strtolower( $result ) ; |
|
| 2737 | + return strtolower($result); |
|
| 2738 | 2738 | } |
| 2739 | 2739 | } |
| 2740 | 2740 | |
@@ -2746,7 +2746,7 @@ discard block |
||
| 2746 | 2746 | */ |
| 2747 | 2747 | public function getColumnType($type) |
| 2748 | 2748 | { |
| 2749 | - return isset($this->type_map[$type])?$this->type_map[$type]:$type; |
|
| 2749 | + return isset($this->type_map[$type]) ? $this->type_map[$type] : $type; |
|
| 2750 | 2750 | } |
| 2751 | 2751 | |
| 2752 | 2752 | /** |
@@ -2760,10 +2760,10 @@ discard block |
||
| 2760 | 2760 | */ |
| 2761 | 2761 | public function isFieldArray($defArray) |
| 2762 | 2762 | { |
| 2763 | - if ( !is_array($defArray) ) |
|
| 2763 | + if (!is_array($defArray)) |
|
| 2764 | 2764 | return false; |
| 2765 | 2765 | |
| 2766 | - if ( isset($defArray['type']) ){ |
|
| 2766 | + if (isset($defArray['type'])) { |
|
| 2767 | 2767 | // type key exists. May be an array of defs or a simple definition |
| 2768 | 2768 | return is_array($defArray['type']); // type is not an array => definition else array |
| 2769 | 2769 | } |
@@ -2798,19 +2798,19 @@ discard block |
||
| 2798 | 2798 | require('metadata/audit_templateMetaData.php'); |
| 2799 | 2799 | $fieldDefs = $dictionary['audit']['fields']; |
| 2800 | 2800 | |
| 2801 | - $values=array(); |
|
| 2801 | + $values = array(); |
|
| 2802 | 2802 | $values['id'] = $this->massageValue(create_guid(), $fieldDefs['id']); |
| 2803 | - $values['parent_id']= $this->massageValue($bean->id, $fieldDefs['parent_id']); |
|
| 2804 | - $values['field_name']= $this->massageValue($changes['field_name'], $fieldDefs['field_name']); |
|
| 2803 | + $values['parent_id'] = $this->massageValue($bean->id, $fieldDefs['parent_id']); |
|
| 2804 | + $values['field_name'] = $this->massageValue($changes['field_name'], $fieldDefs['field_name']); |
|
| 2805 | 2805 | $values['data_type'] = $this->massageValue($changes['data_type'], $fieldDefs['data_type']); |
| 2806 | - if ($changes['data_type']=='text') { |
|
| 2806 | + if ($changes['data_type'] == 'text') { |
|
| 2807 | 2807 | $values['before_value_text'] = $this->massageValue($changes['before'], $fieldDefs['before_value_text']); |
| 2808 | 2808 | $values['after_value_text'] = $this->massageValue($changes['after'], $fieldDefs['after_value_text']); |
| 2809 | 2809 | } else { |
| 2810 | 2810 | $values['before_value_string'] = $this->massageValue($changes['before'], $fieldDefs['before_value_string']); |
| 2811 | 2811 | $values['after_value_string'] = $this->massageValue($changes['after'], $fieldDefs['after_value_string']); |
| 2812 | 2812 | } |
| 2813 | - $values['date_created'] = $this->massageValue(TimeDate::getInstance()->nowDb(), $fieldDefs['date_created'] ); |
|
| 2813 | + $values['date_created'] = $this->massageValue(TimeDate::getInstance()->nowDb(), $fieldDefs['date_created']); |
|
| 2814 | 2814 | $values['created_by'] = $this->massageValue($current_user->id, $fieldDefs['created_by']); |
| 2815 | 2815 | |
| 2816 | 2816 | $sql .= "(".implode(",", array_keys($values)).") "; |
@@ -2840,9 +2840,9 @@ discard block |
||
| 2840 | 2840 | * @param array|null $field_filter Array of filter names to be inspected (NULL means all fields) |
| 2841 | 2841 | * @return array |
| 2842 | 2842 | */ |
| 2843 | - public function getDataChanges(SugarBean &$bean, array $field_filter = null) |
|
| 2843 | + public function getDataChanges(SugarBean & $bean, array $field_filter = null) |
|
| 2844 | 2844 | { |
| 2845 | - $changed_values=array(); |
|
| 2845 | + $changed_values = array(); |
|
| 2846 | 2846 | |
| 2847 | 2847 | $fetched_row = array(); |
| 2848 | 2848 | if (is_array($bean->fetched_row)) |
@@ -2862,40 +2862,40 @@ discard block |
||
| 2862 | 2862 | $field_defs = array_intersect_key($field_defs, $fetched_row); |
| 2863 | 2863 | |
| 2864 | 2864 | // remove fields which do not exist as bean property |
| 2865 | - $field_defs = array_intersect_key($field_defs, (array) $bean); |
|
| 2865 | + $field_defs = array_intersect_key($field_defs, (array)$bean); |
|
| 2866 | 2866 | |
| 2867 | 2867 | foreach ($field_defs as $field => $properties) { |
| 2868 | 2868 | $before_value = $fetched_row[$field]; |
| 2869 | - $after_value=$bean->$field; |
|
| 2869 | + $after_value = $bean->$field; |
|
| 2870 | 2870 | if (isset($properties['type'])) { |
| 2871 | - $field_type=$properties['type']; |
|
| 2871 | + $field_type = $properties['type']; |
|
| 2872 | 2872 | } else { |
| 2873 | 2873 | if (isset($properties['dbType'])) { |
| 2874 | - $field_type=$properties['dbType']; |
|
| 2874 | + $field_type = $properties['dbType']; |
|
| 2875 | 2875 | } |
| 2876 | - else if(isset($properties['data_type'])) { |
|
| 2877 | - $field_type=$properties['data_type']; |
|
| 2876 | + else if (isset($properties['data_type'])) { |
|
| 2877 | + $field_type = $properties['data_type']; |
|
| 2878 | 2878 | } |
| 2879 | 2879 | else { |
| 2880 | - $field_type=$properties['dbtype']; |
|
| 2880 | + $field_type = $properties['dbtype']; |
|
| 2881 | 2881 | } |
| 2882 | 2882 | } |
| 2883 | 2883 | |
| 2884 | 2884 | //Because of bug #25078(sqlserver haven't 'date' type, trim extra "00:00:00" when insert into *_cstm table). |
| 2885 | 2885 | // so when we read the audit datetime field from sqlserver, we have to replace the extra "00:00:00" again. |
| 2886 | - if(!empty($field_type) && $field_type == 'date'){ |
|
| 2887 | - $before_value = $this->fromConvert($before_value , $field_type); |
|
| 2886 | + if (!empty($field_type) && $field_type == 'date') { |
|
| 2887 | + $before_value = $this->fromConvert($before_value, $field_type); |
|
| 2888 | 2888 | } |
| 2889 | 2889 | //if the type and values match, do nothing. |
| 2890 | - if (!($this->_emptyValue($before_value,$field_type) && $this->_emptyValue($after_value,$field_type))) { |
|
| 2890 | + if (!($this->_emptyValue($before_value, $field_type) && $this->_emptyValue($after_value, $field_type))) { |
|
| 2891 | 2891 | $change = false; |
| 2892 | 2892 | if (trim($before_value) !== trim($after_value)) { |
| 2893 | 2893 | // Bug #42475: Don't directly compare numeric values, instead do the subtract and see if the comparison comes out to be "close enough", it is necessary for floating point numbers. |
| 2894 | 2894 | // Manual merge of fix 95727f2eed44852f1b6bce9a9eccbe065fe6249f from DBHelper |
| 2895 | 2895 | // This fix also fixes Bug #44624 in a more generic way and therefore eliminates the need for fix 0a55125b281c4bee87eb347709af462715f33d2d in DBHelper |
| 2896 | 2896 | if ($this->isNumericType($field_type)) { |
| 2897 | - $numerator = abs(2*((trim($before_value)+0)-(trim($after_value)+0))); |
|
| 2898 | - $denominator = abs(((trim($before_value)+0)+(trim($after_value)+0))); |
|
| 2897 | + $numerator = abs(2 * ((trim($before_value) + 0) - (trim($after_value) + 0))); |
|
| 2898 | + $denominator = abs(((trim($before_value) + 0) + (trim($after_value) + 0))); |
|
| 2899 | 2899 | // detect whether to use absolute or relative error. use absolute if denominator is zero to avoid division by zero |
| 2900 | 2900 | $error = ($denominator == 0) ? $numerator : $numerator / $denominator; |
| 2901 | 2901 | if ($error >= 0.0000000001) { // Smaller than 10E-10 |
@@ -2911,7 +2911,7 @@ discard block |
||
| 2911 | 2911 | $change = true; |
| 2912 | 2912 | } |
| 2913 | 2913 | if ($change) { |
| 2914 | - $changed_values[$field]=array('field_name'=>$field, |
|
| 2914 | + $changed_values[$field] = array('field_name'=>$field, |
|
| 2915 | 2915 | 'data_type'=>$field_type, |
| 2916 | 2916 | 'before'=>$before_value, |
| 2917 | 2917 | 'after'=>$after_value); |
@@ -2982,8 +2982,8 @@ discard block |
||
| 2982 | 2982 | */ |
| 2983 | 2983 | public function renameIndexDefs($old_definition, $new_definition, $table_name) |
| 2984 | 2984 | { |
| 2985 | - return array($this->add_drop_constraint($table_name,$old_definition,true), |
|
| 2986 | - $this->add_drop_constraint($table_name,$new_definition), false); |
|
| 2985 | + return array($this->add_drop_constraint($table_name, $old_definition, true), |
|
| 2986 | + $this->add_drop_constraint($table_name, $new_definition), false); |
|
| 2987 | 2987 | } |
| 2988 | 2988 | |
| 2989 | 2989 | /** |
@@ -3005,7 +3005,7 @@ discard block |
||
| 3005 | 3005 | protected function _getBooleanValue($val) |
| 3006 | 3006 | { |
| 3007 | 3007 | //need to put the === sign here otherwise true == 'non empty string' |
| 3008 | - if (empty($val) or $val==='off') |
|
| 3008 | + if (empty($val) or $val === 'off') |
|
| 3009 | 3009 | return false; |
| 3010 | 3010 | |
| 3011 | 3011 | return true; |
@@ -3018,7 +3018,7 @@ discard block |
||
| 3018 | 3018 | */ |
| 3019 | 3019 | public function isNumericType($type) |
| 3020 | 3020 | { |
| 3021 | - if(isset($this->type_class[$type]) && ($this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3021 | + if (isset($this->type_class[$type]) && ($this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3022 | 3022 | return true; |
| 3023 | 3023 | } |
| 3024 | 3024 | return false; |
@@ -3035,7 +3035,7 @@ discard block |
||
| 3035 | 3035 | if (empty($val)) |
| 3036 | 3036 | return true; |
| 3037 | 3037 | |
| 3038 | - if($this->emptyValue($type) == $val) { |
|
| 3038 | + if ($this->emptyValue($type) == $val) { |
|
| 3039 | 3039 | return true; |
| 3040 | 3040 | } |
| 3041 | 3041 | switch ($type) { |
@@ -3094,7 +3094,7 @@ discard block |
||
| 3094 | 3094 | $i = 0; |
| 3095 | 3095 | $order_by_arr = array(); |
| 3096 | 3096 | foreach ($values as $key => $value) { |
| 3097 | - if($key == '') { |
|
| 3097 | + if ($key == '') { |
|
| 3098 | 3098 | $order_by_arr[] = "WHEN ($order_by='' OR $order_by IS NULL) THEN $i"; |
| 3099 | 3099 | } else { |
| 3100 | 3100 | $order_by_arr[] = "WHEN $order_by=".$this->quoted($key)." THEN $i"; |
@@ -3112,7 +3112,7 @@ discard block |
||
| 3112 | 3112 | */ |
| 3113 | 3113 | public function emptyValue($type) |
| 3114 | 3114 | { |
| 3115 | - if(isset($this->type_class[$type]) && ($this->type_class[$type] == 'bool' || $this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3115 | + if (isset($this->type_class[$type]) && ($this->type_class[$type] == 'bool' || $this->type_class[$type] == 'int' || $this->type_class[$type] == 'float')) { |
|
| 3116 | 3116 | return 0; |
| 3117 | 3117 | } |
| 3118 | 3118 | |
@@ -3161,9 +3161,9 @@ discard block |
||
| 3161 | 3161 | * @return resource|bool query result |
| 3162 | 3162 | * @see DBManager::limitQuery() |
| 3163 | 3163 | */ |
| 3164 | - public function limitQuerySql($sql, $start, $count, $dieOnError=false, $msg='') |
|
| 3164 | + public function limitQuerySql($sql, $start, $count, $dieOnError = false, $msg = '') |
|
| 3165 | 3165 | { |
| 3166 | - return $this->limitQuery($sql,$start,$count,$dieOnError,$msg,false); |
|
| 3166 | + return $this->limitQuery($sql, $start, $count, $dieOnError, $msg, false); |
|
| 3167 | 3167 | } |
| 3168 | 3168 | |
| 3169 | 3169 | /** |
@@ -3182,7 +3182,7 @@ discard block |
||
| 3182 | 3182 | */ |
| 3183 | 3183 | public function checkPrivilege($privilege) |
| 3184 | 3184 | { |
| 3185 | - switch($privilege) { |
|
| 3185 | + switch ($privilege) { |
|
| 3186 | 3186 | case "CREATE TABLE": |
| 3187 | 3187 | $this->query("CREATE TABLE temp (id varchar(36))"); |
| 3188 | 3188 | break; |
@@ -3203,23 +3203,23 @@ discard block |
||
| 3203 | 3203 | break; |
| 3204 | 3204 | case "ADD COLUMN": |
| 3205 | 3205 | $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 50)); |
| 3206 | - $sql = $this->changeColumnSQL("temp", $test, "add"); |
|
| 3206 | + $sql = $this->changeColumnSQL("temp", $test, "add"); |
|
| 3207 | 3207 | $this->query($sql); |
| 3208 | 3208 | break; |
| 3209 | 3209 | case "CHANGE COLUMN": |
| 3210 | 3210 | $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 100)); |
| 3211 | - $sql = $this->changeColumnSQL("temp", $test, "modify"); |
|
| 3211 | + $sql = $this->changeColumnSQL("temp", $test, "modify"); |
|
| 3212 | 3212 | $this->query($sql); |
| 3213 | 3213 | break; |
| 3214 | 3214 | case "DROP COLUMN": |
| 3215 | 3215 | $test = array("test" => array("name" => "test", "type" => "varchar", "len" => 100)); |
| 3216 | - $sql = $this->changeColumnSQL("temp", $test, "drop"); |
|
| 3216 | + $sql = $this->changeColumnSQL("temp", $test, "drop"); |
|
| 3217 | 3217 | $this->query($sql); |
| 3218 | 3218 | break; |
| 3219 | 3219 | default: |
| 3220 | 3220 | return false; |
| 3221 | 3221 | } |
| 3222 | - if($this->checkError("Checking privileges")) { |
|
| 3222 | + if ($this->checkError("Checking privileges")) { |
|
| 3223 | 3223 | return false; |
| 3224 | 3224 | } |
| 3225 | 3225 | return true; |
@@ -3236,7 +3236,7 @@ discard block |
||
| 3236 | 3236 | $select_check = strpos(strtolower($query), strtolower("SELECT")); |
| 3237 | 3237 | //Checks to see if there is union select which is valid |
| 3238 | 3238 | $select_check2 = strpos(strtolower($query), strtolower("(SELECT")); |
| 3239 | - if($select_check==0 || $select_check2==0){ |
|
| 3239 | + if ($select_check == 0 || $select_check2 == 0) { |
|
| 3240 | 3240 | //Returning false means query is ok! |
| 3241 | 3241 | return true; |
| 3242 | 3242 | } |
@@ -3255,10 +3255,10 @@ discard block |
||
| 3255 | 3255 | public function parseFulltextQuery($query) |
| 3256 | 3256 | { |
| 3257 | 3257 | /* split on space or comma, double quotes with \ for escape */ |
| 3258 | - if(strpbrk($query, " ,")) { |
|
| 3258 | + if (strpbrk($query, " ,")) { |
|
| 3259 | 3259 | // ("([^"]*?)"|[^" ,]+)((, )+)? |
| 3260 | 3260 | // '/([^" ,]+|".*?[^\\\\]")(,|\s)\s*/' |
| 3261 | - if(!preg_match_all('/("([^"]*?)"|[^"\s,]+)((,\s)+)?/', $query, $m)) { |
|
| 3261 | + if (!preg_match_all('/("([^"]*?)"|[^"\s,]+)((,\s)+)?/', $query, $m)) { |
|
| 3262 | 3262 | return false; |
| 3263 | 3263 | } |
| 3264 | 3264 | $qterms = $m[1]; |
@@ -3266,17 +3266,17 @@ discard block |
||
| 3266 | 3266 | $qterms = array($query); |
| 3267 | 3267 | } |
| 3268 | 3268 | $terms = $must_terms = $not_terms = array(); |
| 3269 | - foreach($qterms as $item) { |
|
| 3270 | - if($item[0] == '"') { |
|
| 3269 | + foreach ($qterms as $item) { |
|
| 3270 | + if ($item[0] == '"') { |
|
| 3271 | 3271 | $item = trim($item, '"'); |
| 3272 | 3272 | } |
| 3273 | - if($item[0] == '+') { |
|
| 3273 | + if ($item[0] == '+') { |
|
| 3274 | 3274 | if (strlen($item) > 1) { |
| 3275 | 3275 | $must_terms[] = substr($item, 1); |
| 3276 | 3276 | } |
| 3277 | 3277 | continue; |
| 3278 | 3278 | } |
| 3279 | - if($item[0] == '-') { |
|
| 3279 | + if ($item[0] == '-') { |
|
| 3280 | 3280 | if (strlen($item) > 1) { |
| 3281 | 3281 | $not_terms[] = substr($item, 1); |
| 3282 | 3282 | } |
@@ -3325,11 +3325,11 @@ discard block |
||
| 3325 | 3325 | public function verifySQLStatement($query, $skipTables) |
| 3326 | 3326 | { |
| 3327 | 3327 | $query = trim($query); |
| 3328 | - foreach($this->standardQueries as $qstart => $check) { |
|
| 3329 | - if(strncasecmp($qstart, $query, strlen($qstart)) == 0) { |
|
| 3330 | - if(is_callable(array($this, $check))) { |
|
| 3328 | + foreach ($this->standardQueries as $qstart => $check) { |
|
| 3329 | + if (strncasecmp($qstart, $query, strlen($qstart)) == 0) { |
|
| 3330 | + if (is_callable(array($this, $check))) { |
|
| 3331 | 3331 | $table = $this->extractTableName($query); |
| 3332 | - if(!in_array($table, $skipTables)) { |
|
| 3332 | + if (!in_array($table, $skipTables)) { |
|
| 3333 | 3333 | return call_user_func(array($this, $check), $table, $query); |
| 3334 | 3334 | } else { |
| 3335 | 3335 | $this->log->debug("Skipping table $table as blacklisted"); |
@@ -3358,20 +3358,20 @@ discard block |
||
| 3358 | 3358 | $tempname = $table."__uw_temp"; |
| 3359 | 3359 | $tempTableQuery = str_replace("CREATE TABLE {$table}", "CREATE TABLE $tempname", $query); |
| 3360 | 3360 | |
| 3361 | - if(strpos($tempTableQuery, '__uw_temp') === false) { |
|
| 3361 | + if (strpos($tempTableQuery, '__uw_temp') === false) { |
|
| 3362 | 3362 | return 'Could not use a temp table to test query!'; |
| 3363 | 3363 | } |
| 3364 | 3364 | |
| 3365 | 3365 | $this->query($tempTableQuery, false, "Preflight Failed for: {$query}"); |
| 3366 | 3366 | |
| 3367 | 3367 | $error = $this->lastError(); // empty on no-errors |
| 3368 | - if(!empty($error)) { |
|
| 3368 | + if (!empty($error)) { |
|
| 3369 | 3369 | return $error; |
| 3370 | 3370 | } |
| 3371 | 3371 | |
| 3372 | 3372 | // check if table exists |
| 3373 | 3373 | $this->log->debug('testing for table: '.$table); |
| 3374 | - if(!$this->tableExists($tempname)) { |
|
| 3374 | + if (!$this->tableExists($tempname)) { |
|
| 3375 | 3375 | return "Failed to create temp table!"; |
| 3376 | 3376 | } |
| 3377 | 3377 | |
@@ -3390,8 +3390,8 @@ discard block |
||
| 3390 | 3390 | public function queryArray(array $sqls, $dieOnError = false, $msg = '', $suppress = false) |
| 3391 | 3391 | { |
| 3392 | 3392 | $last = true; |
| 3393 | - foreach($sqls as $sql) { |
|
| 3394 | - if(!($last = $this->query($sql, $dieOnError, $msg, $suppress))) { |
|
| 3393 | + foreach ($sqls as $sql) { |
|
| 3394 | + if (!($last = $this->query($sql, $dieOnError, $msg, $suppress))) { |
|
| 3395 | 3395 | break; |
| 3396 | 3396 | } |
| 3397 | 3397 | } |
@@ -3409,7 +3409,7 @@ discard block |
||
| 3409 | 3409 | { |
| 3410 | 3410 | if (empty($result)) return false; |
| 3411 | 3411 | |
| 3412 | - if(is_int($encode) && func_num_args() == 3) { |
|
| 3412 | + if (is_int($encode) && func_num_args() == 3) { |
|
| 3413 | 3413 | // old API: $result, $rowNum, $encode |
| 3414 | 3414 | $GLOBALS['log']->deprecated("Using row number in fetchByAssoc is not portable and no longer supported. Please fix your code."); |
| 3415 | 3415 | $encode = func_get_arg(2); |
@@ -3460,7 +3460,7 @@ discard block |
||
| 3460 | 3460 | */ |
| 3461 | 3461 | public function getOption($option) |
| 3462 | 3462 | { |
| 3463 | - if(isset($this->options[$option])) { |
|
| 3463 | + if (isset($this->options[$option])) { |
|
| 3464 | 3464 | return $this->options[$option]; |
| 3465 | 3465 | } |
| 3466 | 3466 | return null; |
@@ -3500,7 +3500,7 @@ discard block |
||
| 3500 | 3500 | public function isDatabaseNameValid($name) |
| 3501 | 3501 | { |
| 3502 | 3502 | // Generic case - no slashes, no dots |
| 3503 | - return preg_match('#[/.\\\\]#', $name)==0; |
|
| 3503 | + return preg_match('#[/.\\\\]#', $name) == 0; |
|
| 3504 | 3504 | } |
| 3505 | 3505 | |
| 3506 | 3506 | /** |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
| 83 | 83 | */ |
| 84 | - public function SugarEmailAddress(){ |
|
| 84 | + public function SugarEmailAddress() { |
|
| 85 | 85 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
| 86 | - if(isset($GLOBALS['log'])) { |
|
| 86 | + if (isset($GLOBALS['log'])) { |
|
| 87 | 87 | $GLOBALS['log']->deprecated($deprecatedMessage); |
| 88 | 88 | } |
| 89 | 89 | else { |
@@ -99,16 +99,16 @@ discard block |
||
| 99 | 99 | * @param string $module |
| 100 | 100 | */ |
| 101 | 101 | function handleLegacySave($bean, $prefix = "") { |
| 102 | - if(!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) { |
|
| 102 | + if (!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) { |
|
| 103 | 103 | if (empty($this->addresses) || !isset($_REQUEST['massupdate'])) { |
| 104 | 104 | $this->addresses = array(); |
| 105 | 105 | $optOut = (isset($bean->email_opt_out) && $bean->email_opt_out == "1") ? true : false; |
| 106 | 106 | $invalid = (isset($bean->invalid_email) && $bean->invalid_email == "1") ? true : false; |
| 107 | 107 | |
| 108 | 108 | $isPrimary = true; |
| 109 | - for($i = 1; $i <= 10; $i++){ |
|
| 109 | + for ($i = 1; $i <= 10; $i++) { |
|
| 110 | 110 | $email = 'email'.$i; |
| 111 | - if(isset($bean->$email) && !empty($bean->$email)){ |
|
| 111 | + if (isset($bean->$email) && !empty($bean->$email)) { |
|
| 112 | 112 | $opt_out_field = $email.'_opt_out'; |
| 113 | 113 | $invalid_field = $email.'_invalid'; |
| 114 | 114 | $field_optOut = (isset($bean->$opt_out_field)) ? $bean->$opt_out_field : $optOut; |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | - $this->populateAddresses($bean->id, $bean->module_dir, array(),''); |
|
| 123 | - if(isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) { |
|
| 122 | + $this->populateAddresses($bean->id, $bean->module_dir, array(), ''); |
|
| 123 | + if (isset($_REQUEST) && isset($_REQUEST['useEmailWidget'])) { |
|
| 124 | 124 | $this->populateLegacyFields($bean); |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - function populateLegacyFields(&$bean){ |
|
| 145 | + function populateLegacyFields(&$bean) { |
|
| 146 | 146 | $primary_found = false; |
| 147 | 147 | $alternate_found = false; |
| 148 | 148 | $alternate2_found = false; |
| 149 | - foreach($this->addresses as $k=>$address) { |
|
| 149 | + foreach ($this->addresses as $k=>$address) { |
|
| 150 | 150 | if ($primary_found && $alternate_found) |
| 151 | 151 | break; |
| 152 | 152 | if ($address['primary_address'] == 1 && !$primary_found) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | } elseif (!$alternate_found) { |
| 156 | 156 | $alternate_index = $k; |
| 157 | 157 | $alternate_found = true; |
| 158 | - } elseif (!$alternate2_found){ |
|
| 158 | + } elseif (!$alternate2_found) { |
|
| 159 | 159 | $alternate2_index = $k; |
| 160 | 160 | $alternate2_found = true; |
| 161 | 161 | } |
@@ -192,27 +192,27 @@ discard block |
||
| 192 | 192 | $args = func_get_args(); |
| 193 | 193 | return call_user_func_array(array($this, '_save'), $args); |
| 194 | 194 | } |
| 195 | - private function _save($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='', $in_workflow=false) { |
|
| 196 | - if(empty($this->addresses) || $in_workflow){ |
|
| 197 | - $this->populateAddresses($id, $module, $new_addrs,$primary); |
|
| 195 | + private function _save($id, $module, $new_addrs = array(), $primary = '', $replyTo = '', $invalid = '', $optOut = '', $in_workflow = false) { |
|
| 196 | + if (empty($this->addresses) || $in_workflow) { |
|
| 197 | + $this->populateAddresses($id, $module, $new_addrs, $primary); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | //find all email addresses.. |
| 201 | - $current_links=array(); |
|
| 201 | + $current_links = array(); |
|
| 202 | 202 | // Need to correct this to handle the Employee/User split |
| 203 | 203 | $module = $this->getCorrectedModule($module); |
| 204 | - $q2="select * from email_addr_bean_rel eabr WHERE eabr.bean_id = '".$this->db->quote($id)."' AND eabr.bean_module = '".$this->db->quote($module)."' and eabr.deleted=0"; |
|
| 204 | + $q2 = "select * from email_addr_bean_rel eabr WHERE eabr.bean_id = '".$this->db->quote($id)."' AND eabr.bean_module = '".$this->db->quote($module)."' and eabr.deleted=0"; |
|
| 205 | 205 | $r2 = $this->db->query($q2); |
| 206 | - while(($row2=$this->db->fetchByAssoc($r2)) != null ) { |
|
| 207 | - $current_links[$row2['email_address_id']]=$row2; |
|
| 206 | + while (($row2 = $this->db->fetchByAssoc($r2)) != null) { |
|
| 207 | + $current_links[$row2['email_address_id']] = $row2; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | $isConversion = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? true : false; |
| 211 | 211 | |
| 212 | 212 | if (!empty($this->addresses)) { |
| 213 | 213 | // insert new relationships and create email address record, if they don't exist |
| 214 | - foreach($this->addresses as $address) { |
|
| 215 | - if(!empty($address['email_address'])) { |
|
| 214 | + foreach ($this->addresses as $address) { |
|
| 215 | + if (!empty($address['email_address'])) { |
|
| 216 | 216 | $guid = create_guid(); |
| 217 | 217 | $emailId = isset($address['email_address_id']) |
| 218 | 218 | && isset($current_links[$address['email_address_id']]) |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | $emailId = $this->AddUpdateEmailAddress($address['email_address'], |
| 221 | 221 | $address['invalid_email'], |
| 222 | 222 | $address['opt_out'], |
| 223 | - $emailId);// this will save the email address if not found |
|
| 223 | + $emailId); // this will save the email address if not found |
|
| 224 | 224 | |
| 225 | 225 | //verify linkage and flags. |
| 226 | - $upd_eabr=""; |
|
| 226 | + $upd_eabr = ""; |
|
| 227 | 227 | if (isset($current_links[$emailId])) { |
| 228 | 228 | if (!$isConversion) { // do not update anything if this is for lead conversion |
| 229 | - if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address'] ) { |
|
| 230 | - $upd_eabr="UPDATE email_addr_bean_rel SET primary_address='".$this->db->quote($address['primary_address'])."', reply_to_address='".$this->db->quote($address['reply_to_address'])."' WHERE id='".$this->db->quote($current_links[$emailId]['id'])."'"; |
|
| 229 | + if ($address['primary_address'] != $current_links[$emailId]['primary_address'] or $address['reply_to_address'] != $current_links[$emailId]['reply_to_address']) { |
|
| 230 | + $upd_eabr = "UPDATE email_addr_bean_rel SET primary_address='".$this->db->quote($address['primary_address'])."', reply_to_address='".$this->db->quote($address['reply_to_address'])."' WHERE id='".$this->db->quote($current_links[$emailId]['id'])."'"; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | unset($current_links[$emailId]); |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | // for lead conversion, do not delete email addresses |
| 259 | 259 | if (!empty($current_links) && !$isConversion) { |
| 260 | 260 | |
| 261 | - $delete=""; |
|
| 261 | + $delete = ""; |
|
| 262 | 262 | foreach ($current_links as $eabr) { |
| 263 | 263 | |
| 264 | - $delete.=empty($delete) ? "'".$this->db->quote($eabr['id']) . "' " : ",'" . $this->db->quote($eabr['id']) . "'"; |
|
| 264 | + $delete .= empty($delete) ? "'".$this->db->quote($eabr['id'])."' " : ",'".$this->db->quote($eabr['id'])."'"; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - $eabr_unlink="update email_addr_bean_rel set deleted=1 where id in ({$delete})"; |
|
| 267 | + $eabr_unlink = "update email_addr_bean_rel set deleted=1 where id in ({$delete})"; |
|
| 268 | 268 | $this->db->query($eabr_unlink); |
| 269 | 269 | } |
| 270 | 270 | $this->stateBeforeWorkflow = null; |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | ) |
| 287 | 287 | { |
| 288 | 288 | $emailCaps = strtoupper(trim($email)); |
| 289 | - if(empty($emailCaps)) |
|
| 289 | + if (empty($emailCaps)) |
|
| 290 | 290 | return 0; |
| 291 | 291 | |
| 292 | 292 | $q = "SELECT * |
@@ -324,10 +324,10 @@ discard block |
||
| 324 | 324 | $r = $this->db->query($q, true); |
| 325 | 325 | |
| 326 | 326 | $retArr = array(); |
| 327 | - while($a = $this->db->fetchByAssoc($r)) { |
|
| 327 | + while ($a = $this->db->fetchByAssoc($r)) { |
|
| 328 | 328 | $retArr[] = $a['bean_id']; |
| 329 | 329 | } |
| 330 | - if(count($retArr) > 0) { |
|
| 330 | + if (count($retArr) > 0) { |
|
| 331 | 331 | return $retArr; |
| 332 | 332 | } else { |
| 333 | 333 | return false; |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | $email = trim($email); |
| 349 | 349 | |
| 350 | - if(empty($email)) { |
|
| 350 | + if (empty($email)) { |
|
| 351 | 351 | return array(); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -356,12 +356,12 @@ discard block |
||
| 356 | 356 | WHERE ea.email_address_caps = $emailCaps and eabl.deleted=0 "; |
| 357 | 357 | $r = $this->db->query($q); |
| 358 | 358 | |
| 359 | - while($a = $this->db->fetchByAssoc($r)) { |
|
| 360 | - if(isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) { |
|
| 359 | + while ($a = $this->db->fetchByAssoc($r)) { |
|
| 360 | + if (isset($beanList[$a['bean_module']]) && !empty($beanList[$a['bean_module']])) { |
|
| 361 | 361 | $className = $beanList[$a['bean_module']]; |
| 362 | 362 | |
| 363 | - if(isset($beanFiles[$className]) && !empty($beanFiles[$className])) { |
|
| 364 | - if(!class_exists($className)) { |
|
| 363 | + if (isset($beanFiles[$className]) && !empty($beanFiles[$className])) { |
|
| 364 | + if (!class_exists($className)) { |
|
| 365 | 365 | require_once($beanFiles[$className]); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @param string $replyTo GUID of reply-to address |
| 390 | 390 | * @param string $invalid GUID of invalid address |
| 391 | 391 | */ |
| 392 | - function populateAddresses($id, $module, $new_addrs=array(), $primary='', $replyTo='', $invalid='', $optOut='') { |
|
| 392 | + function populateAddresses($id, $module, $new_addrs = array(), $primary = '', $replyTo = '', $invalid = '', $optOut = '') { |
|
| 393 | 393 | $module = $this->getCorrectedModule($module); |
| 394 | 394 | //One last check for the ConvertLead action in which case we need to change $module to 'Leads' |
| 395 | 395 | $module = (isset($_REQUEST) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'ConvertLead') ? 'Leads' : $module; |
@@ -400,54 +400,54 @@ discard block |
||
| 400 | 400 | $hasEmailValue = false; |
| 401 | 401 | $email_ids = array(); |
| 402 | 402 | |
| 403 | - if (isset($_REQUEST) && isset($_REQUEST[$module .'_email_widget_id'])) { |
|
| 403 | + if (isset($_REQUEST) && isset($_REQUEST[$module.'_email_widget_id'])) { |
|
| 404 | 404 | |
| 405 | 405 | $fromRequest = false; |
| 406 | 406 | // determine which array to process |
| 407 | - foreach($_REQUEST as $k => $v) { |
|
| 408 | - if(strpos($k, 'emailAddress') !== false) { |
|
| 407 | + foreach ($_REQUEST as $k => $v) { |
|
| 408 | + if (strpos($k, 'emailAddress') !== false) { |
|
| 409 | 409 | $fromRequest = true; |
| 410 | 410 | break; |
| 411 | 411 | } |
| 412 | - $widget_id = $_REQUEST[$module .'_email_widget_id']; |
|
| 412 | + $widget_id = $_REQUEST[$module.'_email_widget_id']; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | //Iterate over the widgets for this module, in case there are multiple email widgets for this module |
| 416 | - while(isset($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount])) |
|
| 416 | + while (isset($_REQUEST[$module.$widget_id."emailAddress".$widgetCount])) |
|
| 417 | 417 | { |
| 418 | - if (empty($_REQUEST[$module . $widget_id . "emailAddress" . $widgetCount])) { |
|
| 418 | + if (empty($_REQUEST[$module.$widget_id."emailAddress".$widgetCount])) { |
|
| 419 | 419 | $widgetCount++; |
| 420 | 420 | continue; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $hasEmailValue = true; |
| 424 | 424 | |
| 425 | - $eId = $module . $widget_id; |
|
| 426 | - if(isset($_REQUEST[$eId . 'emailAddressPrimaryFlag'])) { |
|
| 427 | - $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag']; |
|
| 428 | - } else if(isset($_REQUEST[$module . 'emailAddressPrimaryFlag'])) { |
|
| 429 | - $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag']; |
|
| 425 | + $eId = $module.$widget_id; |
|
| 426 | + if (isset($_REQUEST[$eId.'emailAddressPrimaryFlag'])) { |
|
| 427 | + $primaryValue = $_REQUEST[$eId.'emailAddressPrimaryFlag']; |
|
| 428 | + } else if (isset($_REQUEST[$module.'emailAddressPrimaryFlag'])) { |
|
| 429 | + $primaryValue = $_REQUEST[$module.'emailAddressPrimaryFlag']; |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $optOutValues = array(); |
| 433 | - if(isset($_REQUEST[$eId .'emailAddressOptOutFlag'])) { |
|
| 434 | - $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag']; |
|
| 435 | - } else if(isset($_REQUEST[$module . 'emailAddressOptOutFlag'])) { |
|
| 436 | - $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag']; |
|
| 433 | + if (isset($_REQUEST[$eId.'emailAddressOptOutFlag'])) { |
|
| 434 | + $optOutValues = $_REQUEST[$eId.'emailAddressOptOutFlag']; |
|
| 435 | + } else if (isset($_REQUEST[$module.'emailAddressOptOutFlag'])) { |
|
| 436 | + $optOutValues = $_REQUEST[$module.'emailAddressOptOutFlag']; |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | $invalidValues = array(); |
| 440 | - if(isset($_REQUEST[$eId .'emailAddressInvalidFlag'])) { |
|
| 441 | - $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag']; |
|
| 442 | - } else if(isset($_REQUEST[$module . 'emailAddressInvalidFlag'])) { |
|
| 443 | - $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag']; |
|
| 440 | + if (isset($_REQUEST[$eId.'emailAddressInvalidFlag'])) { |
|
| 441 | + $invalidValues = $_REQUEST[$eId.'emailAddressInvalidFlag']; |
|
| 442 | + } else if (isset($_REQUEST[$module.'emailAddressInvalidFlag'])) { |
|
| 443 | + $invalidValues = $_REQUEST[$module.'emailAddressInvalidFlag']; |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | $deleteValues = array(); |
| 447 | - if(isset($_REQUEST[$eId .'emailAddressDeleteFlag'])) { |
|
| 448 | - $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag']; |
|
| 449 | - } else if(isset($_REQUEST[$module . 'emailAddressDeleteFlag'])) { |
|
| 450 | - $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag']; |
|
| 447 | + if (isset($_REQUEST[$eId.'emailAddressDeleteFlag'])) { |
|
| 448 | + $deleteValues = $_REQUEST[$eId.'emailAddressDeleteFlag']; |
|
| 449 | + } else if (isset($_REQUEST[$module.'emailAddressDeleteFlag'])) { |
|
| 450 | + $deleteValues = $_REQUEST[$module.'emailAddressDeleteFlag']; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | // prep from form save |
@@ -455,36 +455,36 @@ discard block |
||
| 455 | 455 | $replyToField = ''; |
| 456 | 456 | $invalidField = ''; |
| 457 | 457 | $optOutField = ''; |
| 458 | - if($fromRequest && empty($primary) && isset($primaryValue)) { |
|
| 458 | + if ($fromRequest && empty($primary) && isset($primaryValue)) { |
|
| 459 | 459 | $primaryField = $primaryValue; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - if($fromRequest && empty($replyTo)) { |
|
| 463 | - if(isset($_REQUEST[$eId .'emailAddressReplyToFlag'])) { |
|
| 464 | - $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag']; |
|
| 465 | - } else if(isset($_REQUEST[$module . 'emailAddressReplyToFlag'])) { |
|
| 466 | - $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag']; |
|
| 462 | + if ($fromRequest && empty($replyTo)) { |
|
| 463 | + if (isset($_REQUEST[$eId.'emailAddressReplyToFlag'])) { |
|
| 464 | + $replyToField = $_REQUEST[$eId.'emailAddressReplyToFlag']; |
|
| 465 | + } else if (isset($_REQUEST[$module.'emailAddressReplyToFlag'])) { |
|
| 466 | + $replyToField = $_REQUEST[$module.'emailAddressReplyToFlag']; |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | - if($fromRequest && empty($new_addrs)) { |
|
| 470 | - foreach($_REQUEST as $k => $v) { |
|
| 471 | - if(preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) { |
|
| 469 | + if ($fromRequest && empty($new_addrs)) { |
|
| 470 | + foreach ($_REQUEST as $k => $v) { |
|
| 471 | + if (preg_match('/'.$eId.'emailAddress[0-9]+$/i', $k) && !empty($v)) { |
|
| 472 | 472 | $new_addrs[$k] = $v; |
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | } |
| 476 | - if($fromRequest && empty($email_ids)) { |
|
| 477 | - foreach($_REQUEST as $k => $v) { |
|
| 478 | - if(preg_match('/'.$eId.'emailAddressId[0-9]+$/i', $k) && !empty($v)) { |
|
| 476 | + if ($fromRequest && empty($email_ids)) { |
|
| 477 | + foreach ($_REQUEST as $k => $v) { |
|
| 478 | + if (preg_match('/'.$eId.'emailAddressId[0-9]+$/i', $k) && !empty($v)) { |
|
| 479 | 479 | $key = str_replace('emailAddressId', 'emailAddress', $k); |
| 480 | 480 | $email_ids[$key] = $v; |
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - if($fromRequest && empty($new_addrs)) { |
|
| 486 | - foreach($_REQUEST as $k => $v) { |
|
| 487 | - if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) { |
|
| 485 | + if ($fromRequest && empty($new_addrs)) { |
|
| 486 | + foreach ($_REQUEST as $k => $v) { |
|
| 487 | + if (preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) { |
|
| 488 | 488 | $validateFlag = str_replace("Value", "Flag", $k); |
| 489 | 489 | if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true") |
| 490 | 490 | $new_addrs[$k] = $v; |
@@ -493,21 +493,21 @@ discard block |
||
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | //empty the addresses array if the post happened from email address widget. |
| 496 | - if($post_from_email_address_widget) { |
|
| 497 | - $this->addresses=array(); //this gets populated during retrieve of the contact bean. |
|
| 496 | + if ($post_from_email_address_widget) { |
|
| 497 | + $this->addresses = array(); //this gets populated during retrieve of the contact bean. |
|
| 498 | 498 | } else { |
| 499 | 499 | $optOutValues = array(); |
| 500 | 500 | $invalidValues = array(); |
| 501 | - foreach($new_addrs as $k=>$email) { |
|
| 501 | + foreach ($new_addrs as $k=>$email) { |
|
| 502 | 502 | preg_match('/emailAddress([0-9])+$/', $k, $matches); |
| 503 | 503 | $count = $matches[1]; |
| 504 | - $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . $this->db->quote(strtoupper($email)) . "'"); |
|
| 505 | - if(!empty($result)) { |
|
| 506 | - $row=$this->db->fetchByAssoc($result); |
|
| 507 | - if(!empty($row['opt_out'])) { |
|
| 504 | + $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '".$this->db->quote(strtoupper($email))."'"); |
|
| 505 | + if (!empty($result)) { |
|
| 506 | + $row = $this->db->fetchByAssoc($result); |
|
| 507 | + if (!empty($row['opt_out'])) { |
|
| 508 | 508 | $optOutValues[$k] = "emailAddress$count"; |
| 509 | 509 | } |
| 510 | - if(!empty($row['invalid_email'])) { |
|
| 510 | + if (!empty($row['invalid_email'])) { |
|
| 511 | 511 | $invalidValues[$k] = "emailAddress$count"; |
| 512 | 512 | } |
| 513 | 513 | } |
@@ -515,11 +515,11 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | // Re-populate the addresses class variable if we have new address(es). |
| 517 | 517 | if (!empty($new_addrs)) { |
| 518 | - foreach($new_addrs as $k => $reqVar) { |
|
| 518 | + foreach ($new_addrs as $k => $reqVar) { |
|
| 519 | 519 | //$key = preg_match("/^$eId/s", $k) ? substr($k, strlen($eId)) : $k; |
| 520 | 520 | $reqVar = trim($reqVar); |
| 521 | - if(strpos($k, 'emailAddress') !== false) { |
|
| 522 | - if(!empty($reqVar) && !in_array($k, $deleteValues)) { |
|
| 521 | + if (strpos($k, 'emailAddress') !== false) { |
|
| 522 | + if (!empty($reqVar) && !in_array($k, $deleteValues)) { |
|
| 523 | 523 | $email_id = (array_key_exists($k, $email_ids)) ? $email_ids[$k] : null; |
| 524 | 524 | $primary = ($k == $primaryValue) ? true : false; |
| 525 | 525 | $replyTo = ($k == $replyToField) ? true : false; |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | //If no widgets, set addresses array to empty |
| 539 | - if($post_from_email_address_widget && !$hasEmailValue) { |
|
| 539 | + if ($post_from_email_address_widget && !$hasEmailValue) { |
|
| 540 | 540 | $this->addresses = array(); |
| 541 | 541 | } |
| 542 | 542 | } |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | * @param bool $primary Default false |
| 548 | 548 | * @param bool $replyTo Default false |
| 549 | 549 | */ |
| 550 | - function addAddress($addr, $primary=false, $replyTo=false, $invalid=false, $optOut=false, $email_id = null) { |
|
| 550 | + function addAddress($addr, $primary = false, $replyTo = false, $invalid = false, $optOut = false, $email_id = null) { |
|
| 551 | 551 | $addr = html_entity_decode($addr, ENT_QUOTES); |
| 552 | - if(preg_match($this->regex, $addr)) { |
|
| 552 | + if (preg_match($this->regex, $addr)) { |
|
| 553 | 553 | $primaryFlag = ($primary) ? '1' : '0'; |
| 554 | 554 | $replyToFlag = ($replyTo) ? '1' : '0'; |
| 555 | 555 | $invalidFlag = ($invalid) ? '1' : '0'; |
@@ -585,17 +585,17 @@ discard block |
||
| 585 | 585 | * Updates invalid_email and opt_out flags for each address |
| 586 | 586 | */ |
| 587 | 587 | function updateFlags() { |
| 588 | - if(!empty($this->addresses)) { |
|
| 589 | - foreach($this->addresses as $addressMeta) { |
|
| 590 | - if(isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) { |
|
| 588 | + if (!empty($this->addresses)) { |
|
| 589 | + foreach ($this->addresses as $addressMeta) { |
|
| 590 | + if (isset($addressMeta['email_address']) && !empty($addressMeta['email_address'])) { |
|
| 591 | 591 | $address = $this->db->quote($this->_cleanAddress($addressMeta['email_address'])); |
| 592 | 592 | |
| 593 | 593 | $q = "SELECT * FROM email_addresses WHERE email_address = '{$address}'"; |
| 594 | 594 | $r = $this->db->query($q); |
| 595 | 595 | $a = $this->db->fetchByAssoc($r); |
| 596 | 596 | |
| 597 | - if(!empty($a)) { |
|
| 598 | - if(isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) { |
|
| 597 | + if (!empty($a)) { |
|
| 598 | + if (isset($a['invalid_email']) && isset($addressMeta['invalid_email']) && isset($addressMeta['opt_out']) && $a['invalid_email'] != $addressMeta['invalid_email'] || $a['opt_out'] != $addressMeta['opt_out']) { |
|
| 599 | 599 | $qUpdate = "UPDATE email_addresses SET invalid_email = ".intval($addressMeta['invalid_email']).", opt_out = ".intval($addressMeta['opt_out']).", date_modified = '".TimeDate::getInstance()->nowDb()."' WHERE id = '".$this->db->quote($a['id'])."'"; |
| 600 | 600 | $rUpdate = $this->db->query($qUpdate); |
| 601 | 601 | } |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | public function splitEmailAddress($addr) |
| 609 | 609 | { |
| 610 | 610 | $email = $this->_cleanAddress($addr); |
| 611 | - if(!preg_match($this->regex, $email)) { |
|
| 611 | + if (!preg_match($this->regex, $email)) { |
|
| 612 | 612 | $email = ''; // remove bad email addr |
| 613 | 613 | } |
| 614 | 614 | $name = trim(str_replace(array($email, '<', '>', '"', "'"), '', $addr)); |
@@ -624,8 +624,8 @@ discard block |
||
| 624 | 624 | function _cleanAddress($addr) { |
| 625 | 625 | $addr = trim(from_html($addr)); |
| 626 | 626 | |
| 627 | - if(strpos($addr, "<") !== false && strpos($addr, ">") !== false) { |
|
| 628 | - $address = trim(substr($addr, strrpos($addr, "<") +1, strrpos($addr, ">") - strrpos($addr, "<") -1)); |
|
| 627 | + if (strpos($addr, "<") !== false && strpos($addr, ">") !== false) { |
|
| 628 | + $address = trim(substr($addr, strrpos($addr, "<") + 1, strrpos($addr, ">") - strrpos($addr, "<") - 1)); |
|
| 629 | 629 | } else { |
| 630 | 630 | $address = trim($addr); |
| 631 | 631 | } |
@@ -646,11 +646,11 @@ discard block |
||
| 646 | 646 | $r = $this->db->query($q); |
| 647 | 647 | $a = $this->db->fetchByAssoc($r); |
| 648 | 648 | |
| 649 | - if(!empty($a) && !empty($a['id'])) { |
|
| 649 | + if (!empty($a) && !empty($a['id'])) { |
|
| 650 | 650 | return $a['id']; |
| 651 | 651 | } else { |
| 652 | 652 | $guid = ''; |
| 653 | - if(!empty($address)){ |
|
| 653 | + if (!empty($address)) { |
|
| 654 | 654 | $guid = create_guid(); |
| 655 | 655 | $now = TimeDate::getInstance()->nowDb(); |
| 656 | 656 | $qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted) |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | * to propagate to the new SugarEmailAddress - see bug 39188 |
| 673 | 673 | * @return String GUID of Email Address or '' if cleaned address was empty. |
| 674 | 674 | */ |
| 675 | - public function AddUpdateEmailAddress($addr,$invalid=0,$opt_out=0,$id=null) |
|
| 675 | + public function AddUpdateEmailAddress($addr, $invalid = 0, $opt_out = 0, $id = null) |
|
| 676 | 676 | { |
| 677 | 677 | // sanity checks to avoid SQL injection. |
| 678 | 678 | $invalid = intval($invalid); |
@@ -722,12 +722,12 @@ discard block |
||
| 722 | 722 | if ($duplicate_email['invalid_email'] != $new_invalid || |
| 723 | 723 | $duplicate_email['opt_out'] != $new_opt_out || |
| 724 | 724 | (trim($duplicate_email['email_address']) != $address)) { |
| 725 | - $upd_q = 'UPDATE ' . $this->table_name . ' ' . |
|
| 726 | - 'SET email_address=\'' . $address . '\', ' . |
|
| 727 | - 'invalid_email=' . $new_invalid . ', ' . |
|
| 728 | - 'opt_out=' . $new_opt_out . ', ' . |
|
| 729 | - 'date_modified=' . $this->db->now() . ' ' . |
|
| 730 | - 'WHERE id=\'' . $this->db->quote($duplicate_email['id']) . '\''; |
|
| 725 | + $upd_q = 'UPDATE '.$this->table_name.' '. |
|
| 726 | + 'SET email_address=\''.$address.'\', '. |
|
| 727 | + 'invalid_email='.$new_invalid.', '. |
|
| 728 | + 'opt_out='.$new_opt_out.', '. |
|
| 729 | + 'date_modified='.$this->db->now().' '. |
|
| 730 | + 'WHERE id=\''.$this->db->quote($duplicate_email['id']).'\''; |
|
| 731 | 731 | $upd_r = $this->db->query($upd_q); |
| 732 | 732 | } |
| 733 | 733 | return $duplicate_email['id']; |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | else { |
| 736 | 736 | // no case-insensitive address match - it's new, or undeleted. |
| 737 | 737 | $guid = ''; |
| 738 | - if(!empty($address)){ |
|
| 738 | + if (!empty($address)) { |
|
| 739 | 739 | $guid = create_guid(); |
| 740 | 740 | $now = TimeDate::getInstance()->nowDb(); |
| 741 | 741 | $qa = "INSERT INTO email_addresses (id, email_address, email_address_caps, date_created, date_modified, deleted, invalid_email, opt_out) |
@@ -751,12 +751,12 @@ discard block |
||
| 751 | 751 | * @param object $focus Object in focus |
| 752 | 752 | * @return string email |
| 753 | 753 | */ |
| 754 | - function getPrimaryAddress($focus,$parent_id=null,$parent_type=null) { |
|
| 754 | + function getPrimaryAddress($focus, $parent_id = null, $parent_type = null) { |
|
| 755 | 755 | |
| 756 | - $parent_type=empty($parent_type) ? $focus->module_dir : $parent_type; |
|
| 756 | + $parent_type = empty($parent_type) ? $focus->module_dir : $parent_type; |
|
| 757 | 757 | // Bug63174: Email address is not shown in the list view for employees |
| 758 | 758 | $parent_type = $this->getCorrectedModule($parent_type); |
| 759 | - $parent_id=empty($parent_id) ? $focus->id : $parent_id; |
|
| 759 | + $parent_id = empty($parent_id) ? $focus->id : $parent_id; |
|
| 760 | 760 | |
| 761 | 761 | $q = "SELECT ea.email_address FROM email_addresses ea |
| 762 | 762 | LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | $r = $this->db->limitQuery($q, 0, 1); |
| 769 | 769 | $a = $this->db->fetchByAssoc($r); |
| 770 | 770 | |
| 771 | - if(isset($a['email_address'])) { |
|
| 771 | + if (isset($a['email_address'])) { |
|
| 772 | 772 | return $a['email_address']; |
| 773 | 773 | } |
| 774 | 774 | return ''; |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | $r = $this->db->query($q); |
| 810 | 810 | $a = $this->db->fetchByAssoc($r); |
| 811 | 811 | |
| 812 | - if(isset($a['email_address'])) { |
|
| 812 | + if (isset($a['email_address'])) { |
|
| 813 | 813 | return $a['email_address']; |
| 814 | 814 | } |
| 815 | 815 | return ''; |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | ORDER BY ear.reply_to_address, ear.primary_address DESC"; |
| 835 | 835 | $r = $this->db->query($q); |
| 836 | 836 | |
| 837 | - while($a = $this->db->fetchByAssoc($r, FALSE)) { |
|
| 837 | + while ($a = $this->db->fetchByAssoc($r, FALSE)) { |
|
| 838 | 838 | $return[] = $a; |
| 839 | 839 | } |
| 840 | 840 | |
@@ -848,9 +848,9 @@ discard block |
||
| 848 | 848 | * @param bool asMetadata Default false |
| 849 | 849 | * @return string HTML/JS for widget |
| 850 | 850 | */ |
| 851 | - function getEmailAddressWidgetEditView($id, $module, $asMetadata=false, $tpl='',$tabindex='0') |
|
| 851 | + function getEmailAddressWidgetEditView($id, $module, $asMetadata = false, $tpl = '', $tabindex = '0') |
|
| 852 | 852 | { |
| 853 | - if ( !($this->smarty instanceOf Sugar_Smarty ) ) |
|
| 853 | + if (!($this->smarty instanceOf Sugar_Smarty)) |
|
| 854 | 854 | $this->smarty = new Sugar_Smarty(); |
| 855 | 855 | |
| 856 | 856 | global $app_strings, $dictionary, $beanList; |
@@ -861,33 +861,33 @@ discard block |
||
| 861 | 861 | $passedModule = $module; |
| 862 | 862 | $module = $this->getCorrectedModule($module); |
| 863 | 863 | $saveModule = $module; |
| 864 | - if(isset($_POST['is_converted']) && $_POST['is_converted']==true){ |
|
| 865 | - $id=$_POST['return_id']; |
|
| 866 | - $module=$_POST['return_module']; |
|
| 864 | + if (isset($_POST['is_converted']) && $_POST['is_converted'] == true) { |
|
| 865 | + $id = $_POST['return_id']; |
|
| 866 | + $module = $_POST['return_module']; |
|
| 867 | 867 | } |
| 868 | 868 | $prefillDataArr = array(); |
| 869 | - if(!empty($id)) { |
|
| 869 | + if (!empty($id)) { |
|
| 870 | 870 | $prefillDataArr = $this->getAddressesByGUID($id, $module); |
| 871 | 871 | //When coming from convert leads, sometimes module is Contacts while the id is for a lead. |
| 872 | 872 | if (empty($prefillDataArr) && $module == "Contacts") |
| 873 | 873 | $prefillDataArr = $this->getAddressesByGUID($id, "Leads"); |
| 874 | - } else if(isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])){ |
|
| 875 | - $widget_id = isset($_REQUEST[$module . '_email_widget_id']) ? $_REQUEST[$module . '_email_widget_id'] : '0'; |
|
| 874 | + } else if (isset($_REQUEST['full_form']) && !empty($_REQUEST['emailAddressWidget'])) { |
|
| 875 | + $widget_id = isset($_REQUEST[$module.'_email_widget_id']) ? $_REQUEST[$module.'_email_widget_id'] : '0'; |
|
| 876 | 876 | $count = 0; |
| 877 | - $key = $module . $widget_id . 'emailAddress'.$count; |
|
| 878 | - while(isset($_REQUEST[$key])) { |
|
| 877 | + $key = $module.$widget_id.'emailAddress'.$count; |
|
| 878 | + while (isset($_REQUEST[$key])) { |
|
| 879 | 879 | $email = $_REQUEST[$key]; |
| 880 | - $prefillDataArr[] = array('email_address'=>$email, |
|
| 880 | + $prefillDataArr[] = array('email_address'=>$email, |
|
| 881 | 881 | 'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key, |
| 882 | 882 | 'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']), |
| 883 | 883 | 'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']), |
| 884 | 884 | 'reply_to_address'=>false |
| 885 | 885 | ); |
| 886 | - $key = $module . $widget_id . 'emailAddress' . ++$count; |
|
| 886 | + $key = $module.$widget_id.'emailAddress'.++$count; |
|
| 887 | 887 | } //while |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - if(!empty($prefillDataArr)) { |
|
| 890 | + if (!empty($prefillDataArr)) { |
|
| 891 | 891 | $json = new JSON(JSON_LOOSE_TYPE); |
| 892 | 892 | $prefillData = $json->encode($prefillDataArr); |
| 893 | 893 | $prefill = !empty($prefillDataArr) ? 'true' : 'false'; |
@@ -910,23 +910,23 @@ discard block |
||
| 910 | 910 | $form = $this->view; |
| 911 | 911 | |
| 912 | 912 | //determine if this should be a quickcreate form, or a quick create form under subpanels |
| 913 | - if ($this->view == "QuickCreate"){ |
|
| 913 | + if ($this->view == "QuickCreate") { |
|
| 914 | 914 | // Fixed #1120 - fixed email validation for: Accounts -> Contacts subpanel -> Select -> Create Contact -> Save. |
| 915 | 915 | // If email is required it should highlight this field and show an error message. |
| 916 | 916 | // It didnt because the the form was named form_DCSubpanelQuickCreate_Contacts instead of expected form_SubpanelQuickCreate_Contacts |
| 917 | - if($this->object_name = 'EmailAddress' && $saveModule == 'Contacts') { |
|
| 918 | - $form = 'form_'.$this->view .'_'.$module; |
|
| 917 | + if ($this->object_name = 'EmailAddress' && $saveModule == 'Contacts') { |
|
| 918 | + $form = 'form_'.$this->view.'_'.$module; |
|
| 919 | 919 | } else { |
| 920 | - $form = 'form_DC'.$this->view .'_'.$module; |
|
| 920 | + $form = 'form_DC'.$this->view.'_'.$module; |
|
| 921 | 921 | } |
| 922 | - if(isset($_REQUEST['action']) && $_REQUEST['action']=='SubpanelCreates' || $_REQUEST['action']=='SubpanelEdits'){ |
|
| 923 | - $form = 'form_Subpanel'.$this->view .'_'.$module; |
|
| 922 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'SubpanelCreates' || $_REQUEST['action'] == 'SubpanelEdits') { |
|
| 923 | + $form = 'form_Subpanel'.$this->view.'_'.$module; |
|
| 924 | 924 | } |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | $this->smarty->assign('emailView', $form); |
| 928 | 928 | |
| 929 | - if($module == 'Users') { |
|
| 929 | + if ($module == 'Users') { |
|
| 930 | 930 | $this->smarty->assign('useReplyTo', true); |
| 931 | 931 | } else { |
| 932 | 932 | $this->smarty->assign('useOptOut', true); |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | $newEmail = $this->smarty->fetch($template); |
| 938 | 938 | |
| 939 | 939 | |
| 940 | - if($asMetadata) { |
|
| 940 | + if ($asMetadata) { |
|
| 941 | 941 | // used by Email 2.0 |
| 942 | 942 | $ret = array(); |
| 943 | 943 | $ret['prefillData'] = $prefillDataArr; |
@@ -955,18 +955,18 @@ discard block |
||
| 955 | 955 | * @param object $focus Bean in focus |
| 956 | 956 | * @return string HTML/JS for widget |
| 957 | 957 | */ |
| 958 | - function getEmailAddressWidgetDetailView($focus, $tpl='') |
|
| 958 | + function getEmailAddressWidgetDetailView($focus, $tpl = '') |
|
| 959 | 959 | { |
| 960 | - if ( !($this->smarty instanceOf Sugar_Smarty ) ) |
|
| 960 | + if (!($this->smarty instanceOf Sugar_Smarty)) |
|
| 961 | 961 | $this->smarty = new Sugar_Smarty(); |
| 962 | 962 | |
| 963 | 963 | global $app_strings; |
| 964 | 964 | global $current_user; |
| 965 | 965 | $assign = array(); |
| 966 | - if(empty($focus->id))return ''; |
|
| 966 | + if (empty($focus->id))return ''; |
|
| 967 | 967 | $prefillData = $this->getAddressesByGUID($focus->id, $focus->module_dir); |
| 968 | 968 | |
| 969 | - foreach($prefillData as $addressItem) { |
|
| 969 | + foreach ($prefillData as $addressItem) { |
|
| 970 | 970 | $key = ($addressItem['primary_address'] == 1) ? 'primary' : ""; |
| 971 | 971 | $key = ($addressItem['reply_to_address'] == 1) ? 'reply_to' : $key; |
| 972 | 972 | $key = ($addressItem['opt_out'] == 1) ? 'opt_out' : $key; |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | */ |
| 993 | 993 | function getEmailAddressWidgetDuplicatesView($focus) |
| 994 | 994 | { |
| 995 | - if ( !($this->smarty instanceOf Sugar_Smarty ) ) |
|
| 995 | + if (!($this->smarty instanceOf Sugar_Smarty)) |
|
| 996 | 996 | $this->smarty = new Sugar_Smarty(); |
| 997 | 997 | |
| 998 | 998 | $count = 0; |
@@ -1002,49 +1002,49 @@ discard block |
||
| 1002 | 1002 | $invalid = array(); |
| 1003 | 1003 | $mod = isset($focus) ? $focus->module_dir : ""; |
| 1004 | 1004 | |
| 1005 | - $widget_id = $_POST[$mod .'_email_widget_id']; |
|
| 1006 | - $this->smarty->assign('email_widget_id',$widget_id); |
|
| 1007 | - $this->smarty->assign('emailAddressWidget',$_POST['emailAddressWidget']); |
|
| 1005 | + $widget_id = $_POST[$mod.'_email_widget_id']; |
|
| 1006 | + $this->smarty->assign('email_widget_id', $widget_id); |
|
| 1007 | + $this->smarty->assign('emailAddressWidget', $_POST['emailAddressWidget']); |
|
| 1008 | 1008 | |
| 1009 | - if(isset($_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'])) { |
|
| 1010 | - $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag']; |
|
| 1009 | + if (isset($_POST[$mod.$widget_id.'emailAddressPrimaryFlag'])) { |
|
| 1010 | + $primary = $_POST[$mod.$widget_id.'emailAddressPrimaryFlag']; |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - while(isset($_POST[$mod . $widget_id . "emailAddress" . $count])) { |
|
| 1014 | - $emails[] = $_POST[$mod . $widget_id . 'emailAddress' . $count]; |
|
| 1013 | + while (isset($_POST[$mod.$widget_id."emailAddress".$count])) { |
|
| 1014 | + $emails[] = $_POST[$mod.$widget_id.'emailAddress'.$count]; |
|
| 1015 | 1015 | $count++; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - if($count == 0) { |
|
| 1018 | + if ($count == 0) { |
|
| 1019 | 1019 | return ""; |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | - if(isset($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'])) { |
|
| 1023 | - foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) { |
|
| 1022 | + if (isset($_POST[$mod.$widget_id.'emailAddressOptOutFlag'])) { |
|
| 1023 | + foreach ($_POST[$mod.$widget_id.'emailAddressOptOutFlag'] as $v) { |
|
| 1024 | 1024 | $optOut[] = $v; |
| 1025 | 1025 | } |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | - if(isset($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'])) { |
|
| 1029 | - foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) { |
|
| 1028 | + if (isset($_POST[$mod.$widget_id.'emailAddressInvalidFlag'])) { |
|
| 1029 | + foreach ($_POST[$mod.$widget_id.'emailAddressInvalidFlag'] as $v) { |
|
| 1030 | 1030 | $invalid[] = $v; |
| 1031 | 1031 | } |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | - if(isset($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'])) { |
|
| 1035 | - foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) { |
|
| 1034 | + if (isset($_POST[$mod.$widget_id.'emailAddressReplyToFlag'])) { |
|
| 1035 | + foreach ($_POST[$mod.$widget_id.'emailAddressReplyToFlag'] as $v) { |
|
| 1036 | 1036 | $replyTo[] = $v; |
| 1037 | 1037 | } |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | - if(isset($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'])) { |
|
| 1041 | - foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) { |
|
| 1040 | + if (isset($_POST[$mod.$widget_id.'emailAddressDeleteFlag'])) { |
|
| 1041 | + foreach ($_POST[$mod.$widget_id.'emailAddressDeleteFlag'] as $v) { |
|
| 1042 | 1042 | $delete[] = $v; |
| 1043 | 1043 | } |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - while(isset($_POST[$mod . $widget_id . "emailAddressVerifiedValue" . $count])) { |
|
| 1047 | - $verified[] = $_POST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]; |
|
| 1046 | + while (isset($_POST[$mod.$widget_id."emailAddressVerifiedValue".$count])) { |
|
| 1047 | + $verified[] = $_POST[$mod.$widget_id.'emailAddressVerifiedValue'.$count]; |
|
| 1048 | 1048 | $count++; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
@@ -1069,33 +1069,33 @@ discard block |
||
| 1069 | 1069 | $count = 0; |
| 1070 | 1070 | $mod = isset($focus) ? $focus->module_dir : ""; |
| 1071 | 1071 | |
| 1072 | - $widget_id = $_POST[$mod .'_email_widget_id']; |
|
| 1073 | - $get .= '&' . $mod . '_email_widget_id='. $widget_id; |
|
| 1072 | + $widget_id = $_POST[$mod.'_email_widget_id']; |
|
| 1073 | + $get .= '&'.$mod.'_email_widget_id='.$widget_id; |
|
| 1074 | 1074 | $get .= '&emailAddressWidget='.$_POST['emailAddressWidget']; |
| 1075 | 1075 | |
| 1076 | - while(isset($_REQUEST[$mod . $widget_id . 'emailAddress' . $count])) { |
|
| 1077 | - $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]); |
|
| 1076 | + while (isset($_REQUEST[$mod.$widget_id.'emailAddress'.$count])) { |
|
| 1077 | + $get .= "&".$mod.$widget_id."emailAddress".$count."=".urlencode($_REQUEST[$mod.$widget_id.'emailAddress'.$count]); |
|
| 1078 | 1078 | $count++; |
| 1079 | 1079 | } //while |
| 1080 | 1080 | |
| 1081 | - while(isset($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count])) { |
|
| 1082 | - $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]); |
|
| 1081 | + while (isset($_REQUEST[$mod.$widget_id.'emailAddressVerifiedValue'.$count])) { |
|
| 1082 | + $get .= "&".$mod.$widget_id."emailAddressVerifiedValue".$count."=".urlencode($_REQUEST[$mod.$widget_id.'emailAddressVerifiedValue'.$count]); |
|
| 1083 | 1083 | $count++; |
| 1084 | 1084 | } //while |
| 1085 | 1085 | |
| 1086 | 1086 | $options = array('emailAddressPrimaryFlag', 'emailAddressOptOutFlag', 'emailAddressInvalidFlag', 'emailAddressDeleteFlag', 'emailAddressReplyToFlag'); |
| 1087 | 1087 | |
| 1088 | - foreach($options as $option) { |
|
| 1088 | + foreach ($options as $option) { |
|
| 1089 | 1089 | $count = 0; |
| 1090 | 1090 | $optionIdentifier = $mod.$widget_id.$option; |
| 1091 | - if(isset($_REQUEST[$optionIdentifier])) { |
|
| 1092 | - if(is_array($_REQUEST[$optionIdentifier])) { |
|
| 1093 | - foreach($_REQUEST[$optionIdentifier] as $optOut) { |
|
| 1094 | - $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut; |
|
| 1091 | + if (isset($_REQUEST[$optionIdentifier])) { |
|
| 1092 | + if (is_array($_REQUEST[$optionIdentifier])) { |
|
| 1093 | + foreach ($_REQUEST[$optionIdentifier] as $optOut) { |
|
| 1094 | + $get .= "&".$optionIdentifier."[".$count."]=".$optOut; |
|
| 1095 | 1095 | $count++; |
| 1096 | 1096 | } //foreach |
| 1097 | 1097 | } else { |
| 1098 | - $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier]; |
|
| 1098 | + $get .= "&".$optionIdentifier."=".$_REQUEST[$optionIdentifier]; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | } //if |
| 1101 | 1101 | } //foreach |
@@ -1113,7 +1113,7 @@ discard block |
||
| 1113 | 1113 | * @return string The value for the bean_module column in the email_addr_bean_rel table |
| 1114 | 1114 | */ |
| 1115 | 1115 | function getCorrectedModule(&$module) { |
| 1116 | - return ($module == "Employees")? "Users" : $module; |
|
| 1116 | + return ($module == "Employees") ? "Users" : $module; |
|
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | 1119 | public function stash($parentBeanId, $moduleName) |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | $ids = array(); |
| 1124 | 1124 | while ($row = $this->db->fetchByAssoc($result, false)) |
| 1125 | 1125 | { |
| 1126 | - $ids[] =$this->db->quote($row['email_address_id']); // avoid 2nd order SQL Injection |
|
| 1126 | + $ids[] = $this->db->quote($row['email_address_id']); // avoid 2nd order SQL Injection |
|
| 1127 | 1127 | } |
| 1128 | 1128 | if (!empty($ids)) |
| 1129 | 1129 | { |
@@ -1147,15 +1147,15 @@ discard block |
||
| 1147 | 1147 | * @param string $view DetailView or EditView |
| 1148 | 1148 | * @return string |
| 1149 | 1149 | */ |
| 1150 | -function getEmailAddressWidget($focus, $field, $value, $view, $tabindex='0') { |
|
| 1150 | +function getEmailAddressWidget($focus, $field, $value, $view, $tabindex = '0') { |
|
| 1151 | 1151 | $sea = new SugarEmailAddress(); |
| 1152 | 1152 | $sea->setView($view); |
| 1153 | 1153 | |
| 1154 | - if($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') { |
|
| 1154 | + if ($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') { |
|
| 1155 | 1155 | $module = $focus->module_dir; |
| 1156 | 1156 | if ($view == 'ConvertLead' && $module == "Contacts") $module = "Leads"; |
| 1157 | 1157 | |
| 1158 | - return $sea->getEmailAddressWidgetEditView($focus->id, $module, false,'',$tabindex); |
|
| 1158 | + return $sea->getEmailAddressWidgetEditView($focus->id, $module, false, '', $tabindex); |
|
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | 1161 | return $sea->getEmailAddressWidgetDetailView($focus); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $temp = tempnam($dir, 'temp'); |
| 187 | 187 | |
| 188 | 188 | if (!($f = @fopen($temp, $mode))) { |
| 189 | - $temp = $dir . DIRECTORY_SEPARATOR . uniqid('temp'); |
|
| 189 | + $temp = $dir.DIRECTORY_SEPARATOR.uniqid('temp'); |
|
| 190 | 190 | if (!($f = @fopen($temp, $mode))) { |
| 191 | 191 | trigger_error("sugar_file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING); |
| 192 | 192 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | if (!is_windows()) { |
| 395 | 395 | $conf_inst = SugarConfig::getInstance(); |
| 396 | - $mode = $conf_inst->get('default_permissions.' . $key, $mode); |
|
| 396 | + $mode = $conf_inst->get('default_permissions.'.$key, $mode); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | return $mode; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | $id = $layout_def['focus']->id; |
| 49 | 49 | $module = $layout_def['focus']->module_name; |
| 50 | 50 | |
| 51 | - $href = "index.php?module=$module&action=WizardMarketing&campaign_id=$id" . (!empty($layout_def['func']) ? '&func=' . $layout_def['func'] : ''); |
|
| 51 | + $href = "index.php?module=$module&action=WizardMarketing&campaign_id=$id".(!empty($layout_def['func']) ? '&func='.$layout_def['func'] : ''); |
|
| 52 | 52 | |
| 53 | 53 | $label = $app_strings['LBL_CREATE_BUTTON_LABEL']; |
| 54 | 54 | |
| 55 | - return '<a onclick="location.href=\'' . $href . '\';">' . $label . '</a>'; |
|
| 55 | + return '<a onclick="location.href=\''.$href.'\';">'.$label.'</a>'; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | \ No newline at end of file |
@@ -6,9 +6,9 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | //execute the contructor and check for the Object type and attributes |
| 8 | 8 | $contact = new Contact(); |
| 9 | - $this->assertInstanceOf('Contact',$contact); |
|
| 10 | - $this->assertInstanceOf('Person',$contact); |
|
| 11 | - $this->assertInstanceOf('SugarBean',$contact); |
|
| 9 | + $this->assertInstanceOf('Contact', $contact); |
|
| 10 | + $this->assertInstanceOf('Person', $contact); |
|
| 11 | + $this->assertInstanceOf('SugarBean', $contact); |
|
| 12 | 12 | |
| 13 | 13 | $this->assertAttributeEquals('Contacts', 'module_dir', $contact); |
| 14 | 14 | $this->assertAttributeEquals('Contact', 'object_name', $contact); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | //test with empty strings |
| 30 | 30 | $query = ""; |
| 31 | 31 | $contact->add_list_count_joins($query, ''); |
| 32 | - $this->assertEquals(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ",$query); |
|
| 32 | + $this->assertEquals(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ", $query); |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | //test with valid string |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | $expected = "\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id\n LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c "; |
| 38 | 38 | $contact->add_list_count_joins($query, 'accounts.name'); |
| 39 | 39 | $query = preg_replace('/\s+/', '', $query); |
| 40 | - $expected =preg_replace('/\s+/', '', $expected); |
|
| 41 | - $this->assertSame($expected,$query); |
|
| 40 | + $expected = preg_replace('/\s+/', '', $expected); |
|
| 41 | + $this->assertSame($expected, $query); |
|
| 42 | 42 | |
| 43 | 43 | //test with valid string |
| 44 | 44 | $query = ""; |
| 45 | 45 | $expected = "\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id\n LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c "; |
| 46 | 46 | $contact->add_list_count_joins($query, 'contacts.name'); |
| 47 | - $this->assertSame(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ",$query); |
|
| 47 | + $this->assertSame(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ", $query); |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | } |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $contact = new Contact(); |
| 55 | 55 | |
| 56 | - $expected = array( "MAIN"=>"a", "ACCOUNT"=>"a"); |
|
| 56 | + $expected = array("MAIN"=>"a", "ACCOUNT"=>"a"); |
|
| 57 | 57 | $actual = $contact->listviewACLHelper(); |
| 58 | - $this->assertSame($expected,$actual); |
|
| 58 | + $this->assertSame($expected, $actual); |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -89,14 +89,14 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | //test with empty string params |
| 91 | 91 | $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,contacts_cstm.*\n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where contacts.deleted=0 "; |
| 92 | - $actual = $contact->address_popup_create_new_list_query('',''); |
|
| 93 | - $this->assertSame($expected,$actual); |
|
| 92 | + $actual = $contact->address_popup_create_new_list_query('', ''); |
|
| 93 | + $this->assertSame($expected, $actual); |
|
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | //test with valid string params |
| 97 | 97 | $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n contacts.*,\n accounts.name as account_name,\n accounts.id as account_id,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,contacts_cstm.*\n FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id\n LEFT JOIN accounts_contacts\n ON contacts.id=accounts_contacts.contact_id and accounts_contacts.deleted = 0\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND contacts.deleted=0 "; |
| 98 | - $actual = $contact->address_popup_create_new_list_query('contacts.id','contacts.name=""'); |
|
| 99 | - $this->assertSame($expected,$actual); |
|
| 98 | + $actual = $contact->address_popup_create_new_list_query('contacts.id', 'contacts.name=""'); |
|
| 99 | + $this->assertSame($expected, $actual); |
|
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | //test with empty string params |
| 108 | 108 | $expected = "SELECT\n contacts.*,\n email_addresses.email_address email_address,\n '' email_addresses_non_primary, accounts.name as account_name,\n users.user_name as assigned_user_name ,contacts_cstm.jjwg_maps_lng_c,contacts_cstm.jjwg_maps_lat_c,contacts_cstm.jjwg_maps_geocode_status_c,contacts_cstm.jjwg_maps_address_c FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id LEFT JOIN email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where ( accounts.deleted IS NULL OR accounts.deleted=0 )\n AND contacts.deleted=0 "; |
| 109 | - $actual = $contact->create_export_query('',''); |
|
| 110 | - $this->assertSame($expected,$actual); |
|
| 109 | + $actual = $contact->create_export_query('', ''); |
|
| 110 | + $this->assertSame($expected, $actual); |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | //test with valid string params |
| 114 | 114 | $expected = "SELECT\n contacts.*,\n email_addresses.email_address email_address,\n '' email_addresses_non_primary, accounts.name as account_name,\n users.user_name as assigned_user_name ,contacts_cstm.jjwg_maps_lng_c,contacts_cstm.jjwg_maps_lat_c,contacts_cstm.jjwg_maps_geocode_status_c,contacts_cstm.jjwg_maps_address_c FROM contacts LEFT JOIN users\n ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n LEFT JOIN accounts\n ON accounts_contacts.account_id=accounts.id LEFT JOIN email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND ( accounts.deleted IS NULL OR accounts.deleted=0 )\n AND contacts.deleted=0 "; |
| 115 | - $actual = $contact->create_export_query('contacts.id','contacts.name=""'); |
|
| 116 | - $this->assertSame($expected,$actual); |
|
| 115 | + $actual = $contact->create_export_query('contacts.id', 'contacts.name=""'); |
|
| 116 | + $this->assertSame($expected, $actual); |
|
| 117 | 117 | |
| 118 | 118 | } |
| 119 | 119 | |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | $contact->fill_in_additional_list_fields(); |
| 132 | 132 | |
| 133 | - $this->assertEquals("firstn lastn",$contact->full_name); |
|
| 134 | - $this->assertEquals("firstn lastn <[email protected]>",$contact->email_and_name1); |
|
| 135 | - $this->assertEquals("firstn lastn <[email protected]>",$contact->email_and_name2); |
|
| 133 | + $this->assertEquals("firstn lastn", $contact->full_name); |
|
| 134 | + $this->assertEquals("firstn lastn <[email protected]>", $contact->email_and_name1); |
|
| 135 | + $this->assertEquals("firstn lastn <[email protected]>", $contact->email_and_name2); |
|
| 136 | 136 | |
| 137 | 137 | } |
| 138 | 138 | |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $contact->fill_in_additional_detail_fields(); |
| 147 | 147 | |
| 148 | - $this->assertEquals("",$contact->account_name); |
|
| 149 | - $this->assertEquals("",$contact->account_id); |
|
| 150 | - $this->assertEquals("",$contact->report_to_name); |
|
| 148 | + $this->assertEquals("", $contact->account_name); |
|
| 149 | + $this->assertEquals("", $contact->account_id); |
|
| 150 | + $this->assertEquals("", $contact->report_to_name); |
|
| 151 | 151 | |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
| 155 | - public function testload_contacts_users_relationship(){ |
|
| 155 | + public function testload_contacts_users_relationship() { |
|
| 156 | 156 | |
| 157 | 157 | $contact = new Contact(); |
| 158 | 158 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $contact->first_name = "first"; |
| 176 | 176 | $contact->last_name = "last"; |
| 177 | 177 | |
| 178 | - $expected = array ( |
|
| 178 | + $expected = array( |
|
| 179 | 179 | 'NAME' => 'first last', |
| 180 | 180 | 'DELETED' => 0, |
| 181 | 181 | 'FIRST_NAME' => 'first', |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | |
| 204 | - public function testbuild_generic_where_clause () |
|
| 204 | + public function testbuild_generic_where_clause() |
|
| 205 | 205 | { |
| 206 | 206 | |
| 207 | 207 | $contact = new Contact(); |
@@ -209,13 +209,13 @@ discard block |
||
| 209 | 209 | //test with string |
| 210 | 210 | $expected = "contacts.last_name like 'test%' or contacts.first_name like 'test%' or accounts.name like 'test%' or contacts.assistant like 'test%' or ea.email_address like 'test%'"; |
| 211 | 211 | $actual = $contact->build_generic_where_clause('test'); |
| 212 | - $this->assertSame($expected,$actual); |
|
| 212 | + $this->assertSame($expected, $actual); |
|
| 213 | 213 | |
| 214 | 214 | |
| 215 | 215 | //test with number |
| 216 | 216 | $expected = "contacts.last_name like '1%' or contacts.first_name like '1%' or accounts.name like '1%' or contacts.assistant like '1%' or ea.email_address like '1%' or contacts.phone_home like '%1%' or contacts.phone_mobile like '%1%' or contacts.phone_work like '%1%' or contacts.phone_other like '%1%' or contacts.phone_fax like '%1%' or contacts.assistant_phone like '%1%'"; |
| 217 | 217 | $actual = $contact->build_generic_where_clause(1); |
| 218 | - $this->assertSame($expected,$actual); |
|
| 218 | + $this->assertSame($expected, $actual); |
|
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | $result = $contact->set_notification_body(new Sugar_Smarty(), $contact); |
| 233 | 233 | |
| 234 | - $this->assertEquals($contact->full_name ,$result->_tpl_vars['CONTACT_NAME']); |
|
| 235 | - $this->assertEquals($contact->description ,$result->_tpl_vars['CONTACT_DESCRIPTION']); |
|
| 234 | + $this->assertEquals($contact->full_name, $result->_tpl_vars['CONTACT_NAME']); |
|
| 235 | + $this->assertEquals($contact->description, $result->_tpl_vars['CONTACT_DESCRIPTION']); |
|
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $contact = new Contact(); |
| 242 | 242 | |
| 243 | 243 | $result = $contact->get_contact_id_by_email(""); |
| 244 | - $this->assertEquals(null,$result); |
|
| 244 | + $this->assertEquals(null, $result); |
|
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | //$result = $contact->get_contact_id_by_email("[email protected]"); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | //execute the method and verify that it retunrs expected results |
| 283 | 283 | $expected = "SELECT emails.id FROM emails JOIN (select DISTINCT email_id from emails_email_addr_rel eear\n\n join email_addr_bean_rel eabr on eabr.bean_id ='' and eabr.bean_module = 'Contacts' and\n eabr.email_address_id = eear.email_address_id and eabr.deleted=0\n where eear.deleted=0 and eear.email_id not in\n (select eb.email_id from emails_beans eb where eb.bean_module ='Contacts' and eb.bean_id = '')\n ) derivedemails on derivedemails.email_id = emails.id"; |
| 284 | 284 | $actual = $contact->get_unlinked_email_query(); |
| 285 | - $this->assertSame($expected,$actual); |
|
| 285 | + $this->assertSame($expected, $actual); |
|
| 286 | 286 | |
| 287 | 287 | } |
| 288 | 288 | |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | $output = $me->jsParser(); |
| 36 | 36 | |
| 37 | 37 | return $output; |
| 38 | - } catch (Exception $e) { |
|
| 38 | + }catch (Exception $e) { |
|
| 39 | 39 | // Exception handling is left up to the implementer. |
| 40 | 40 | throw $e; |
| 41 | 41 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | global $current_user; |
| 41 | 41 | $module_name = "Tasks"; |
| 42 | 42 | $searchFields['Tasks'] = |
| 43 | - array ( |
|
| 44 | - 'name' => array( 'query_type'=>'default'), |
|
| 43 | + array( |
|
| 44 | + 'name' => array('query_type'=>'default'), |
|
| 45 | 45 | 'contact_name' => array('query_type' => 'default', 'db_field' => array('contacts.first_name', 'contacts.last_name'), 'force_unifiedsearch' => true), |
| 46 | - 'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'), |
|
| 46 | + 'current_user_only'=> array('query_type'=>'default', 'db_field'=>array('assigned_user_id'), 'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'), |
|
| 47 | 47 | 'assigned_user_id'=> array('query_type'=>'default'), |
| 48 | 48 | 'status'=> array('query_type'=>'default', 'options' => 'task_status_dom', 'template_var' => 'STATUS_FILTER'), |
| 49 | 49 | |
@@ -60,22 +60,22 @@ discard block |
||
| 60 | 60 | 'subquery' => "SELECT favorites.parent_id FROM favorites |
| 61 | 61 | WHERE favorites.deleted = 0 |
| 62 | 62 | and favorites.parent_type = '".$module_name."' |
| 63 | - and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}", |
|
| 63 | + and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}", |
|
| 64 | 64 | 'db_field'=>array('id')), |
| 65 | 65 | //Range Search Support |
| 66 | - 'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 67 | - 'start_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 68 | - 'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 69 | - 'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 70 | - 'start_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 71 | - 'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 66 | + 'range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 67 | + 'start_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 68 | + 'end_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 69 | + 'range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 70 | + 'start_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 71 | + 'end_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 72 | 72 | |
| 73 | - 'range_date_start' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 74 | - 'start_range_date_start' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 75 | - 'end_range_date_start' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 76 | - 'range_date_due' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 77 | - 'start_range_date_due' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 78 | - 'end_range_date_due' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 73 | + 'range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 74 | + 'start_range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 75 | + 'end_range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 76 | + 'range_date_due' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 77 | + 'start_range_date_due' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 78 | + 'end_range_date_due' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true), |
|
| 79 | 79 | //Range Search Support |
| 80 | 80 | ); |
| 81 | 81 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -39,33 +39,33 @@ discard block |
||
| 39 | 39 | ********************************************************************************/ |
| 40 | 40 | global $current_user; |
| 41 | 41 | $module_name = "Calls"; |
| 42 | -$searchFields['Calls'] = array ( |
|
| 42 | +$searchFields['Calls'] = array( |
|
| 43 | 43 | 'name' => |
| 44 | - array ( |
|
| 44 | + array( |
|
| 45 | 45 | 'query_type' => 'default', |
| 46 | 46 | ), |
| 47 | 47 | 'contact_name' => |
| 48 | - array ( |
|
| 48 | + array( |
|
| 49 | 49 | 'query_type' => 'default', |
| 50 | 50 | 'db_field' => |
| 51 | - array ( |
|
| 51 | + array( |
|
| 52 | 52 | 0 => 'contacts.first_name', |
| 53 | 53 | 1 => 'contacts.last_name', |
| 54 | 54 | ), |
| 55 | 55 | ), |
| 56 | 56 | 'date_start' => |
| 57 | - array ( |
|
| 57 | + array( |
|
| 58 | 58 | 'query_type' => 'default', |
| 59 | 59 | ), |
| 60 | 60 | 'location' => |
| 61 | - array ( |
|
| 61 | + array( |
|
| 62 | 62 | 'query_type' => 'default', |
| 63 | 63 | ), |
| 64 | 64 | 'current_user_only' => |
| 65 | - array ( |
|
| 65 | + array( |
|
| 66 | 66 | 'query_type' => 'default', |
| 67 | 67 | 'db_field' => |
| 68 | - array ( |
|
| 68 | + array( |
|
| 69 | 69 | 0 => 'assigned_user_id', |
| 70 | 70 | ), |
| 71 | 71 | 'my_items' => true, |
@@ -73,98 +73,98 @@ discard block |
||
| 73 | 73 | 'type' => 'bool', |
| 74 | 74 | ), |
| 75 | 75 | 'assigned_user_id' => |
| 76 | - array ( |
|
| 76 | + array( |
|
| 77 | 77 | 'query_type' => 'default', |
| 78 | 78 | ), |
| 79 | 79 | 'status' => |
| 80 | - array ( |
|
| 80 | + array( |
|
| 81 | 81 | 'query_type' => 'default', |
| 82 | 82 | 'options' => 'call_status_dom', |
| 83 | 83 | 'template_var' => 'STATUS_FILTER', |
| 84 | 84 | ), |
| 85 | 85 | 'open_only' => |
| 86 | - array ( |
|
| 86 | + array( |
|
| 87 | 87 | 'query_type' => 'default', |
| 88 | 88 | 'db_field' => |
| 89 | - array ( |
|
| 89 | + array( |
|
| 90 | 90 | 0 => 'status', |
| 91 | 91 | ), |
| 92 | 92 | 'operator' => 'not in', |
| 93 | 93 | 'closed_values' => |
| 94 | - array ( |
|
| 94 | + array( |
|
| 95 | 95 | 0 => 'Held', |
| 96 | 96 | 1 => 'Not Held', |
| 97 | 97 | ), |
| 98 | 98 | 'type' => 'bool', |
| 99 | 99 | ), |
| 100 | 100 | 'range_date_entered' => |
| 101 | - array ( |
|
| 101 | + array( |
|
| 102 | 102 | 'query_type' => 'default', |
| 103 | 103 | 'enable_range_search' => true, |
| 104 | 104 | 'is_date_field' => true, |
| 105 | 105 | ), |
| 106 | 106 | 'start_range_date_entered' => |
| 107 | - array ( |
|
| 107 | + array( |
|
| 108 | 108 | 'query_type' => 'default', |
| 109 | 109 | 'enable_range_search' => true, |
| 110 | 110 | 'is_date_field' => true, |
| 111 | 111 | ), |
| 112 | 112 | 'end_range_date_entered' => |
| 113 | - array ( |
|
| 113 | + array( |
|
| 114 | 114 | 'query_type' => 'default', |
| 115 | 115 | 'enable_range_search' => true, |
| 116 | 116 | 'is_date_field' => true, |
| 117 | 117 | ), |
| 118 | 118 | 'range_date_modified' => |
| 119 | - array ( |
|
| 119 | + array( |
|
| 120 | 120 | 'query_type' => 'default', |
| 121 | 121 | 'enable_range_search' => true, |
| 122 | 122 | 'is_date_field' => true, |
| 123 | 123 | ), |
| 124 | 124 | 'start_range_date_modified' => |
| 125 | - array ( |
|
| 125 | + array( |
|
| 126 | 126 | 'query_type' => 'default', |
| 127 | 127 | 'enable_range_search' => true, |
| 128 | 128 | 'is_date_field' => true, |
| 129 | 129 | ), |
| 130 | 130 | 'end_range_date_modified' => |
| 131 | - array ( |
|
| 131 | + array( |
|
| 132 | 132 | 'query_type' => 'default', |
| 133 | 133 | 'enable_range_search' => true, |
| 134 | 134 | 'is_date_field' => true, |
| 135 | 135 | ), |
| 136 | 136 | 'range_date_start' => |
| 137 | - array ( |
|
| 137 | + array( |
|
| 138 | 138 | 'query_type' => 'default', |
| 139 | 139 | 'enable_range_search' => true, |
| 140 | 140 | 'is_date_field' => true, |
| 141 | 141 | ), |
| 142 | 142 | 'start_range_date_start' => |
| 143 | - array ( |
|
| 143 | + array( |
|
| 144 | 144 | 'query_type' => 'default', |
| 145 | 145 | 'enable_range_search' => true, |
| 146 | 146 | 'is_date_field' => true, |
| 147 | 147 | ), |
| 148 | 148 | 'end_range_date_start' => |
| 149 | - array ( |
|
| 149 | + array( |
|
| 150 | 150 | 'query_type' => 'default', |
| 151 | 151 | 'enable_range_search' => true, |
| 152 | 152 | 'is_date_field' => true, |
| 153 | 153 | ), |
| 154 | 154 | 'range_date_end' => |
| 155 | - array ( |
|
| 155 | + array( |
|
| 156 | 156 | 'query_type' => 'default', |
| 157 | 157 | 'enable_range_search' => true, |
| 158 | 158 | 'is_date_field' => true, |
| 159 | 159 | ), |
| 160 | 160 | 'start_range_date_end' => |
| 161 | - array ( |
|
| 161 | + array( |
|
| 162 | 162 | 'query_type' => 'default', |
| 163 | 163 | 'enable_range_search' => true, |
| 164 | 164 | 'is_date_field' => true, |
| 165 | 165 | ), |
| 166 | 166 | 'end_range_date_end' => |
| 167 | - array ( |
|
| 167 | + array( |
|
| 168 | 168 | 'query_type' => 'default', |
| 169 | 169 | 'enable_range_search' => true, |
| 170 | 170 | 'is_date_field' => true, |
@@ -175,6 +175,6 @@ discard block |
||
| 175 | 175 | 'subquery' => "SELECT favorites.parent_id FROM favorites |
| 176 | 176 | WHERE favorites.deleted = 0 |
| 177 | 177 | and favorites.parent_type = '".$module_name."' |
| 178 | - and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}", |
|
| 178 | + and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}", |
|
| 179 | 179 | 'db_field'=>array('id')), |
| 180 | 180 | ); |
| 181 | 181 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -39,42 +39,42 @@ discard block |
||
| 39 | 39 | ********************************************************************************/ |
| 40 | 40 | global $current_user; |
| 41 | 41 | $module_name = "Cases"; |
| 42 | -$searchFields['Cases'] = array ( |
|
| 42 | +$searchFields['Cases'] = array( |
|
| 43 | 43 | 'name' => |
| 44 | - array ( |
|
| 44 | + array( |
|
| 45 | 45 | 'query_type' => 'default', |
| 46 | 46 | ), |
| 47 | 47 | 'account_name' => |
| 48 | - array ( |
|
| 48 | + array( |
|
| 49 | 49 | 'query_type' => 'default', |
| 50 | 50 | 'db_field' => |
| 51 | - array ( |
|
| 51 | + array( |
|
| 52 | 52 | 0 => 'accounts.name', |
| 53 | 53 | ), |
| 54 | 54 | ), |
| 55 | 55 | 'status' => |
| 56 | - array ( |
|
| 56 | + array( |
|
| 57 | 57 | 'query_type' => 'default', |
| 58 | 58 | 'options' => 'case_status_dom', |
| 59 | 59 | 'template_var' => 'STATUS_OPTIONS', |
| 60 | 60 | ), |
| 61 | 61 | 'priority' => |
| 62 | - array ( |
|
| 62 | + array( |
|
| 63 | 63 | 'query_type' => 'default', |
| 64 | 64 | 'options' => 'case_priority_dom', |
| 65 | 65 | 'template_var' => 'PRIORITY_OPTIONS', |
| 66 | 66 | 'options_add_blank' => true, |
| 67 | 67 | ), |
| 68 | 68 | 'case_number' => |
| 69 | - array ( |
|
| 69 | + array( |
|
| 70 | 70 | 'query_type' => 'default', |
| 71 | 71 | 'operator' => 'in', |
| 72 | 72 | ), |
| 73 | 73 | 'current_user_only' => |
| 74 | - array ( |
|
| 74 | + array( |
|
| 75 | 75 | 'query_type' => 'default', |
| 76 | 76 | 'db_field' => |
| 77 | - array ( |
|
| 77 | + array( |
|
| 78 | 78 | 0 => 'assigned_user_id', |
| 79 | 79 | ), |
| 80 | 80 | 'my_items' => true, |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | 'type' => 'bool', |
| 83 | 83 | ), |
| 84 | 84 | 'assigned_user_id' => |
| 85 | - array ( |
|
| 85 | + array( |
|
| 86 | 86 | 'query_type' => 'default', |
| 87 | 87 | ), |
| 88 | 88 | 'open_only' => |
| 89 | - array ( |
|
| 89 | + array( |
|
| 90 | 90 | 'query_type' => 'default', |
| 91 | 91 | 'db_field' => |
| 92 | - array ( |
|
| 92 | + array( |
|
| 93 | 93 | 0 => 'status', |
| 94 | 94 | ), |
| 95 | 95 | 'operator' => 'not in', |
| 96 | 96 | 'closed_values' => |
| 97 | - array ( |
|
| 97 | + array( |
|
| 98 | 98 | 0 => 'Closed', |
| 99 | 99 | 1 => 'Rejected', |
| 100 | 100 | 2 => 'Duplicate', |
@@ -105,43 +105,43 @@ discard block |
||
| 105 | 105 | 'type' => 'bool', |
| 106 | 106 | ), |
| 107 | 107 | 'range_date_entered' => |
| 108 | - array ( |
|
| 108 | + array( |
|
| 109 | 109 | 'query_type' => 'default', |
| 110 | 110 | 'enable_range_search' => true, |
| 111 | 111 | 'is_date_field' => true, |
| 112 | 112 | ), |
| 113 | 113 | 'start_range_date_entered' => |
| 114 | - array ( |
|
| 114 | + array( |
|
| 115 | 115 | 'query_type' => 'default', |
| 116 | 116 | 'enable_range_search' => true, |
| 117 | 117 | 'is_date_field' => true, |
| 118 | 118 | ), |
| 119 | 119 | 'end_range_date_entered' => |
| 120 | - array ( |
|
| 120 | + array( |
|
| 121 | 121 | 'query_type' => 'default', |
| 122 | 122 | 'enable_range_search' => true, |
| 123 | 123 | 'is_date_field' => true, |
| 124 | 124 | ), |
| 125 | 125 | 'range_date_modified' => |
| 126 | - array ( |
|
| 126 | + array( |
|
| 127 | 127 | 'query_type' => 'default', |
| 128 | 128 | 'enable_range_search' => true, |
| 129 | 129 | 'is_date_field' => true, |
| 130 | 130 | ), |
| 131 | 131 | 'start_range_date_modified' => |
| 132 | - array ( |
|
| 132 | + array( |
|
| 133 | 133 | 'query_type' => 'default', |
| 134 | 134 | 'enable_range_search' => true, |
| 135 | 135 | 'is_date_field' => true, |
| 136 | 136 | ), |
| 137 | 137 | 'end_range_date_modified' => |
| 138 | - array ( |
|
| 138 | + array( |
|
| 139 | 139 | 'query_type' => 'default', |
| 140 | 140 | 'enable_range_search' => true, |
| 141 | 141 | 'is_date_field' => true, |
| 142 | 142 | ), |
| 143 | 143 | 'state' => |
| 144 | - array ( |
|
| 144 | + array( |
|
| 145 | 145 | 'query_type' => 'default', |
| 146 | 146 | ), |
| 147 | 147 | 'favorites_only' => array( |
@@ -150,6 +150,6 @@ discard block |
||
| 150 | 150 | 'subquery' => "SELECT favorites.parent_id FROM favorites |
| 151 | 151 | WHERE favorites.deleted = 0 |
| 152 | 152 | and favorites.parent_type = '".$module_name."' |
| 153 | - and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}", |
|
| 153 | + and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}", |
|
| 154 | 154 | 'db_field'=>array('id')), |
| 155 | 155 | ); |
| 156 | 156 | \ No newline at end of file |