@@ -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. |
@@ -170,25 +170,25 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
172 | 172 | { |
173 | - if(is_array($sql)) { |
|
173 | + if (is_array($sql)) { |
|
174 | 174 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
175 | 175 | } |
176 | 176 | |
177 | 177 | parent::countQuery($sql); |
178 | - $GLOBALS['log']->info('Query:' . $sql); |
|
178 | + $GLOBALS['log']->info('Query:'.$sql); |
|
179 | 179 | $this->checkConnection(); |
180 | 180 | $this->query_time = microtime(true); |
181 | 181 | $this->lastsql = $sql; |
182 | - $result = $suppress?@mysql_query($sql, $this->database):mysql_query($sql, $this->database); |
|
182 | + $result = $suppress ? @mysql_query($sql, $this->database) : mysql_query($sql, $this->database); |
|
183 | 183 | |
184 | 184 | $this->query_time = microtime(true) - $this->query_time; |
185 | 185 | $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
186 | 186 | |
187 | 187 | |
188 | - if($keepResult) |
|
188 | + if ($keepResult) |
|
189 | 189 | $this->lastResult = $result; |
190 | 190 | |
191 | - $this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError); |
|
191 | + $this->checkError($msg.' Query Failed:'.$sql.'::', $dieOnError); |
|
192 | 192 | return $result; |
193 | 193 | } |
194 | 194 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | public function disconnect() |
225 | 225 | { |
226 | 226 | $GLOBALS['log']->debug('Calling MySQL::disconnect()'); |
227 | - if(!empty($this->database)){ |
|
227 | + if (!empty($this->database)) { |
|
228 | 228 | $this->freeResult(); |
229 | 229 | mysql_close($this->database); |
230 | 230 | $this->database = null; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | protected function freeDbResult($dbResult) |
238 | 238 | { |
239 | - if(!empty($dbResult)) |
|
239 | + if (!empty($dbResult)) |
|
240 | 240 | mysql_free_result($dbResult); |
241 | 241 | } |
242 | 242 | |
@@ -262,15 +262,15 @@ discard block |
||
262 | 262 | $count = (int)$count; |
263 | 263 | if ($start < 0) |
264 | 264 | $start = 0; |
265 | - $GLOBALS['log']->debug('Limit Query:' . $sql. ' Start: ' .$start . ' count: ' . $count); |
|
265 | + $GLOBALS['log']->debug('Limit Query:'.$sql.' Start: '.$start.' count: '.$count); |
|
266 | 266 | |
267 | 267 | $sql = "$sql LIMIT $start,$count"; |
268 | 268 | $this->lastsql = $sql; |
269 | 269 | |
270 | - if(!empty($GLOBALS['sugar_config']['check_query'])){ |
|
270 | + if (!empty($GLOBALS['sugar_config']['check_query'])) { |
|
271 | 271 | $this->checkQuery($sql); |
272 | 272 | } |
273 | - if(!$execute) { |
|
273 | + if (!$execute) { |
|
274 | 274 | return $sql; |
275 | 275 | } |
276 | 276 | |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | */ |
284 | 284 | protected function checkQuery($sql, $object_name = false) |
285 | 285 | { |
286 | - $result = $this->query('EXPLAIN ' . $sql); |
|
286 | + $result = $this->query('EXPLAIN '.$sql); |
|
287 | 287 | $badQuery = array(); |
288 | 288 | while ($row = $this->fetchByAssoc($result)) { |
289 | 289 | if (empty($row['table'])) |
290 | 290 | continue; |
291 | 291 | $badQuery[$row['table']] = ''; |
292 | 292 | if (strtoupper($row['type']) == 'ALL') |
293 | - $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
293 | + $badQuery[$row['table']] .= ' Full Table Scan;'; |
|
294 | 294 | if (empty($row['key'])) |
295 | 295 | $badQuery[$row['table']] .= ' No Index Key Used;'; |
296 | 296 | if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0) |
@@ -299,18 +299,18 @@ discard block |
||
299 | 299 | $badQuery[$row['table']] .= ' Using Temporary Table;'; |
300 | 300 | } |
301 | 301 | |
302 | - if ( empty($badQuery) ) |
|
302 | + if (empty($badQuery)) |
|
303 | 303 | return true; |
304 | 304 | |
305 | - foreach($badQuery as $table=>$data ){ |
|
306 | - if(!empty($data)){ |
|
307 | - $warning = ' Table:' . $table . ' Data:' . $data; |
|
308 | - if(!empty($GLOBALS['sugar_config']['check_query_log'])){ |
|
305 | + foreach ($badQuery as $table=>$data) { |
|
306 | + if (!empty($data)) { |
|
307 | + $warning = ' Table:'.$table.' Data:'.$data; |
|
308 | + if (!empty($GLOBALS['sugar_config']['check_query_log'])) { |
|
309 | 309 | $GLOBALS['log']->fatal($sql); |
310 | - $GLOBALS['log']->fatal('CHECK QUERY:' .$warning); |
|
310 | + $GLOBALS['log']->fatal('CHECK QUERY:'.$warning); |
|
311 | 311 | } |
312 | - else{ |
|
313 | - $GLOBALS['log']->warn('CHECK QUERY:' .$warning); |
|
312 | + else { |
|
313 | + $GLOBALS['log']->warn('CHECK QUERY:'.$warning); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | } |
@@ -327,19 +327,19 @@ discard block |
||
327 | 327 | $result = $this->query("DESCRIBE $tablename"); |
328 | 328 | |
329 | 329 | $columns = array(); |
330 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
330 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
331 | 331 | $name = strtolower($row['Field']); |
332 | - $columns[$name]['name']=$name; |
|
332 | + $columns[$name]['name'] = $name; |
|
333 | 333 | $matches = array(); |
334 | 334 | preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*)\)|)( unsigned)?/i', $row['Type'], $matches); |
335 | - $columns[$name]['type']=strtolower($matches[1][0]); |
|
336 | - if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) ) |
|
337 | - $columns[$name]['len']=strtolower($matches[2][0]); |
|
338 | - if ( stristr($row['Extra'],'auto_increment') ) |
|
335 | + $columns[$name]['type'] = strtolower($matches[1][0]); |
|
336 | + if (isset($matches[2][0]) && in_array(strtolower($matches[1][0]), array('varchar', 'char', 'varchar2', 'int', 'decimal', 'float'))) |
|
337 | + $columns[$name]['len'] = strtolower($matches[2][0]); |
|
338 | + if (stristr($row['Extra'], 'auto_increment')) |
|
339 | 339 | $columns[$name]['auto_increment'] = '1'; |
340 | - if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI')) |
|
340 | + if ($row['Null'] == 'NO' && !stristr($row['Key'], 'PRI')) |
|
341 | 341 | $columns[$name]['required'] = 'true'; |
342 | - if (!empty($row['Default']) ) |
|
342 | + if (!empty($row['Default'])) |
|
343 | 343 | $columns[$name]['default'] = $row['Default']; |
344 | 344 | } |
345 | 345 | return $columns; |
@@ -348,20 +348,20 @@ discard block |
||
348 | 348 | /** |
349 | 349 | * @see DBManager::getFieldsArray() |
350 | 350 | */ |
351 | - public function getFieldsArray($result, $make_lower_case=false) |
|
351 | + public function getFieldsArray($result, $make_lower_case = false) |
|
352 | 352 | { |
353 | 353 | $field_array = array(); |
354 | 354 | |
355 | - if(empty($result)) |
|
355 | + if (empty($result)) |
|
356 | 356 | return 0; |
357 | 357 | |
358 | 358 | $fields = mysql_num_fields($result); |
359 | - for ($i=0; $i < $fields; $i++) { |
|
359 | + for ($i = 0; $i < $fields; $i++) { |
|
360 | 360 | $meta = mysql_fetch_field($result, $i); |
361 | 361 | if (!$meta) |
362 | 362 | return array(); |
363 | 363 | |
364 | - if($make_lower_case == true) |
|
364 | + if ($make_lower_case == true) |
|
365 | 365 | $meta->name = strtolower($meta->name); |
366 | 366 | |
367 | 367 | $field_array[] = $meta->name; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | if (!empty($r)) { |
394 | 394 | while ($a = $this->fetchByAssoc($r)) { |
395 | 395 | $row = array_values($a); |
396 | - $tables[]=$row[0]; |
|
396 | + $tables[] = $row[0]; |
|
397 | 397 | } |
398 | 398 | return $tables; |
399 | 399 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | if ($this->getDatabase()) { |
421 | 421 | $result = $this->query("SHOW TABLES LIKE ".$this->quoted($tableName)); |
422 | - if(empty($result)) return false; |
|
422 | + if (empty($result)) return false; |
|
423 | 423 | $row = $this->fetchByAssoc($result); |
424 | 424 | return !empty($row); |
425 | 425 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | if (!empty($r)) { |
441 | 441 | while ($a = $this->fetchByAssoc($r)) { |
442 | 442 | $row = array_values($a); |
443 | - $tables[]=$row[0]; |
|
443 | + $tables[] = $row[0]; |
|
444 | 444 | } |
445 | 445 | return $tables; |
446 | 446 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | */ |
454 | 454 | public function quote($string) |
455 | 455 | { |
456 | - if(is_array($string)) { |
|
456 | + if (is_array($string)) { |
|
457 | 457 | return $this->arrayQuote($string); |
458 | 458 | } |
459 | 459 | return mysql_real_escape_string($this->quoteInternal($string), $this->getDatabase()); |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | { |
475 | 475 | global $sugar_config; |
476 | 476 | |
477 | - if(is_null($configOptions)) |
|
477 | + if (is_null($configOptions)) |
|
478 | 478 | $configOptions = $sugar_config['dbconfig']; |
479 | 479 | |
480 | 480 | if ($this->getOption('persistent')) { |
@@ -491,10 +491,10 @@ discard block |
||
491 | 491 | $configOptions['db_user_name'], |
492 | 492 | $configOptions['db_password'] |
493 | 493 | ); |
494 | - if(empty($this->database)) { |
|
494 | + if (empty($this->database)) { |
|
495 | 495 | $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']." as ".$configOptions['db_user_name'].":".mysql_error()); |
496 | - if($dieOnError) { |
|
497 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
496 | + if ($dieOnError) { |
|
497 | + if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
498 | 498 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
499 | 499 | } else { |
500 | 500 | sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
@@ -504,15 +504,15 @@ discard block |
||
504 | 504 | } |
505 | 505 | } |
506 | 506 | // Do not pass connection information because we have not connected yet |
507 | - if($this->database && $this->getOption('persistent')){ |
|
507 | + if ($this->database && $this->getOption('persistent')) { |
|
508 | 508 | $_SESSION['administrator_error'] = "<b>Severe Performance Degradation: Persistent Database Connections " |
509 | 509 | . "not working. Please set \$sugar_config['dbconfigoption']['persistent'] to false " |
510 | 510 | . "in your config.php file</b>"; |
511 | 511 | } |
512 | 512 | } |
513 | - if(!empty($configOptions['db_name']) && !@mysql_select_db($configOptions['db_name'])) { |
|
514 | - $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysql_error($this->database)); |
|
515 | - if($dieOnError) { |
|
513 | + if (!empty($configOptions['db_name']) && !@mysql_select_db($configOptions['db_name'])) { |
|
514 | + $GLOBALS['log']->fatal("Unable to select database {$configOptions['db_name']}: ".mysql_error($this->database)); |
|
515 | + if ($dieOnError) { |
|
516 | 516 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
517 | 517 | } else { |
518 | 518 | return false; |
@@ -523,12 +523,12 @@ discard block |
||
523 | 523 | mysql_query("SET CHARACTER SET utf8", $this->database); |
524 | 524 | $names = "SET NAMES 'utf8'"; |
525 | 525 | $collation = $this->getOption('collation'); |
526 | - if(!empty($collation)) { |
|
526 | + if (!empty($collation)) { |
|
527 | 527 | $names .= " COLLATE '$collation'"; |
528 | 528 | } |
529 | 529 | mysql_query($names, $this->database); |
530 | 530 | |
531 | - if(!$this->checkError('Could Not Connect:', $dieOnError)) |
|
531 | + if (!$this->checkError('Could Not Connect:', $dieOnError)) |
|
532 | 532 | $GLOBALS['log']->info("connected to db"); |
533 | 533 | $this->connectOptions = $configOptions; |
534 | 534 | |
@@ -544,16 +544,16 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null) |
546 | 546 | { |
547 | - $sql = parent::repairTableParams($tablename,$fielddefs,$indices,false,$engine); |
|
547 | + $sql = parent::repairTableParams($tablename, $fielddefs, $indices, false, $engine); |
|
548 | 548 | |
549 | - if ( $sql == '' ) |
|
549 | + if ($sql == '') |
|
550 | 550 | return ''; |
551 | 551 | |
552 | - if ( stristr($sql,'create table') ) |
|
552 | + if (stristr($sql, 'create table')) |
|
553 | 553 | { |
554 | 554 | if ($execute) { |
555 | - $msg = "Error creating table: ".$tablename. ":"; |
|
556 | - $this->query($sql,true,$msg); |
|
555 | + $msg = "Error creating table: ".$tablename.":"; |
|
556 | + $this->query($sql, true, $msg); |
|
557 | 557 | } |
558 | 558 | return $sql; |
559 | 559 | } |
@@ -562,23 +562,23 @@ discard block |
||
562 | 562 | $match = array(); |
563 | 563 | preg_match_all('!/\*.*?\*/!is', $sql, $match); |
564 | 564 | $commentBlocks = $match[0]; |
565 | - $sql = preg_replace('!/\*.*?\*/!is','', $sql); |
|
565 | + $sql = preg_replace('!/\*.*?\*/!is', '', $sql); |
|
566 | 566 | |
567 | 567 | // now, we should only have alter table statements |
568 | 568 | // let's replace the 'alter table name' part with a comma |
569 | - $sql = preg_replace("!alter table $tablename!is",', ', $sql); |
|
569 | + $sql = preg_replace("!alter table $tablename!is", ', ', $sql); |
|
570 | 570 | |
571 | 571 | // re-add it at the beginning |
572 | - $sql = substr_replace($sql,'',strpos($sql,','),1); |
|
573 | - $sql = str_replace(";","",$sql); |
|
574 | - $sql = str_replace("\n","",$sql); |
|
572 | + $sql = substr_replace($sql, '', strpos($sql, ','), 1); |
|
573 | + $sql = str_replace(";", "", $sql); |
|
574 | + $sql = str_replace("\n", "", $sql); |
|
575 | 575 | $sql = "ALTER TABLE $tablename $sql"; |
576 | 576 | |
577 | - if ( $execute ) |
|
578 | - $this->query($sql,'Error with MySQL repair table'); |
|
577 | + if ($execute) |
|
578 | + $this->query($sql, 'Error with MySQL repair table'); |
|
579 | 579 | |
580 | 580 | // and re-add the comments at the beginning |
581 | - $sql = implode("\n",$commentBlocks) . "\n". $sql . "\n"; |
|
581 | + $sql = implode("\n", $commentBlocks)."\n".$sql."\n"; |
|
582 | 582 | |
583 | 583 | return $sql; |
584 | 584 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | public function convert($string, $type, array $additional_parameters = array()) |
590 | 590 | { |
591 | 591 | $all_parameters = $additional_parameters; |
592 | - if(is_array($string)) { |
|
592 | + if (is_array($string)) { |
|
593 | 593 | $all_parameters = array_merge($string, $all_parameters); |
594 | 594 | } elseif (!is_null($string)) { |
595 | 595 | array_unshift($all_parameters, $string); |
@@ -602,17 +602,17 @@ discard block |
||
602 | 602 | case 'left': |
603 | 603 | return "LEFT($all_strings)"; |
604 | 604 | case 'date_format': |
605 | - if(empty($additional_parameters)) { |
|
605 | + if (empty($additional_parameters)) { |
|
606 | 606 | return "DATE_FORMAT($string,'%Y-%m-%d')"; |
607 | 607 | } else { |
608 | 608 | $format = $additional_parameters[0]; |
609 | - if($format[0] != "'") { |
|
609 | + if ($format[0] != "'") { |
|
610 | 610 | $format = $this->quoted($format); |
611 | 611 | } |
612 | 612 | return "DATE_FORMAT($string,$format)"; |
613 | 613 | } |
614 | 614 | case 'ifnull': |
615 | - if(empty($additional_parameters) && !strstr($all_strings, ",")) { |
|
615 | + if (empty($additional_parameters) && !strstr($all_strings, ",")) { |
|
616 | 616 | $all_strings .= ",''"; |
617 | 617 | } |
618 | 618 | return "IFNULL($all_strings)"; |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | case 'add_tz_offset' : |
632 | 632 | $getUserUTCOffset = $GLOBALS['timedate']->getUserUTCOffset(); |
633 | 633 | $operation = $getUserUTCOffset < 0 ? '-' : '+'; |
634 | - return $string . ' ' . $operation . ' INTERVAL ' . abs($getUserUTCOffset) . ' MINUTE'; |
|
634 | + return $string.' '.$operation.' INTERVAL '.abs($getUserUTCOffset).' MINUTE'; |
|
635 | 635 | case 'avg': |
636 | 636 | return "avg($string)"; |
637 | 637 | } |
@@ -672,15 +672,15 @@ discard block |
||
672 | 672 | */ |
673 | 673 | protected function isEngineEnabled($engine) |
674 | 674 | { |
675 | - if(!is_string($engine)) return false; |
|
675 | + if (!is_string($engine)) return false; |
|
676 | 676 | |
677 | 677 | $engine = strtoupper($engine); |
678 | 678 | |
679 | 679 | $r = $this->query("SHOW ENGINES"); |
680 | 680 | |
681 | - while ( $row = $this->fetchByAssoc($r) ) |
|
682 | - if ( strtoupper($row['Engine']) == $engine ) |
|
683 | - return ($row['Support']=='YES' || $row['Support']=='DEFAULT'); |
|
681 | + while ($row = $this->fetchByAssoc($r)) |
|
682 | + if (strtoupper($row['Engine']) == $engine) |
|
683 | + return ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT'); |
|
684 | 684 | |
685 | 685 | return false; |
686 | 686 | } |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | */ |
709 | 709 | public function createTableSQLParams($tablename, $fieldDefs, $indices, $engine = null) |
710 | 710 | { |
711 | - if ( empty($engine) && isset($fieldDefs['engine'])) |
|
711 | + if (empty($engine) && isset($fieldDefs['engine'])) |
|
712 | 712 | $engine = $fieldDefs['engine']; |
713 | - if ( !$this->isEngineEnabled($engine) ) |
|
713 | + if (!$this->isEngineEnabled($engine)) |
|
714 | 714 | $engine = ''; |
715 | 715 | |
716 | 716 | $columns = $this->columnSQLRep($fieldDefs, false, $tablename); |
@@ -723,13 +723,13 @@ discard block |
||
723 | 723 | |
724 | 724 | // cn: bug 9873 - module tables do not get created in utf8 with assoc collation |
725 | 725 | $collation = $this->getOption('collation'); |
726 | - if(empty($collation)) { |
|
726 | + if (empty($collation)) { |
|
727 | 727 | $collation = 'utf8_general_ci'; |
728 | 728 | } |
729 | 729 | $sql = "CREATE TABLE $tablename ($columns $keys) CHARACTER SET utf8 COLLATE $collation"; |
730 | 730 | |
731 | 731 | if (!empty($engine)) |
732 | - $sql.= " ENGINE=$engine"; |
|
732 | + $sql .= " ENGINE=$engine"; |
|
733 | 733 | |
734 | 734 | return $sql; |
735 | 735 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | public function isTextType($type) |
742 | 742 | { |
743 | 743 | $type = $this->getColumnType(strtolower($type)); |
744 | - return in_array($type, array('blob','text','longblob', 'longtext')); |
|
744 | + return in_array($type, array('blob', 'text', 'longblob', 'longtext')); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -752,16 +752,16 @@ discard block |
||
752 | 752 | // always return as array for post-processing |
753 | 753 | $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); |
754 | 754 | |
755 | - if ( $ref['colType'] == 'int' && !empty($fieldDef['len']) ) { |
|
755 | + if ($ref['colType'] == 'int' && !empty($fieldDef['len'])) { |
|
756 | 756 | $ref['colType'] .= "(".$fieldDef['len'].")"; |
757 | 757 | } |
758 | 758 | |
759 | 759 | // bug 22338 - don't set a default value on text or blob fields |
760 | - if ( isset($ref['default']) && |
|
760 | + if (isset($ref['default']) && |
|
761 | 761 | in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob'))) |
762 | 762 | $ref['default'] = ''; |
763 | 763 | |
764 | - if ( $return_as_array ) |
|
764 | + if ($return_as_array) |
|
765 | 765 | return $ref; |
766 | 766 | else |
767 | 767 | return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) |
774 | 774 | { |
775 | 775 | $columns = array(); |
776 | - if ($this->isFieldArray($fieldDefs)){ |
|
777 | - foreach ($fieldDefs as $def){ |
|
776 | + if ($this->isFieldArray($fieldDefs)) { |
|
777 | + foreach ($fieldDefs as $def) { |
|
778 | 778 | if ($action == 'drop') |
779 | 779 | $columns[] = $def['name']; |
780 | 780 | else |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | |
812 | 812 | $columns = array(); |
813 | 813 | foreach ($indices as $index) { |
814 | - if(!empty($index['db']) && $index['db'] != $this->dbType) |
|
814 | + if (!empty($index['db']) && $index['db'] != $this->dbType) |
|
815 | 815 | continue; |
816 | 816 | if (isset($index['source']) && $index['source'] != 'db') |
817 | 817 | continue; |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * that this can easily be fixed by referring to db dictionary |
842 | 842 | * to find the correct primary field name |
843 | 843 | */ |
844 | - if ( $alter_table ) |
|
844 | + if ($alter_table) |
|
845 | 845 | $columns[] = " INDEX $name ($fields)"; |
846 | 846 | else |
847 | 847 | $columns[] = " KEY $name ($fields)"; |
@@ -850,13 +850,13 @@ discard block |
||
850 | 850 | if ($this->full_text_indexing_installed()) |
851 | 851 | $columns[] = " FULLTEXT ($fields)"; |
852 | 852 | else |
853 | - $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name); |
|
853 | + $GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:', $name); |
|
854 | 854 | break; |
855 | 855 | } |
856 | 856 | } |
857 | 857 | $columns = implode(", $alter_action ", $columns); |
858 | - if(!empty($alter_action)){ |
|
859 | - $columns = $alter_action . ' '. $columns; |
|
858 | + if (!empty($alter_action)) { |
|
859 | + $columns = $alter_action.' '.$columns; |
|
860 | 860 | } |
861 | 861 | return $columns; |
862 | 862 | } |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | public function setAutoIncrementStart($table, $field_name, $start_value) |
879 | 879 | { |
880 | 880 | $start_value = (int)$start_value; |
881 | - return $this->query( "ALTER TABLE $table AUTO_INCREMENT = $start_value;"); |
|
881 | + return $this->query("ALTER TABLE $table AUTO_INCREMENT = $start_value;"); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
@@ -907,18 +907,18 @@ discard block |
||
907 | 907 | $result = $this->query("SHOW INDEX FROM $tablename"); |
908 | 908 | |
909 | 909 | $indices = array(); |
910 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
911 | - $index_type='index'; |
|
912 | - if ($row['Key_name'] =='PRIMARY') { |
|
913 | - $index_type='primary'; |
|
910 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
911 | + $index_type = 'index'; |
|
912 | + if ($row['Key_name'] == 'PRIMARY') { |
|
913 | + $index_type = 'primary'; |
|
914 | 914 | } |
915 | - elseif ( $row['Non_unique'] == '0' ) { |
|
916 | - $index_type='unique'; |
|
915 | + elseif ($row['Non_unique'] == '0') { |
|
916 | + $index_type = 'unique'; |
|
917 | 917 | } |
918 | 918 | $name = strtolower($row['Key_name']); |
919 | - $indices[$name]['name']=$name; |
|
920 | - $indices[$name]['type']=$index_type; |
|
921 | - $indices[$name]['fields'][]=strtolower($row['Column_name']); |
|
919 | + $indices[$name]['name'] = $name; |
|
920 | + $indices[$name]['type'] = $index_type; |
|
921 | + $indices[$name]['fields'][] = strtolower($row['Column_name']); |
|
922 | 922 | } |
923 | 923 | return $indices; |
924 | 924 | } |
@@ -929,11 +929,11 @@ discard block |
||
929 | 929 | public function add_drop_constraint($table, $definition, $drop = false) |
930 | 930 | { |
931 | 931 | $type = $definition['type']; |
932 | - $fields = implode(',',$definition['fields']); |
|
932 | + $fields = implode(',', $definition['fields']); |
|
933 | 933 | $name = $definition['name']; |
934 | 934 | $sql = ''; |
935 | 935 | |
936 | - switch ($type){ |
|
936 | + switch ($type) { |
|
937 | 937 | // generic indices |
938 | 938 | case 'index': |
939 | 939 | case 'alternate_key': |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | */ |
978 | 978 | public function fetchOne($sql, $dieOnError = false, $msg = '', $suppress = false) |
979 | 979 | { |
980 | - if(stripos($sql, ' LIMIT ') === false) { |
|
980 | + if (stripos($sql, ' LIMIT ') === false) { |
|
981 | 981 | // little optimization to just fetch one row |
982 | 982 | $sql .= " LIMIT 0,1"; |
983 | 983 | } |
@@ -997,13 +997,13 @@ discard block |
||
997 | 997 | */ |
998 | 998 | public function massageFieldDef(&$fieldDef, $tablename) |
999 | 999 | { |
1000 | - parent::massageFieldDef($fieldDef,$tablename); |
|
1000 | + parent::massageFieldDef($fieldDef, $tablename); |
|
1001 | 1001 | |
1002 | - if ( isset($fieldDef['default']) && |
|
1002 | + if (isset($fieldDef['default']) && |
|
1003 | 1003 | ($fieldDef['dbType'] == 'text' |
1004 | 1004 | || $fieldDef['dbType'] == 'blob' |
1005 | 1005 | || $fieldDef['dbType'] == 'longtext' |
1006 | - || $fieldDef['dbType'] == 'longblob' )) |
|
1006 | + || $fieldDef['dbType'] == 'longblob')) |
|
1007 | 1007 | unset($fieldDef['default']); |
1008 | 1008 | if ($fieldDef['dbType'] == 'uint') |
1009 | 1009 | $fieldDef['len'] = '10'; |
@@ -1011,22 +1011,22 @@ discard block |
||
1011 | 1011 | $fieldDef['len'] = '20'; |
1012 | 1012 | if ($fieldDef['dbType'] == 'bool') |
1013 | 1013 | $fieldDef['type'] = 'tinyint'; |
1014 | - if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) ) |
|
1014 | + if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default'])) |
|
1015 | 1015 | $fieldDef['default'] = '0'; |
1016 | - if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) ) |
|
1016 | + if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len'])) |
|
1017 | 1017 | $fieldDef['len'] = '255'; |
1018 | 1018 | if ($fieldDef['dbType'] == 'uint') |
1019 | 1019 | $fieldDef['len'] = '10'; |
1020 | - if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) ) |
|
1020 | + if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len'])) |
|
1021 | 1021 | $fieldDef['len'] = '11'; |
1022 | 1022 | |
1023 | - if($fieldDef['dbType'] == 'decimal') { |
|
1024 | - if(isset($fieldDef['len'])) { |
|
1025 | - if(strstr($fieldDef['len'], ",") === false) { |
|
1023 | + if ($fieldDef['dbType'] == 'decimal') { |
|
1024 | + if (isset($fieldDef['len'])) { |
|
1025 | + if (strstr($fieldDef['len'], ",") === false) { |
|
1026 | 1026 | $fieldDef['len'] .= ",0"; |
1027 | 1027 | } |
1028 | 1028 | } else { |
1029 | - $fieldDef['len'] = '10,0'; |
|
1029 | + $fieldDef['len'] = '10,0'; |
|
1030 | 1030 | } |
1031 | 1031 | } |
1032 | 1032 | } |
@@ -1046,8 +1046,8 @@ discard block |
||
1046 | 1046 | { |
1047 | 1047 | $sql = array(); |
1048 | 1048 | foreach ($indexes as $index) { |
1049 | - $name =$index['name']; |
|
1050 | - if($execute) { |
|
1049 | + $name = $index['name']; |
|
1050 | + if ($execute) { |
|
1051 | 1051 | unset(self::$index_descriptions[$tablename][$name]); |
1052 | 1052 | } |
1053 | 1053 | if ($index['type'] == 'primary') { |
@@ -1057,8 +1057,8 @@ discard block |
||
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 | if (!empty($sql)) { |
1060 | - $sql = "ALTER TABLE $tablename " . join(",", $sql) . ";"; |
|
1061 | - if($execute) |
|
1060 | + $sql = "ALTER TABLE $tablename ".join(",", $sql).";"; |
|
1061 | + if ($execute) |
|
1062 | 1062 | $this->query($sql); |
1063 | 1063 | } else { |
1064 | 1064 | $sql = ''; |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | $q = "SHOW COLLATION LIKE 'utf8%'"; |
1085 | 1085 | $r = $this->query($q); |
1086 | 1086 | $res = array(); |
1087 | - while($a = $this->fetchByAssoc($r)) { |
|
1087 | + while ($a = $this->fetchByAssoc($r)) { |
|
1088 | 1088 | $res[] = $a['Collation']; |
1089 | 1089 | } |
1090 | 1090 | return $res; |
@@ -1104,13 +1104,13 @@ discard block |
||
1104 | 1104 | public function emptyValue($type) |
1105 | 1105 | { |
1106 | 1106 | $ctype = $this->getColumnType($type); |
1107 | - if($ctype == "datetime") { |
|
1107 | + if ($ctype == "datetime") { |
|
1108 | 1108 | return $this->convert($this->quoted("0000-00-00 00:00:00"), "datetime"); |
1109 | 1109 | } |
1110 | - if($ctype == "date") { |
|
1110 | + if ($ctype == "date") { |
|
1111 | 1111 | return $this->convert($this->quoted("0000-00-00"), "date"); |
1112 | 1112 | } |
1113 | - if($ctype == "time") { |
|
1113 | + if ($ctype == "time") { |
|
1114 | 1114 | return $this->convert($this->quoted("00:00:00"), "time"); |
1115 | 1115 | } |
1116 | 1116 | return parent::emptyValue($type); |
@@ -1122,13 +1122,13 @@ discard block |
||
1122 | 1122 | */ |
1123 | 1123 | public function lastDbError() |
1124 | 1124 | { |
1125 | - if($this->database) { |
|
1126 | - if(mysql_errno($this->database)) { |
|
1125 | + if ($this->database) { |
|
1126 | + if (mysql_errno($this->database)) { |
|
1127 | 1127 | return "MySQL error ".mysql_errno($this->database).": ".mysql_error($this->database); |
1128 | 1128 | } |
1129 | 1129 | } else { |
1130 | - $err = mysql_error(); |
|
1131 | - if($err) { |
|
1130 | + $err = mysql_error(); |
|
1131 | + if ($err) { |
|
1132 | 1132 | return $err; |
1133 | 1133 | } |
1134 | 1134 | } |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | */ |
1142 | 1142 | protected function quoteTerm($term) |
1143 | 1143 | { |
1144 | - if(strpos($term, ' ') !== false) { |
|
1144 | + if (strpos($term, ' ') !== false) { |
|
1145 | 1145 | return '"'.$term.'"'; |
1146 | 1146 | } |
1147 | 1147 | return $term; |
@@ -1157,16 +1157,16 @@ discard block |
||
1157 | 1157 | public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array()) |
1158 | 1158 | { |
1159 | 1159 | $condition = array(); |
1160 | - foreach($terms as $term) { |
|
1160 | + foreach ($terms as $term) { |
|
1161 | 1161 | $condition[] = $this->quoteTerm($term); |
1162 | 1162 | } |
1163 | - foreach($must_terms as $term) { |
|
1163 | + foreach ($must_terms as $term) { |
|
1164 | 1164 | $condition[] = "+".$this->quoteTerm($term); |
1165 | 1165 | } |
1166 | - foreach($exclude_terms as $term) { |
|
1166 | + foreach ($exclude_terms as $term) { |
|
1167 | 1167 | $condition[] = "-".$this->quoteTerm($term); |
1168 | 1168 | } |
1169 | - $condition = $this->quoted(join(" ",$condition)); |
|
1169 | + $condition = $this->quoted(join(" ", $condition)); |
|
1170 | 1170 | return "MATCH($field) AGAINST($condition IN BOOLEAN MODE)"; |
1171 | 1171 | } |
1172 | 1172 | |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | { |
1179 | 1179 | $charsets = array(); |
1180 | 1180 | $res = $this->query("show variables like 'character\\_set\\_%'"); |
1181 | - while($row = $this->fetchByAssoc($res)) { |
|
1181 | + while ($row = $this->fetchByAssoc($res)) { |
|
1182 | 1182 | $charsets[$row['Variable_name']] = $row['Value']; |
1183 | 1183 | } |
1184 | 1184 | return $charsets; |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | { |
1189 | 1189 | $charsets = $this->getCharsetInfo(); |
1190 | 1190 | $charset_str = array(); |
1191 | - foreach($charsets as $name => $value) { |
|
1191 | + foreach ($charsets as $name => $value) { |
|
1192 | 1192 | $charset_str[] = "$name = $value"; |
1193 | 1193 | } |
1194 | 1194 | return array( |
@@ -1210,18 +1210,18 @@ discard block |
||
1210 | 1210 | { |
1211 | 1211 | $this->log->debug("creating temp table for [$table]..."); |
1212 | 1212 | $result = $this->query("SHOW CREATE TABLE {$table}"); |
1213 | - if(empty($result)) { |
|
1213 | + if (empty($result)) { |
|
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | 1216 | $row = $this->fetchByAssoc($result); |
1217 | - if(empty($row) || empty($row['Create Table'])) { |
|
1217 | + if (empty($row) || empty($row['Create Table'])) { |
|
1218 | 1218 | return false; |
1219 | 1219 | } |
1220 | 1220 | $create = $row['Create Table']; |
1221 | 1221 | // rewrite DDL with _temp name |
1222 | 1222 | $tempTableQuery = str_replace("CREATE TABLE `{$table}`", "CREATE TABLE `{$table}__uw_temp`", $create); |
1223 | 1223 | $r2 = $this->query($tempTableQuery); |
1224 | - if(empty($r2)) { |
|
1224 | + if (empty($r2)) { |
|
1225 | 1225 | return false; |
1226 | 1226 | } |
1227 | 1227 | |
@@ -1243,11 +1243,11 @@ discard block |
||
1243 | 1243 | $this->log->debug("verifying ALTER TABLE"); |
1244 | 1244 | // Skipping ALTER TABLE [table] DROP PRIMARY KEY because primary keys are not being copied |
1245 | 1245 | // over to the temp tables |
1246 | - if(strpos(strtoupper($query), 'DROP PRIMARY KEY') !== false) { |
|
1246 | + if (strpos(strtoupper($query), 'DROP PRIMARY KEY') !== false) { |
|
1247 | 1247 | $this->log->debug("Skipping DROP PRIMARY KEY"); |
1248 | 1248 | return ''; |
1249 | 1249 | } |
1250 | - if(!$this->makeTempTableCopy($table)) { |
|
1250 | + if (!$this->makeTempTableCopy($table)) { |
|
1251 | 1251 | return 'Could not create temp table copy'; |
1252 | 1252 | } |
1253 | 1253 | |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | $this->log->debug('testing query: ['.$query.']'); |
1256 | 1256 | $tempTableTestQuery = str_replace("ALTER TABLE `{$table}`", "ALTER TABLE `{$table}__uw_temp`", $query); |
1257 | 1257 | if (strpos($tempTableTestQuery, 'idx') === false) { |
1258 | - if(strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1258 | + if (strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1259 | 1259 | return 'Could not use a temp table to test query!'; |
1260 | 1260 | } |
1261 | 1261 | |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | $this->query($tempTableTestQuery_idx, false, "Preflight Failed for: {$query}"); |
1269 | 1269 | } |
1270 | 1270 | $mysqlError = $this->getL(); |
1271 | - if(!empty($mysqlError)) { |
|
1271 | + if (!empty($mysqlError)) { |
|
1272 | 1272 | return $mysqlError; |
1273 | 1273 | } |
1274 | 1274 | $this->dropTableName("{$table}__uw_temp"); |
@@ -1280,13 +1280,13 @@ discard block |
||
1280 | 1280 | { |
1281 | 1281 | $this->log->debug("verifying $querytype statement"); |
1282 | 1282 | |
1283 | - if(!$this->makeTempTableCopy($table)) { |
|
1283 | + if (!$this->makeTempTableCopy($table)) { |
|
1284 | 1284 | return 'Could not create temp table copy'; |
1285 | 1285 | } |
1286 | 1286 | // test the query on the test table |
1287 | 1287 | $this->log->debug('testing query: ['.$query.']'); |
1288 | 1288 | $tempTableTestQuery = str_replace("$querytype `{$table}`", "$querytype `{$table}__uw_temp`", $query); |
1289 | - if(strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1289 | + if (strpos($tempTableTestQuery, '__uw_temp') === false) { |
|
1290 | 1290 | return 'Could not use a temp table to test query!'; |
1291 | 1291 | } |
1292 | 1292 | |
@@ -1366,11 +1366,11 @@ discard block |
||
1366 | 1366 | public function userExists($username) |
1367 | 1367 | { |
1368 | 1368 | $db = $this->getOne("SELECT DATABASE()"); |
1369 | - if(!$this->selectDb("mysql")) { |
|
1369 | + if (!$this->selectDb("mysql")) { |
|
1370 | 1370 | return false; |
1371 | 1371 | } |
1372 | 1372 | $user = $this->getOne("select count(*) from user where user = ".$this->quoted($username)); |
1373 | - if(!$this->selectDb($db)) { |
|
1373 | + if (!$this->selectDb($db)) { |
|
1374 | 1374 | $this->checkError("Cannot select database $db", true); |
1375 | 1375 | } |
1376 | 1376 | return !empty($user); |
@@ -1392,7 +1392,7 @@ discard block |
||
1392 | 1392 | IDENTIFIED BY '{$qpassword}';", true); |
1393 | 1393 | |
1394 | 1394 | $this->query("SET PASSWORD FOR \"{$user}\"@\"{$host_name}\" = password('{$qpassword}');", true); |
1395 | - if($host_name != 'localhost') { |
|
1395 | + if ($host_name != 'localhost') { |
|
1396 | 1396 | $this->createDbUser($database_name, "localhost", $user, $password); |
1397 | 1397 | } |
1398 | 1398 | } |
@@ -1438,10 +1438,10 @@ discard block |
||
1438 | 1438 | public function canInstall() |
1439 | 1439 | { |
1440 | 1440 | $db_version = $this->version(); |
1441 | - if(empty($db_version)) { |
|
1441 | + if (empty($db_version)) { |
|
1442 | 1442 | return array('ERR_DB_VERSION_FAILURE'); |
1443 | 1443 | } |
1444 | - if(version_compare($db_version, '4.1.2') < 0) { |
|
1444 | + if (version_compare($db_version, '4.1.2') < 0) { |
|
1445 | 1445 | return array('ERR_DB_MYSQL_VERSION', $db_version); |
1446 | 1446 | } |
1447 | 1447 | return true; |
@@ -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. |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | { |
70 | 70 | global $sugar_config; |
71 | 71 | |
72 | - if(empty($config['db_manager'])) { |
|
72 | + if (empty($config['db_manager'])) { |
|
73 | 73 | // standard types |
74 | - switch($type) { |
|
74 | + switch ($type) { |
|
75 | 75 | case "mysql": |
76 | 76 | if (empty($sugar_config['mysqli_disabled']) && function_exists('mysqli_connect')) { |
77 | 77 | $my_db_manager = 'MysqliManager'; |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | } |
81 | 81 | break; |
82 | 82 | case "mssql": |
83 | - if ( function_exists('sqlsrv_connect') |
|
84 | - && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv' )) { |
|
83 | + if (function_exists('sqlsrv_connect') |
|
84 | + && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv')) { |
|
85 | 85 | $my_db_manager = 'SqlsrvManager'; |
86 | 86 | } elseif (self::isFreeTDS() |
87 | - && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds' )) { |
|
87 | + && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds')) { |
|
88 | 88 | $my_db_manager = 'FreeTDSManager'; |
89 | 89 | } else { |
90 | 90 | $my_db_manager = 'MssqlManager'; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | break; |
93 | 93 | default: |
94 | 94 | $my_db_manager = self::getManagerByType($type, false); |
95 | - if(empty($my_db_manager)) { |
|
95 | + if (empty($my_db_manager)) { |
|
96 | 96 | $GLOBALS['log']->fatal("unable to load DB manager for: $type"); |
97 | 97 | sugar_die("Cannot load DB manager"); |
98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | // sanitize the name |
105 | 105 | $my_db_manager = preg_replace("/[^A-Za-z0-9_-]/", "", $my_db_manager); |
106 | 106 | |
107 | - if(!empty($config['db_manager_class'])){ |
|
107 | + if (!empty($config['db_manager_class'])) { |
|
108 | 108 | $my_db_manager = $config['db_manager_class']; |
109 | 109 | } else { |
110 | - if(file_exists("custom/include/database/{$my_db_manager}.php")) { |
|
110 | + if (file_exists("custom/include/database/{$my_db_manager}.php")) { |
|
111 | 111 | require_once("custom/include/database/{$my_db_manager}.php"); |
112 | 112 | } else { |
113 | 113 | require_once("include/database/{$my_db_manager}.php"); |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - if(class_exists($my_db_manager)) { |
|
117 | + if (class_exists($my_db_manager)) { |
|
118 | 118 | return new $my_db_manager(); |
119 | 119 | } else { |
120 | 120 | return null; |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | static $count = 0, $old_count = 0; |
135 | 135 | |
136 | 136 | //fall back to the default instance name |
137 | - if(empty($sugar_config['db'][$instanceName])){ |
|
137 | + if (empty($sugar_config['db'][$instanceName])) { |
|
138 | 138 | $instanceName = ''; |
139 | 139 | } |
140 | - if(!isset(self::$instances[$instanceName])){ |
|
140 | + if (!isset(self::$instances[$instanceName])) { |
|
141 | 141 | $config = $sugar_config['dbconfig']; |
142 | 142 | $count++; |
143 | 143 | self::$instances[$instanceName] = self::getTypeInstance($config['db_type'], $config); |
144 | - if(!empty($sugar_config['dbconfigoption'])) { |
|
144 | + if (!empty($sugar_config['dbconfigoption'])) { |
|
145 | 145 | self::$instances[$instanceName]->setOptions($sugar_config['dbconfigoption']); |
146 | 146 | } |
147 | 147 | self::$instances[$instanceName]->connect($config, true); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public static function disconnectAll() |
161 | 161 | { |
162 | - foreach(self::$instances as $instance) { |
|
162 | + foreach (self::$instances as $instance) { |
|
163 | 163 | $instance->disconnect(); |
164 | 164 | } |
165 | 165 | self::$instances = array(); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | public static function getManagerByType($type, $validate = true) |
178 | 178 | { |
179 | 179 | $drivers = self::getDbDrivers($validate); |
180 | - if(!empty($drivers[$type])) { |
|
180 | + if (!empty($drivers[$type])) { |
|
181 | 181 | return get_class($drivers[$type]); |
182 | 182 | } |
183 | 183 | return false; |
@@ -191,19 +191,19 @@ discard block |
||
191 | 191 | */ |
192 | 192 | protected static function scanDriverDir($dir, &$drivers, $validate = true) |
193 | 193 | { |
194 | - if(!is_dir($dir)) return; |
|
194 | + if (!is_dir($dir)) return; |
|
195 | 195 | $scandir = opendir($dir); |
196 | - if($scandir === false) return; |
|
197 | - while(($name = readdir($scandir)) !== false) { |
|
198 | - if(substr($name, -11) != "Manager.php") continue; |
|
199 | - if($name == "DBManager.php") continue; |
|
196 | + if ($scandir === false) return; |
|
197 | + while (($name = readdir($scandir)) !== false) { |
|
198 | + if (substr($name, -11) != "Manager.php") continue; |
|
199 | + if ($name == "DBManager.php") continue; |
|
200 | 200 | require_once("$dir/$name"); |
201 | 201 | $classname = substr($name, 0, -4); |
202 | - if(!class_exists($classname)) continue; |
|
202 | + if (!class_exists($classname)) continue; |
|
203 | 203 | $driver = new $classname; |
204 | - if(!$validate || $driver->valid()) { |
|
205 | - if(empty($drivers[$driver->dbType])) { |
|
206 | - $drivers[$driver->dbType] = array(); |
|
204 | + if (!$validate || $driver->valid()) { |
|
205 | + if (empty($drivers[$driver->dbType])) { |
|
206 | + $drivers[$driver->dbType] = array(); |
|
207 | 207 | } |
208 | 208 | $drivers[$driver->dbType][] = $driver; |
209 | 209 | } |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | self::scanDriverDir("custom/include/database", $drivers, $validate); |
236 | 236 | |
237 | 237 | $result = array(); |
238 | - foreach($drivers as $type => $tdrivers) { |
|
239 | - if(empty($tdrivers)) continue; |
|
240 | - if(count($tdrivers) > 1) { |
|
238 | + foreach ($drivers as $type => $tdrivers) { |
|
239 | + if (empty($tdrivers)) continue; |
|
240 | + if (count($tdrivers) > 1) { |
|
241 | 241 | usort($tdrivers, array(__CLASS__, "_compareDrivers")); |
242 | 242 | } |
243 | 243 | $result[$type] = $tdrivers[0]; |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | { |
256 | 256 | static $is_freetds = null; |
257 | 257 | |
258 | - if($is_freetds === null) { |
|
258 | + if ($is_freetds === null) { |
|
259 | 259 | ob_start(); |
260 | 260 | phpinfo(INFO_MODULES); |
261 | - $info=ob_get_contents(); |
|
261 | + $info = ob_get_contents(); |
|
262 | 262 | ob_end_clean(); |
263 | 263 | |
264 | - $is_freetds = (strpos($info,'FreeTDS') !== false); |
|
264 | + $is_freetds = (strpos($info, 'FreeTDS') !== false); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $is_freetds; |
@@ -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. |
@@ -53,39 +53,39 @@ discard block |
||
53 | 53 | * @param $context |
54 | 54 | * @return boolean - Returns true on success false on failure |
55 | 55 | */ |
56 | -function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') { |
|
56 | +function sugar_mkdir($pathname, $mode = null, $recursive = false, $context = '') { |
|
57 | 57 | $mode = get_mode('dir_mode', $mode); |
58 | 58 | |
59 | - if ( sugar_is_dir($pathname,$mode) ) |
|
59 | + if (sugar_is_dir($pathname, $mode)) |
|
60 | 60 | return true; |
61 | 61 | |
62 | 62 | $result = false; |
63 | - if(empty($mode)) |
|
63 | + if (empty($mode)) |
|
64 | 64 | $mode = 0777; |
65 | - if(empty($context)) { |
|
65 | + if (empty($context)) { |
|
66 | 66 | $result = @mkdir($pathname, $mode, $recursive); |
67 | 67 | } else { |
68 | 68 | $result = @mkdir($pathname, $mode, $recursive, $context); |
69 | 69 | } |
70 | 70 | |
71 | - if($result){ |
|
72 | - if(!sugar_chmod($pathname, $mode)){ |
|
71 | + if ($result) { |
|
72 | + if (!sugar_chmod($pathname, $mode)) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){ |
|
76 | - if(!sugar_chown($pathname)){ |
|
75 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) { |
|
76 | + if (!sugar_chown($pathname)) { |
|
77 | 77 | return false; |
78 | 78 | } |
79 | 79 | } |
80 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){ |
|
81 | - if(!sugar_chgrp($pathname)) { |
|
80 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) { |
|
81 | + if (!sugar_chgrp($pathname)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
86 | 86 | else { |
87 | 87 | $errorMessage = "Cannot create directory $pathname cannot be touched"; |
88 | - if(is_null($GLOBALS['log'])) { |
|
88 | + if (is_null($GLOBALS['log'])) { |
|
89 | 89 | throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\""); |
90 | 90 | } |
91 | 91 | $GLOBALS['log']->error($errorMessage); |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * @param $context |
109 | 109 | * @return boolean - Returns a file pointer on success, false otherwise |
110 | 110 | */ |
111 | -function sugar_fopen($filename, $mode, $use_include_path=false, $context=null){ |
|
111 | +function sugar_fopen($filename, $mode, $use_include_path = false, $context = null) { |
|
112 | 112 | //check to see if the file exists, if not then use touch to create it. |
113 | - if(!file_exists($filename)){ |
|
113 | + if (!file_exists($filename)) { |
|
114 | 114 | sugar_touch($filename); |
115 | 115 | } |
116 | 116 | |
117 | - if(empty($context)) { |
|
117 | + if (empty($context)) { |
|
118 | 118 | |
119 | 119 | return fopen($filename, $mode, $use_include_path); |
120 | 120 | } else { |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * @param $context |
137 | 137 | * @return int - Returns the number of bytes written to the file, false otherwise. |
138 | 138 | */ |
139 | -function sugar_file_put_contents($filename, $data, $flags=null, $context=null){ |
|
139 | +function sugar_file_put_contents($filename, $data, $flags = null, $context = null) { |
|
140 | 140 | //check to see if the file exists, if not then use touch to create it. |
141 | - if(!file_exists($filename)){ |
|
141 | + if (!file_exists($filename)) { |
|
142 | 142 | sugar_touch($filename); |
143 | 143 | } |
144 | 144 | |
145 | - if ( !is_writable($filename) ) { |
|
145 | + if (!is_writable($filename)) { |
|
146 | 146 | $GLOBALS['log']->error("File $filename cannot be written to"); |
147 | 147 | return false; |
148 | 148 | } |
149 | 149 | |
150 | - if(empty($flags)) { |
|
150 | + if (empty($flags)) { |
|
151 | 151 | return file_put_contents($filename, $data); |
152 | - } elseif(empty($context)) { |
|
152 | + } elseif (empty($context)) { |
|
153 | 153 | return file_put_contents($filename, $data, $flags); |
154 | - } else{ |
|
154 | + } else { |
|
155 | 155 | return file_put_contents($filename, $data, $flags, $context); |
156 | 156 | } |
157 | 157 | } |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | * @param context $context Context to pass into fopen operation |
170 | 170 | * @return boolean - Returns true if $filename was created, false otherwise. |
171 | 171 | */ |
172 | -function sugar_file_put_contents_atomic($filename, $data, $mode='wb', $use_include_path=false, $context=null){ |
|
172 | +function sugar_file_put_contents_atomic($filename, $data, $mode = 'wb', $use_include_path = false, $context = null) { |
|
173 | 173 | |
174 | 174 | $dir = dirname($filename); |
175 | 175 | $temp = tempnam($dir, 'temp'); |
176 | 176 | |
177 | 177 | if (!($f = @fopen($temp, $mode))) { |
178 | - $temp = $dir . DIRECTORY_SEPARATOR . uniqid('temp'); |
|
178 | + $temp = $dir.DIRECTORY_SEPARATOR.uniqid('temp'); |
|
179 | 179 | if (!($f = @fopen($temp, $mode))) { |
180 | 180 | trigger_error("sugar_file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING); |
181 | 181 | return false; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - if(file_exists($filename)) |
|
199 | + if (file_exists($filename)) |
|
200 | 200 | { |
201 | 201 | return sugar_chmod($filename, 0755); |
202 | 202 | } |
@@ -214,18 +214,18 @@ discard block |
||
214 | 214 | * @param $context |
215 | 215 | * @return string|boolean - Returns a file data on success, false otherwise |
216 | 216 | */ |
217 | -function sugar_file_get_contents($filename, $use_include_path=false, $context=null){ |
|
217 | +function sugar_file_get_contents($filename, $use_include_path = false, $context = null) { |
|
218 | 218 | //check to see if the file exists, if not then use touch to create it. |
219 | - if(!file_exists($filename)){ |
|
219 | + if (!file_exists($filename)) { |
|
220 | 220 | sugar_touch($filename); |
221 | 221 | } |
222 | 222 | |
223 | - if ( !is_readable($filename) ) { |
|
223 | + if (!is_readable($filename)) { |
|
224 | 224 | $GLOBALS['log']->error("File $filename cannot be read"); |
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | - if(empty($context)) { |
|
228 | + if (empty($context)) { |
|
229 | 229 | return file_get_contents($filename, $use_include_path); |
230 | 230 | } else { |
231 | 231 | return file_get_contents($filename, $use_include_path, $context); |
@@ -246,29 +246,29 @@ discard block |
||
246 | 246 | * @return boolean - Returns TRUE on success or FALSE on failure. |
247 | 247 | * |
248 | 248 | */ |
249 | -function sugar_touch($filename, $time=null, $atime=null) { |
|
249 | +function sugar_touch($filename, $time = null, $atime = null) { |
|
250 | 250 | |
251 | 251 | $result = false; |
252 | 252 | |
253 | - if(!empty($atime) && !empty($time)) { |
|
253 | + if (!empty($atime) && !empty($time)) { |
|
254 | 254 | $result = @touch($filename, $time, $atime); |
255 | - } else if(!empty($time)) { |
|
255 | + } else if (!empty($time)) { |
|
256 | 256 | $result = @touch($filename, $time); |
257 | 257 | } else { |
258 | 258 | $result = @touch($filename); |
259 | 259 | } |
260 | 260 | |
261 | - if(!$result) { |
|
261 | + if (!$result) { |
|
262 | 262 | $GLOBALS['log']->error("File $filename cannot be touched"); |
263 | 263 | return $result; |
264 | 264 | } |
265 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){ |
|
265 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])) { |
|
266 | 266 | sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']); |
267 | 267 | } |
268 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){ |
|
268 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) { |
|
269 | 269 | sugar_chown($filename); |
270 | 270 | } |
271 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){ |
|
271 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) { |
|
272 | 272 | sugar_chgrp($filename); |
273 | 273 | } |
274 | 274 | |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | * @param int $mode The integer value of the permissions mode to set the created directory to |
285 | 285 | * @return boolean Returns TRUE on success or FALSE on failure. |
286 | 286 | */ |
287 | -function sugar_chmod($filename, $mode=null) { |
|
288 | - if ( !is_int($mode) ) |
|
289 | - $mode = (int) $mode; |
|
290 | - if(!is_windows()){ |
|
291 | - if(!isset($mode)){ |
|
287 | +function sugar_chmod($filename, $mode = null) { |
|
288 | + if (!is_int($mode)) |
|
289 | + $mode = (int)$mode; |
|
290 | + if (!is_windows()) { |
|
291 | + if (!isset($mode)) { |
|
292 | 292 | $mode = get_mode('file_mode', $mode); |
293 | 293 | } |
294 | - if(isset($mode) && $mode > 0){ |
|
294 | + if (isset($mode) && $mode > 0) { |
|
295 | 295 | return @chmod($filename, $mode); |
296 | - }else{ |
|
296 | + } else { |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | } |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | * @param user - A user name or number |
310 | 310 | * @return boolean - Returns TRUE on success or FALSE on failure. |
311 | 311 | */ |
312 | -function sugar_chown($filename, $user='') { |
|
313 | - if(!is_windows()){ |
|
314 | - if(strlen($user)){ |
|
312 | +function sugar_chown($filename, $user = '') { |
|
313 | + if (!is_windows()) { |
|
314 | + if (strlen($user)) { |
|
315 | 315 | return chown($filename, $user); |
316 | - }else{ |
|
317 | - if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){ |
|
316 | + } else { |
|
317 | + if (strlen($GLOBALS['sugar_config']['default_permissions']['user'])) { |
|
318 | 318 | $user = $GLOBALS['sugar_config']['default_permissions']['user']; |
319 | 319 | return chown($filename, $user); |
320 | - }else{ |
|
320 | + } else { |
|
321 | 321 | return false; |
322 | 322 | } |
323 | 323 | } |
@@ -334,15 +334,15 @@ discard block |
||
334 | 334 | * @param group - A group name or number |
335 | 335 | * @return boolean - Returns TRUE on success or FALSE on failure. |
336 | 336 | */ |
337 | -function sugar_chgrp($filename, $group='') { |
|
338 | - if(!is_windows()){ |
|
339 | - if(!empty($group)){ |
|
337 | +function sugar_chgrp($filename, $group = '') { |
|
338 | + if (!is_windows()) { |
|
339 | + if (!empty($group)) { |
|
340 | 340 | return chgrp($filename, $group); |
341 | - }else{ |
|
342 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){ |
|
341 | + } else { |
|
342 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) { |
|
343 | 343 | $group = $GLOBALS['sugar_config']['default_permissions']['group']; |
344 | 344 | return chgrp($filename, $group); |
345 | - }else{ |
|
345 | + } else { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | } |
@@ -360,26 +360,26 @@ discard block |
||
360 | 360 | * defined in the config file. |
361 | 361 | * @return int - the mode either found in the config file or passed in via the input parameter |
362 | 362 | */ |
363 | -function get_mode($key = 'dir_mode', $mode=null) { |
|
364 | - if ( !is_int($mode) ) |
|
365 | - $mode = (int) $mode; |
|
366 | - if(!class_exists('SugarConfig', true)) { |
|
363 | +function get_mode($key = 'dir_mode', $mode = null) { |
|
364 | + if (!is_int($mode)) |
|
365 | + $mode = (int)$mode; |
|
366 | + if (!class_exists('SugarConfig', true)) { |
|
367 | 367 | require 'include/SugarObjects/SugarConfig.php'; |
368 | 368 | } |
369 | - if(!is_windows()){ |
|
370 | - $conf_inst=SugarConfig::getInstance(); |
|
369 | + if (!is_windows()) { |
|
370 | + $conf_inst = SugarConfig::getInstance(); |
|
371 | 371 | $mode = $conf_inst->get('default_permissions.'.$key, $mode); |
372 | 372 | } |
373 | 373 | return $mode; |
374 | 374 | } |
375 | 375 | |
376 | -function sugar_is_dir($path, $mode='r'){ |
|
377 | - if(defined('TEMPLATE_URL'))return is_dir($path, $mode); |
|
376 | +function sugar_is_dir($path, $mode = 'r') { |
|
377 | + if (defined('TEMPLATE_URL'))return is_dir($path, $mode); |
|
378 | 378 | return is_dir($path); |
379 | 379 | } |
380 | 380 | |
381 | -function sugar_is_file($path, $mode='r'){ |
|
382 | - if(defined('TEMPLATE_URL'))return is_file($path, $mode); |
|
381 | +function sugar_is_file($path, $mode = 'r') { |
|
382 | + if (defined('TEMPLATE_URL'))return is_file($path, $mode); |
|
383 | 383 | return is_file($path); |
384 | 384 | } |
385 | 385 | |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | function sugar_cached($file) |
392 | 392 | { |
393 | 393 | static $cdir = null; |
394 | - if(empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) { |
|
394 | + if (empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) { |
|
395 | 395 | $cdir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); |
396 | 396 | } |
397 | - if(empty($cdir)) { |
|
397 | + if (empty($cdir)) { |
|
398 | 398 | $cdir = "cache"; |
399 | 399 | } |
400 | 400 | return "$cdir/$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. |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * Connector factory |
43 | 43 | * @api |
44 | 44 | */ |
45 | -class ConnectorFactory{ |
|
45 | +class ConnectorFactory { |
|
46 | 46 | |
47 | 47 | static $source_map = array(); |
48 | 48 | |
49 | - public static function getInstance($source_name){ |
|
50 | - if(empty(self::$source_map[$source_name])) { |
|
49 | + public static function getInstance($source_name) { |
|
50 | + if (empty(self::$source_map[$source_name])) { |
|
51 | 51 | require_once('include/connectors/sources/SourceFactory.php'); |
52 | 52 | require_once('include/connectors/component.php'); |
53 | 53 | $source = SourceFactory::getSource($source_name); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * which represents the inheritance structure to load up all required parents. |
65 | 65 | * @param string $class the root class we want to load. |
66 | 66 | */ |
67 | - public static function load($class, $type){ |
|
67 | + public static function load($class, $type) { |
|
68 | 68 | self::loadClass($class, $type); |
69 | 69 | } |
70 | 70 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | * include a source class file. |
73 | 73 | * @param string $class a class file to include. |
74 | 74 | */ |
75 | - public static function loadClass($class, $type){ |
|
76 | - $dir = str_replace('_','/',$class); |
|
75 | + public static function loadClass($class, $type) { |
|
76 | + $dir = str_replace('_', '/', $class); |
|
77 | 77 | $parts = explode("/", $dir); |
78 | - $file = $parts[count($parts)-1] . '.php'; |
|
79 | - if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){ |
|
78 | + $file = $parts[count($parts) - 1].'.php'; |
|
79 | + if (file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")) { |
|
80 | 80 | require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file"); |
81 | - } else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) { |
|
81 | + } else if (file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) { |
|
82 | 82 | require_once("modules/Connectors/connectors/{$type}/{$dir}/$file"); |
83 | - } else if(file_exists("connectors/{$type}/{$dir}/$file")) { |
|
83 | + } else if (file_exists("connectors/{$type}/{$dir}/$file")) { |
|
84 | 84 | require_once("connectors/{$type}/{$dir}/$file"); |
85 | 85 | } |
86 | 86 | } |
@@ -49,31 +49,31 @@ |
||
49 | 49 | * |
50 | 50 | * @return an instance of SugarController |
51 | 51 | */ |
52 | - static function getController($module){ |
|
52 | + static function getController($module) { |
|
53 | 53 | $class = ucfirst($module).'Controller'; |
54 | - $customClass = 'Custom' . $class; |
|
55 | - if(file_exists('custom/modules/'.$module.'/controller.php')){ |
|
56 | - $customClass = 'Custom' . $class; |
|
54 | + $customClass = 'Custom'.$class; |
|
55 | + if (file_exists('custom/modules/'.$module.'/controller.php')) { |
|
56 | + $customClass = 'Custom'.$class; |
|
57 | 57 | require_once('custom/modules/'.$module.'/controller.php'); |
58 | - if(class_exists($customClass)){ |
|
58 | + if (class_exists($customClass)) { |
|
59 | 59 | $controller = new $customClass(); |
60 | - }else if(class_exists($class)){ |
|
60 | + } else if (class_exists($class)) { |
|
61 | 61 | $controller = new $class(); |
62 | 62 | } |
63 | - }elseif(file_exists('modules/'.$module.'/controller.php')){ |
|
63 | + }elseif (file_exists('modules/'.$module.'/controller.php')) { |
|
64 | 64 | require_once('modules/'.$module.'/controller.php'); |
65 | - if(class_exists($customClass)){ |
|
65 | + if (class_exists($customClass)) { |
|
66 | 66 | $controller = new $customClass(); |
67 | - }else if(class_exists($class)){ |
|
67 | + } else if (class_exists($class)) { |
|
68 | 68 | $controller = new $class(); |
69 | 69 | } |
70 | - }else{ |
|
71 | - if(file_exists('custom/include/MVC/Controller/SugarController.php')){ |
|
70 | + } else { |
|
71 | + if (file_exists('custom/include/MVC/Controller/SugarController.php')) { |
|
72 | 72 | require_once('custom/include/MVC/Controller/SugarController.php'); |
73 | 73 | } |
74 | - if(class_exists('CustomSugarController')){ |
|
74 | + if (class_exists('CustomSugarController')) { |
|
75 | 75 | $controller = new CustomSugarController(); |
76 | - }else{ |
|
76 | + } else { |
|
77 | 77 | $controller = new SugarController(); |
78 | 78 | } |
79 | 79 | } |
@@ -44,21 +44,21 @@ |
||
44 | 44 | * Window - Preferences - PHPeclipse - PHP - Code Templates |
45 | 45 | */ |
46 | 46 | //format '<action_name>' => '<view_name>' |
47 | -$action_view_map['multieditview']= 'multiedit'; |
|
48 | -$action_view_map['detailview']= 'detail'; |
|
49 | -$action_view_map['editview']= 'edit'; |
|
50 | -$action_view_map['listview']= 'list'; |
|
51 | -$action_view_map['popup']= 'popup'; |
|
52 | -$action_view_map['vcard']= 'vcard'; |
|
53 | -$action_view_map['importvcard']= 'importvcard'; |
|
54 | -$action_view_map['importvcardsave']= 'importvcardsave'; |
|
55 | -$action_view_map['modulelistmenu']= 'modulelistmenu'; |
|
56 | -$action_view_map['favorites']= 'favorites'; |
|
57 | -$action_view_map['ajaxui']= 'ajaxui'; |
|
58 | -$action_view_map['noaccess']= 'noaccess'; |
|
47 | +$action_view_map['multieditview'] = 'multiedit'; |
|
48 | +$action_view_map['detailview'] = 'detail'; |
|
49 | +$action_view_map['editview'] = 'edit'; |
|
50 | +$action_view_map['listview'] = 'list'; |
|
51 | +$action_view_map['popup'] = 'popup'; |
|
52 | +$action_view_map['vcard'] = 'vcard'; |
|
53 | +$action_view_map['importvcard'] = 'importvcard'; |
|
54 | +$action_view_map['importvcardsave'] = 'importvcardsave'; |
|
55 | +$action_view_map['modulelistmenu'] = 'modulelistmenu'; |
|
56 | +$action_view_map['favorites'] = 'favorites'; |
|
57 | +$action_view_map['ajaxui'] = 'ajaxui'; |
|
58 | +$action_view_map['noaccess'] = 'noaccess'; |
|
59 | 59 | |
60 | 60 | // SugarPDF |
61 | -$action_view_map['sugarpdf']= 'sugarpdf'; |
|
61 | +$action_view_map['sugarpdf'] = 'sugarpdf'; |
|
62 | 62 | $action_view_map['dc'] = 'dc'; |
63 | 63 | $action_view_map['dcajax'] = 'dcajax'; |
64 | 64 | $action_view_map['quick'] = 'quick'; |
@@ -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. |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $version = $version[0]; |
66 | 66 | if (empty($yui_path[$version])) continue; |
67 | 67 | |
68 | - $path = $yui_path[$version] . substr($param, strlen($version)); |
|
68 | + $path = $yui_path[$version].substr($param, strlen($version)); |
|
69 | 69 | |
70 | 70 | $extension = substr($path, strrpos($path, "_") + 1); |
71 | 71 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $contentType = $types[$extension]; |
79 | 79 | } |
80 | 80 | //Put together the final filepath |
81 | - $path = substr($path, 0, strrpos($path, "_")) . "." . $extension; |
|
81 | + $path = substr($path, 0, strrpos($path, "_")).".".$extension; |
|
82 | 82 | $contents = ''; |
83 | 83 | if (is_file($path)) { |
84 | - $out .= "/*" . $path . "*/\n"; |
|
85 | - $contents = file_get_contents($path); |
|
86 | - $out .= $contents . "\n"; |
|
84 | + $out .= "/*".$path."*/\n"; |
|
85 | + $contents = file_get_contents($path); |
|
86 | + $out .= $contents."\n"; |
|
87 | 87 | } |
88 | 88 | $path = empty($contents) ? $path : $contents; |
89 | 89 | $allpath .= md5($path); |
@@ -95,6 +95,6 @@ discard block |
||
95 | 95 | header("Cache-Control: private"); |
96 | 96 | header("Pragma: dummy=bogus"); |
97 | 97 | header("Etag: $etag"); |
98 | -header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000)); |
|
98 | +header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000)); |
|
99 | 99 | header("Content-Type: $contentType"); |
100 | 100 | echo ($out); |
101 | 101 | \ 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. |
@@ -64,28 +64,28 @@ discard block |
||
64 | 64 | $cacheDir = create_cache_directory('dashlets/'); |
65 | 65 | $allDashlets = array_merge($dashletFiles, $dashletFilesCustom); |
66 | 66 | $dashletFiles = array(); |
67 | - foreach($allDashlets as $num => $file) { |
|
68 | - if(substr_count($file, '.meta') == 0) { // ignore meta data files |
|
67 | + foreach ($allDashlets as $num => $file) { |
|
68 | + if (substr_count($file, '.meta') == 0) { // ignore meta data files |
|
69 | 69 | $class = substr($file, strrpos($file, '/') + 1, -4); |
70 | 70 | $dashletFiles[$class] = array(); |
71 | 71 | $dashletFiles[$class]['file'] = $file; |
72 | 72 | $dashletFiles[$class]['class'] = $class; |
73 | - if(is_file(preg_replace('/(.*\/.*)(\.php)/Uis', '$1.meta$2', $file))) { // is there an associated meta data file? |
|
73 | + if (is_file(preg_replace('/(.*\/.*)(\.php)/Uis', '$1.meta$2', $file))) { // is there an associated meta data file? |
|
74 | 74 | $dashletFiles[$class]['meta'] = preg_replace('/(.*\/.*)(\.php)/Uis', '$1.meta$2', $file); |
75 | 75 | require($dashletFiles[$class]['meta']); |
76 | - if ( isset($dashletMeta[$class]['module']) ) |
|
76 | + if (isset($dashletMeta[$class]['module'])) |
|
77 | 77 | $dashletFiles[$class]['module'] = $dashletMeta[$class]['module']; |
78 | 78 | } |
79 | 79 | |
80 | 80 | $filesInDirectory = array(); |
81 | 81 | getFiles($filesInDirectory, substr($file, 0, strrpos($file, '/')), '/^.*\/Dashlets\/[^\.]*\.icon\.(jpg|jpeg|gif|png)$/i'); |
82 | - if(!empty($filesInDirectory)) { |
|
82 | + if (!empty($filesInDirectory)) { |
|
83 | 83 | $dashletFiles[$class]['icon'] = $filesInDirectory[0]; // take the first icon we see |
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - write_array_to_file('dashletsFiles', $dashletFiles, $cacheDir . 'dashlets.php'); |
|
88 | + write_array_to_file('dashletsFiles', $dashletFiles, $cacheDir.'dashlets.php'); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | ?> |
92 | 92 | \ No newline at end of file |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | */ |
93 | 93 | public function getTitle() { |
94 | - $matches = array (); |
|
94 | + $matches = array(); |
|
95 | 95 | preg_match("/<title>.*?<\/title>/i", $this->contents, $matches); |
96 | 96 | if (isset($matches[0])) { |
97 | 97 | $this->title = str_replace(array('<![CDATA[', '<title>', '</title>', ']]>'), '', $matches[0]); |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | |
101 | 101 | public function cutLength() { |
102 | 102 | if (mb_strlen(trim($this->title), $this->defaultEncoding) > $this->cut) { |
103 | - $this->title = mb_substr($this->title, 0, $this->cut, $this->defaultEncoding) . $this->endWith; |
|
103 | + $this->title = mb_substr($this->title, 0, $this->cut, $this->defaultEncoding).$this->endWith; |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | 107 | private function _identifyXmlEncoding() { |
108 | - $matches = array (); |
|
108 | + $matches = array(); |
|
109 | 109 | preg_match('/encoding\=*\".*?\"/', $this->contents, $matches); |
110 | 110 | if (isset($matches[0])) { |
111 | 111 | $this->xmlEncoding = trim(str_replace('encoding="', '"', $matches[0]), '"'); |