Test Failed
Push — CI ( 02428e...3e0292 )
by Adam
55:43
created
include/database/MysqlManager.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
include/database/MysqliManager.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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.
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false)
123 123
 	{
124
-		if(is_array($sql)) {
124
+		if (is_array($sql)) {
125 125
 			return $this->queryArray($sql, $dieOnError, $msg, $suppress);
126 126
         }
127 127
 
128 128
 		static $queryMD5 = array();
129 129
 
130 130
 		parent::countQuery($sql);
131
-		$GLOBALS['log']->info('Query:' . $sql);
131
+		$GLOBALS['log']->info('Query:'.$sql);
132 132
 		$this->checkConnection();
133 133
 		$this->query_time = microtime(true);
134 134
 		$this->lastsql = $sql;
135
-		$result = $suppress?@mysqli_query($this->database,$sql):mysqli_query($this->database,$sql);
135
+		$result = $suppress ? @mysqli_query($this->database, $sql) : mysqli_query($this->database, $sql);
136 136
 		$md5 = md5($sql);
137 137
 
138 138
 		if (empty($queryMD5[$md5]))
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 		*/
155 155
 
156 156
 
157
-		if($keepResult)
157
+		if ($keepResult)
158 158
 			$this->lastResult = $result;
159
-		$this->checkError($msg.' Query Failed: ' . $sql, $dieOnError);
159
+		$this->checkError($msg.' Query Failed: '.$sql, $dieOnError);
160 160
 
161 161
 		return $result;
162 162
 	}
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	public function disconnect()
195 195
 	{
196
-		if(isset($GLOBALS['log']) && !is_null($GLOBALS['log'])) {
196
+		if (isset($GLOBALS['log']) && !is_null($GLOBALS['log'])) {
197 197
 			$GLOBALS['log']->debug('Calling MySQLi::disconnect()');
198 198
 		}
199
-		if(!empty($this->database)){
199
+		if (!empty($this->database)) {
200 200
 			$this->freeResult();
201 201
 			mysqli_close($this->database);
202 202
 			$this->database = null;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	protected function freeDbResult($dbResult)
210 210
 	{
211
-		if(!empty($dbResult))
211
+		if (!empty($dbResult))
212 212
 			mysqli_free_result($dbResult);
213 213
 	}
214 214
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 			if (!$meta)
229 229
 				return 0;
230 230
 
231
-			if($make_lower_case == true)
231
+			if ($make_lower_case == true)
232 232
 				$meta->name = strtolower($meta->name);
233 233
 
234 234
 			$field_array[] = $meta->name;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		if (empty($result))	return false;
248 248
 
249 249
 		$row = mysqli_fetch_assoc($result);
250
-		if($row == null) $row = false; //Make sure MySQLi driver results are consistent with other database drivers
250
+		if ($row == null) $row = false; //Make sure MySQLi driver results are consistent with other database drivers
251 251
 		return $row;
252 252
 	}
253 253
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	public function quote($string)
258 258
 	{
259
-		return mysqli_real_escape_string($this->getDatabase(),$this->quoteInternal($string));
259
+		return mysqli_real_escape_string($this->getDatabase(), $this->quoteInternal($string));
260 260
 	}
261 261
 
262 262
 	/**
@@ -269,23 +269,23 @@  discard block
 block discarded – undo
269 269
 		if (is_null($configOptions))
270 270
 			$configOptions = $sugar_config['dbconfig'];
271 271
 
272
-		if(!isset($this->database)) {
272
+		if (!isset($this->database)) {
273 273
 
274 274
 			//mysqli connector has a separate parameter for port.. We need to separate it out from the host name
275
-			$dbhost=$configOptions['db_host_name'];
276
-            $dbport=isset($configOptions['db_port']) ? ($configOptions['db_port'] == '' ? null : $configOptions['db_port']) : null;
275
+			$dbhost = $configOptions['db_host_name'];
276
+            $dbport = isset($configOptions['db_port']) ? ($configOptions['db_port'] == '' ? null : $configOptions['db_port']) : null;
277 277
 			
278
-			$pos=strpos($configOptions['db_host_name'],':');
278
+			$pos = strpos($configOptions['db_host_name'], ':');
279 279
 			if ($pos !== false) {
280
-				$dbhost=substr($configOptions['db_host_name'],0,$pos);
281
-				$dbport=substr($configOptions['db_host_name'],$pos+1);
280
+				$dbhost = substr($configOptions['db_host_name'], 0, $pos);
281
+				$dbport = substr($configOptions['db_host_name'], $pos + 1);
282 282
 			}
283 283
 
284
-			$this->database = @mysqli_connect($dbhost,$configOptions['db_user_name'],$configOptions['db_password'],isset($configOptions['db_name'])?$configOptions['db_name']:'',$dbport);
285
-			if(empty($this->database)) {
286
-				$GLOBALS['log']->fatal("Could not connect to DB server ".$dbhost." as ".$configOptions['db_user_name'].". port " .$dbport . ": " . mysqli_connect_error());
287
-				if($dieOnError) {
288
-					if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
284
+			$this->database = @mysqli_connect($dbhost, $configOptions['db_user_name'], $configOptions['db_password'], isset($configOptions['db_name']) ? $configOptions['db_name'] : '', $dbport);
285
+			if (empty($this->database)) {
286
+				$GLOBALS['log']->fatal("Could not connect to DB server ".$dbhost." as ".$configOptions['db_user_name'].". port ".$dbport.": ".mysqli_connect_error());
287
+				if ($dieOnError) {
288
+					if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
289 289
 						sugar_die($GLOBALS['app_strings']['ERR_NO_DB']);
290 290
 					} else {
291 291
 						sugar_die("Could not connect to the database. Please refer to suitecrm.log for details.");
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
 			}
297 297
 		}
298 298
 
299
-		if(!empty($configOptions['db_name']) && !@mysqli_select_db($this->database,$configOptions['db_name'])) {
300
-			$GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysqli_connect_error());
301
-			if($dieOnError) {
302
-					if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
299
+		if (!empty($configOptions['db_name']) && !@mysqli_select_db($this->database, $configOptions['db_name'])) {
300
+			$GLOBALS['log']->fatal("Unable to select database {$configOptions['db_name']}: ".mysqli_connect_error());
301
+			if ($dieOnError) {
302
+					if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
303 303
 						sugar_die($GLOBALS['app_strings']['ERR_NO_DB']);
304 304
 					} else {
305 305
 						sugar_die("Could not connect to the database. Please refer to suitecrm.log for details.");
@@ -310,15 +310,15 @@  discard block
 block discarded – undo
310 310
 	    }
311 311
 
312 312
 		// cn: using direct calls to prevent this from spamming the Logs
313
-	    mysqli_query($this->database,"SET CHARACTER SET utf8");
313
+	    mysqli_query($this->database, "SET CHARACTER SET utf8");
314 314
 	    $names = "SET NAMES 'utf8'";
315 315
 	    $collation = $this->getOption('collation');
316
-	    if(!empty($collation)) {
316
+	    if (!empty($collation)) {
317 317
 	        $names .= " COLLATE '$collation'";
318 318
 		}
319
-	    mysqli_query($this->database,$names);
319
+	    mysqli_query($this->database, $names);
320 320
 
321
-		if($this->checkError('Could Not Connect', $dieOnError))
321
+		if ($this->checkError('Could Not Connect', $dieOnError))
322 322
 			$GLOBALS['log']->info("connected to db");
323 323
 
324 324
 		$this->connectOptions = $configOptions;
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 	 */
332 332
 	public function lastDbError()
333 333
 	{
334
-		if($this->database) {
335
-		    if(mysqli_errno($this->database)) {
334
+		if ($this->database) {
335
+		    if (mysqli_errno($this->database)) {
336 336
 			    return "MySQL error ".mysqli_errno($this->database).": ".mysqli_error($this->database);
337 337
 		    }
338 338
 		} else {
339
-			$err =  mysqli_connect_error();
340
-			if($err) {
339
+			$err = mysqli_connect_error();
340
+			if ($err) {
341 341
 			    return $err;
342 342
 			}
343 343
 		}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	{
350 350
 		$charsets = $this->getCharsetInfo();
351 351
 		$charset_str = array();
352
-		foreach($charsets as $name => $value) {
352
+		foreach ($charsets as $name => $value) {
353 353
 			$charset_str[] = "$name = $value";
354 354
 		}
355 355
 		return array(
Please login to merge, or discard this patch.
include/database/DBManagerFactory.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
include/ListView/ListView.php 1 patch
Spacing   +373 added lines, -373 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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.
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
  */
46 46
 class ListView
47 47
 {
48
-    var $local_theme= null;
49
-    var $local_app_strings= null;
48
+    var $local_theme = null;
49
+    var $local_app_strings = null;
50 50
     var $local_image_path = null;
51 51
     var $local_current_module = null;
52 52
     var $local_mod_strings = null;
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
     var $child_focus = '';
82 82
     var $layout_manager = null;
83 83
     var $process_for_popups = false;
84
-    var $multi_select_popup=false;
84
+    var $multi_select_popup = false;
85 85
     var $_additionalDetails = false;
86 86
     var $additionalDetailsFunction = null;
87 87
     var $sort_order = '';
88
-    var $force_mass_update=false;
89
-    var $keep_mass_update_form_open=false;
88
+    var $force_mass_update = false;
89
+    var $keep_mass_update_form_open = false;
90 90
     var $ignorePopulateOnly = false;
91 91
 
92 92
 function setDataArray($value) {
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     echo "<form name='MassUpdate' method='post' action='index.php'>";
101 101
     $this->processListViewTwo($seed, $xTemplateSection, $html_varName);
102 102
 
103
-    echo "<a href='javascript:" . ((!$this->multi_select_popup) ? 'sListView.' : ''). "check_all(document.MassUpdate, \"mass[]\", true)'>".translate('LBL_CHECKALL')."</a> - <a href='javascript:sListView.check_all(document.MassUpdate, \"mass[]\", false);'>".translate('LBL_CLEARALL')."</a>";
103
+    echo "<a href='javascript:".((!$this->multi_select_popup) ? 'sListView.' : '')."check_all(document.MassUpdate, \"mass[]\", true)'>".translate('LBL_CHECKALL')."</a> - <a href='javascript:sListView.check_all(document.MassUpdate, \"mass[]\", false);'>".translate('LBL_CLEARALL')."</a>";
104 104
     echo '<br><br>';
105 105
 }
106 106
 
@@ -110,109 +110,109 @@  discard block
 block discarded – undo
110 110
     global $sugar_config;
111 111
 
112 112
     $populateOnly = $this->ignorePopulateOnly ? FALSE : (!empty($sugar_config['save_query']) && $sugar_config['save_query'] == 'populate_only');
113
-    if(isset($seed->module_dir) && $populateOnly) {
114
-        if(empty($GLOBALS['displayListView']) && strcmp(strtolower($_REQUEST['action']), 'popup') != 0 && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $seed->module_dir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI')&& (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $seed->module_dir)))) {
115
-            $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
113
+    if (isset($seed->module_dir) && $populateOnly) {
114
+        if (empty($GLOBALS['displayListView']) && strcmp(strtolower($_REQUEST['action']), 'popup') != 0 && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $seed->module_dir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI') && (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $seed->module_dir)))) {
115
+            $_SESSION['last_search_mod'] = $_REQUEST['module'];
116 116
             return;
117 117
         }
118 118
     }
119
-    if(strcmp(strtolower($_REQUEST['action']), 'popup') != 0){
120
-        $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
119
+    if (strcmp(strtolower($_REQUEST['action']), 'popup') != 0) {
120
+        $_SESSION['last_search_mod'] = $_REQUEST['module'];
121 121
     }
122 122
     //following session variable will track the detail view navigation history.
123 123
     //needs to the reset after each search.
124
-    $this->setLocalSessionVariable($html_varName,"DETAIL_NAV_HISTORY",false);
124
+    $this->setLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY", false);
125 125
 
126 126
     require_once('include/MassUpdate.php');
127 127
     $mass = new MassUpdate();
128 128
     $add_acl_javascript = false;
129
-    if(!isset($_REQUEST['action'])) {
130
-        $this->shouldProcess=false;
129
+    if (!isset($_REQUEST['action'])) {
130
+        $this->shouldProcess = false;
131 131
     } else {
132 132
     $this->shouldProcess = is_subclass_of($seed, "SugarBean")
133
-        && (($_REQUEST['action'] == 'index') || ('ListView' == substr($_REQUEST['action'],0,8)) /* cn: to include all ListViewXXX.php type views */)
133
+        && (($_REQUEST['action'] == 'index') || ('ListView' == substr($_REQUEST['action'], 0, 8)) /* cn: to include all ListViewXXX.php type views */)
134 134
         && ($_REQUEST['module'] == $seed->module_dir);
135 135
     }
136 136
 
137 137
     //when processing a multi-select popup.
138
-    if($this->process_for_popups && $this->multi_select_popup)  $this->shouldProcess =true;
138
+    if ($this->process_for_popups && $this->multi_select_popup)  $this->shouldProcess = true;
139 139
     //mass update turned off?
140
-    if(!$this->show_mass_update) $this->shouldProcess = false;
141
-    if(is_subclass_of($seed, "SugarBean")) {
142
-        if($seed->bean_implements('ACL')) {
143
-            if(!ACLController::checkAccess($seed->module_dir,'list',true)) {
144
-                if($_REQUEST['module'] != 'Home') {
140
+    if (!$this->show_mass_update) $this->shouldProcess = false;
141
+    if (is_subclass_of($seed, "SugarBean")) {
142
+        if ($seed->bean_implements('ACL')) {
143
+            if (!ACLController::checkAccess($seed->module_dir, 'list', true)) {
144
+                if ($_REQUEST['module'] != 'Home') {
145 145
                     ACLController::displayNoAccess();
146 146
                 }
147 147
                 return;
148 148
             }
149
-            if(!ACLController::checkAccess($seed->module_dir,'export',true)) {
150
-                $sugar_config['disable_export']= true;
149
+            if (!ACLController::checkAccess($seed->module_dir, 'export', true)) {
150
+                $sugar_config['disable_export'] = true;
151 151
             }
152 152
 
153 153
         }
154 154
     }
155 155
 
156 156
     //force mass update form if requested.
157
-    if($this->force_mass_update) {
157
+    if ($this->force_mass_update) {
158 158
         $this->shouldProcess = true;
159 159
     }
160 160
 
161
-    if($this->shouldProcess) {
161
+    if ($this->shouldProcess) {
162 162
         echo $mass->getDisplayMassUpdateForm(true, $this->multi_select_popup);
163 163
         echo $mass->getMassUpdateFormHeader($this->multi_select_popup);
164 164
         $mass->setSugarBean($seed);
165 165
 
166 166
         //C.L. Fix for 10048, do not process handleMassUpdate for multi select popups
167
-        if(!$this->multi_select_popup) {
167
+        if (!$this->multi_select_popup) {
168 168
             $mass->handleMassUpdate();
169 169
         }
170 170
     }
171 171
 
172
-    $this->processListViewTwo($seed,$xTemplateSection, $html_varName);
172
+    $this->processListViewTwo($seed, $xTemplateSection, $html_varName);
173 173
 
174
-    if($this->shouldProcess && empty($this->process_for_popups)) {
174
+    if ($this->shouldProcess && empty($this->process_for_popups)) {
175 175
         //echo "<a href='javascript:sListView.clear_all(document.MassUpdate, \"mass[]\");'>".translate('LBL_CLEARALL')."</a>";
176 176
         // cn: preserves current functionality, exception is InboundEmail
177
-        if($this->show_mass_update_form) {
177
+        if ($this->show_mass_update_form) {
178 178
             echo $mass->getMassUpdateForm();
179 179
         }
180
-        if(!$this->keep_mass_update_form_open) {
180
+        if (!$this->keep_mass_update_form_open) {
181 181
             echo $mass->endMassUpdateForm();
182 182
         }
183 183
     }
184 184
 }
185 185
 
186 186
 
187
-function process_dynamic_listview($source_module, $sugarbean,$subpanel_def)
187
+function process_dynamic_listview($source_module, $sugarbean, $subpanel_def)
188 188
 {
189 189
         $this->source_module = $source_module;
190 190
         $this->subpanel_module = $subpanel_def->name;
191
-        if(!isset($this->xTemplate))
191
+        if (!isset($this->xTemplate))
192 192
             $this->createXTemplate();
193 193
 
194
-        $html_var = $this->subpanel_module . "_CELL";
194
+        $html_var = $this->subpanel_module."_CELL";
195 195
 
196
-        $list_data = $this->processUnionBeans($sugarbean,$subpanel_def, $html_var);
196
+        $list_data = $this->processUnionBeans($sugarbean, $subpanel_def, $html_var);
197 197
 
198 198
         $list = $list_data['list'];
199 199
         $parent_data = $list_data['parent_data'];
200 200
 
201
-        if($subpanel_def->isCollection()) {
202
-            $thepanel=$subpanel_def->get_header_panel_def();
201
+        if ($subpanel_def->isCollection()) {
202
+            $thepanel = $subpanel_def->get_header_panel_def();
203 203
         } else {
204
-            $thepanel=$subpanel_def;
204
+            $thepanel = $subpanel_def;
205 205
         }
206 206
 
207 207
 
208 208
 
209 209
         $this->process_dynamic_listview_header($thepanel->get_module_name(), $thepanel, $html_var);
210
-        $this->process_dynamic_listview_rows($list,$parent_data, 'dyn_list_view', $html_var,$subpanel_def);
210
+        $this->process_dynamic_listview_rows($list, $parent_data, 'dyn_list_view', $html_var, $subpanel_def);
211 211
 
212
-        if($this->display_header_and_footer)
212
+        if ($this->display_header_and_footer)
213 213
         {
214 214
             $this->getAdditionalHeader();
215
-            if(!empty($this->header_title))
215
+            if (!empty($this->header_title))
216 216
             {
217 217
                 echo get_form_header($this->header_title, $this->header_text, false);
218 218
             }
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 
221 221
         $this->xTemplate->out('dyn_list_view');
222 222
 
223
-        if(isset($_SESSION['validation']))
223
+        if (isset($_SESSION['validation']))
224 224
         {
225 225
             print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg==');
226 226
         }
227
-        if(isset($list_data['query'])) {
227
+        if (isset($list_data['query'])) {
228 228
             return ($list_data['query']);
229 229
         }
230 230
     }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
  * @param unknown $html_varName
237 237
  * @desc INTERNAL FUNCTION handles the rows
238 238
  */
239
- function process_dynamic_listview_rows($data,$parent_data, $xtemplateSection, $html_varName, $subpanel_def)
239
+ function process_dynamic_listview_rows($data, $parent_data, $xtemplateSection, $html_varName, $subpanel_def)
240 240
  {
241 241
     global $subpanel_item_count;
242 242
     global $odd_bg;
@@ -261,37 +261,37 @@  discard block
 block discarded – undo
261 261
     //Either retrieve the is_fill_in_additional_fields property from the lone
262 262
     //subpanel or visit each subpanel's subpanels to retrieve the is_fill_in_addition_fields
263 263
     //property
264
-    $subpanel_list=array();
265
-    if($subpanel_def->isCollection()) {
266
-        $subpanel_list=$subpanel_def->sub_subpanels;
264
+    $subpanel_list = array();
265
+    if ($subpanel_def->isCollection()) {
266
+        $subpanel_list = $subpanel_def->sub_subpanels;
267 267
     } else {
268
-        $subpanel_list[]= $subpanel_def;
268
+        $subpanel_list[] = $subpanel_def;
269 269
     }
270 270
 
271
-    foreach($subpanel_list as $this_subpanel)
271
+    foreach ($subpanel_list as $this_subpanel)
272 272
     {
273
-        if($this_subpanel->is_fill_in_additional_fields())
273
+        if ($this_subpanel->is_fill_in_additional_fields())
274 274
         {
275 275
             $fill_additional_fields[] = $this_subpanel->bean_name;
276 276
             $fill_additional_fields[$this_subpanel->bean_name] = true;
277 277
         }
278 278
     }
279 279
 
280
-    if ( empty($data) ) {
280
+    if (empty($data)) {
281 281
         $this->xTemplate->assign("ROW_COLOR", 'oddListRow');
282
-        $thepanel=$subpanel_def;
283
-        if($subpanel_def->isCollection())
284
-            $thepanel=$subpanel_def->get_header_panel_def();
282
+        $thepanel = $subpanel_def;
283
+        if ($subpanel_def->isCollection())
284
+            $thepanel = $subpanel_def->get_header_panel_def();
285 285
         $this->xTemplate->assign("COL_COUNT", count($thepanel->get_list_fields()));
286 286
         $this->xTemplate->parse($xtemplateSection.".nodata");
287 287
     }
288
-    while(list($aVal, $aItem) = each($data))
288
+    while (list($aVal, $aItem) = each($data))
289 289
     {
290 290
         $subpanel_item_count++;
291 291
         $aItem->check_date_relationships_load();
292 292
         // TODO: expensive and needs to be removed and done better elsewhere
293 293
 
294
-        if(!empty($fill_additional_fields[$aItem->object_name])
294
+        if (!empty($fill_additional_fields[$aItem->object_name])
295 295
         || ($aItem->object_name == 'Case' && !empty($fill_additional_fields['aCase']))
296 296
         )
297 297
         {
@@ -301,15 +301,15 @@  discard block
 block discarded – undo
301 301
         //rrs bug: 25343
302 302
         $aItem->call_custom_logic("process_record");
303 303
 
304
-        if(isset($parent_data[$aItem->id])) {
304
+        if (isset($parent_data[$aItem->id])) {
305 305
 
306 306
             $aItem->parent_name = $parent_data[$aItem->id]['parent_name'];
307
-            if(!empty($parent_data[$aItem->id]['parent_name_owner'])) {
308
-            $aItem->parent_name_owner =  $parent_data[$aItem->id]['parent_name_owner'];
309
-            $aItem->parent_name_mod =  $parent_data[$aItem->id]['parent_name_mod'];
307
+            if (!empty($parent_data[$aItem->id]['parent_name_owner'])) {
308
+            $aItem->parent_name_owner = $parent_data[$aItem->id]['parent_name_owner'];
309
+            $aItem->parent_name_mod = $parent_data[$aItem->id]['parent_name_mod'];
310 310
         }}
311 311
         $fields = $aItem->get_list_view_data();
312
-        if(isset($processed_ids[$aItem->id])) {
312
+        if (isset($processed_ids[$aItem->id])) {
313 313
             continue;
314 314
 
315 315
         } else {
@@ -320,50 +320,50 @@  discard block
 block discarded – undo
320 320
         //ADD OFFSET TO ARRAY
321 321
         $fields['OFFSET'] = ($offset + $count + 1);
322 322
 
323
-        if($this->shouldProcess) {
324
-            if($aItem->ACLAccess('EditView')) {
325
-            $this->xTemplate->assign('PREROW', "<input type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "' />");
323
+        if ($this->shouldProcess) {
324
+            if ($aItem->ACLAccess('EditView')) {
325
+            $this->xTemplate->assign('PREROW', "<input type='checkbox' class='checkbox' name='mass[]' value='".$fields['ID']."' />");
326 326
             } else {
327 327
                 $this->xTemplate->assign('PREROW', '');
328 328
 
329 329
             }
330
-            if($aItem->ACLAccess('DetailView')) {
331
-                $this->xTemplate->assign('TAG_NAME','a');
330
+            if ($aItem->ACLAccess('DetailView')) {
331
+                $this->xTemplate->assign('TAG_NAME', 'a');
332 332
             } else {
333
-                $this->xTemplate->assign('TAG_NAME','span');
333
+                $this->xTemplate->assign('TAG_NAME', 'span');
334 334
             }
335 335
             $this->xTemplate->assign('CHECKALL', "<input type='checkbox'  title='".$GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE']."' class='checkbox' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' />");
336 336
         }
337 337
 
338
-        if($oddRow)
338
+        if ($oddRow)
339 339
         {
340 340
             $ROW_COLOR = 'oddListRow';
341
-            $BG_COLOR =  $odd_bg;
341
+            $BG_COLOR = $odd_bg;
342 342
         }
343 343
         else
344 344
         {
345 345
             $ROW_COLOR = 'evenListRow';
346
-            $BG_COLOR =  $even_bg;
346
+            $BG_COLOR = $even_bg;
347 347
         }
348 348
         $oddRow = !$oddRow;
349 349
 		$button_contents = array();
350 350
         $this->xTemplate->assign("ROW_COLOR", $ROW_COLOR);
351 351
         $this->xTemplate->assign("BG_COLOR", $BG_COLOR);
352 352
         $layout_manager = $this->getLayoutManager();
353
-        $layout_manager->setAttribute('context','List');
354
-        $layout_manager->setAttribute('image_path',$this->local_image_path);
353
+        $layout_manager->setAttribute('context', 'List');
354
+        $layout_manager->setAttribute('image_path', $this->local_image_path);
355 355
         $layout_manager->setAttribute('module_name', $subpanel_def->_instance_properties['module']);
356
-        if(!empty($this->child_focus))
357
-            $layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir);
356
+        if (!empty($this->child_focus))
357
+            $layout_manager->setAttribute('related_module_name', $this->child_focus->module_dir);
358 358
 
359 359
         //AG$subpanel_data = $this->list_field_defs;
360 360
         //$bla = array_pop($subpanel_data);
361 361
         //select which sub-panel to display here, the decision will be made based on the type of
362 362
         //the sub-panel and panel in the bean being processed.
363
-        if($subpanel_def->isCollection()) {
364
-            $thepanel=$subpanel_def->sub_subpanels[$aItem->panel_name];
363
+        if ($subpanel_def->isCollection()) {
364
+            $thepanel = $subpanel_def->sub_subpanels[$aItem->panel_name];
365 365
         } else {
366
-            $thepanel=$subpanel_def;
366
+            $thepanel = $subpanel_def;
367 367
         }
368 368
 
369 369
 		/* BEGIN - SECURITY GROUPS */ 
@@ -374,22 +374,22 @@  discard block
 block discarded – undo
374 374
 		$aclaccess_in_group = false;
375 375
 
376 376
 		global $current_user;
377
-		if(is_admin($current_user)) {
377
+		if (is_admin($current_user)) {
378 378
 			$aclaccess_is_owner = true;
379 379
 		} else {
380 380
 			$aclaccess_is_owner = $aItem->isOwner($current_user->id);
381 381
 		}
382 382
 
383 383
 		require_once("modules/SecurityGroups/SecurityGroup.php");
384
-		$aclaccess_in_group = SecurityGroup::groupHasAccess($aItem->module_dir,$aItem->id);
384
+		$aclaccess_in_group = SecurityGroup::groupHasAccess($aItem->module_dir, $aItem->id);
385 385
         	
386 386
     	/* END - SECURITY GROUPS */ 
387 387
     	
388 388
         //get data source name
389
-        $linked_field=$thepanel->get_data_source_name();
390
-        $linked_field_set=$thepanel->get_data_source_name(true);
389
+        $linked_field = $thepanel->get_data_source_name();
390
+        $linked_field_set = $thepanel->get_data_source_name(true);
391 391
         static $count;
392
-        if(!isset($count))$count = 0;
392
+        if (!isset($count))$count = 0;
393 393
 		/* BEGIN - SECURITY GROUPS */ 
394 394
 		/**
395 395
         $field_acl['DetailView'] = $aItem->ACLAccess('DetailView');
@@ -398,19 +398,19 @@  discard block
 block discarded – undo
398 398
         $field_acl['Delete'] = $aItem->ACLAccess('Delete');
399 399
 		*/
400 400
 		//pass is_owner, in_group...vars defined above
401
-        $field_acl['DetailView'] = $aItem->ACLAccess('DetailView',$aclaccess_is_owner,$aclaccess_in_group);
402
-        $field_acl['ListView'] = $aItem->ACLAccess('ListView',$aclaccess_is_owner,$aclaccess_in_group);
403
-        $field_acl['EditView'] = $aItem->ACLAccess('EditView',$aclaccess_is_owner,$aclaccess_in_group);
404
-        $field_acl['Delete'] = $aItem->ACLAccess('Delete',$aclaccess_is_owner,$aclaccess_in_group);
401
+        $field_acl['DetailView'] = $aItem->ACLAccess('DetailView', $aclaccess_is_owner, $aclaccess_in_group);
402
+        $field_acl['ListView'] = $aItem->ACLAccess('ListView', $aclaccess_is_owner, $aclaccess_in_group);
403
+        $field_acl['EditView'] = $aItem->ACLAccess('EditView', $aclaccess_is_owner, $aclaccess_in_group);
404
+        $field_acl['Delete'] = $aItem->ACLAccess('Delete', $aclaccess_is_owner, $aclaccess_in_group);
405 405
 		/* END - SECURITY GROUPS */ 
406
-        foreach($thepanel->get_list_fields() as $field_name=>$list_field)
406
+        foreach ($thepanel->get_list_fields() as $field_name=>$list_field)
407 407
         {
408 408
             //add linked field attribute to the array.
409
-            $list_field['linked_field']=$linked_field;
410
-            $list_field['linked_field_set']=$linked_field_set;
409
+            $list_field['linked_field'] = $linked_field;
410
+            $list_field['linked_field_set'] = $linked_field_set;
411 411
 
412 412
             $usage = empty($list_field['usage']) ? '' : $list_field['usage'];
413
-            if($usage == 'query_only' && !empty($list_field['force_query_only_display'])){
413
+            if ($usage == 'query_only' && !empty($list_field['force_query_only_display'])) {
414 414
                 //if you are here you have column that is query only but needs to be displayed as blank.  This is helpful
415 415
                 //for collections such as Activities where you have a field in only one object and wish to show it in the subpanel list
416 416
                 $count++;
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
                 $this->xTemplate->assign('CELL', $widget_contents);
421 421
                 $this->xTemplate->parse($xtemplateSection.".row.cell");
422 422
 
423
-            }else if($usage != 'query_only')
423
+            } else if ($usage != 'query_only')
424 424
             {
425
-                $list_field['name']=$field_name;
425
+                $list_field['name'] = $field_name;
426 426
 
427 427
                 $module_field = $field_name.'_mod';
428 428
                 $owner_field = $field_name.'_owner';
429
-                if(!empty($aItem->$module_field)) {
429
+                if (!empty($aItem->$module_field)) {
430 430
 
431 431
                     $list_field['owner_id'] = $aItem->$owner_field;
432 432
                     $list_field['owner_module'] = $aItem->$module_field;
@@ -435,71 +435,71 @@  discard block
 block discarded – undo
435 435
                     $list_field['owner_id'] = false;
436 436
                     $list_field['owner_module'] = false;
437 437
                 }
438
-                if(isset($list_field['alias'])) $list_field['name'] = $list_field['alias'];
439
-                else $list_field['name']=$field_name;
438
+                if (isset($list_field['alias'])) $list_field['name'] = $list_field['alias'];
439
+                else $list_field['name'] = $field_name;
440 440
                 $list_field['fields'] = $fields;
441 441
                 $list_field['module'] = $aItem->module_dir;
442 442
                 $list_field['start_link_wrapper'] = $this->start_link_wrapper;
443 443
                 $list_field['end_link_wrapper'] = $this->end_link_wrapper;
444 444
                 $list_field['subpanel_id'] = $this->subpanel_id;
445 445
                 $list_field += $field_acl;
446
-                if ( isset($aItem->field_defs[strtolower($list_field['name'])])) {
446
+                if (isset($aItem->field_defs[strtolower($list_field['name'])])) {
447 447
                     require_once('include/SugarFields/SugarFieldHandler.php');
448 448
                     // We need to see if a sugar field exists for this field type first,
449 449
                     // if it doesn't, toss it at the old sugarWidgets. This is for
450 450
                     // backwards compatibility and will be removed in a future release
451 451
                     $vardef = $aItem->field_defs[strtolower($list_field['name'])];
452
-                    if ( isset($vardef['type']) ) {
453
-                        $fieldType = isset($vardef['custom_type'])?$vardef['custom_type']:$vardef['type'];
454
-                        $tmpField = SugarFieldHandler::getSugarField($fieldType,true);
452
+                    if (isset($vardef['type'])) {
453
+                        $fieldType = isset($vardef['custom_type']) ? $vardef['custom_type'] : $vardef['type'];
454
+                        $tmpField = SugarFieldHandler::getSugarField($fieldType, true);
455 455
                     } else {
456 456
                         $tmpField = NULL;
457 457
                     }
458 458
 
459
-                    if ( $tmpField != NULL ) {
460
-                        $widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'],$vardef,'ListView',$list_field);
459
+                    if ($tmpField != NULL) {
460
+                        $widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'], $vardef, 'ListView', $list_field);
461 461
                     } else {
462 462
                         // No SugarField for this particular type
463 463
                         // Use the old, icky, SugarWidget for now
464 464
                         $widget_contents = $layout_manager->widgetDisplay($list_field);
465 465
                     }
466 466
 
467
-                    if ( isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink' ) {
467
+                    if (isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink') {
468 468
                         // We need to call into the old SugarWidgets for the time being, so it can generate a proper link with all the various corner-cases handled
469 469
                         // So we'll populate the field data with the pre-rendered display for the field
470 470
                         $list_field['fields'][$field_name] = $widget_contents;
471
-                        if('full_name' == $field_name){//bug #32465
471
+                        if ('full_name' == $field_name) {//bug #32465
472 472
                            $list_field['fields'][strtoupper($field_name)] = $widget_contents;
473 473
                         }
474 474
 
475 475
                         //vardef source is non db, assign the field name to varname for processing of column.
476
-                        if(!empty($vardef['source']) && $vardef['source']=='non-db'){
476
+                        if (!empty($vardef['source']) && $vardef['source'] == 'non-db') {
477 477
                             $list_field['varname'] = $field_name;
478 478
 
479 479
                         }
480 480
                         $widget_contents = $layout_manager->widgetDisplay($list_field);
481
-                    } else if(isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink' ) {
481
+                    } else if (isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink') {
482 482
                         $widget_contents = $layout_manager->widgetDisplay($list_field);
483 483
                     }
484 484
 
485 485
                  $count++;
486 486
                 $this->xTemplate->assign('CELL_COUNT', $count);
487 487
                 $this->xTemplate->assign('CLASS', "");
488
-                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
488
+                if (empty($widget_contents)) $widget_contents = '&nbsp;';
489 489
                 $this->xTemplate->assign('CELL', $widget_contents);
490 490
                 $this->xTemplate->parse($xtemplateSection.".row.cell");
491 491
                 } else {
492 492
                     // This handles the edit and remove buttons and icon widget
493
-                	if( isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") {
493
+                	if (isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") {
494 494
 		                $count++;
495 495
 		                $widget_contents = $layout_manager->widgetDisplay($list_field);
496 496
 		                $this->xTemplate->assign('CELL_COUNT', $count);
497 497
 		                $this->xTemplate->assign('CLASS', "");
498
-		                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
498
+		                if (empty($widget_contents)) $widget_contents = '&nbsp;';
499 499
 		                $this->xTemplate->assign('CELL', $widget_contents);
500 500
 		                $this->xTemplate->parse($xtemplateSection.".row.cell");
501 501
                 	} elseif (preg_match("/button/i", $list_field['name'])) {
502
-                        if ((($list_field['name'] === 'edit_button' && $field_acl['EditView']) || ($list_field['name'] === 'close_button' && $field_acl['EditView']) || ($list_field['name'] === 'remove_button' && $field_acl['Delete'])) && '' != ($_content = $layout_manager->widgetDisplay($list_field)) )
502
+                        if ((($list_field['name'] === 'edit_button' && $field_acl['EditView']) || ($list_field['name'] === 'close_button' && $field_acl['EditView']) || ($list_field['name'] === 'remove_button' && $field_acl['Delete'])) && '' != ($_content = $layout_manager->widgetDisplay($list_field)))
503 503
                         {
504 504
                             $button_contents[] = $_content;
505 505
                             unset($_content);
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
                			$this->xTemplate->assign('CLASS', "");
514 514
                			$widget_contents = $layout_manager->widgetDisplay($list_field);
515 515
 		                $this->xTemplate->assign('CELL_COUNT', $count);
516
-		                if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
516
+		                if (empty($widget_contents)) $widget_contents = '&nbsp;';
517 517
 		                $this->xTemplate->assign('CELL', $widget_contents);
518 518
 		                $this->xTemplate->parse($xtemplateSection.".row.cell");
519 519
                 	}
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 
526 526
         // Make sure we have at least one button before rendering a column for
527 527
         // the action buttons in a list view. Relevant bugs: #51647 and #51640.
528
-        if(!empty($button_contents))
528
+        if (!empty($button_contents))
529 529
         {
530 530
             $button_contents = array_filter($button_contents);
531 531
             if (!empty($button_contents))
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
             // bug#51275: smarty widget to help provide the action menu functionality as it is currently sprinkled throughout the app with html
535 535
                 require_once('include/Smarty/plugins/function.sugar_action_menu.php');
536 536
                 $tempid = create_guid();
537
-                array_unshift($button_contents, "<div style='display: inline' id='$tempid'>" . array_shift($button_contents) . "</div>");
537
+                array_unshift($button_contents, "<div style='display: inline' id='$tempid'>".array_shift($button_contents)."</div>");
538 538
                 $action_button = smarty_function_sugar_action_menu(array(
539 539
                     'id' => $tempid,
540 540
                     'buttons' => $button_contents,
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
             $this->xTemplate->assign('CELL_COUNT', ++$count);
551 551
             //Bug#51275 for beta3 pre_script is not required any more
552 552
             $this->xTemplate->assign('CELL', $action_button);
553
-            $this->xTemplate->parse($xtemplateSection . ".row.cell");
553
+            $this->xTemplate->parse($xtemplateSection.".row.cell");
554 554
         }
555 555
 
556 556
 
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
  function ListView() {
583 583
 
584 584
 
585
-    if(!$this->initialized) {
585
+    if (!$this->initialized) {
586 586
         global $sugar_config;
587 587
         $this->records_per_page = $sugar_config['list_max_entries_per_page'] + 0;
588 588
         $this->initialized = true;
589 589
         global $app_strings, $currentModule;
590 590
         $this->local_theme = SugarThemeRegistry::current()->__toString();
591
-        $this->local_app_strings =$app_strings;
591
+        $this->local_app_strings = $app_strings;
592 592
         $this->local_image_path = SugarThemeRegistry::current()->getImagePath();
593 593
         $this->local_current_module = $currentModule;
594 594
     }
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
  * Contributor(s): ______________________________________.
620 620
 */
621 621
  function setXTemplatePath($value) {
622
-    $this->xTemplatePath= $value;
622
+    $this->xTemplatePath = $value;
623 623
 }
624 624
 
625 625
 /**this is a helper function for allowing ListView to create a new XTemplate it groups parameters that should be set into a single function
@@ -629,22 +629,22 @@  discard block
 block discarded – undo
629 629
 */
630 630
  function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) {
631 631
     $this->setXTemplatePath($XTemplatePath);
632
-    if(isset($modString))
632
+    if (isset($modString))
633 633
         $this->setModStrings($modString);
634
-    if(isset($imagePath))
634
+    if (isset($imagePath))
635 635
         $this->setImagePath($imagePath);
636 636
 }
637 637
 
638 638
 
639
-function getOrderBy($varName, $defaultOrderBy='', $force_sortorder='') {
640
-    $sortBy = $this->getSessionVariable($varName, "ORDER_BY") ;
639
+function getOrderBy($varName, $defaultOrderBy = '', $force_sortorder = '') {
640
+    $sortBy = $this->getSessionVariable($varName, "ORDER_BY");
641 641
 
642 642
     $orderByDirection = $this->getSessionVariableName($varName, "order_by_direction");
643 643
     $orderByColumn = $this->getSessionVariableName($varName, "ORDER_BY");
644 644
     $lastEqualsSortBy = false;
645 645
     $defaultOrder = false; //ascending
646 646
 
647
-    if(empty($sortBy)) {
647
+    if (empty($sortBy)) {
648 648
         $this->setUserVariable($varName, "ORDER_BY", $defaultOrderBy);
649 649
         $sortBy = $defaultOrderBy;
650 650
     } else {
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
         }
683 683
         $desc = $orderByValue == 'desc';
684 684
         $orderByDirectionValue = false;
685
-        $this->setSessionVariable($varName, $sortBy . "S", $desc);
685
+        $this->setSessionVariable($varName, $sortBy."S", $desc);
686 686
         if (!empty($sortBy))
687 687
         {
688 688
             if (empty($force_sortorder))
@@ -693,11 +693,11 @@  discard block
 block discarded – undo
693 693
                     {
694 694
                         $orderByDirectionValue = $desc ? 'asc' : 'desc';
695 695
                     }
696
-                    $this->query_orderby = $sortBy . ' ' . $orderByValue;
696
+                    $this->query_orderby = $sortBy.' '.$orderByValue;
697 697
                 }
698 698
             } else
699 699
             {
700
-                $this->query_orderby = $sortBy . ' ' . $force_sortorder;
700
+                $this->query_orderby = $sortBy.' '.$force_sortorder;
701 701
             }
702 702
             if (!isset($this->appendToBaseUrl))
703 703
             {
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
             }
715 715
             //Just clear from url...
716 716
             $this->appendToBaseUrl[$orderByColumn] = false;
717
-    }else {
717
+    } else {
718 718
         $this->query_orderby = "";
719 719
     }
720 720
     $this->sortby = $sortBy;
@@ -728,15 +728,15 @@  discard block
 block discarded – undo
728 728
  * All Rights Reserved.
729 729
  * Contributor(s): ______________________________________.
730 730
 */
731
- function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride=true) {
731
+ function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride = true) {
732 732
     $this->query_where = $where;
733
-    if($this->getSessionVariable("query", "where") != $where) {
733
+    if ($this->getSessionVariable("query", "where") != $where) {
734 734
         $this->query_where_has_changed = true;
735 735
         $this->setSessionVariable("query", "where", $where);
736 736
     }
737 737
 
738 738
     $this->query_limit = $limit;
739
-    if(!$allowOrderByOveride) {
739
+    if (!$allowOrderByOveride) {
740 740
         $this->query_orderby = $orderBy;
741 741
         return;
742 742
     }
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 */
760 760
  function setTheme($theme) {
761 761
     $this->local_theme = $theme;
762
-    if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme);
762
+    if (isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme);
763 763
 }
764 764
 
765 765
 /**sets the AppStrings used only use if it is different from the global
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
  function setAppStrings($app_strings) {
771 771
     unset($this->local_app_strings);
772 772
     $this->local_app_strings = $app_strings;
773
-    if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings);
773
+    if (isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings);
774 774
 }
775 775
 
776 776
 /**sets the ModStrings used
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
  function setModStrings($mod_strings) {
782 782
     unset($this->local_module_strings);
783 783
     $this->local_mod_strings = $mod_strings;
784
-    if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings);
784
+    if (isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings);
785 785
 }
786 786
 
787 787
 /**sets the ImagePath used
@@ -791,10 +791,10 @@  discard block
 block discarded – undo
791 791
 */
792 792
  function setImagePath($image_path) {
793 793
     $this->local_image_path = $image_path;
794
-    if(empty($this->local_image_path)) {
794
+    if (empty($this->local_image_path)) {
795 795
         $this->local_image_path = SugarThemeRegistry::get($this->local_theme)->getImagePath();
796 796
     }
797
-    if(isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
797
+    if (isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
798 798
 }
799 799
 
800 800
 /**sets the currentModule only use if this is different from the global
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
  function setCurrentModule($currentModule) {
806 806
     unset($this->local_current_module);
807 807
     $this->local_current_module = $currentModule;
808
-    if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
808
+    if (isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
809 809
 }
810 810
 
811 811
 /**INTERNAL FUNCTION creates an XTemplate DO NOT CALL THIS THIS IS AN INTERNAL FUNCTION
@@ -814,12 +814,12 @@  discard block
 block discarded – undo
814 814
  * Contributor(s): ______________________________________.
815 815
 */
816 816
  function createXTemplate() {
817
-    if(!isset($this->xTemplate)) {
818
-        if(isset($this->xTemplatePath)) {
817
+    if (!isset($this->xTemplate)) {
818
+        if (isset($this->xTemplatePath)) {
819 819
 
820 820
             $this->xTemplate = new XTemplate($this->xTemplatePath);
821 821
             $this->xTemplate->assign("APP", $this->local_app_strings);
822
-            if(isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings);
822
+            if (isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings);
823 823
             $this->xTemplate->assign("THEME", $this->local_theme);
824 824
             $this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
825 825
             $this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 */
855 855
  function xTemplateAssign($name, $value) {
856 856
 
857
-        if(!isset($this->xTemplate)) {
857
+        if (!isset($this->xTemplate)) {
858 858
             $this->createXTemplate();
859 859
         }
860 860
         $this->xTemplate->assign($name, $value);
@@ -867,11 +867,11 @@  discard block
 block discarded – undo
867 867
  * Contributor(s): ______________________________________.
868 868
 */
869 869
  function getOffset($localVarName) {
870
- 	if($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) {
871
- 		$this->setSessionVariable($localVarName,"offset", 0);
870
+ 	if ($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) {
871
+ 		$this->setSessionVariable($localVarName, "offset", 0);
872 872
  	}
873
-	$offset = $this->getSessionVariable($localVarName,"offset");
874
-	if(isset($offset)) {
873
+	$offset = $this->getSessionVariable($localVarName, "offset");
874
+	if (isset($offset)) {
875 875
 		return $offset;
876 876
 	}
877 877
 	return 0;
@@ -891,12 +891,12 @@  discard block
 block discarded – undo
891 891
  * All Rights Reserved.
892 892
  * Contributor(s): ______________________________________.
893 893
 */
894
- function setSessionVariable($localVarName,$varName, $value) {
894
+ function setSessionVariable($localVarName, $varName, $value) {
895 895
     $_SESSION[$this->local_current_module."_".$localVarName."_".$varName] = $value;
896 896
 }
897 897
 
898
-function setUserVariable($localVarName,$varName, $value) {
899
-        if($this->is_dynamic ||  $localVarName == 'CELL')return;
898
+function setUserVariable($localVarName, $varName, $value) {
899
+        if ($this->is_dynamic || $localVarName == 'CELL')return;
900 900
         global $current_user;
901 901
         $current_user->setPreference($this->local_current_module."_".$localVarName."_".$varName, $value);
902 902
 }
@@ -906,13 +906,13 @@  discard block
 block discarded – undo
906 906
  * All Rights Reserved.
907 907
  * Contributor(s): ______________________________________.
908 908
 */
909
- function getSessionVariable($localVarName,$varName) {
909
+ function getSessionVariable($localVarName, $varName) {
910 910
     //Set any variables pass in through request first
911
-    if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
912
-        $this->setSessionVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
911
+    if (isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
912
+        $this->setSessionVariable($localVarName, $varName, $_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
913 913
     }
914 914
 
915
-    if(isset($_SESSION[$this->getSessionVariableName($localVarName, $varName)])) {
915
+    if (isset($_SESSION[$this->getSessionVariableName($localVarName, $varName)])) {
916 916
         return $_SESSION[$this->getSessionVariableName($localVarName, $varName)];
917 917
     }
918 918
     return "";
@@ -920,10 +920,10 @@  discard block
 block discarded – undo
920 920
 
921 921
 function getUserVariable($localVarName, $varName) {
922 922
     global $current_user;
923
-    if($this->is_dynamic ||  $localVarName == 'CELL')return;
924
-    if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
923
+    if ($this->is_dynamic || $localVarName == 'CELL')return;
924
+    if (isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
925 925
 
926
-            $this->setUserVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
926
+            $this->setUserVariable($localVarName, $varName, $_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
927 927
     }
928 928
     return $current_user->getPreference($this->getSessionVariableName($localVarName, $varName));
929 929
 }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
           'default',
948 948
         );
949 949
 
950
-        foreach($priority_map as $p) {
950
+        foreach ($priority_map as $p) {
951 951
             if (key_exists($p, $sortOrderList)) {
952 952
                 $order = strtolower($sortOrderList[$p]);
953 953
                 if (in_array($order, array('asc', 'desc'))) {
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
     * All Rights Reserved.
970 970
     * Contributor(s): ______________________________________..
971 971
     */
972
-    function getSessionVariableName($localVarName,$varName) {
972
+    function getSessionVariableName($localVarName, $varName) {
973 973
         return $this->local_current_module."_".$localVarName."_".$varName;
974 974
     }
975 975
 
@@ -997,22 +997,22 @@  discard block
 block discarded – undo
997 997
         SugarVCR::erase($seed->module_dir);
998 998
         $params = array();
999 999
         //$filter = array('id', 'full_name');
1000
-        $filter=array();
1000
+        $filter = array();
1001 1001
         $ret_array = $seed->create_new_list_query($this->query_orderby, $this->query_where, $filter, $params, 0, '', true, $seed, true);
1002
-        if(!is_array($params)) $params = array();
1003
-        if(!isset($params['custom_select'])) $params['custom_select'] = '';
1004
-        if(!isset($params['custom_from'])) $params['custom_from'] = '';
1005
-        if(!isset($params['custom_where'])) $params['custom_where'] = '';
1006
-        if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
1007
-        $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
1008
-        SugarVCR::store($seed->module_dir,  $main_query);
1002
+        if (!is_array($params)) $params = array();
1003
+        if (!isset($params['custom_select'])) $params['custom_select'] = '';
1004
+        if (!isset($params['custom_from'])) $params['custom_from'] = '';
1005
+        if (!isset($params['custom_where'])) $params['custom_where'] = '';
1006
+        if (!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
1007
+        $main_query = $ret_array['select'].$params['custom_select'].$ret_array['from'].$params['custom_from'].$ret_array['where'].$params['custom_where'].$ret_array['order_by'].$params['custom_order_by'];
1008
+        SugarVCR::store($seed->module_dir, $main_query);
1009 1009
         //ADDING VCR CONTROL
1010 1010
 
1011
-        if(empty($this->related_field_name)) {
1011
+        if (empty($this->related_field_name)) {
1012 1012
             $response = $seed->get_list($this->query_orderby, $this->query_where, $current_offset, $this->query_limit);
1013 1013
         } else {
1014 1014
             $related_field_name = $this->related_field_name;
1015
-            $response = $seed->get_related_list($this->child_focus,$related_field_name, $this->query_orderby,
1015
+            $response = $seed->get_related_list($this->child_focus, $related_field_name, $this->query_orderby,
1016 1016
             $this->query_where, $current_offset, $this->query_limit);
1017 1017
         }
1018 1018
 
@@ -1021,12 +1021,12 @@  discard block
 block discarded – undo
1021 1021
         $next_offset = $response['next_offset'];
1022 1022
         $previous_offset = $response['previous_offset'];
1023 1023
 
1024
-        if(!empty($response['current_offset'])) {
1024
+        if (!empty($response['current_offset'])) {
1025 1025
             $current_offset = $response['current_offset'];
1026 1026
         }
1027 1027
 
1028 1028
         $list_view_row_count = $row_count;
1029
-        $this->processListNavigation($xtemplateSection,$html_varName, $current_offset, $next_offset, $previous_offset, $row_count, null, null, empty($seed->column_fields) ? null : count($seed->column_fields));
1029
+        $this->processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, null, null, empty($seed->column_fields) ? null : count($seed->column_fields));
1030 1030
 
1031 1031
         return $list;
1032 1032
     }
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
     function processUnionBeans($sugarbean, $subpanel_def, $html_var = 'CELL') {
1037 1037
 
1038 1038
 		$last_detailview_record = $this->getSessionVariable("detailview", "record");
1039
-		if(!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id){
1039
+		if (!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id) {
1040 1040
 			$GLOBALS['record_has_changed'] = true;
1041 1041
 		}
1042 1042
 		$this->setSessionVariable("detailview", "record", $sugarbean->id);
@@ -1053,14 +1053,14 @@  discard block
 block discarded – undo
1053 1053
         $sort_order['request'] = isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : null;
1054 1054
 
1055 1055
         // see if the session data has a sort order
1056
-        if (isset($_SESSION['last_sub' . $this->subpanel_module . '_order']))
1056
+        if (isset($_SESSION['last_sub'.$this->subpanel_module.'_order']))
1057 1057
         {
1058
-            $sort_order['session'] = $_SESSION['last_sub' . $this->subpanel_module . '_order'];
1058
+            $sort_order['session'] = $_SESSION['last_sub'.$this->subpanel_module.'_order'];
1059 1059
 
1060 1060
             // We swap the order when the request contains an offset (indicating a column sort issued);
1061 1061
             // otherwise we do not sort.  If we don't make this check, then the subpanel listview will
1062 1062
             // swap ordering each time a new record is entered via quick create forms
1063
-            if (isset($_REQUEST[$module . '_' . $html_var . '_offset']))
1063
+            if (isset($_REQUEST[$module.'_'.$html_var.'_offset']))
1064 1064
             {
1065 1065
                 $sort_order['session'] = $sort_order['session'] == 'asc' ? 'desc' : 'asc';
1066 1066
             }
@@ -1083,10 +1083,10 @@  discard block
 block discarded – undo
1083 1083
             $this->query_orderby = 'id';
1084 1084
         }
1085 1085
 
1086
-        $this->getOrderBy($html_var,$this->query_orderby, $this->sort_order);
1086
+        $this->getOrderBy($html_var, $this->query_orderby, $this->sort_order);
1087 1087
 
1088
-        $_SESSION['last_sub' .$this->subpanel_module. '_order'] = $this->sort_order;
1089
-        $_SESSION['last_sub' .$this->subpanel_module. '_url'] = $this->getBaseURL($html_var);
1088
+        $_SESSION['last_sub'.$this->subpanel_module.'_order'] = $this->sort_order;
1089
+        $_SESSION['last_sub'.$this->subpanel_module.'_url'] = $this->getBaseURL($html_var);
1090 1090
 
1091 1091
 		// Bug 8139 - Correct Subpanel sorting on 'name', when subpanel sorting default is 'last_name, first_name'
1092 1092
 		if (($this->sortby == 'name' || $this->sortby == 'last_name') &&
@@ -1094,21 +1094,21 @@  discard block
 block discarded – undo
1094 1094
 			$this->sortby = 'last_name '.$this->sort_order.', first_name ';
1095 1095
 		}
1096 1096
 
1097
-        if(!empty($this->response)){
1098
-            $response =& $this->response;
1097
+        if (!empty($this->response)) {
1098
+            $response = & $this->response;
1099 1099
             echo 'cached';
1100
-        }else{
1101
-            $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def);
1102
-            $this->response =& $response;
1100
+        } else {
1101
+            $response = SugarBean::get_union_related_list($sugarbean, $this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page, $this->query_limit, $subpanel_def);
1102
+            $this->response = & $response;
1103 1103
         }
1104 1104
         $list = $response['list'];
1105 1105
         $row_count = $response['row_count'];
1106 1106
         $next_offset = $response['next_offset'];
1107 1107
         $previous_offset = $response['previous_offset'];
1108
-        if(!empty($response['current_offset']))$current_offset = $response['current_offset'];
1108
+        if (!empty($response['current_offset']))$current_offset = $response['current_offset'];
1109 1109
         global $list_view_row_count;
1110 1110
         $list_view_row_count = $row_count;
1111
-        $this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean,$subpanel_def);
1111
+        $this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean, $subpanel_def);
1112 1112
 
1113 1113
         return array('list'=>$list, 'parent_data'=>$response['parent_data'], 'query'=>$response['query']);
1114 1114
     }
@@ -1116,34 +1116,34 @@  discard block
 block discarded – undo
1116 1116
     function getBaseURL($html_varName) {
1117 1117
         static $cache = array();
1118 1118
 
1119
-        if(!empty($cache[$html_varName]))return $cache[$html_varName];
1120
-        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount','current_query_by_page');
1121
-        if(!empty($this->base_URL)) {
1119
+        if (!empty($cache[$html_varName]))return $cache[$html_varName];
1120
+        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'current_query_by_page');
1121
+        if (!empty($this->base_URL)) {
1122 1122
             return $this->base_URL;
1123 1123
         }
1124 1124
 
1125 1125
             $baseurl = $_SERVER['PHP_SELF'];
1126
-            if(empty($baseurl)) {
1126
+            if (empty($baseurl)) {
1127 1127
                 $baseurl = 'index.php';
1128 1128
             }
1129 1129
 
1130 1130
             /*fixes an issue with deletes when doing a search*/
1131
-            foreach(array_merge($_GET, $_POST) as $name=>$value) {
1131
+            foreach (array_merge($_GET, $_POST) as $name=>$value) {
1132 1132
                 //echo ("$name = $value <br/>");
1133
-                if(!empty($value) && $name != 'sort_order' //&& $name != ListView::getSessionVariableName($html_varName,"ORDER_BY")
1134
-                        && $name != ListView::getSessionVariableName($html_varName,"offset")
1133
+                if (!empty($value) && $name != 'sort_order' //&& $name != ListView::getSessionVariableName($html_varName,"ORDER_BY")
1134
+                        && $name != ListView::getSessionVariableName($html_varName, "offset")
1135 1135
                         /*&& substr_count($name, "ORDER_BY")==0*/ && !in_array($name, $blockVariables))
1136 1136
                 {
1137
-                    if(is_array($value)) {
1138
-                        foreach($value as $valuename=>$valuevalue) {
1139
-                            if(substr_count($baseurl, '?') > 0)
1137
+                    if (is_array($value)) {
1138
+                        foreach ($value as $valuename=>$valuevalue) {
1139
+                            if (substr_count($baseurl, '?') > 0)
1140 1140
                                 $baseurl	.= "&{$name}[]=".$valuevalue;
1141 1141
                             else
1142 1142
                                 $baseurl	.= "?{$name}[]=".$valuevalue;
1143 1143
                         }
1144 1144
                     } else {
1145 1145
                         $value = urlencode($value);
1146
-                        if(substr_count($baseurl, '?') > 0) {
1146
+                        if (substr_count($baseurl, '?') > 0) {
1147 1147
                             $baseurl	.= "&$name=$value";
1148 1148
                         } else {
1149 1149
                             $baseurl	.= "?$name=$value";
@@ -1153,17 +1153,17 @@  discard block
 block discarded – undo
1153 1153
             }
1154 1154
 
1155 1155
 
1156
-            if($_SERVER['REQUEST_METHOD'] == 'POST') {
1156
+            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1157 1157
                 // at this point it is possible that the above foreach already executed resulting in double ?'s in the url
1158
-                if(substr_count($baseurl, '?') == 0) {
1158
+                if (substr_count($baseurl, '?') == 0) {
1159 1159
                     $baseurl .= '?';
1160 1160
                 }
1161
-                if(isset($_REQUEST['action'])) $baseurl.= '&action='.$_REQUEST['action'];
1162
-                if(isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record'];
1163
-                if(isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module'];
1161
+                if (isset($_REQUEST['action'])) $baseurl .= '&action='.$_REQUEST['action'];
1162
+                if (isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record'];
1163
+                if (isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module'];
1164 1164
             }
1165 1165
 
1166
-            $baseurl .= "&".ListView::getSessionVariableName($html_varName,"offset")."=";
1166
+            $baseurl .= "&".ListView::getSessionVariableName($html_varName, "offset")."=";
1167 1167
             $cache[$html_varName] = $baseurl;
1168 1168
             return $baseurl;
1169 1169
     }
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
     * All Rights Reserved.
1178 1178
     * Contributor(s): ______________________________________..
1179 1179
     */
1180
-    function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean=null, $subpanel_def=null, $col_count = 20) {
1180
+    function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean = null, $subpanel_def = null, $col_count = 20) {
1181 1181
 
1182 1182
         global $export_module;
1183 1183
         global $sugar_config;
@@ -1187,40 +1187,40 @@  discard block
 block discarded – undo
1187 1187
 
1188 1188
         $start_record = $current_offset + 1;
1189 1189
 
1190
-        if(!is_numeric($col_count))
1190
+        if (!is_numeric($col_count))
1191 1191
             $col_count = 20;
1192 1192
 
1193
-        if($row_count == 0)
1193
+        if ($row_count == 0)
1194 1194
             $start_record = 0;
1195 1195
 
1196 1196
         $end_record = $start_record + $this->records_per_page;
1197 1197
         // back up the the last page.
1198
-        if($end_record > $row_count+1) {
1199
-            $end_record = $row_count+1;
1198
+        if ($end_record > $row_count + 1) {
1199
+            $end_record = $row_count + 1;
1200 1200
         }
1201 1201
         // Determine the start location of the last page
1202
-        if($row_count == 0)
1202
+        if ($row_count == 0)
1203 1203
             $number_pages = 0;
1204 1204
         else
1205 1205
             $number_pages = floor(($row_count - 1) / $this->records_per_page);
1206 1206
 
1207 1207
         $last_offset = $number_pages * $this->records_per_page;
1208 1208
 
1209
-        if(empty($this->query_limit)  || $this->query_limit > $this->records_per_page) {
1209
+        if (empty($this->query_limit) || $this->query_limit > $this->records_per_page) {
1210 1210
             $this->base_URL = $this->getBaseURL($html_varName);
1211 1211
             $dynamic_url = '';
1212 1212
 
1213
-            if($this->is_dynamic) {
1214
-                $dynamic_url .='&'. $this->getSessionVariableName($html_varName,'ORDER_BY') . '='. $this->getSessionVariable($html_varName,'ORDER_BY').'&sort_order='.$this->sort_order.'&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->subpanel_module;
1213
+            if ($this->is_dynamic) {
1214
+                $dynamic_url .= '&'.$this->getSessionVariableName($html_varName, 'ORDER_BY').'='.$this->getSessionVariable($html_varName, 'ORDER_BY').'&sort_order='.$this->sort_order.'&to_pdf=true&action=SubPanelViewer&subpanel='.$this->subpanel_module;
1215 1215
             }
1216 1216
 
1217 1217
             $current_URL = htmlentities($this->base_URL.$current_offset.$dynamic_url);
1218 1218
             $start_URL = htmlentities($this->base_URL."0".$dynamic_url);
1219
-            $previous_URL  = htmlentities($this->base_URL.$previous_offset.$dynamic_url);
1219
+            $previous_URL = htmlentities($this->base_URL.$previous_offset.$dynamic_url);
1220 1220
             $next_URL  = htmlentities($this->base_URL.$next_offset.$dynamic_url);
1221
-            $end_URL  = htmlentities($this->base_URL.'end'.$dynamic_url);
1221
+            $end_URL = htmlentities($this->base_URL.'end'.$dynamic_url);
1222 1222
 
1223
-            if(!empty($this->start_link_wrapper)) {
1223
+            if (!empty($this->start_link_wrapper)) {
1224 1224
                 $current_URL = $this->start_link_wrapper.$current_URL.$this->end_link_wrapper;
1225 1225
                 $start_URL = $this->start_link_wrapper.$start_URL.$this->end_link_wrapper;
1226 1226
                 $previous_URL = $this->start_link_wrapper.$previous_URL.$this->end_link_wrapper;
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 
1231 1231
             $moduleString = htmlspecialchars("{$currentModule}_{$html_varName}_offset");
1232 1232
             $moduleStringOrder = htmlspecialchars("{$currentModule}_{$html_varName}_ORDER_BY");
1233
-            if($this->shouldProcess && !$this->multi_select_popup) {
1233
+            if ($this->shouldProcess && !$this->multi_select_popup) {
1234 1234
                 // check the checkboxes onload
1235 1235
                 echo "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n";
1236 1236
 
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
                 $uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid'];
1239 1239
                 $select_entire_list = ($massUpdateRun) ? 0 : (isset($_POST['select_entire_list']) ? $_POST['select_entire_list'] : (isset($_REQUEST['select_entire_list']) ? htmlspecialchars($_REQUEST['select_entire_list']) : 0));
1240 1240
 
1241
-                echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" .
1241
+                echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n".
1242 1242
                     "<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n".
1243 1243
                     "<input type='hidden' name='{$moduleString}' value='0'>\n".
1244 1244
                     "<input type='hidden' name='{$moduleStringOrder}' value='0'>\n";
@@ -1248,64 +1248,64 @@  discard block
 block discarded – undo
1248 1248
 
1249 1249
             $GLOBALS['log']->debug("Offsets: (start, previous, next, last)(0, $previous_offset, $next_offset, $last_offset)");
1250 1250
 
1251
-            if(0 == $current_offset) {
1252
-                $start_link = "<button type='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("start_off","aborder='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1253
-                $previous_link = "<button type='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1251
+            if (0 == $current_offset) {
1252
+                $start_link = "<button type='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("start_off", "aborder='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START'])."</button>";
1253
+                $previous_link = "<button type='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1254 1254
             } else {
1255
-                if($this->multi_select_popup) {// nav links for multiselect popup, submit form to save checks.
1256
-                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='javascript:save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1257
-                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='javascript:save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1258
-                } elseif($this->shouldProcess) {
1259
-                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"$start_URL\"; sListView.save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1260
-                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"$previous_URL\"; sListView.save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1255
+                if ($this->multi_select_popup) {// nav links for multiselect popup, submit form to save checks.
1256
+                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='javascript:save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START'])."</button>";
1257
+                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='javascript:save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1258
+                } elseif ($this->shouldProcess) {
1259
+                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"$start_URL\"; sListView.save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START'])."</button>";
1260
+                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"$previous_URL\"; sListView.save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1261 1261
                 } else {
1262 1262
                     $onClick = '';
1263
-                    if(0 != preg_match('/javascript.*/', $start_URL)){
1263
+                    if (0 != preg_match('/javascript.*/', $start_URL)) {
1264 1264
                         $onClick = "\"$start_URL;\"";
1265
-                    }else{
1266
-                        $onClick ="'location.href=\"$start_URL\";'";
1265
+                    } else {
1266
+                        $onClick = "'location.href=\"$start_URL\";'";
1267 1267
                     }
1268
-                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1268
+                    $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START'])."</button>";
1269 1269
 
1270 1270
                     $onClick = '';
1271
-                    if(0 != preg_match('/javascript.*/', $previous_URL)){
1271
+                    if (0 != preg_match('/javascript.*/', $previous_URL)) {
1272 1272
                         $onClick = "\"$previous_URL;\"";
1273
-                    }else{
1273
+                    } else {
1274 1274
                         $onClick = "'location.href=\"$previous_URL\";'";
1275 1275
                     }
1276
-                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1276
+                    $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1277 1277
                 }
1278 1278
             }
1279 1279
 
1280
-            if($last_offset <= $current_offset) {
1281
-                $end_link = "<button type='button' name='listViewEndButton' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("end_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1282
-                $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("next_off","aborder='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1280
+            if ($last_offset <= $current_offset) {
1281
+                $end_link = "<button type='button' name='listViewEndButton' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("end_off", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END'])."</button>";
1282
+                $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("next_off", "aborder='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1283 1283
             } else {
1284
-                if($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks.
1285
-                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='javascript:save_checks($last_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1286
-                    if(!empty($sugar_config['disable_count_query'])) {
1284
+                if ($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks.
1285
+                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='javascript:save_checks($last_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END'])."</button>";
1286
+                    if (!empty($sugar_config['disable_count_query'])) {
1287 1287
                         $end_link = '';
1288 1288
                     }
1289
-                    $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' onClick='javascript:save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1290
-                } elseif($this->shouldProcess) {
1291
-                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"$end_URL\"; sListView.save_checks(\"end\", \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1292
-                    $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"$next_URL\"; sListView.save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1289
+                    $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' onClick='javascript:save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1290
+                } elseif ($this->shouldProcess) {
1291
+                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"$end_URL\"; sListView.save_checks(\"end\", \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END'])."</button>";
1292
+                    $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"$next_URL\"; sListView.save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1293 1293
                 } else {
1294 1294
                     $onClick = '';
1295
-                    if(0 != preg_match('/javascript.*/', $next_URL)){
1295
+                    if (0 != preg_match('/javascript.*/', $next_URL)) {
1296 1296
                         $onClick = "\"$next_URL;\"";
1297
-                    }else{
1298
-                        $onClick ="'location.href=\"$next_URL\";'";
1297
+                    } else {
1298
+                        $onClick = "'location.href=\"$next_URL\";'";
1299 1299
                     }
1300
-                    $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1300
+                    $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1301 1301
 
1302 1302
                     $onClick = '';
1303
-                    if(0 != preg_match('/javascript.*/', $end_URL)){
1303
+                    if (0 != preg_match('/javascript.*/', $end_URL)) {
1304 1304
                         $onClick = "\"$end_URL;\"";
1305
-                    }else{
1305
+                    } else {
1306 1306
                         $onClick = "'location.href=\"$end_URL\";'";
1307 1307
                     }
1308
-                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1308
+                    $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END'])."</button>";
1309 1309
 
1310 1310
                 }
1311 1311
             }
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
             $GLOBALS['log']->info("Offset (next, current, prev)($next_offset, $current_offset, $previous_offset)");
1314 1314
             $GLOBALS['log']->info("Start/end records ($start_record, $end_record)");
1315 1315
 
1316
-            $end_record = $end_record-1;
1316
+            $end_record = $end_record - 1;
1317 1317
 
1318 1318
 $script_href = "<a style=\'width: 150px\' name=\"thispage\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $this->records_per_page)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}&nbsp;&#x28;{$this->records_per_page}&#x29;&#x200E;</a>"
1319 1319
  . "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;&#x28;{$row_count}&#x29;&#x200E;</a>"
@@ -1336,14 +1336,14 @@  discard block
 block discarded – undo
1336 1336
                 }
1337 1337
                 </script>";
1338 1338
 
1339
-            if($this->show_select_menu)
1339
+            if ($this->show_select_menu)
1340 1340
             {
1341 1341
                 $total_label = "";
1342 1342
                 $total = $row_count;
1343 1343
                 $pageTotal = ($row_count > 0) ? $end_record - $start_record + 1 : 0;
1344 1344
                 if (!empty($GLOBALS['sugar_config']['disable_count_query']) && $GLOBALS['sugar_config']['disable_count_query'] === true && $total > $pageTotal) {
1345 1345
                     $this->show_plus = true;
1346
-                    $total =  $pageTotal;
1346
+                    $total = $pageTotal;
1347 1347
                     $total_label = $total.'+';
1348 1348
                 } else {
1349 1349
                     $this->show_plus = false;
@@ -1365,16 +1365,16 @@  discard block
 block discarded – undo
1365 1365
                     'id' => 'selectLink',
1366 1366
                     'buttons' => $menuItems,
1367 1367
                     'flat' => false,
1368
-                ),$this->xTemplate);
1368
+                ), $this->xTemplate);
1369 1369
 
1370 1370
             } else {
1371 1371
                 $select_link = "&nbsp;";
1372 1372
             }
1373 1373
 
1374
-            $export_link = '<input class="button" type="button" value="'.$this->local_app_strings['LBL_EXPORT'].'" ' .
1374
+            $export_link = '<input class="button" type="button" value="'.$this->local_app_strings['LBL_EXPORT'].'" '.
1375 1375
                     'onclick="return sListView.send_form(true, \''.$_REQUEST['module'].'\', \'index.php?entryPoint=export\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\')">';
1376 1376
 
1377
-            if($this->show_delete_button) {
1377
+            if ($this->show_delete_button) {
1378 1378
                 $delete_link = '<input class="button" type="button" id="delete_button" name="Delete" value="'.$this->local_app_strings['LBL_DELETE_BUTTON_LABEL'].'" onclick="return sListView.send_mass_update(\'selected\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\', 1)">';
1379 1379
             } else {
1380 1380
                 $delete_link = '&nbsp;';
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
             $admin->retrieveSettings('system');
1385 1385
 
1386 1386
             $user_merge = $current_user->getPreference('mailmerge_on');
1387
-            if($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) {
1387
+            if ($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) {
1388 1388
                 echo "<script>
1389 1389
                 function mailmerge_dialog(el) {
1390 1390
                    	var \$dialog = \$('<div></div>')
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
                         . "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' href=\'index.php?action=index&module=MailMerge&entire=true\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>')
1394 1394
 					.dialog({
1395 1395
 						autoOpen: false,
1396
-						title: '". $this->local_app_strings['LBL_MAILMERGE']."',
1396
+						title: '".$this->local_app_strings['LBL_MAILMERGE']."',
1397 1397
 						width: 150,
1398 1398
 						position: {
1399 1399
 						    my: myPos,
@@ -1409,16 +1409,16 @@  discard block
 block discarded – undo
1409 1409
                 $merge_link = "&nbsp;";
1410 1410
             }
1411 1411
 
1412
-            $selected_objects_span = "&nbsp;|&nbsp;{$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input  style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='" . ((isset($_POST['mass'])) ? count($_POST['mass']): 0) . "' />";
1412
+            $selected_objects_span = "&nbsp;|&nbsp;{$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input  style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='".((isset($_POST['mass'])) ? count($_POST['mass']) : 0)."' />";
1413 1413
 
1414
-            if($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import'
1414
+            if ($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import'
1415 1415
                 || $this->show_export_button == false
1416 1416
                 || (!empty($sugar_config['disable_export']))
1417 1417
                 || (!empty($sugar_config['admin_export_only'])
1418 1418
                 && !(
1419 1419
                         is_admin($current_user)
1420 1420
                         || (ACLController::moduleSupportsACL($_REQUEST['module'])
1421
-                            && ACLAction::getUserAccessLevel($current_user->id,$_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED
1421
+                            && ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED
1422 1422
                             && (ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN ||
1423 1423
                                 ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN_DEV)))))
1424 1424
             {
@@ -1427,13 +1427,13 @@  discard block
 block discarded – undo
1427 1427
                 }
1428 1428
                 $export_link = "&nbsp;";
1429 1429
                 $merge_link = "&nbsp;";
1430
-            } elseif($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") {
1430
+            } elseif ($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") {
1431 1431
                 $merge_link = "&nbsp;";
1432 1432
             }
1433 1433
 
1434
-            if($this->show_paging == true) {
1435
-                if(!empty($sugar_config['disable_count_query'])) {
1436
-                    if($row_count > $end_record) {
1434
+            if ($this->show_paging == true) {
1435
+                if (!empty($sugar_config['disable_count_query'])) {
1436
+                    if ($row_count > $end_record) {
1437 1437
                         $row_count .= '+';
1438 1438
                     }
1439 1439
                 }
@@ -1449,16 +1449,16 @@  discard block
 block discarded – undo
1449 1449
                     $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"  >";
1450 1450
 
1451 1451
                     //attempt to get the query to recreate this subpanel
1452
-                    if(!empty($this->response)){
1453
-                        $response =& $this->response;
1454
-                    }else{
1455
-                        $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def);
1452
+                    if (!empty($this->response)) {
1453
+                        $response = & $this->response;
1454
+                    } else {
1455
+                        $response = SugarBean::get_union_related_list($sugarbean, $this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page, $this->query_limit, $subpanel_def);
1456 1456
                         $this->response = $response;
1457 1457
                     }
1458 1458
                     //if query is present, then pass it in as parameter
1459
-                    if (isset($response['query']) && !empty($response['query'])){
1459
+                    if (isset($response['query']) && !empty($response['query'])) {
1460 1460
                         $html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']);
1461
-                    }else{
1461
+                    } else {
1462 1462
                         $html_text .= $subpanelTiles->get_buttons($subpanel_def);
1463 1463
                     }
1464 1464
                 }
@@ -1468,11 +1468,11 @@  discard block
 block discarded – undo
1468 1468
                 $html_text .= "</td>\n<td nowrap align=\"right\">".$start_link."&nbsp;&nbsp;".$previous_link."&nbsp;&nbsp;<span class='pageNumbers'>(".$start_record." - ".$end_record." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.")</span>&nbsp;&nbsp;".$next_link."&nbsp;&nbsp;".$end_link."</td></tr></table>\n";
1469 1469
                 $html_text .= "</td>\n";
1470 1470
                 $html_text .= "</tr>\n";
1471
-                $this->xTemplate->assign("PAGINATION",$html_text);
1471
+                $this->xTemplate->assign("PAGINATION", $html_text);
1472 1472
             }
1473 1473
 
1474 1474
             //C.L. - Fix for 23461
1475
-            if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1475
+            if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1476 1476
                 $_SESSION['export_where'] = $this->query_where;
1477 1477
             }
1478 1478
             $this->xTemplate->parse($xtemplateSection.".list_nav_row");
@@ -1481,24 +1481,24 @@  discard block
 block discarded – undo
1481 1481
 
1482 1482
     function processOrderBy($html_varName) {
1483 1483
 
1484
-        if(!isset($this->base_URL)) {
1484
+        if (!isset($this->base_URL)) {
1485 1485
             $this->base_URL = $_SERVER['PHP_SELF'];
1486 1486
 
1487
-            if(isset($_SERVER['QUERY_STRING'])) {
1488
-                $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=[0-9a-zA-Z\_\.]*/","",$this->base_URL .'?'.$_SERVER['QUERY_STRING']);
1489
-                $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"offset")."=[0-9]*/","",$this->base_URL);
1487
+            if (isset($_SERVER['QUERY_STRING'])) {
1488
+                $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName, "ORDER_BY")."=[0-9a-zA-Z\_\.]*/", "", $this->base_URL.'?'.$_SERVER['QUERY_STRING']);
1489
+                $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName, "offset")."=[0-9]*/", "", $this->base_URL);
1490 1490
             }
1491
-            if($_SERVER['REQUEST_METHOD'] == 'POST') {
1491
+            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1492 1492
                 $this->base_URL .= '?';
1493
-                if(isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action'];
1494
-                if(isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record'];
1495
-                if(isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module'];
1493
+                if (isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action'];
1494
+                if (isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record'];
1495
+                if (isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module'];
1496 1496
             }
1497
-            $this->base_URL .= "&".$this->getSessionVariableName($html_varName,"offset")."=";
1497
+            $this->base_URL .= "&".$this->getSessionVariableName($html_varName, "offset")."=";
1498 1498
         }
1499 1499
 
1500
-        if($this->is_dynamic) {
1501
-            $this->base_URL.='&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->source_module;
1500
+        if ($this->is_dynamic) {
1501
+            $this->base_URL .= '&to_pdf=true&action=SubPanelViewer&subpanel='.$this->source_module;
1502 1502
         }
1503 1503
 
1504 1504
         //bug43465 start
@@ -1506,19 +1506,19 @@  discard block
 block discarded – undo
1506 1506
         {
1507 1507
             foreach ($this->appendToBaseUrl as $key => $value)
1508 1508
             {
1509
-                $fullRequestString = $key . '=' . $value;
1509
+                $fullRequestString = $key.'='.$value;
1510 1510
 
1511 1511
                 if ($this->base_URL == "/index.php")
1512 1512
                 {
1513 1513
                     $this->base_URL .= "?";
1514 1514
                 } else
1515 1515
                 {
1516
-                    if ($fullRequestString == substr($this->baseURL, '-' . strlen($fullRequestString)))
1516
+                    if ($fullRequestString == substr($this->baseURL, '-'.strlen($fullRequestString)))
1517 1517
                     {
1518
-                        $this->base_URL = preg_replace("/&" . $key . "\=.*/", "", $this->base_URL);
1518
+                        $this->base_URL = preg_replace("/&".$key."\=.*/", "", $this->base_URL);
1519 1519
                     } else
1520 1520
                     {
1521
-                        $this->base_URL = preg_replace("/&" . $key . "\=.*?&/", "&", $this->base_URL);
1521
+                        $this->base_URL = preg_replace("/&".$key."\=.*?&/", "&", $this->base_URL);
1522 1522
                     }
1523 1523
                     $this->base_URL .= "&";
1524 1524
                 }
@@ -1530,9 +1530,9 @@  discard block
 block discarded – undo
1530 1530
         }
1531 1531
         //bug43465 end
1532 1532
 
1533
-        $sort_URL_base = $this->base_URL. "&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=";
1533
+        $sort_URL_base = $this->base_URL."&".$this->getSessionVariableName($html_varName, "ORDER_BY")."=";
1534 1534
 
1535
-        if($sort_URL_base !== "")
1535
+        if ($sort_URL_base !== "")
1536 1536
         {
1537 1537
             $this->xTemplate->assign("ORDER_BY", $sort_URL_base);
1538 1538
             return $sort_URL_base;
@@ -1583,19 +1583,19 @@  discard block
 block discarded – undo
1583 1583
         $mergeList = array();
1584 1584
         $module = '';
1585 1585
         //todo what is this?  It is using an array as a boolean
1586
-        while(list($aVal, $aItem) = each($data))
1586
+        while (list($aVal, $aItem) = each($data))
1587 1587
         {
1588
-            if(isset($this->data_array)) {
1588
+            if (isset($this->data_array)) {
1589 1589
                 $fields = $this->data_array;
1590 1590
             } else {
1591 1591
                 $aItem->check_date_relationships_load();
1592 1592
                 $fields = $aItem->get_list_view_data();
1593 1593
             }
1594 1594
 
1595
-            if(is_object($aItem)) { // cn: bug 5349
1595
+            if (is_object($aItem)) { // cn: bug 5349
1596 1596
                 //add item id to merge list, if the button is clicked
1597 1597
                 $mergeList[] = $aItem->id;
1598
-                if(empty($module)) {
1598
+                if (empty($module)) {
1599 1599
                     $module = $aItem->module_dir;
1600 1600
                 }
1601 1601
             }
@@ -1604,37 +1604,37 @@  discard block
 block discarded – undo
1604 1604
                 $fields['OFFSET'] = ($offset + $count + 1);
1605 1605
 
1606 1606
             $fields['STAMP'] = $timeStamp;
1607
-            if($this->shouldProcess) {
1607
+            if ($this->shouldProcess) {
1608 1608
 
1609 1609
             $prerow = '';
1610
-            if(!isset($this->data_array)) {
1611
-                $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "'>";
1610
+            if (!isset($this->data_array)) {
1611
+                $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='".$fields['ID']."'>";
1612 1612
             }
1613 1613
             $this->xTemplate->assign('PREROW', $prerow);
1614 1614
 
1615 1615
             $this->xTemplate->assign('CHECKALL', "<input type='checkbox' class='checkbox'  title='".$GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE']."'  name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked)'>");
1616 1616
             }
1617
-            if(!isset($this->data_array)) {
1617
+            if (!isset($this->data_array)) {
1618 1618
                 $tag = $aItem->listviewACLHelper();
1619
-                $this->xTemplate->assign('TAG',$tag) ;
1619
+                $this->xTemplate->assign('TAG', $tag);
1620 1620
             }
1621 1621
 
1622
-            if($oddRow)
1622
+            if ($oddRow)
1623 1623
             {
1624 1624
                 $ROW_COLOR = 'oddListRow';
1625
-                $BG_COLOR =  $odd_bg;
1625
+                $BG_COLOR = $odd_bg;
1626 1626
             }
1627 1627
             else
1628 1628
             {
1629 1629
                 $ROW_COLOR = 'evenListRow';
1630
-                $BG_COLOR =  $even_bg;
1630
+                $BG_COLOR = $even_bg;
1631 1631
             }
1632 1632
             $oddRow = !$oddRow;
1633 1633
 
1634 1634
             $this->xTemplate->assign('ROW_COLOR', $ROW_COLOR);
1635 1635
             $this->xTemplate->assign('BG_COLOR', $BG_COLOR);
1636 1636
 
1637
-            if(isset($this->data_array))
1637
+            if (isset($this->data_array))
1638 1638
             {
1639 1639
                 $this->xTemplate->assign('KEY', $aVal);
1640 1640
                 $this->xTemplate->assign('VALUE', $aItem);
@@ -1645,23 +1645,23 @@  discard block
 block discarded – undo
1645 1645
             {
1646 1646
     //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
1647 1647
     // Bug #2786
1648
-                if($this->_additionalDetails && $aItem->ACLAccess('DetailView') && (file_exists('modules/' . $aItem->module_dir . '/metadata/additionalDetails.php') || file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php'))) {
1648
+                if ($this->_additionalDetails && $aItem->ACLAccess('DetailView') && (file_exists('modules/'.$aItem->module_dir.'/metadata/additionalDetails.php') || file_exists('custom/modules/'.$aItem->module_dir.'/metadata/additionalDetails.php'))) {
1649 1649
 
1650
-                    $additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
1651
-                    if(file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')){
1652
-                        $additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
1650
+                    $additionalDetailsFile = 'modules/'.$aItem->module_dir.'/metadata/additionalDetails.php';
1651
+                    if (file_exists('custom/modules/'.$aItem->module_dir.'/metadata/additionalDetails.php')) {
1652
+                        $additionalDetailsFile = 'custom/modules/'.$aItem->module_dir.'/metadata/additionalDetails.php';
1653 1653
                     }
1654 1654
 
1655 1655
                     require_once($additionalDetailsFile);
1656
-                    $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name;
1656
+                    $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction).$aItem->object_name;
1657 1657
                     $results = $ad_function($fields);
1658 1658
                     $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
1659 1659
 
1660
-                    if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
1660
+                    if (trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
1661 1661
                     $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']].'</a>';
1662 1662
                 }
1663 1663
 
1664
-                if($aItem->ACLAccess('Delete')) {
1664
+                if ($aItem->ACLAccess('Delete')) {
1665 1665
                     $delete = '<a class="listViewTdToolsS1" onclick="return confirm(\''.$this->local_app_strings['NTC_DELETE_CONFIRMATION'].'\')" href="'.'index.php?action=Delete&module='.$aItem->module_dir.'&record='.$fields['ID'].'&return_module='.$aItem->module_dir.'&return_action=index&return_id=">'.$this->local_app_strings['LBL_DELETE_INLINE'].'</a>';
1666 1666
                     require_once('include/Smarty/plugins/function.sugar_action_menu.php');
1667 1667
                     $fields['DELETE_BUTTON'] = smarty_function_sugar_action_menu(array(
@@ -1675,26 +1675,26 @@  discard block
 block discarded – undo
1675 1675
                 $aItem->setupCustomFields($aItem->module_dir);
1676 1676
                 $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
1677 1677
             }
1678
-            if(!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
1678
+            if (!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
1679 1679
                 $count++;
1680 1680
             }
1681
-            if(isset($this->data_array)) {
1681
+            if (isset($this->data_array)) {
1682 1682
                 $count++;
1683 1683
             }
1684
-            if(!isset($this->data_array)) {
1684
+            if (!isset($this->data_array)) {
1685 1685
                 $aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection);
1686 1686
 
1687
-                if($this->xTemplate->exists($xtemplateSection.'.row.pro')) {
1687
+                if ($this->xTemplate->exists($xtemplateSection.'.row.pro')) {
1688 1688
                     $this->xTemplate->parse($xtemplateSection.'.row.pro');
1689 1689
                 }
1690 1690
             }
1691
-            $this->xTemplate->parse($xtemplateSection . '.row');
1691
+            $this->xTemplate->parse($xtemplateSection.'.row');
1692 1692
 
1693
-            if(isset($fields['ID'])) {
1693
+            if (isset($fields['ID'])) {
1694 1694
                 $associated_row_data[$fields['ID']] = $fields;
1695 1695
                 // Bug 38908: cleanup data for JS to avoid having &nbsp; shuffled around
1696
-                foreach($fields as $key => $value) {
1697
-                    if($value == '&nbsp;') {
1696
+                foreach ($fields as $key => $value) {
1697
+                    if ($value == '&nbsp;') {
1698 1698
                         $associated_row_data[$fields['ID']][$key] = '';
1699 1699
                     }
1700 1700
                 }
@@ -1703,21 +1703,21 @@  discard block
 block discarded – undo
1703 1703
 
1704 1704
         $_SESSION['MAILMERGE_RECORDS'] = $mergeList;
1705 1705
         $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module;
1706
-        if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1706
+        if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1707 1707
             $_SESSION['MAILMERGE_MODULE'] = $module;
1708 1708
         }
1709 1709
 
1710
-        if($this->process_for_popups)
1710
+        if ($this->process_for_popups)
1711 1711
         {
1712 1712
             $json = getJSONobj();
1713 1713
             $is_show_fullname = showFullName() ? 1 : 0;
1714
-            $associated_javascript_data = '<script type="text/javascript">' . "\n"
1714
+            $associated_javascript_data = '<script type="text/javascript">'."\n"
1715 1715
                 //. '<!-- // associated javascript data generated by ListView' . "\n"
1716 1716
                 . 'var associated_javascript_data = '
1717
-                . $json->encode($associated_row_data) . ";\n"
1717
+                . $json->encode($associated_row_data).";\n"
1718 1718
                 //. '-->' . "\n"
1719 1719
                 . 'var is_show_fullname = '
1720
-                . $is_show_fullname . ";\n"
1720
+                . $is_show_fullname.";\n"
1721 1721
                 . '</script>';
1722 1722
             $this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data);
1723 1723
         }
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
     function getLayoutManager()
1730 1730
     {
1731 1731
         require_once('include/generic/LayoutManager.php');
1732
-        if($this->layout_manager == null)
1732
+        if ($this->layout_manager == null)
1733 1733
         {
1734 1734
             $this->layout_manager = new LayoutManager();
1735 1735
         }
@@ -1742,36 +1742,36 @@  discard block
 block discarded – undo
1742 1742
 
1743 1743
 
1744 1744
         $layout_manager = $this->getLayoutManager();
1745
-        $layout_manager->setAttribute('order_by_link',$this->processOrderBy($html_var));
1746
-        $layout_manager->setAttribute('context','HeaderCell');
1747
-        $layout_manager->setAttribute('image_path',$this->local_image_path);
1748
-        $layout_manager->setAttribute('html_varName',$html_var);
1745
+        $layout_manager->setAttribute('order_by_link', $this->processOrderBy($html_var));
1746
+        $layout_manager->setAttribute('context', 'HeaderCell');
1747
+        $layout_manager->setAttribute('image_path', $this->local_image_path);
1748
+        $layout_manager->setAttribute('html_varName', $html_var);
1749 1749
         $layout_manager->setAttribute('module_name', $source_module);
1750
-        list($orderBy,$desc) = $this->getOrderByInfo($html_var);
1750
+        list($orderBy, $desc) = $this->getOrderByInfo($html_var);
1751 1751
 
1752
-        if($orderBy == 'amount*1')
1752
+        if ($orderBy == 'amount*1')
1753 1753
         {
1754
-            $orderBy=  'amount';
1754
+            $orderBy = 'amount';
1755 1755
         }
1756 1756
 		$buttons = false;
1757 1757
         $col_count = 0;
1758
-        foreach($subpanel_def->get_list_fields() as $column_name=>$widget_args)
1758
+        foreach ($subpanel_def->get_list_fields() as $column_name=>$widget_args)
1759 1759
         {
1760 1760
             $usage = empty($widget_args['usage']) ? '' : $widget_args['usage'];
1761
-            if($usage != 'query_only' || !empty($widget_args['force_query_only_display']))
1761
+            if ($usage != 'query_only' || !empty($widget_args['force_query_only_display']))
1762 1762
             {
1763 1763
                 $imgArrow = '';
1764 1764
 
1765
-                if($orderBy == $column_name || (isset($widget_args['sort_by']) && str_replace('.','_',$widget_args['sort_by']) == $orderBy))
1765
+                if ($orderBy == $column_name || (isset($widget_args['sort_by']) && str_replace('.', '_', $widget_args['sort_by']) == $orderBy))
1766 1766
                 {
1767 1767
                     $imgArrow = "_down";
1768
-                    if($this->sort_order == 'asc') {
1768
+                    if ($this->sort_order == 'asc') {
1769 1769
                         $imgArrow = "_up";
1770 1770
                     }
1771 1771
                 }
1772 1772
 
1773 1773
                 if (!preg_match("/_button/i", $column_name)) {
1774
-	                $widget_args['name']=$column_name;
1774
+	                $widget_args['name'] = $column_name;
1775 1775
 	                $widget_args['sort'] = $imgArrow;
1776 1776
 	                $widget_args['start_link_wrapper'] = $this->start_link_wrapper;
1777 1777
 	                $widget_args['end_link_wrapper'] = $this->end_link_wrapper;
@@ -1781,8 +1781,8 @@  discard block
 block discarded – undo
1781 1781
 	                $cell_width = empty($widget_args['width']) ? '' : $widget_args['width'];
1782 1782
 	                $this->xTemplate->assign('HEADER_CELL', $widget_contents);
1783 1783
 	                static $count;
1784
-	            if(!isset($count))$count = 0; else $count++;
1785
-                    if($col_count == 0 || $column_name == 'name') $footable = 'data-toggle="true"';
1784
+	            if (!isset($count))$count = 0; else $count++;
1785
+                    if ($col_count == 0 || $column_name == 'name') $footable = 'data-toggle="true"';
1786 1786
                     else {
1787 1787
                         $footable = 'data-hide="phone"';
1788 1788
                         if ($col_count > 2) $footable = 'data-hide="phone,phonelandscape"';
@@ -1799,7 +1799,7 @@  discard block
 block discarded – undo
1799 1799
             ++$col_count;
1800 1800
         }
1801 1801
 
1802
-        if($buttons) {
1802
+        if ($buttons) {
1803 1803
                     $this->xTemplate->assign('FOOTABLE', '');
1804 1804
         			$this->xTemplate->assign('HEADER_CELL', "&nbsp;");
1805 1805
         			$this->xTemplate->assign('CELL_COUNT', $count);
@@ -1827,37 +1827,37 @@  discard block
 block discarded – undo
1827 1827
 
1828 1828
     function processListViewTwo($seed, $xTemplateSection, $html_varName) {
1829 1829
         global $current_user;
1830
-        if(!isset($this->xTemplate)) {
1830
+        if (!isset($this->xTemplate)) {
1831 1831
             $this->createXTemplate();
1832 1832
         }
1833 1833
 
1834 1834
         $isSugarBean = is_subclass_of($seed, "SugarBean");
1835 1835
         $list = null;
1836 1836
 
1837
-        if($isSugarBean) {
1837
+        if ($isSugarBean) {
1838 1838
             $list = $this->processSugarBean($xTemplateSection, $html_varName, $seed);
1839 1839
         } else {
1840 1840
             $list = $seed;
1841 1841
         }
1842 1842
 
1843 1843
         if (is_object($seed) && isset($seed->object_name) && $seed->object_name == 'WorkFlow') {
1844
-            $tab=array();
1844
+            $tab = array();
1845 1845
             $access = get_workflow_admin_modules_for_user($current_user);
1846 1846
             for ($i = 0; $i < count($list); $i++) {
1847
-                if(!empty($access[$list[$i]->base_module])){
1848
-                    $tab[]=$list[$i];
1847
+                if (!empty($access[$list[$i]->base_module])) {
1848
+                    $tab[] = $list[$i];
1849 1849
                 }
1850 1850
             }
1851 1851
             $list = $tab;
1852 1852
         }
1853 1853
 
1854
-        if($this->is_dynamic) {
1855
-            $this->processHeaderDynamic($xTemplateSection,$html_varName);
1856
-            $this->processListRows($list,$xTemplateSection, $html_varName);
1854
+        if ($this->is_dynamic) {
1855
+            $this->processHeaderDynamic($xTemplateSection, $html_varName);
1856
+            $this->processListRows($list, $xTemplateSection, $html_varName);
1857 1857
         } else {
1858 1858
             $this->processSortArrows($html_varName);
1859 1859
 
1860
-            if($isSugarBean) {
1860
+            if ($isSugarBean) {
1861 1861
                 $seed->parse_additional_headers($this->xTemplate, $xTemplateSection);
1862 1862
             }
1863 1863
             $this->xTemplateAssign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", ''));
@@ -1866,19 +1866,19 @@  discard block
 block discarded – undo
1866 1866
             $this->processOrderBy($html_varName);
1867 1867
 
1868 1868
 
1869
-            $this->processListRows($list,$xTemplateSection, $html_varName);
1869
+            $this->processListRows($list, $xTemplateSection, $html_varName);
1870 1870
         }
1871 1871
 
1872
-        if($this->display_header_and_footer) {
1872
+        if ($this->display_header_and_footer) {
1873 1873
             $this->getAdditionalHeader();
1874
-            if(!empty($this->header_title)) {
1874
+            if (!empty($this->header_title)) {
1875 1875
                 echo get_form_header($this->header_title, $this->header_text, false);
1876 1876
             }
1877 1877
         }
1878 1878
 
1879 1879
         $this->xTemplate->out($xTemplateSection);
1880 1880
 
1881
-        if(isset($_SESSION['validation'])) {
1881
+        if (isset($_SESSION['validation'])) {
1882 1882
             print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg==');
1883 1883
         }
1884 1884
     }
@@ -1890,7 +1890,7 @@  discard block
 block discarded – undo
1890 1890
     }
1891 1891
 
1892 1892
     function getArrowUpDownStart($upDown) {
1893
-        $ext = ( SugarThemeRegistry::current()->pngSupport ? "png" : "gif" );
1893
+        $ext = (SugarThemeRegistry::current()->pngSupport ? "png" : "gif");
1894 1894
 
1895 1895
         if (!isset($upDown) || empty($upDown)) {
1896 1896
             $upDown = "";
@@ -1901,7 +1901,7 @@  discard block
 block discarded – undo
1901 1901
 	function getArrowEnd() {
1902 1902
 		$imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif"));
1903 1903
 
1904
-        list($width,$height) = ListView::getArrowImageSize();
1904
+        list($width, $height) = ListView::getArrowImageSize();
1905 1905
 
1906 1906
 		return '.'.$imgFileParts['extension']."' width='$width' height='$height' align='absmiddle' alt=".translate('LBL_SORT').">";
1907 1907
     }
@@ -1912,13 +1912,13 @@  discard block
 block discarded – undo
1912 1912
         }
1913 1913
         $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif"));
1914 1914
 
1915
-        list($width,$height) = ListView::getArrowUpDownImageSize($upDown);
1915
+        list($width, $height) = ListView::getArrowUpDownImageSize($upDown);
1916 1916
 
1917 1917
         //get the right alt tag for the sort
1918 1918
         $sortStr = translate('LBL_ALT_SORT');
1919
-        if($upDown == '_down'){
1919
+        if ($upDown == '_down') {
1920 1920
             $sortStr = translate('LBL_ALT_SORT_DESC');
1921
-        }elseif($upDown == '_up'){
1921
+        }elseif ($upDown == '_up') {
1922 1922
             $sortStr = translate('LBL_ALT_SORT_ASC');
1923 1923
         }
1924 1924
         return " width='$width' height='$height' align='absmiddle' alt='$sortStr'>";
@@ -1926,13 +1926,13 @@  discard block
 block discarded – undo
1926 1926
 
1927 1927
 	function getArrowImageSize() {
1928 1928
 	    // jbasicChartDashletsExpColust get the non-sort image's size.. the up and down have be the same.
1929
-		$image = SugarThemeRegistry::current()->getImageURL("arrow.gif",false);
1929
+		$image = SugarThemeRegistry::current()->getImageURL("arrow.gif", false);
1930 1930
 
1931 1931
         $cache_key = 'arrow_size.'.$image;
1932 1932
 
1933 1933
         // Check the cache
1934 1934
         $result = sugar_cache_retrieve($cache_key);
1935
-        if(!empty($result))
1935
+        if (!empty($result))
1936 1936
         return $result;
1937 1937
 
1938 1938
         // No cache hit.  Calculate the value and return.
@@ -1943,13 +1943,13 @@  discard block
 block discarded – undo
1943 1943
 
1944 1944
     function getArrowUpDownImageSize($upDown) {
1945 1945
         // just get the non-sort image's size.. the up and down have be the same.
1946
-        $image = SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif",false);
1946
+        $image = SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif", false);
1947 1947
 
1948 1948
         $cache_key = 'arrowupdown_size.'.$image;
1949 1949
 
1950 1950
         // Check the cache
1951 1951
         $result = sugar_cache_retrieve($cache_key);
1952
-        if(!empty($result))
1952
+        if (!empty($result))
1953 1953
         return $result;
1954 1954
 
1955 1955
         // No cache hit.  Calculate the value and return.
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
 		$orderBy = $this->getSessionVariable($html_varName, "OBL");
1964 1964
 		$desc = $this->getSessionVariable($html_varName, $orderBy.'S');
1965 1965
 		$orderBy = str_replace('.', '_', $orderBy);
1966
-		return array($orderBy,$desc);
1966
+		return array($orderBy, $desc);
1967 1967
 	}
1968 1968
 
1969 1969
     function processSortArrows($html_varName)
@@ -1971,20 +1971,20 @@  discard block
 block discarded – undo
1971 1971
 
1972 1972
         $this->xTemplateAssign("arrow_start", $this->getArrowStart());
1973 1973
 
1974
-        list($orderBy,$desc) = $this->getOrderByInfo($html_varName);
1974
+        list($orderBy, $desc) = $this->getOrderByInfo($html_varName);
1975 1975
 
1976 1976
 		$imgArrow = "_up";
1977
-		if($desc) {
1977
+		if ($desc) {
1978 1978
 			$imgArrow = "_down";
1979 1979
 		}
1980 1980
 		/**
1981 1981
 		 * @deprecated only used by legacy opportunites listview, nothing current. Leaving for BC
1982 1982
 		 */
1983
-		if($orderBy == 'amount')
1983
+		if ($orderBy == 'amount')
1984 1984
 		{
1985 1985
 			$this->xTemplateAssign('amount_arrow', $imgArrow);
1986 1986
 		}
1987
-		else if($orderBy == 'amount_usdollar')
1987
+		else if ($orderBy == 'amount_usdollar')
1988 1988
 		{
1989 1989
 			$this->xTemplateAssign('amount_usdollar_arrow', $imgArrow);
1990 1990
 		}
@@ -1997,31 +1997,31 @@  discard block
 block discarded – undo
1997 1997
     }
1998 1998
 
1999 1999
     // this is where translation happens for dynamic list views
2000
-    function loadListFieldDefs(&$subpanel_fields,&$child_focus)
2000
+    function loadListFieldDefs(&$subpanel_fields, &$child_focus)
2001 2001
     {
2002 2002
         $this->list_field_defs = $subpanel_fields;
2003 2003
 
2004
-        for($i=0;$i < count($this->list_field_defs);$i++)
2004
+        for ($i = 0; $i < count($this->list_field_defs); $i++)
2005 2005
         {
2006 2006
             $list_field = $this->list_field_defs[$i];
2007 2007
             $field_def = null;
2008 2008
             $key = '';
2009
-            if(!empty($list_field['vname']))
2009
+            if (!empty($list_field['vname']))
2010 2010
             {
2011 2011
                 $key = $list_field['vname'];
2012
-            } else if(isset($list_field['name']) &&  isset($child_focus->field_defs[$list_field['name']]))
2012
+            } else if (isset($list_field['name']) && isset($child_focus->field_defs[$list_field['name']]))
2013 2013
             {
2014 2014
                     $field_def = $child_focus->field_defs[$list_field['name']];
2015 2015
                     $key = $field_def['vname'];
2016 2016
             }
2017
-            if(!empty($key))
2017
+            if (!empty($key))
2018 2018
             {
2019
-                $list_field['label'] = translate($key,$child_focus->module_dir);
2020
-                $this->list_field_defs[$i]['label'] = preg_replace('/:$/','',$list_field['label']);
2019
+                $list_field['label'] = translate($key, $child_focus->module_dir);
2020
+                $this->list_field_defs[$i]['label'] = preg_replace('/:$/', '', $list_field['label']);
2021 2021
             }
2022 2022
             else
2023 2023
             {
2024
-                $this->list_field_defs[$i]['label'] ='&nbsp;';
2024
+                $this->list_field_defs[$i]['label'] = '&nbsp;';
2025 2025
             }
2026 2026
         }
2027 2027
     }
@@ -2036,7 +2036,7 @@  discard block
 block discarded – undo
2036 2036
      * All Rights Reserved.
2037 2037
      * Contributor(s): ______________________________________.
2038 2038
      */
2039
-     function setLocalSessionVariable($localVarName,$varName, $value) {
2039
+     function setLocalSessionVariable($localVarName, $varName, $value) {
2040 2040
         $_SESSION[$localVarName."_".$varName] = $value;
2041 2041
      }
2042 2042
 
@@ -2046,11 +2046,11 @@  discard block
 block discarded – undo
2046 2046
      * All Rights Reserved.
2047 2047
      * Contributor(s): ______________________________________.
2048 2048
      */
2049
- function getLocalSessionVariable($localVarName,$varName) {
2050
-    if(isset($_SESSION[$localVarName."_".$varName])) {
2049
+ function getLocalSessionVariable($localVarName, $varName) {
2050
+    if (isset($_SESSION[$localVarName."_".$varName])) {
2051 2051
         return $_SESSION[$localVarName."_".$varName];
2052 2052
     }
2053
-    else{
2053
+    else {
2054 2054
         return "";
2055 2055
     }
2056 2056
  }
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
  /* Set to true if you want Additional Details to appear in the listview
2059 2059
   */
2060 2060
  function setAdditionalDetails($value = true, $function = '') {
2061
-    if(!empty($function)) $this->additionalDetailsFunction = $function;
2061
+    if (!empty($function)) $this->additionalDetailsFunction = $function;
2062 2062
     $this->_additionalDetails = $value;
2063 2063
  }
2064 2064
 
Please login to merge, or discard this patch.
include/ListView/ListViewData.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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.
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	function getOrderBy($orderBy = '', $direction = '') {
77 77
 		if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
78
-            if(!empty($_REQUEST[$this->var_order_by])) {
78
+            if (!empty($_REQUEST[$this->var_order_by])) {
79 79
     			$direction = 'ASC';
80 80
     			$orderBy = $_REQUEST[$this->var_order_by];
81
-    			if(!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0) ){
81
+    			if (!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0)) {
82 82
     				$direction = $_REQUEST['lvso'];
83 83
     			}
84 84
             }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         }
88 88
 		else {
89 89
             $userPreferenceOrder = $GLOBALS['current_user']->getPreference('listviewOrder', $this->var_name);
90
-			if(!empty($_SESSION[$this->var_order_by])) {
90
+			if (!empty($_SESSION[$this->var_order_by])) {
91 91
 				$orderBy = $_SESSION[$this->var_order_by]['orderBy'];
92 92
 				$direction = $_SESSION[$this->var_order_by]['direction'];
93 93
             } elseif (!empty($userPreferenceOrder)) {
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 				$direction = 'DESC';
99 99
 			}
100 100
 		}
101
-		if(!empty($direction)) {
102
-    		if(strtolower($direction) == "desc") {
101
+		if (!empty($direction)) {
102
+    		if (strtolower($direction) == "desc") {
103 103
     		    $direction = 'DESC';
104 104
     		} else {
105 105
     		    $direction = 'ASC';
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @param STRING (ASC or DESC) $current_order
115 115
 	 * @return  STRING (ASC or DESC)
116 116
 	 */
117
-	function getReverseSortOrder($current_order){
118
-		return (strcmp(strtolower($current_order), 'asc') == 0)?'DESC':'ASC';
117
+	function getReverseSortOrder($current_order) {
118
+		return (strcmp(strtolower($current_order), 'asc') == 0) ? 'DESC' : 'ASC';
119 119
 	}
120 120
 	/**
121 121
 	 * gets the limit of how many rows to show per page
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
     {
146 146
         global $beanList;
147 147
 
148
-        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount',$this->var_order_by, $this->var_offset, 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
149
-        foreach($beanList as $bean)
148
+        $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', $this->var_order_by, $this->var_offset, 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
149
+        foreach ($beanList as $bean)
150 150
         {
151 151
             $blockVariables[] = 'Home2_'.strtoupper($bean).'_ORDER_BY';
152 152
         }
@@ -164,30 +164,30 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @param unknown_type $baseName
166 166
 	 */
167
-	function setVariableName($baseName, $where, $listviewName = null){
167
+	function setVariableName($baseName, $where, $listviewName = null) {
168 168
         global $timedate;
169
-        $module = (!empty($listviewName)) ? $listviewName: $_REQUEST['module'];
170
-        $this->var_name = $module .'2_'. strtoupper($baseName);
169
+        $module = (!empty($listviewName)) ? $listviewName : $_REQUEST['module'];
170
+        $this->var_name = $module.'2_'.strtoupper($baseName);
171 171
 
172
-		$this->var_order_by = $this->var_name .'_ORDER_BY';
173
-		$this->var_offset = $this->var_name . '_offset';
172
+		$this->var_order_by = $this->var_name.'_ORDER_BY';
173
+		$this->var_offset = $this->var_name.'_offset';
174 174
         $timestamp = sugar_microtime();
175 175
         $this->stamp = $timestamp;
176 176
 
177
-        $_SESSION[$module .'2_QUERY_QUERY'] = $where;
177
+        $_SESSION[$module.'2_QUERY_QUERY'] = $where;
178 178
 
179
-        $_SESSION[strtoupper($baseName) . "_FROM_LIST_VIEW"] = $timestamp;
180
-        $_SESSION[strtoupper($baseName) . "_DETAIL_NAV_HISTORY"] = false;
179
+        $_SESSION[strtoupper($baseName)."_FROM_LIST_VIEW"] = $timestamp;
180
+        $_SESSION[strtoupper($baseName)."_DETAIL_NAV_HISTORY"] = false;
181 181
 	}
182 182
 
183
-	function getTotalCount($main_query){
184
-		if(!empty($this->count_query)){
183
+	function getTotalCount($main_query) {
184
+		if (!empty($this->count_query)) {
185 185
 		    $count_query = $this->count_query;
186
-		}else{
186
+		} else {
187 187
 	        $count_query = $this->seed->create_list_count_query($main_query);
188 188
 	    }
189 189
 		$result = $this->db->query($count_query);
190
-		if($row = $this->db->fetchByAssoc($result)){
190
+		if ($row = $this->db->fetchByAssoc($result)) {
191 191
 			return $row['c'];
192 192
 		}
193 193
 		return 0;
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 	 * @param string:'id' $id_field
230 230
 	 * @return array('data'=> row data, 'pageData' => page data information, 'query' => original query string)
231 231
 	 */
232
-	function getListViewData($seed, $where, $offset=-1, $limit = -1, $filter_fields=array(),$params=array(),$id_field = 'id',$singleSelect=true) {
232
+	function getListViewData($seed, $where, $offset = -1, $limit = -1, $filter_fields = array(), $params = array(), $id_field = 'id', $singleSelect = true) {
233 233
         global $current_user;
234 234
         SugarVCR::erase($seed->module_dir);
235
-        $this->seed =& $seed;
235
+        $this->seed = & $seed;
236 236
         $totalCounted = empty($GLOBALS['sugar_config']['disable_count_query']);
237 237
         $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $seed->module_dir;
238
-        if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup'){
238
+        if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
239 239
             $_SESSION['MAILMERGE_MODULE'] = $seed->module_dir;
240 240
         }
241 241
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		$this->seed->id = '[SELECT_ID_LIST]';
245 245
 
246 246
         // if $params tell us to override all ordering
247
-        if(!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
247
+        if (!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
248 248
             $order = $this->getOrderBy(strtolower($params['orderBy']), (empty($params['sortOrder']) ? '' : $params['sortOrder'])); // retreive from $_REQUEST
249 249
         }
250 250
         else {
@@ -252,17 +252,17 @@  discard block
 block discarded – undo
252 252
         }
253 253
 
254 254
         // still empty? try to use settings passed in $param
255
-        if(empty($order['orderBy']) && !empty($params['orderBy'])) {
255
+        if (empty($order['orderBy']) && !empty($params['orderBy'])) {
256 256
             $order['orderBy'] = $params['orderBy'];
257
-            $order['sortOrder'] =  (empty($params['sortOrder']) ? '' : $params['sortOrder']);
257
+            $order['sortOrder'] = (empty($params['sortOrder']) ? '' : $params['sortOrder']);
258 258
         }
259 259
 
260 260
         //rrs - bug: 21788. Do not use Order by stmts with fields that are not in the query.
261 261
         // Bug 22740 - Tweak this check to strip off the table name off the order by parameter.
262 262
         // Samir Gandhi : Do not remove the report_cache.date_modified condition as the report list view is broken
263 263
         $orderby = $order['orderBy'];
264
-        if (strpos($order['orderBy'],'.') && ($order['orderBy'] != "report_cache.date_modified")) {
265
-            $orderby = substr($order['orderBy'],strpos($order['orderBy'],'.')+1);
264
+        if (strpos($order['orderBy'], '.') && ($order['orderBy'] != "report_cache.date_modified")) {
265
+            $orderby = substr($order['orderBy'], strpos($order['orderBy'], '.') + 1);
266 266
         }
267 267
         if ($orderby != 'date_entered' && !in_array($orderby, array_keys($filter_fields))) {
268 268
         	$order['orderBy'] = '';
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 		if (empty($order['orderBy'])) {
273 273
             $orderBy = '';
274 274
         } else {
275
-            $orderBy = $order['orderBy'] . ' ' . $order['sortOrder'];
275
+            $orderBy = $order['orderBy'].' '.$order['sortOrder'];
276 276
             //wdong, Bug 25476, fix the sorting problem of Oracle.
277 277
             if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code'])
278
-                $orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder'];
278
+                $orderBy = $params['custom_order_by_override']['custom_code'].' '.$order['sortOrder'];
279 279
         }
280 280
 
281 281
         if (empty($params['skipOrderSave'])) { // don't save preferences if told so
@@ -290,34 +290,34 @@  discard block
 block discarded – undo
290 290
 		$ret_array = $seed->create_new_list_query($orderBy, $where, $filter_fields, $params, 0, '', true, $seed, $singleSelect);
291 291
         $ret_array['inner_join'] = '';
292 292
         if (!empty($this->seed->listview_inner_join)) {
293
-            $ret_array['inner_join'] = ' ' . implode(' ', $this->seed->listview_inner_join) . ' ';
293
+            $ret_array['inner_join'] = ' '.implode(' ', $this->seed->listview_inner_join).' ';
294 294
         }
295 295
 
296
-		if(!is_array($params)) $params = array();
297
-        if(!isset($params['custom_select'])) $params['custom_select'] = '';
298
-        if(!isset($params['custom_from'])) $params['custom_from'] = '';
299
-        if(!isset($params['custom_where'])) $params['custom_where'] = '';
300
-        if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
301
-		$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
296
+		if (!is_array($params)) $params = array();
297
+        if (!isset($params['custom_select'])) $params['custom_select'] = '';
298
+        if (!isset($params['custom_from'])) $params['custom_from'] = '';
299
+        if (!isset($params['custom_where'])) $params['custom_where'] = '';
300
+        if (!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
301
+		$main_query = $ret_array['select'].$params['custom_select'].$ret_array['from'].$params['custom_from'].$ret_array['inner_join'].$ret_array['where'].$params['custom_where'].$ret_array['order_by'].$params['custom_order_by'];
302 302
 		//C.L. - Fix for 23461
303
-		if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
303
+		if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
304 304
           	   $_SESSION['export_where'] = $ret_array['where'];
305 305
 		}
306
-   		if($limit < -1) {
306
+   		if ($limit < -1) {
307 307
 			$result = $this->db->query($main_query);
308 308
 		}
309 309
 		else {
310
-			if($limit == -1) {
310
+			if ($limit == -1) {
311 311
 				$limit = $this->getLimit();
312 312
             }
313 313
 			$dyn_offset = $this->getOffset();
314
-			if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
314
+			if ($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
315 315
 
316
-            if(strcmp($offset, 'end') == 0){
316
+            if (strcmp($offset, 'end') == 0) {
317 317
             	$totalCount = $this->getTotalCount($main_query);
318
-            	$offset = (floor(($totalCount -1) / $limit)) * $limit;
318
+            	$offset = (floor(($totalCount - 1) / $limit)) * $limit;
319 319
             }
320
-            if($this->seed->ACLAccess('ListView')) {
320
+            if ($this->seed->ACLAccess('ListView')) {
321 321
                 $result = $this->db->limitQuery($main_query, $offset, $limit + 1);
322 322
             }
323 323
             else {
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
         $idIndex = array();
336 336
         $id_list = '';
337 337
 
338
-   		while(($row = $this->db->fetchByAssoc($result)) != null)
338
+   		while (($row = $this->db->fetchByAssoc($result)) != null)
339 339
         {
340
-   			if($count < $limit)
340
+   			if ($count < $limit)
341 341
             {
342 342
    				$id_list .= ',\''.$row[$id_field].'\'';
343 343
    				$idIndex[$row[$id_field]][] = count($rows);
@@ -351,51 +351,51 @@  discard block
 block discarded – undo
351 351
             $id_list = '('.substr($id_list, 1).')';
352 352
         }
353 353
 
354
-        SugarVCR::store($this->seed->module_dir,  $main_query);
355
-		if($count != 0) {
354
+        SugarVCR::store($this->seed->module_dir, $main_query);
355
+		if ($count != 0) {
356 356
 			//NOW HANDLE SECONDARY QUERIES
357
-			if(!empty($ret_array['secondary_select'])) {
358
-				$secondary_query = $ret_array['secondary_select'] . $ret_array['secondary_from'] . ' WHERE '.$this->seed->table_name.'.id IN ' .$id_list;
359
-                if(isset($ret_array['order_by']))
357
+			if (!empty($ret_array['secondary_select'])) {
358
+				$secondary_query = $ret_array['secondary_select'].$ret_array['secondary_from'].' WHERE '.$this->seed->table_name.'.id IN '.$id_list;
359
+                if (isset($ret_array['order_by']))
360 360
                 {
361
-                    $secondary_query .= ' ' . $ret_array['order_by'];
361
+                    $secondary_query .= ' '.$ret_array['order_by'];
362 362
                 }
363 363
 
364 364
                 $secondary_result = $this->db->query($secondary_query);
365 365
 
366 366
                 $ref_id_count = array();
367
-				while($row = $this->db->fetchByAssoc($secondary_result)) {
367
+				while ($row = $this->db->fetchByAssoc($secondary_result)) {
368 368
 
369 369
                     $ref_id_count[$row['ref_id']][] = true;
370
-					foreach($row as $name=>$value) {
370
+					foreach ($row as $name=>$value) {
371 371
 						//add it to every row with the given id
372
-						foreach($idIndex[$row['ref_id']] as $index){
373
-						    $rows[$index][$name]=$value;
372
+						foreach ($idIndex[$row['ref_id']] as $index) {
373
+						    $rows[$index][$name] = $value;
374 374
 						}
375 375
 					}
376 376
 				}
377 377
 
378 378
                 $rows_keys = array_keys($rows);
379
-                foreach($rows_keys as $key)
379
+                foreach ($rows_keys as $key)
380 380
                 {
381 381
                     $rows[$key]['secondary_select_count'] = count($ref_id_count[$rows[$key]['ref_id']]);
382 382
                 }
383 383
 			}
384 384
 
385 385
             // retrieve parent names
386
-            if(!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
387
-                foreach($idIndex as $id => $rowIndex) {
388
-                    if(!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
386
+            if (!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
387
+                foreach ($idIndex as $id => $rowIndex) {
388
+                    if (!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
389 389
                         $post_retrieve[$rows[$rowIndex[0]]['parent_type']] = array();
390 390
                     }
391
-                    if(!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
391
+                    if (!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id, 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
392 392
                 }
393
-                if(isset($post_retrieve)) {
393
+                if (isset($post_retrieve)) {
394 394
                     $parent_fields = $seed->retrieve_parent_fields($post_retrieve);
395
-                    foreach($parent_fields as $child_id => $parent_data) {
395
+                    foreach ($parent_fields as $child_id => $parent_data) {
396 396
                         //add it to every row with the given id
397
-						foreach($idIndex[$child_id] as $index){
398
-						    $rows[$index]['parent_name']= $parent_data['parent_name'];
397
+						foreach ($idIndex[$child_id] as $index) {
398
+						    $rows[$index]['parent_name'] = $parent_data['parent_name'];
399 399
 						}
400 400
                     }
401 401
                 }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			$pageData = array();
405 405
 
406 406
 			reset($rows);
407
-			while($row = current($rows)){
407
+			while ($row = current($rows)) {
408 408
 
409 409
                 $temp = clone $seed;
410 410
 			    $dataIndex = count($data);
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 				if (empty($this->seed->assigned_user_id) && !empty($temp->assigned_user_id)) {
415 415
 				    $this->seed->assigned_user_id = $temp->assigned_user_id;
416 416
 				}
417
-				if($idIndex[$row[$id_field]][0] == $dataIndex){
417
+				if ($idIndex[$row[$id_field]][0] == $dataIndex) {
418 418
 				    $pageData['tag'][$dataIndex] = $temp->listviewACLHelper();
419
-				}else{
419
+				} else {
420 420
 				    $pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]];
421 421
 				}
422 422
 				$data[$dataIndex] = $temp->get_list_view_data($filter_fields);
@@ -424,21 +424,21 @@  discard block
 block discarded – undo
424 424
                 $editViewAccess = $temp->ACLAccess('EditView');
425 425
                 $pageData['rowAccess'][$dataIndex] = array('view' => $detailViewAccess, 'edit' => $editViewAccess);
426 426
                 $additionalDetailsAllow = $this->additionalDetails && $detailViewAccess && (file_exists(
427
-                         'modules/' . $temp->module_dir . '/metadata/additionalDetails.php'
428
-                     ) || file_exists('custom/modules/' . $temp->module_dir . '/metadata/additionalDetails.php'));
427
+                         'modules/'.$temp->module_dir.'/metadata/additionalDetails.php'
428
+                     ) || file_exists('custom/modules/'.$temp->module_dir.'/metadata/additionalDetails.php'));
429 429
                 $additionalDetailsEdit = $editViewAccess;
430
-                if($additionalDetailsAllow) {
431
-                    if($this->additionalDetailsAjax) {
430
+                if ($additionalDetailsAllow) {
431
+                    if ($this->additionalDetailsAjax) {
432 432
 					   $ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']);
433 433
                     }
434 434
                     else {
435
-                        $additionalDetailsFile = 'modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
436
-                        if(file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php')){
437
-                        	$additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
435
+                        $additionalDetailsFile = 'modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php';
436
+                        if (file_exists('custom/modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php')) {
437
+                        	$additionalDetailsFile = 'custom/modules/'.$this->seed->module_dir.'/metadata/additionalDetails.php';
438 438
                         }
439 439
                         require_once($additionalDetailsFile);
440 440
                         $ar = $this->getAdditionalDetails($data[$dataIndex],
441
-                                    (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $this->seed->object_name,
441
+                                    (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction).$this->seed->object_name,
442 442
                                     $additionalDetailsEdit);
443 443
                     }
444 444
                     $pageData['additionalDetails'][$dataIndex] = $ar['string'];
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
 		$nextOffset = -1;
451 451
 		$prevOffset = -1;
452 452
 		$endOffset = -1;
453
-		if($count > $limit) {
453
+		if ($count > $limit) {
454 454
 			$nextOffset = $offset + $limit;
455 455
 		}
456 456
 
457
-		if($offset > 0) {
457
+		if ($offset > 0) {
458 458
 			$prevOffset = $offset - $limit;
459
-			if($prevOffset < 0)$prevOffset = 0;
459
+			if ($prevOffset < 0)$prevOffset = 0;
460 460
 		}
461 461
 		$totalCount = $count + $offset;
462 462
 
463
-		if( $count >= $limit && $totalCounted){
464
-			$totalCount  = $this->getTotalCount($main_query);
463
+		if ($count >= $limit && $totalCounted) {
464
+			$totalCount = $this->getTotalCount($main_query);
465 465
 		}
466 466
 		SugarVCR::recordIDs($this->seed->module_dir, array_keys($idIndex), $offset, $totalCount);
467 467
         $module_names = array(
@@ -471,21 +471,21 @@  discard block
 block discarded – undo
471 471
 		$pageData['ordering'] = $order;
472 472
 		$pageData['ordering']['sortOrder'] = $this->getReverseSortOrder($pageData['ordering']['sortOrder']);
473 473
         //get url parameters as an array
474
-        $pageData['queries'] = $this->generateQueries($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset,  $endOffset, $totalCounted);
474
+        $pageData['queries'] = $this->generateQueries($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset, $endOffset, $totalCounted);
475 475
         //join url parameters from array to a string
476 476
         $pageData['urls'] = $this->generateURLS($pageData['queries']);
477
-		$pageData['offsets'] = array( 'current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
477
+		$pageData['offsets'] = array('current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
478 478
 		$pageData['bean'] = array('objectName' => $seed->object_name, 'moduleDir' => $seed->module_dir, 'moduleName' => strtr($seed->module_dir, $module_names));
479 479
         $pageData['stamp'] = $this->stamp;
480 480
         $pageData['access'] = array('view' => $this->seed->ACLAccess('DetailView'), 'edit' => $this->seed->ACLAccess('EditView'));
481 481
 		$pageData['idIndex'] = $idIndex;
482
-        if(!$this->seed->ACLAccess('ListView')) {
482
+        if (!$this->seed->ACLAccess('ListView')) {
483 483
             $pageData['error'] = 'ACL restricted access';
484 484
         }
485 485
 
486 486
         $queryString = '';
487 487
 
488
-        if( isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "advanced_search" ||
488
+        if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "advanced_search" ||
489 489
         	isset($_REQUEST["type_basic"]) && (count($_REQUEST["type_basic"] > 1) || $_REQUEST["type_basic"][0] != "") ||
490 490
         	isset($_REQUEST["module"]) && $_REQUEST["module"] == "MergeRecords")
491 491
         {
@@ -493,19 +493,19 @@  discard block
 block discarded – undo
493 493
         }
494 494
         else if (isset($_REQUEST["searchFormTab"]) && $_REQUEST["searchFormTab"] == "basic_search")
495 495
         {
496
-            if($seed->module_dir == "Reports") $searchMetaData = SearchFormReports::retrieveReportsSearchDefs();
496
+            if ($seed->module_dir == "Reports") $searchMetaData = SearchFormReports::retrieveReportsSearchDefs();
497 497
             else $searchMetaData = SearchForm::retrieveSearchDefs($seed->module_dir);
498 498
 
499 499
             $basicSearchFields = array();
500 500
 
501
-            if( isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']) )
501
+            if (isset($searchMetaData['searchdefs']) && isset($searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search']))
502 502
                 $basicSearchFields = $searchMetaData['searchdefs'][$seed->module_dir]['layout']['basic_search'];
503 503
 
504
-            foreach( $basicSearchFields as $basicSearchField)
504
+            foreach ($basicSearchFields as $basicSearchField)
505 505
             {
506 506
                 $field_name = (is_array($basicSearchField) && isset($basicSearchField['name'])) ? $basicSearchField['name'] : $basicSearchField;
507 507
                 $field_name .= "_basic";
508
-                if( isset($_REQUEST[$field_name])  && ( !is_array($basicSearchField) || !isset($basicSearchField['type']) || $basicSearchField['type'] == 'text' || $basicSearchField['type'] == 'name') )
508
+                if (isset($_REQUEST[$field_name]) && (!is_array($basicSearchField) || !isset($basicSearchField['type']) || $basicSearchField['type'] == 'text' || $basicSearchField['type'] == 'name'))
509 509
                 {
510 510
                     // Ensure the encoding is UTF-8
511 511
                     $queryString = htmlentities($_REQUEST[$field_name], null, 'UTF-8');
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             }
515 515
         }
516 516
 
517
-		return array('data'=>$data , 'pageData'=>$pageData, 'query' => $queryString);
517
+		return array('data'=>$data, 'pageData'=>$pageData, 'query' => $queryString);
518 518
 	}
519 519
 
520 520
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
     {
529 529
         foreach ($queries as $name => $value)
530 530
         {
531
-            $queries[$name] = 'index.php?' . http_build_query($value);
531
+            $queries[$name] = 'index.php?'.http_build_query($value);
532 532
         }
533 533
         $this->base_url = $queries['baseURL'];
534 534
         return $queries;
@@ -554,22 +554,22 @@  discard block
 block discarded – undo
554 554
         $queries['orderBy'] = $queries['baseURL'];
555 555
         $queries['orderBy'][$this->var_order_by] = '';
556 556
 
557
-        if($nextOffset > -1)
557
+        if ($nextOffset > -1)
558 558
         {
559 559
             $queries['nextPage'] = $queries['baseURL'];
560 560
             $queries['nextPage'][$this->var_offset] = $nextOffset;
561 561
         }
562
-        if($offset > 0)
562
+        if ($offset > 0)
563 563
         {
564 564
             $queries['startPage'] = $queries['baseURL'];
565 565
             $queries['startPage'][$this->var_offset] = 0;
566 566
         }
567
-        if($prevOffset > -1)
567
+        if ($prevOffset > -1)
568 568
         {
569 569
             $queries['prevPage'] = $queries['baseURL'];
570 570
             $queries['prevPage'][$this->var_offset] = $prevOffset;
571 571
         }
572
-        if($totalCounted)
572
+        if ($totalCounted)
573 573
         {
574 574
             $queries['endPage'] = $queries['baseURL'];
575 575
             $queries['endPage'][$this->var_offset] = $endOffset;
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 
595 595
         $jscalendarImage = SugarThemeRegistry::current()->getImageURL('info_inline.gif');
596 596
 
597
-        $extra = "<span id='adspan_" . $id . "' "
597
+        $extra = "<span id='adspan_".$id."' "
598 598
                 . "onclick=\"lvg_dtails('$id')\" "
599 599
 				. " style='position: relative;'><!--not_in_theme!--><img vertical-align='middle' class='info' border='0' alt='".$app_strings['LBL_ADDITIONAL_DETAILS']."' src='$jscalendarImage'></span>";
600 600
 
@@ -618,27 +618,27 @@  discard block
 block discarded – undo
618 618
 
619 619
         $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
620 620
 
621
-        if(trim($results['string']) == '')
621
+        if (trim($results['string']) == '')
622 622
         {
623 623
             $results['string'] = $app_strings['LBL_NONE'];
624 624
         }
625 625
          	$close = false;
626 626
             $extra = "<img alt='{$app_strings['LBL_INFOINLINE']}' style='padding: 0px 5px 0px 2px' border='0' onclick=\"SUGAR.util.getStaticAdditionalDetails(this,'";
627 627
 
628
-            $extra .= str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string']) ;
628
+            $extra .= str_replace(array("\rn", "\r", "\n"), array('', '', '<br />'), $results['string']);
629 629
             $extra .= "','<div style=\'float:left\'>{$app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\'float: right\'>";
630 630
 
631
-	        if($editAccess && !empty($results['editLink']))
631
+	        if ($editAccess && !empty($results['editLink']))
632 632
 	        {
633
-	            $extra .=  "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('edit_inline.png')."\'></a>";
633
+	            $extra .= "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('edit_inline.png')."\'></a>";
634 634
 	            $close = true;
635 635
 	        }
636 636
 	        $close = (!empty($results['viewLink'])) ? true : $close;
637 637
 	        $extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=\'0\' src=".SugarThemeRegistry::current()->getImageURL('view_inline.png')."></a>" : '');
638 638
 
639
-            if($close == true) {
639
+            if ($close == true) {
640 640
             	$closeVal = "true";
641
-            	$extra .=  "<a title=\'{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}\' href=\'javascript: SUGAR.util.closeStaticAdditionalDetails();\'><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('close.png')."\'></a>";
641
+            	$extra .= "<a title=\'{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}\' href=\'javascript: SUGAR.util.closeStaticAdditionalDetails();\'><img style=\'margin-left: 2px;\' border=\'0\' src=\'".SugarThemeRegistry::current()->getImageURL('close.png')."\'></a>";
642 642
             } else {
643 643
             	$closeVal = "false";
644 644
             }
Please login to merge, or discard this patch.
include/utils/sugar_file_utils.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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";
Please login to merge, or discard this patch.
include/modules.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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.
@@ -79,18 +79,18 @@  discard block
 block discarded – undo
79 79
 $beanList['Cases']          = 'aCase';
80 80
 $beanList['Bugs']           = 'Bug';
81 81
 $beanList['ProspectLists']      = 'ProspectList';
82
-$beanList['Prospects']  = 'Prospect';
82
+$beanList['Prospects'] = 'Prospect';
83 83
 $beanList['Project']            = 'Project';
84
-$beanList['ProjectTask']            = 'ProjectTask';
84
+$beanList['ProjectTask'] = 'ProjectTask';
85 85
 $beanList['Campaigns']          = 'Campaign';
86
-$beanList['EmailMarketing']  = 'EmailMarketing';
86
+$beanList['EmailMarketing'] = 'EmailMarketing';
87 87
 $beanList['CampaignLog']        = 'CampaignLog';
88 88
 $beanList['CampaignTrackers']   = 'CampaignTracker';
89
-$beanList['Releases']       = 'Release';
89
+$beanList['Releases'] = 'Release';
90 90
 $beanList['Groups'] = 'Group';
91 91
 $beanList['EmailMan'] = 'EmailMan';
92
-$beanList['Schedulers']  = 'Scheduler';
93
-$beanList['SchedulersJobs']  = 'SchedulersJob';
92
+$beanList['Schedulers'] = 'Scheduler';
93
+$beanList['SchedulersJobs'] = 'SchedulersJob';
94 94
 $beanList['Contacts']       = 'Contact';
95 95
 $beanList['Accounts']       = 'Account';
96 96
 $beanList['DynamicFields']  = 'DynamicField';
@@ -106,19 +106,19 @@  discard block
 block discarded – undo
106 106
 $beanList['Currencies']     = 'Currency';
107 107
 $beanList['Trackers']       = 'Tracker';
108 108
 $beanList['Connectors']     = 'Connectors';
109
-$beanList['Import_1']         = 'ImportMap';
109
+$beanList['Import_1'] = 'ImportMap';
110 110
 $beanList['Import_2']       = 'UsersLastImport';
111 111
 $beanList['Versions']       = 'Version';
112 112
 $beanList['Administration'] = 'Administration';
113 113
 $beanList['vCals']          = 'vCal';
114 114
 $beanList['CustomFields']   = 'CustomFields';
115
-$beanList['Alerts']  = 'Alert';
115
+$beanList['Alerts'] = 'Alert';
116 116
 
117 117
 
118 118
 
119 119
 
120
-$beanList['Documents']  = 'Document';
121
-$beanList['DocumentRevisions']  = 'DocumentRevision';
120
+$beanList['Documents'] = 'Document';
121
+$beanList['DocumentRevisions'] = 'DocumentRevision';
122 122
 $beanList['Roles']  = 'Role';
123 123
 
124 124
 $beanList['Audit']  = 'Audit';
@@ -152,24 +152,24 @@  discard block
 block discarded – undo
152 152
 $beanFiles['aCase']         = 'modules/Cases/Case.php';
153 153
 $beanFiles['Bug']           = 'modules/Bugs/Bug.php';
154 154
 $beanFiles['Group'] = 'modules/Groups/Group.php';
155
-$beanFiles['CampaignLog']  = 'modules/CampaignLog/CampaignLog.php';
155
+$beanFiles['CampaignLog'] = 'modules/CampaignLog/CampaignLog.php';
156 156
 $beanFiles['Project']           = 'modules/Project/Project.php';
157
-$beanFiles['ProjectTask']           = 'modules/ProjectTask/ProjectTask.php';
157
+$beanFiles['ProjectTask'] = 'modules/ProjectTask/ProjectTask.php';
158 158
 $beanFiles['Campaign']          = 'modules/Campaigns/Campaign.php';
159 159
 $beanFiles['ProspectList']      = 'modules/ProspectLists/ProspectList.php';
160
-$beanFiles['Prospect']  = 'modules/Prospects/Prospect.php';
160
+$beanFiles['Prospect'] = 'modules/Prospects/Prospect.php';
161 161
 
162
-$beanFiles['EmailMarketing']          = 'modules/EmailMarketing/EmailMarketing.php';
163
-$beanFiles['CampaignTracker']  = 'modules/CampaignTrackers/CampaignTracker.php';
162
+$beanFiles['EmailMarketing'] = 'modules/EmailMarketing/EmailMarketing.php';
163
+$beanFiles['CampaignTracker'] = 'modules/CampaignTrackers/CampaignTracker.php';
164 164
 $beanFiles['Release']           = 'modules/Releases/Release.php';
165 165
 $beanFiles['EmailMan']          = 'modules/EmailMan/EmailMan.php';
166 166
 
167
-$beanFiles['Scheduler']  = 'modules/Schedulers/Scheduler.php';
168
-$beanFiles['SchedulersJob']  = 'modules/SchedulersJobs/SchedulersJob.php';
167
+$beanFiles['Scheduler'] = 'modules/Schedulers/Scheduler.php';
168
+$beanFiles['SchedulersJob'] = 'modules/SchedulersJobs/SchedulersJob.php';
169 169
 $beanFiles['Contact']       = 'modules/Contacts/Contact.php';
170 170
 $beanFiles['Account']       = 'modules/Accounts/Account.php';
171 171
 $beanFiles['Opportunity']   = 'modules/Opportunities/Opportunity.php';
172
-$beanFiles['EmailTemplate']         = 'modules/EmailTemplates/EmailTemplate.php';
172
+$beanFiles['EmailTemplate'] = 'modules/EmailTemplates/EmailTemplate.php';
173 173
 $beanFiles['Note']          = 'modules/Notes/Note.php';
174 174
 $beanFiles['Call']          = 'modules/Calls/Call.php';
175 175
 $beanFiles['Email']         = 'modules/Emails/Email.php';
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
 $beanFiles['Task']          = 'modules/Tasks/Task.php';
178 178
 $beanFiles['User']          = 'modules/Users/User.php';
179 179
 $beanFiles['Employee']      = 'modules/Employees/Employee.php';
180
-$beanFiles['Currency']          = 'modules/Currencies/Currency.php';
181
-$beanFiles['Tracker']          = 'modules/Trackers/Tracker.php';
180
+$beanFiles['Currency'] = 'modules/Currencies/Currency.php';
181
+$beanFiles['Tracker'] = 'modules/Trackers/Tracker.php';
182 182
 $beanFiles['ImportMap']     = 'modules/Import/maps/ImportMap.php';
183
-$beanFiles['UsersLastImport']= 'modules/Import/UsersLastImport.php';
184
-$beanFiles['Administration']= 'modules/Administration/Administration.php';
185
-$beanFiles['UpgradeHistory']= 'modules/Administration/UpgradeHistory.php';
183
+$beanFiles['UsersLastImport'] = 'modules/Import/UsersLastImport.php';
184
+$beanFiles['Administration'] = 'modules/Administration/Administration.php';
185
+$beanFiles['UpgradeHistory'] = 'modules/Administration/UpgradeHistory.php';
186 186
 $beanFiles['vCal']          = 'modules/vCals/vCal.php';
187
-$beanFiles['Alert']          = 'modules/Alerts/Alert.php';
188
-$beanFiles['Version']           = 'modules/Versions/Version.php';
187
+$beanFiles['Alert'] = 'modules/Alerts/Alert.php';
188
+$beanFiles['Version'] = 'modules/Versions/Version.php';
189 189
 
190 190
 
191 191
 
192
-$beanFiles['Role']          = 'modules/Roles/Role.php';
192
+$beanFiles['Role'] = 'modules/Roles/Role.php';
193 193
 
194
-$beanFiles['Document']  = 'modules/Documents/Document.php';
194
+$beanFiles['Document'] = 'modules/Documents/Document.php';
195 195
 $beanFiles['DocumentRevision']  = 'modules/DocumentRevisions/DocumentRevision.php';
196 196
 $beanFiles['FieldsMetaData']    = 'modules/DynamicFields/FieldsMetaData.php';
197 197
 //$beanFiles['Audit']           = 'modules/Audit/Audit.php';
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 
206 206
 $beanFiles['SavedSearch']  = 'modules/SavedSearch/SavedSearch.php';
207
-$beanFiles['UserPreference']  = 'modules/UserPreferences/UserPreference.php';
207
+$beanFiles['UserPreference'] = 'modules/UserPreferences/UserPreference.php';
208 208
 $beanFiles['MergeRecord']  = 'modules/MergeRecords/MergeRecord.php';
209 209
 $beanFiles['EmailAddress'] = 'modules/EmailAddresses/EmailAddress.php';
210 210
 $beanFiles['EmailText'] = 'modules/EmailText/EmailText.php';
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
 //$beanList['Library']= 'Library';
217 217
 //$beanFiles['Library'] = 'modules/Library/Library.php';
218 218
 
219
-$beanFiles['Configurator']          = 'modules/Configurator/Configurator.php';
219
+$beanFiles['Configurator'] = 'modules/Configurator/Configurator.php';
220 220
 
221 221
 // added these lists for security settings for tabs
222 222
 $modInvisList = array('Administration', 'Currencies', 'CustomFields', 'Connectors',
223 223
     'Dropdown', 'Dynamic', 'DynamicFields', 'DynamicLayout', 'EditCustomFields',
224
-    'Help', 'Import',  'MySettings', 'EditCustomFields','FieldsMetaData',
224
+    'Help', 'Import', 'MySettings', 'EditCustomFields', 'FieldsMetaData',
225 225
     'UpgradeWizard', 'Trackers', 'Connectors', 'Employees', 'Calendar',
226
-    'Releases','Sync',
227
-    'Users',  'Versions', 'LabelEditor','Roles','EmailMarketing'
228
-    ,'OptimisticLock', 'TeamMemberships', 'TeamSets', 'TeamSetModule', 'Audit', 'MailMerge', 'MergeRecords', 'EmailAddresses','EmailText',
229
-    'Schedulers','Schedulers_jobs', /*'Queues',*/ 'EmailTemplates',
226
+    'Releases', 'Sync',
227
+    'Users', 'Versions', 'LabelEditor', 'Roles', 'EmailMarketing'
228
+    ,'OptimisticLock', 'TeamMemberships', 'TeamSets', 'TeamSetModule', 'Audit', 'MailMerge', 'MergeRecords', 'EmailAddresses', 'EmailText',
229
+    'Schedulers', 'Schedulers_jobs', /*'Queues',*/ 'EmailTemplates',
230 230
     'CampaignTrackers', 'CampaignLog', 'EmailMan', 'Prospects', 'ProspectLists',
231
-    'Groups','InboundEmail',
231
+    'Groups', 'InboundEmail',
232 232
     'ACLActions', 'ACLRoles',
233 233
     'DocumentRevisions',
234 234
     'ProjectTask',
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
 $modInvisList[] = 'Connectors';
266 266
 
267 267
 $report_include_modules = array();
268
-$report_include_modules['Currencies']='Currency';
268
+$report_include_modules['Currencies'] = 'Currency';
269 269
 //add prospects
270
-$report_include_modules['Prospects']='Prospect';
270
+$report_include_modules['Prospects'] = 'Prospect';
271 271
 $report_include_modules['DocumentRevisions'] = 'DocumentRevision';
272 272
 $report_include_modules['ProductCategories'] = 'ProductCategory';
273 273
 $report_include_modules['ProductTypes'] = 'ProductType';
274 274
 //add Tracker modules
275 275
 
276
-$report_include_modules['Trackers']         = 'Tracker';
276
+$report_include_modules['Trackers'] = 'Tracker';
277 277
 
278 278
 
279 279
 
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 //the bean class name == dictionary entry/object name convention
324 324
 //No future module should need an entry here.
325 325
 $objectList = array();
326
-$objectList['Cases'] =  'Case';
327
-$objectList['Groups'] =  'User';
328
-$objectList['Users'] =  'User';
326
+$objectList['Cases'] = 'Case';
327
+$objectList['Groups'] = 'User';
328
+$objectList['Users'] = 'User';
329 329
 
330 330
 
331 331
 // knowledge base
Please login to merge, or discard this patch.
include/TemplateHandler/TemplateHandler.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
       $this->cacheDir = sugar_cached('');
54 54
     }
55 55
 
56
-    function loadSmarty(){
57
-        if(empty($this->ss)){
56
+    function loadSmarty() {
57
+        if (empty($this->ss)) {
58 58
             $this->ss = new Sugar_Smarty();
59 59
         }
60 60
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     static function clearAll() {
69 69
     	global $beanList;
70
-		foreach($beanList as $module_dir =>$object_name){
70
+		foreach ($beanList as $module_dir =>$object_name) {
71 71
                 TemplateHandler::clearCache($module_dir);
72 72
 		}
73 73
     }
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
      * @param String $module The module directory to clear
81 81
      * @param String $view Optional view value (DetailView, EditView, etc.)
82 82
      */
83
-    static function clearCache($module, $view=''){
84
-        $cacheDir = create_cache_directory('modules/'. $module . '/');
83
+    static function clearCache($module, $view = '') {
84
+        $cacheDir = create_cache_directory('modules/'.$module.'/');
85 85
         $d = dir($cacheDir);
86
-        while($e = $d->read()){
87
-            if(!empty($view) && $e != $view )continue;
88
-            $end =strlen($e) - 4;
89
-            if(is_file($cacheDir . $e) && $end > 1 && substr($e, $end) == '.tpl'){
90
-                unlink($cacheDir . $e);
86
+        while ($e = $d->read()) {
87
+            if (!empty($view) && $e != $view)continue;
88
+            $end = strlen($e) - 4;
89
+            if (is_file($cacheDir.$e) && $end > 1 && substr($e, $end) == '.tpl') {
90
+                unlink($cacheDir.$e);
91 91
             }
92 92
         }
93 93
     }
@@ -105,21 +105,21 @@  discard block
 block discarded – undo
105 105
     function buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs) {
106 106
         $this->loadSmarty();
107 107
 
108
-        $cacheDir = create_cache_directory($this->templateDir. $module . '/');
109
-        $file = $cacheDir . $view . '.tpl';
110
-        $string = '{* Create Date: ' . date('Y-m-d H:i:s') . "*}\n";
108
+        $cacheDir = create_cache_directory($this->templateDir.$module.'/');
109
+        $file = $cacheDir.$view.'.tpl';
110
+        $string = '{* Create Date: '.date('Y-m-d H:i:s')."*}\n";
111 111
         $this->ss->left_delimiter = '{{';
112 112
         $this->ss->right_delimiter = '}}';
113 113
         $this->ss->assign('module', $module);
114 114
         $this->ss->assign('built_in_buttons', array('CANCEL', 'DELETE', 'DUPLICATE', 'EDIT', 'FIND_DUPLICATES', 'SAVE', 'CONNECTOR'));
115 115
         $contents = $this->ss->fetch($tpl);
116 116
         //Insert validation and quicksearch stuff here
117
-        if($view == 'EditView' || strpos($view,'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
117
+        if ($view == 'EditView' || strpos($view, 'QuickCreate') || $ajaxSave || $view == "ConvertLead") {
118 118
 
119 119
             global $dictionary, $beanList, $app_strings, $mod_strings;
120 120
             $mod = $beanList[$module];
121 121
 
122
-            if($mod == 'aCase') {
122
+            if ($mod == 'aCase') {
123 123
                 $mod = 'Case';
124 124
             }
125 125
 
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
             //Retrieve all panel field definitions with displayParams Array field set
129 129
             $panelFields = array();
130 130
 
131
-            foreach($metaDataDefs['panels'] as $panel) {
132
-                    foreach($panel as $row) {
133
-                            foreach($row as $entry) {
134
-                                    if(empty($entry)) {
131
+            foreach ($metaDataDefs['panels'] as $panel) {
132
+                    foreach ($panel as $row) {
133
+                            foreach ($row as $entry) {
134
+                                    if (empty($entry)) {
135 135
                                        continue;
136 136
                                     }
137 137
 
138
-                                    if(is_array($entry) &&
138
+                                    if (is_array($entry) &&
139 139
                                        isset($entry['name']) &&
140 140
                                        isset($entry['displayParams']) &&
141 141
                                        isset($entry['displayParams']['required']) &&
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                                        $panelFields[$entry['name']] = $entry;
144 144
                                     }
145 145
 
146
-                                    if(is_array($entry)) {
146
+                                    if (is_array($entry)) {
147 147
                                       $defs2[$entry['name']] = $entry;
148 148
                                     } else {
149 149
                                       $defs2[$entry] = array('name' => $entry);
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
                     } //foreach
153 153
             } //foreach
154 154
 
155
-            foreach($panelFields as $field=>$value) {
155
+            foreach ($panelFields as $field=>$value) {
156 156
                       $nameList = array();
157
-                      if(!is_array($value['displayParams']['required'])) {
157
+                      if (!is_array($value['displayParams']['required'])) {
158 158
                          $nameList[] = $field;
159 159
                       } else {
160
-                         foreach($value['displayParams']['required'] as $groupedField) {
160
+                         foreach ($value['displayParams']['required'] as $groupedField) {
161 161
                                  $nameList[] = $groupedField;
162 162
                          }
163 163
                       }
164 164
 
165
-                      foreach($nameList as $x) {
166
-                         if(isset($defs[$x]) &&
165
+                      foreach ($nameList as $x) {
166
+                         if (isset($defs[$x]) &&
167 167
                             isset($defs[$x]['type']) &&
168 168
                             !isset($defs[$x]['required'])) {
169 169
                             $defs[$x]['required'] = true;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
             $javascript->setSugarBean($sugarbean);
184 184
             if ($view != "ConvertLead")
185
-                $javascript->addAllFields('', null,true);
185
+                $javascript->addAllFields('', null, true);
186 186
 
187 187
             $validatedFields = array();
188 188
             $javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty('LBL_ASSIGNED_TO'), 'false', '', 'assigned_user_id');
@@ -193,20 +193,20 @@  discard block
 block discarded – undo
193 193
             //3) not have validateDepedency set to false in metadata
194 194
             //4) have id_name in vardef entry
195 195
             //5) not already been added to Array
196
-            foreach($sugarbean->field_name_map as $name=>$def) {
196
+            foreach ($sugarbean->field_name_map as $name=>$def) {
197 197
 
198
-               if($def['type']=='relate' &&
198
+               if ($def['type'] == 'relate' &&
199 199
                   isset($defs2[$name]) &&
200 200
                   (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) &&
201 201
                   isset($def['id_name']) &&
202 202
                   !in_array($name, $validatedFields)) {
203 203
 
204
-                  if(isset($mod_strings[$def['vname']])
204
+                  if (isset($mod_strings[$def['vname']])
205 205
                         || isset($app_strings[$def['vname']])
206
-                        || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) {
206
+                        || translate($def['vname'], $sugarbean->module_dir) != $def['vname']) {
207 207
                      $vname = $def['vname'];
208 208
                   }
209
-                  else{
209
+                  else {
210 210
                      $vname = "undefined";
211 211
                   }
212 212
                   $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']);
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
             $contents .= $javascript->getScript();
219 219
             $contents .= $this->createQuickSearchCode($defs, $defs2, $view, $module);
220 220
             $contents .= "{/literal}\n";
221
-        }else if(preg_match('/^SearchForm_.+/', $view)){
221
+        } else if (preg_match('/^SearchForm_.+/', $view)) {
222 222
             global $dictionary, $beanList, $app_strings, $mod_strings;
223 223
             $mod = $beanList[$module];
224 224
 
225
-            if($mod == 'aCase') {
225
+            if ($mod == 'aCase') {
226 226
                 $mod = 'Case';
227 227
             }
228 228
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         //Remove all the copyright comments
236 236
         $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents);
237 237
 
238
-        if($fh = @sugar_fopen($file, 'w')) {
238
+        if ($fh = @sugar_fopen($file, 'w')) {
239 239
             fputs($fh, $contents);
240 240
             fclose($fh);
241 241
         }
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
      * @param module string module name
252 252
      * @param view string view need (eg DetailView, EditView, etc)
253 253
      */
254
-    function checkTemplate($module, $view, $checkFormName = false, $formName='') {
255
-        if(inDeveloperMode() || !empty($_SESSION['developerMode'])){
254
+    function checkTemplate($module, $view, $checkFormName = false, $formName = '') {
255
+        if (inDeveloperMode() || !empty($_SESSION['developerMode'])) {
256 256
             return false;
257 257
         }
258 258
         $view = $checkFormName ? $formName : $view;
259
-        return file_exists($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
259
+        return file_exists($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
260 260
     }
261 261
 
262 262
     /**
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
      */
271 271
     function displayTemplate($module, $view, $tpl, $ajaxSave = false, $metaDataDefs = null) {
272 272
         $this->loadSmarty();
273
-        if(!$this->checkTemplate($module, $view)) {
273
+        if (!$this->checkTemplate($module, $view)) {
274 274
             $this->buildTemplate($module, $view, $tpl, $ajaxSave, $metaDataDefs);
275 275
         }
276
-        $file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl';
277
-        if(file_exists($file)) {
276
+        $file = $this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl';
277
+        if (file_exists($file)) {
278 278
            return $this->ss->fetch($file);
279 279
         } else {
280 280
            global $app_strings;
281
-           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file");
282
-           return $app_strings['ERR_NO_SUCH_FILE'] .": $file";
281
+           $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'].": $file");
282
+           return $app_strings['ERR_NO_SUCH_FILE'].": $file";
283 283
         }
284 284
     }
285 285
 
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
      * @param view string view need (eg DetailView, EditView, etc)
291 291
      */
292 292
     function deleteTemplate($module, $view) {
293
-        if(is_file($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl')) {
293
+        if (is_file($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl')) {
294 294
             // Bug #54634 : RTC 18144 : Cannot add more than 1 user to role but popup is multi-selectable
295
-            if ( !isset($this->ss) )
295
+            if (!isset($this->ss))
296 296
             {
297 297
                 $this->loadSmarty();
298 298
             }
299
-            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
299
+            $cache_file_name = $this->ss->_get_compile_path($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
300 300
             SugarCache::cleanFile($cache_file_name);
301 301
 
302
-            return unlink($this->cacheDir . $this->templateDir . $module . '/' .$view . '.tpl');
302
+            return unlink($this->cacheDir.$this->templateDir.$module.'/'.$view.'.tpl');
303 303
         }
304 304
         return false;
305 305
     }
@@ -316,47 +316,47 @@  discard block
 block discarded – undo
316 316
      * @param strign $module
317 317
      * @return string
318 318
      */
319
-    public function createQuickSearchCode($defs, $defs2, $view = '', $module='')
319
+    public function createQuickSearchCode($defs, $defs2, $view = '', $module = '')
320 320
     {
321 321
         $sqs_objects = array();
322 322
         require_once('include/QuickSearchDefaults.php');
323
-        if(isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
323
+        if (isset($this) && $this instanceof TemplateHandler) //If someone calls createQuickSearchCode as a static method (@see ImportViewStep3) $this becomes anoter object, not TemplateHandler
324 324
         {
325 325
             $qsd = QuickSearchDefaults::getQuickSearchDefaults($this->getQSDLookup());
326
-        }else
326
+        } else
327 327
         {
328 328
             $qsd = QuickSearchDefaults::getQuickSearchDefaults(array());
329 329
         }
330 330
         $qsd->setFormName($view);
331
-        if(preg_match('/^SearchForm_.+/', $view)){
332
-        	if(strpos($view, 'popup_query_form')){
331
+        if (preg_match('/^SearchForm_.+/', $view)) {
332
+        	if (strpos($view, 'popup_query_form')) {
333 333
         		$qsd->setFormName('popup_query_form');
334 334
             	$parsedView = 'advanced';
335
-        	}else{
335
+        	} else {
336 336
         		$qsd->setFormName('search_form');
337 337
             	$parsedView = preg_replace("/^SearchForm_/", "", $view);
338 338
         	}
339 339
             //Loop through the Meta-Data fields to see which ones need quick search support
340
-            foreach($defs as $f) {
340
+            foreach ($defs as $f) {
341 341
                 $field = $f;
342
-                $name = $qsd->form_name . '_' . $field['name'];
342
+                $name = $qsd->form_name.'_'.$field['name'];
343 343
 
344
-                if($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si',$name)  || !empty($field['quicksearch']) ) {
345
-                    if(preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
344
+                if ($field['type'] == 'relate' && isset($field['module']) && preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch'])) {
345
+                    if (preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)) {
346 346
 
347
-                        if($matches[0] == 'Campaigns') {
347
+                        if ($matches[0] == 'Campaigns') {
348 348
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
349
-                        } else if($matches[0] == 'Users'){
349
+                        } else if ($matches[0] == 'Users') {
350 350
 
351
-                            if(!empty($f['name']) && !empty($f['id_name'])) {
352
-                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'],$f['id_name']);
351
+                            if (!empty($f['name']) && !empty($f['id_name'])) {
352
+                                $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser($f['name'], $f['id_name']);
353 353
                             }
354 354
                             else {
355 355
                                 $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSUser();
356 356
                             }
357
-                        } else if($matches[0] == 'Campaigns') {
357
+                        } else if ($matches[0] == 'Campaigns') {
358 358
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
359
-                        } else if($matches[0] == 'Accounts') {
359
+                        } else if ($matches[0] == 'Accounts') {
360 360
                             $nameKey = $name;
361 361
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
362 362
 
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
                             $shippingKey = isset($f['displayParams']['shippingKey']) ? $f['displayParams']['shippingKey'] : null;
370 370
                             $additionalFields = isset($f['displayParams']['additionalFields']) ? $f['displayParams']['additionalFields'] : null;
371 371
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
372
-                        } else if($matches[0] == 'Contacts'){
372
+                        } else if ($matches[0] == 'Contacts') {
373 373
                             $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], $field['id_name']);
374 374
                         }
375 375
                     } else {
376 376
                          $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']);
377
-                         if(!isset($field['field_list']) && !isset($field['populate_list'])) {
377
+                         if (!isset($field['field_list']) && !isset($field['populate_list'])) {
378 378
                              $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']);
379 379
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id');
380 380
                          } else {
@@ -382,63 +382,63 @@  discard block
 block discarded – undo
382 382
                              $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list'];
383 383
                          }
384 384
                     }
385
-                } else if($field['type'] == 'parent') {
385
+                } else if ($field['type'] == 'parent') {
386 386
                     $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent();
387 387
                 } //if-else
388 388
             } //foreach
389 389
 
390
-            foreach ( $sqs_objects as $name => $field )
391
-               foreach ( $field['populate_list'] as $key => $fieldname )
392
-                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView;
393
-        }else{
390
+            foreach ($sqs_objects as $name => $field)
391
+               foreach ($field['populate_list'] as $key => $fieldname)
392
+                    $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key].'_'.$parsedView;
393
+        } else {
394 394
             //Loop through the Meta-Data fields to see which ones need quick search support
395
-            foreach($defs2 as $f) {
396
-                if(!isset($defs[$f['name']])) continue;
395
+            foreach ($defs2 as $f) {
396
+                if (!isset($defs[$f['name']])) continue;
397 397
 
398 398
                 $field = $defs[$f['name']];
399 399
                 if ($view == "ConvertLead")
400 400
                 {
401
-                    $field['name'] = $module . $field['name'];
401
+                    $field['name'] = $module.$field['name'];
402 402
                     if (isset($field['module']) && isset($field['id_name']) && substr($field['id_name'], -4) == "_ida") {
403 403
                         $lc_module = strtolower($field['module']);
404 404
                         $ida_suffix = "_".$lc_module.$lc_module."_ida";
405 405
                         if (preg_match('/'.$ida_suffix.'$/', $field['id_name']) > 0) {
406
-                            $field['id_name'] = $module . $field['id_name'];
406
+                            $field['id_name'] = $module.$field['id_name'];
407 407
                         }
408 408
                         else
409
-                            $field['id_name'] = $field['name'] . "_" . $field['id_name'];
409
+                            $field['id_name'] = $field['name']."_".$field['id_name'];
410 410
                     }
411 411
                     else {
412 412
                         if (!empty($field['id_name']))
413 413
                             $field['id_name'] = $module.$field['id_name'];
414 414
                     }
415 415
                 }
416
-				$name = $qsd->form_name . '_' . $field['name'];
416
+				$name = $qsd->form_name.'_'.$field['name'];
417 417
 
418 418
 
419
-                if($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si',$name) || !empty($field['quicksearch']))) {
420
-                    if (!preg_match('/_c$/si',$name)
421
-                        && (!isset($field['id_name']) || !preg_match('/_c$/si',$field['id_name']))
419
+                if ($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si', $name) || !empty($field['quicksearch']))) {
420
+                    if (!preg_match('/_c$/si', $name)
421
+                        && (!isset($field['id_name']) || !preg_match('/_c$/si', $field['id_name']))
422 422
                         && preg_match('/^(Campaigns|Teams|Users|Contacts|Accounts)$/si', $field['module'], $matches)
423 423
                     ) {
424 424
 
425
-                        if($matches[0] == 'Campaigns') {
425
+                        if ($matches[0] == 'Campaigns') {
426 426
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
427
-                        } else if($matches[0] == 'Users'){
428
-                            if($field['name'] == 'reports_to_name'){
429
-                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id');
427
+                        } else if ($matches[0] == 'Users') {
428
+                            if ($field['name'] == 'reports_to_name') {
429
+                                $sqs_objects[$name] = $qsd->getQSUser('reports_to_name', 'reports_to_id');
430 430
                              // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user
431
-                            }elseif($field['name'] == 'assigned_user_name'){
432
-                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id');
431
+                            }elseif ($field['name'] == 'assigned_user_name') {
432
+                                 $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name', 'assigned_user_id');
433 433
                              }
434 434
                              else
435 435
                              {
436 436
                                  $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']);
437 437
 
438 438
 							}
439
-                        } else if($matches[0] == 'Campaigns') {
439
+                        } else if ($matches[0] == 'Campaigns') {
440 440
                             $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']);
441
-                        } else if($matches[0] == 'Accounts') {
441
+                        } else if ($matches[0] == 'Accounts') {
442 442
                             $nameKey = $name;
443 443
                             $idKey = isset($field['id_name']) ? $field['id_name'] : 'account_id';
444 444
 
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
                             $shippingKey = SugarArray::staticGet($f, 'displayParams.shippingKey');
452 452
                             $additionalFields = SugarArray::staticGet($f, 'displayParams.additionalFields');
453 453
                             $sqs_objects[$name] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
454
-                        } else if($matches[0] == 'Contacts'){
454
+                        } else if ($matches[0] == 'Contacts') {
455 455
                             $sqs_objects[$name] = $qsd->getQSContact($field['name'], $field['id_name']);
456
-                            if(preg_match('/_c$/si',$name) || !empty($field['quicksearch'])){
456
+                            if (preg_match('/_c$/si', $name) || !empty($field['quicksearch'])) {
457 457
                                 $sqs_objects[$name]['field_list'] = array('salutation', 'first_name', 'last_name', 'id');
458 458
                             }
459 459
                         }
460 460
                     } else {
461 461
                         $sqs_objects[$name] = $qsd->getQSParent($field['module']);
462
-                        if(!isset($field['field_list']) && !isset($field['populate_list'])) {
462
+                        if (!isset($field['field_list']) && !isset($field['populate_list'])) {
463 463
                             $sqs_objects[$name]['populate_list'] = array($field['name'], $field['id_name']);
464 464
                             // now handle quicksearches where the column to match is not 'name' but rather specified in 'rname'
465 465
                             if (!isset($field['rname']))
@@ -468,14 +468,14 @@  discard block
 block discarded – undo
468 468
                             {
469 469
                                 $sqs_objects[$name]['field_list'] = array($field['rname'], 'id');
470 470
                                 $sqs_objects[$name]['order'] = $field['rname'];
471
-                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'],'op'=>'like_custom','end'=>'%','value'=>''));
471
+                                $sqs_objects[$name]['conditions'] = array(array('name'=>$field['rname'], 'op'=>'like_custom', 'end'=>'%', 'value'=>''));
472 472
                             }
473 473
                         } else {
474 474
                             $sqs_objects[$name]['populate_list'] = $field['field_list'];
475 475
                             $sqs_objects[$name]['field_list'] = $field['populate_list'];
476 476
                         }
477 477
                     }
478
-                } else if($field['type'] == 'parent') {
478
+                } else if ($field['type'] == 'parent') {
479 479
                     $sqs_objects[$name] = $qsd->getQSParent();
480 480
                 } //if-else
481 481
 
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
 
486 486
                 //merge populate_list && field_list with vardef
487 487
                 if (!empty($field['field_list']) && !empty($field['populate_list'])) {
488
-                    for ($j=0; $j<count($field['field_list']); $j++) {
488
+                    for ($j = 0; $j < count($field['field_list']); $j++) {
489 489
                 		//search for the same couple (field_list_item,populate_field_item)
490 490
                			$field_list_item = $field['field_list'][$j];
491
-               			$field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j];
491
+               			$field_list_item_alternate = $qsd->form_name.'_'.$field['field_list'][$j];
492 492
                			$populate_list_item = $field['populate_list'][$j];
493 493
                 		$found = false;
494
-                		for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) {
494
+                		for ($k = 0; $k < count($sqs_objects[$name]['field_list']); $k++) {
495 495
                 			if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus)
496 496
                 				$populate_list_item == $sqs_objects[$name]['field_list'][$k]) {
497 497
                 				$found = true;
@@ -509,14 +509,14 @@  discard block
 block discarded – undo
509 509
         }
510 510
 
511 511
        //Implement QuickSearch for the field
512
-       if(!empty($sqs_objects) && count($sqs_objects) > 0) {
512
+       if (!empty($sqs_objects) && count($sqs_objects) > 0) {
513 513
            $quicksearch_js = '<script language="javascript">';
514
-           $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
514
+           $quicksearch_js .= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
515 515
            $json = getJSONobj();
516
-           foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
516
+           foreach ($sqs_objects as $sqsfield=>$sqsfieldArray) {
517 517
                $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};";
518 518
            }
519
-           return $quicksearch_js . '</script>';
519
+           return $quicksearch_js.'</script>';
520 520
        }
521 521
        return '';
522 522
     }
Please login to merge, or discard this patch.
include/connectors/ConnectorFactory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.