Completed
Push — develop ( 7c1bda...edae1e )
by Adam
18:38 queued 03:14
created
tests/tests/modules/Project/ProjectTest.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,8 +69,7 @@
 block discarded – undo
69 69
     	try {
70 70
     		$project->save_relationship_changes(true);
71 71
     		$this->assertTrue(true);
72
-    	}
73
-    	catch (Exception $e) {
72
+    	} catch (Exception $e) {
74 73
     		$this->fail();
75 74
     	}
76 75
         	
Please login to merge, or discard this patch.
tests/tests/modules/Users/UserTest.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -221,8 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$user->savePreferencesToDB();
223 223
 			$this->assertTrue(true);
224
-		}
225
-		catch (Exception $e) {
224
+		} catch (Exception $e) {
226 225
 			$this->fail();
227 226
 		}
228 227
 		
@@ -1095,8 +1094,7 @@  discard block
 block discarded – undo
1095 1094
     	try {
1096 1095
     		$result = $user->afterImportSave();
1097 1096
     		$this->assertTrue(true);
1098
-    	}
1099
-    	catch (Exception $e) {
1097
+    	} catch (Exception $e) {
1100 1098
     		$this->assertStringStartsWith('Cannot modify header information', $e->getMessage());
1101 1099
     	}
1102 1100
     	
Please login to merge, or discard this patch.
tests/tests/modules/ProspectLists/ProspectListTest.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -179,8 +179,7 @@  discard block
 block discarded – undo
179 179
 		try {
180 180
 			$prospectList->mark_relationships_deleted('');
181 181
 			$this->assertTrue(true);
182
-		}
183
-		catch (Exception $e) {
182
+		} catch (Exception $e) {
184 183
 			$this->fail();
185 184
 		}
186 185
 		 
@@ -196,8 +195,7 @@  discard block
 block discarded – undo
196 195
 		try {
197 196
 			$prospectList->fill_in_additional_list_fields();
198 197
 			$this->assertTrue(true);
199
-		}
200
-		catch (Exception $e) {
198
+		} catch (Exception $e) {
201 199
 			$this->fail();
202 200
 		}
203 201
 		 
@@ -224,8 +222,7 @@  discard block
 block discarded – undo
224 222
 		try {
225 223
 			$prospectList->update_currency_id('','');
226 224
 			$this->assertTrue(true);
227
-		}
228
-		catch (Exception $e) {
225
+		} catch (Exception $e) {
229 226
 			$this->fail();
230 227
 		}
231 228
 		 
Please login to merge, or discard this patch.
tests/tests/modules/Employees/EmployeeTest.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@  discard block
 block discarded – undo
43 43
 		try {
44 44
 			$employee->fill_in_additional_list_fields();
45 45
 			$this->assertTrue(true);
46
-		}
47
-		catch (Exception $e) {
46
+		} catch (Exception $e) {
48 47
 			$this->fail();
49 48
 		}
50 49
 		
@@ -118,8 +117,7 @@  discard block
 block discarded – undo
118 117
 		try {
119 118
 			$employee->list_view_parse_additional_sections(new Sugar_Smarty(), $xTemplateSection);
120 119
 			$this->assertTrue(true);
121
-		}
122
-		catch (Exception $e) {
120
+		} catch (Exception $e) {
123 121
 			$this->fail();
124 122
 		}
125 123
 		
@@ -151,8 +149,7 @@  discard block
 block discarded – undo
151 149
 		try {
152 150
 			$employee->preprocess_fields_on_save();
153 151
 			$this->assertTrue(true);
154
-		}
155
-		catch (Exception $e) {
152
+		} catch (Exception $e) {
156 153
 			$this->fail();
157 154
 		}
158 155
 
Please login to merge, or discard this patch.
tests/tests/modules/Contacts/ContactTest.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -154,8 +154,7 @@  discard block
 block discarded – undo
154 154
 		try {
155 155
 			$contact->load_contacts_users_relationship();
156 156
 			$this->assertTrue(true);
157
-		}
158
-		catch (Exception $e) {
157
+		} catch (Exception $e) {
159 158
 			$this->fail();
160 159
 		}
161 160
 		
@@ -254,8 +253,7 @@  discard block
 block discarded – undo
254 253
 			$contact->save_relationship_changes(true);
255 254
 			$contact->save_relationship_changes(false);
256 255
 			$this->assertTrue(true);
257
-		}
258
-		catch (Exception $e) {
256
+		} catch (Exception $e) {
259 257
 			$this->fail();
260 258
 		}
261 259
 		
@@ -289,8 +287,7 @@  discard block
 block discarded – undo
289 287
     	try {
290 288
    			$contact->process_sync_to_outlook("all");
291 289
     		$this->assertTrue(true);
292
-    	}
293
-    	catch (Exception $e) {
290
+    	} catch (Exception $e) {
294 291
     		$this->fail();
295 292
     	}
296 293
     	 
@@ -299,8 +296,7 @@  discard block
 block discarded – undo
299 296
     	try {
300 297
     		$contact->process_sync_to_outlook("1");
301 298
     		$this->assertTrue(true);
302
-    	}
303
-    	catch (Exception $e) {
299
+    	} catch (Exception $e) {
304 300
     		$this->fail();
305 301
     	}
306 302
     	 	
Please login to merge, or discard this patch.
modules/Reminders/Reminder.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,9 @@  discard block
 block discarded – undo
105 105
     {
106 106
         $savedReminderIds = array();
107 107
         foreach ($remindersData as $reminderData) {
108
-            if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $reminderData->id = '';
108
+            if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) {
109
+                $reminderData->id = '';
110
+            }
109 111
             $reminderBean = BeanFactory::getBean('Reminders', $reminderData->id);
110 112
             $reminderBean->popup = $reminderData->popup;
111 113
             $reminderBean->email = $reminderData->email;
@@ -379,7 +381,9 @@  discard block
 block discarded – undo
379 381
     {
380 382
         $ret = '';
381 383
         for ($i = 0; $i < strlen($timestr); $i++) {
382
-            if ($timestr[$i] != "'") $ret .= $timestr[$i];
384
+            if ($timestr[$i] != "'") {
385
+                $ret .= $timestr[$i];
386
+            }
383 387
         }
384 388
         return $ret;
385 389
     }
Please login to merge, or discard this patch.
Charts/Dashlets/PipelineBySalesStageDashlet/PipelineBySalesStageDashlet.php 1 patch
Braces   +26 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -67,14 +69,17 @@  discard block
 block discarded – undo
67 69
     {
68 70
         global $timedate;
69 71
 
70
-        if(empty($options['pbss_date_start']))
71
-            $options['pbss_date_start'] = $timedate->nowDbDate();
72
+        if(empty($options['pbss_date_start'])) {
73
+                    $options['pbss_date_start'] = $timedate->nowDbDate();
74
+        }
72 75
 
73
-        if(empty($options['pbss_date_end']))
74
-            $options['pbss_date_end'] = $timedate->asDbDate($timedate->getNow()->modify("+6 months"));
76
+        if(empty($options['pbss_date_end'])) {
77
+                    $options['pbss_date_end'] = $timedate->asDbDate($timedate->getNow()->modify("+6 months"));
78
+        }
75 79
 
76
-        if(empty($options['title']))
77
-            $options['title'] = translate('LBL_RGraph_PIPELINE_FORM_TITLE', 'Home');
80
+        if(empty($options['title'])) {
81
+                    $options['title'] = translate('LBL_RGraph_PIPELINE_FORM_TITLE', 'Home');
82
+        }
78 83
 
79 84
         parent::__construct($id,$options);
80 85
     }
@@ -86,11 +91,12 @@  discard block
 block discarded – undo
86 91
     {
87 92
         global $app_list_strings;
88 93
 
89
-        if (!empty($this->pbss_sales_stages) && count($this->pbss_sales_stages) > 0)
90
-            foreach ($this->pbss_sales_stages as $key)
94
+        if (!empty($this->pbss_sales_stages) && count($this->pbss_sales_stages) > 0) {
95
+                    foreach ($this->pbss_sales_stages as $key)
91 96
                 $selected_datax[] = $key;
92
-        else
93
-            $selected_datax = array_keys($app_list_strings['sales_stage_dom']);
97
+        } else {
98
+                    $selected_datax = array_keys($app_list_strings['sales_stage_dom']);
99
+        }
94 100
 
95 101
         $this->_searchFields['pbss_sales_stages']['options'] = $app_list_strings['sales_stage_dom'];
96 102
         $this->_searchFields['pbss_sales_stages']['input_name0'] = $selected_datax;
@@ -265,15 +271,15 @@  discard block
 block discarded – undo
265 271
                 $datax[$key] = $app_list_strings['sales_stage_dom'][$key];
266 272
                 $selected_datax[] = $key;
267 273
             }
268
-        }
269
-        else {
274
+        } else {
270 275
             $datax = $app_list_strings['sales_stage_dom'];
271 276
             $selected_datax = array_keys($app_list_strings['sales_stage_dom']);
272 277
         }
273 278
 
274 279
         $result = $db->query($query);
275
-        while($row = $db->fetchByAssoc($result, false))
276
-            $temp_data[] = $row;
280
+        while($row = $db->fetchByAssoc($result, false)) {
281
+                    $temp_data[] = $row;
282
+        }
277 283
 
278 284
         // reorder and set the array based on the order of selected_datax
279 285
         foreach($selected_datax as $sales_stage){
@@ -348,10 +354,11 @@  discard block
 block discarded – undo
348 354
 
349 355
     protected function resizeLabel($label)
350 356
     {
351
-        if(strlen($label) < $this->maxLabelSizeBeforeTotal)
352
-            return $label;
353
-        else
354
-            return substr($label,0,$this->maxLabelSizeBeforeTotal).$this->labelReplacementString;
357
+        if(strlen($label) < $this->maxLabelSizeBeforeTotal) {
358
+                    return $label;
359
+        } else {
360
+                    return substr($label,0,$this->maxLabelSizeBeforeTotal).$this->labelReplacementString;
361
+        }
355 362
 
356 363
     }
357 364
 
Please login to merge, or discard this patch.
include/database/DBManager.php 1 patch
Braces   +276 added lines, -198 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -403,13 +405,15 @@  discard block
 block discarded – undo
403 405
 	$match = array();
404 406
 	preg_match_all("'.* FROM ([^ ]*).* ORDER BY (.*)'is", $sql, $match);
405 407
 	$indices = false;
406
-	if (!empty($match[1][0]))
407
-		$table = $match[1][0];
408
-	else
409
-		return false;
408
+	if (!empty($match[1][0])) {
409
+			$table = $match[1][0];
410
+	} else {
411
+			return false;
412
+	}
410 413
 
411
-	if (!empty($object_name) && !empty($GLOBALS['dictionary'][$object_name]))
412
-		$indices = $GLOBALS['dictionary'][$object_name]['indices'];
414
+	if (!empty($object_name) && !empty($GLOBALS['dictionary'][$object_name])) {
415
+			$indices = $GLOBALS['dictionary'][$object_name]['indices'];
416
+	}
413 417
 
414 418
 	if (empty($indices)) {
415 419
 		foreach ( $GLOBALS['dictionary'] as $current ) {
@@ -427,25 +431,29 @@  discard block
 block discarded – undo
427 431
 		$orderBys = explode(' ', $match[2][0]);
428 432
 		foreach ($orderBys as $orderBy){
429 433
 			$orderBy = trim($orderBy);
430
-			if (empty($orderBy))
431
-				continue;
434
+			if (empty($orderBy)) {
435
+							continue;
436
+			}
432 437
 			$orderBy = strtolower($orderBy);
433
-			if ($orderBy == 'asc' || $orderBy == 'desc')
434
-				continue;
438
+			if ($orderBy == 'asc' || $orderBy == 'desc') {
439
+							continue;
440
+			}
435 441
 
436 442
 			$orderBy = str_replace(array($table . '.', ','), '', $orderBy);
437 443
 
438
-			foreach ($indices as $index)
439
-				if (empty($index['db']) || $index['db'] == $this->dbType)
444
+			foreach ($indices as $index) {
445
+							if (empty($index['db']) || $index['db'] == $this->dbType)
440 446
 					foreach ($index['fields'] as $field)
441 447
 						if ($field == $orderBy)
442 448
 							return true;
449
+			}
443 450
 
444 451
 			$warning = 'Missing Index For Order By Table: ' . $table . ' Order By:' . $orderBy ;
445
-			if (!empty($GLOBALS['sugar_config']['dump_slow_queries']))
446
-				$this->log->fatal('CHECK QUERY:' .$warning);
447
-			else
448
-				$this->log->warn('CHECK QUERY:' .$warning);
452
+			if (!empty($GLOBALS['sugar_config']['dump_slow_queries'])) {
453
+							$this->log->fatal('CHECK QUERY:' .$warning);
454
+			} else {
455
+							$this->log->warn('CHECK QUERY:' .$warning);
456
+			}
449 457
 		}
450 458
 	}
451 459
 	return false;
@@ -467,8 +475,9 @@  discard block
 block discarded – undo
467 475
 	public function checkConnection()
468 476
 	{
469 477
 		$this->last_error = '';
470
-		if (!isset($this->database))
471
-			$this->connect();
478
+		if (!isset($this->database)) {
479
+					$this->connect();
480
+		}
472 481
 	}
473 482
 
474 483
 	/**
@@ -510,9 +519,13 @@  discard block
 block discarded – undo
510 519
 		$values = array();
511 520
 		foreach ($field_defs as $field => $fieldDef)
512 521
 		{
513
-			if (isset($fieldDef['source']) && $fieldDef['source'] != 'db')  continue;
522
+			if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') {
523
+			    continue;
524
+			}
514 525
 			//custom fields handle there save seperatley
515
-			if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) continue;
526
+			if(!empty($field_map) && !empty($field_map[$field]['custom_type'])) {
527
+			    continue;
528
+			}
516 529
 
517 530
 			if(isset($data[$field])) {
518 531
 				// clean the incoming value..
@@ -541,8 +554,10 @@  discard block
 block discarded – undo
541 554
 			}
542 555
 		}
543 556
 
544
-		if (empty($values))
545
-			return $execute?true:''; // no columns set
557
+		if (empty($values)) {
558
+					return $execute?true:'';
559
+		}
560
+		// no columns set
546 561
 
547 562
 		// get the entire sql
548 563
 		$query = "INSERT INTO $table (".implode(",", array_keys($values)).")
@@ -642,9 +657,10 @@  discard block
 block discarded – undo
642 657
 		if(!$this->supports("inline_keys")) {
643 658
 		// handle constraints and indices
644 659
 			$indicesArr = $this->createConstraintSql($bean);
645
-			if (count($indicesArr) > 0)
646
-				foreach ($indicesArr as $indexSql)
660
+			if (count($indicesArr) > 0) {
661
+							foreach ($indicesArr as $indexSql)
647 662
 					$this->query($indexSql, true, $msg);
663
+			}
648 664
 		}
649 665
 	}
650 666
 
@@ -681,9 +697,10 @@  discard block
 block discarded – undo
681 697
 			if(!$this->supports("inline_keys")) {
682 698
 				// handle constraints and indices
683 699
 				$indicesArr = $this->getConstraintSql($indices, $tablename);
684
-				if (count($indicesArr) > 0)
685
-					foreach ($indicesArr as $indexSql)
700
+				if (count($indicesArr) > 0) {
701
+									foreach ($indicesArr as $indexSql)
686 702
 						$res = ($res and $this->query($indexSql, true, "Error creating indexes"));
703
+				}
687 704
 			}
688 705
 			return $res;
689 706
 		}
@@ -710,13 +727,15 @@  discard block
 block discarded – undo
710 727
 		}
711 728
 		//jc: added this for beans that do not actually have a table, namely
712 729
 		//ForecastOpportunities
713
-		if($tablename == 'does_not_exist' || $tablename == '')
714
-			return '';
730
+		if($tablename == 'does_not_exist' || $tablename == '') {
731
+					return '';
732
+		}
715 733
 
716 734
 		global $dictionary;
717 735
 		$engine=null;
718
-		if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) )
719
-			$engine = $dictionary[$bean->getObjectName()]['engine'];
736
+		if (isset($dictionary[$bean->getObjectName()]['engine']) && !empty($dictionary[$bean->getObjectName()]['engine']) ) {
737
+					$engine = $dictionary[$bean->getObjectName()]['engine'];
738
+		}
720 739
 
721 740
 		return $this->repairTableParams($tablename, $fielddefs,$new_index,$execute,$engine);
722 741
 	}
@@ -760,8 +779,9 @@  discard block
 block discarded – undo
760 779
 	{
761 780
 		//jc: had a bug when running the repair if the tablename is blank the repair will
762 781
 		//fail when it tries to create a repair table
763
-		if ($tablename == '' || empty($fielddefs))
764
-			return '';
782
+		if ($tablename == '' || empty($fielddefs)) {
783
+					return '';
784
+		}
765 785
 
766 786
 		//if the table does not exist create it and we are done
767 787
 		$sql = "/* Table : $tablename */\n";
@@ -784,16 +804,16 @@  discard block
 block discarded – undo
784 804
 		// do column comparisons
785 805
 		$sql .=	"/*COLUMNS*/\n";
786 806
 		foreach ($fielddefs as $name => $value) {
787
-			if (isset($value['source']) && $value['source'] != 'db')
788
-				continue;
807
+			if (isset($value['source']) && $value['source'] != 'db') {
808
+							continue;
809
+			}
789 810
 
790 811
             // Bug #42406. Skipping breaked vardef without type or name
791 812
             if (isset($value['name']) == false || $value['name'] == false)
792 813
             {
793 814
                 $sql .= "/* NAME IS MISSING IN VARDEF $tablename::$name */\n";
794 815
                 continue;
795
-            }
796
-            else if (isset($value['type']) == false || $value['type'] == false)
816
+            } else if (isset($value['type']) == false || $value['type'] == false)
797 817
             {
798 818
                 $sql .= "/* TYPE IS MISSING IN VARDEF $tablename::$name */\n";
799 819
                 continue;
@@ -823,8 +843,9 @@  discard block
 block discarded – undo
823 843
 				// ok we need this field lets create it
824 844
 				$sql .=	"/*MISSING IN DATABASE - $name -  ROW*/\n";
825 845
 				$sql .= $this->addColumnSQL($tablename, $value) .  "\n";
826
-				if ($execute)
827
-					$this->addColumn($tablename, $value);
846
+				if ($execute) {
847
+									$this->addColumn($tablename, $value);
848
+				}
828 849
 				$take_action = true;
829 850
 			} elseif ( !$this->compareVarDefs($compareFieldDefs[$name],$value)) {
830 851
 				//fields are different lets alter it
@@ -880,8 +901,9 @@  discard block
 block discarded – undo
880 901
 		unset($compareIndices_case_insensitive);
881 902
 
882 903
 		foreach ($indices as $value) {
883
-			if (isset($value['source']) && $value['source'] != 'db')
884
-				continue;
904
+			if (isset($value['source']) && $value['source'] != 'db') {
905
+							continue;
906
+			}
885 907
 
886 908
 
887 909
 			$validDBName = $this->getValidDBName($value['name'], true, 'index', true);
@@ -891,19 +913,23 @@  discard block
 block discarded – undo
891 913
 		    $name = strtolower($value['name']);
892 914
 
893 915
 			//Don't attempt to fix the same index twice in one pass;
894
-			if (isset($correctedIndexs[$name]))
895
-				continue;
916
+			if (isset($correctedIndexs[$name])) {
917
+							continue;
918
+			}
896 919
 
897 920
 			//don't bother checking primary nothing we can do about them
898
-			if (isset($value['type']) && $value['type'] == 'primary')
899
-				continue;
921
+			if (isset($value['type']) && $value['type'] == 'primary') {
922
+							continue;
923
+			}
900 924
 
901 925
 			//database helpers do not know how to handle full text indices
902
-			if ($value['type']=='fulltext')
903
-				continue;
926
+			if ($value['type']=='fulltext') {
927
+							continue;
928
+			}
904 929
 
905
-			if ( in_array($value['type'],array('alternate_key','foreign')) )
906
-				$value['type'] = 'index';
930
+			if ( in_array($value['type'],array('alternate_key','foreign')) ) {
931
+							$value['type'] = 'index';
932
+			}
907 933
 
908 934
 			if ( !isset($compareIndices[$name]) ) {
909 935
 				//First check if an index exists that doesn't match our name, if so, try to rename it
@@ -934,21 +960,23 @@  discard block
 block discarded – undo
934 960
 				$sql .=	"/*INDEX MISMATCH WITH DATABASE - $name -  ROW ";
935 961
 				foreach ($compareIndices[$name] as $n1 => $t1) {
936 962
 					$sql .=	 "<$n1>";
937
-					if ( $n1 == 'fields' )
938
-						foreach($t1 as $rKey => $rValue)
963
+					if ( $n1 == 'fields' ) {
964
+											foreach($t1 as $rKey => $rValue)
939 965
 							$sql .= "[$rKey] => '$rValue'  ";
940
-					else
941
-						$sql .= " $t1 ";
966
+					} else {
967
+											$sql .= " $t1 ";
968
+					}
942 969
 				}
943 970
 				$sql .=	"*/\n";
944 971
 				$sql .=	"/* VARDEF - $name -  ROW";
945 972
 				foreach ($value as $n1 => $t1) {
946 973
 					$sql .=	"<$n1>";
947
-					if ( $n1 == 'fields' )
948
-						foreach ($t1 as $rKey => $rValue)
974
+					if ( $n1 == 'fields' ) {
975
+											foreach ($t1 as $rKey => $rValue)
949 976
 							$sql .=	"[$rKey] => '$rValue'  ";
950
-					else
951
-						$sql .= " $t1 ";
977
+					} else {
978
+											$sql .= " $t1 ";
979
+					}
952 980
 				}
953 981
 				$sql .=	"*/\n";
954 982
 				$sql .= $this->modifyIndexes($tablename,array($value), $execute) .  "\n";
@@ -971,8 +999,9 @@  discard block
 block discarded – undo
971 999
 	public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false)
972 1000
 	{
973 1001
 		foreach ( $fielddef1 as $key => $value ) {
974
-			if ($key == 'name' && $ignoreName)
975
-				continue;
1002
+			if ($key == 'name' && $ignoreName) {
1003
+							continue;
1004
+			}
976 1005
             if (isset($fielddef2[$key]))
977 1006
             {
978 1007
                 if (!is_array($fielddef1[$key]) && !is_array($fielddef2[$key]))
@@ -981,8 +1010,7 @@  discard block
 block discarded – undo
981 1010
                     {
982 1011
                         continue;
983 1012
                     }
984
-                }
985
-                else
1013
+                } else
986 1014
                 {
987 1015
                     if (array_map('strtolower', $fielddef1[$key]) == array_map('strtolower',$fielddef2[$key]))
988 1016
                     {
@@ -991,8 +1019,9 @@  discard block
 block discarded – undo
991 1019
                 }
992 1020
             }
993 1021
 			//Ignore len if its not set in the vardef
994
-			if ($key == 'len' && empty($fielddef2[$key]))
995
-				continue;
1022
+			if ($key == 'len' && empty($fielddef2[$key])) {
1023
+							continue;
1024
+			}
996 1025
             // if the length in db is greather than the vardef, ignore it
997 1026
             if ($key == 'len' && ($fielddef1[$key] >= $fielddef2[$key])) {
998 1027
                 continue;
@@ -1026,12 +1055,10 @@  discard block
 block discarded – undo
1026 1055
 			if (!$row2) {
1027 1056
 				// Exists on table1 but not table2
1028 1057
 				$returnArray['msg'] = 'not_exists_table2';
1029
-			}
1030
-			else {
1058
+			} else {
1031 1059
 				if (sizeof($row1) != sizeof($row2)) {
1032 1060
 					$returnArray['msg'] = 'no_match';
1033
-				}
1034
-				else {
1061
+				} else {
1035 1062
 					$returnArray['msg'] = 'match';
1036 1063
 					foreach($row1 as $key => $value){
1037 1064
 						//ignore keys when checking we will check them when we do the index check
@@ -1041,8 +1068,7 @@  discard block
 block discarded – undo
1041 1068
 					}
1042 1069
 				}
1043 1070
 			}
1044
-		}
1045
-		else {
1071
+		} else {
1046 1072
 			$returnArray['msg'] = 'not_exists_table1';
1047 1073
 		}
1048 1074
 
@@ -1122,16 +1148,19 @@  discard block
 block discarded – undo
1122 1148
 	 */
1123 1149
 	public function getConstraintSql($indices, $table)
1124 1150
 	{
1125
-		if (!$this->isFieldArray($indices))
1126
-			$indices = array($indices);
1151
+		if (!$this->isFieldArray($indices)) {
1152
+					$indices = array($indices);
1153
+		}
1127 1154
 
1128 1155
 		$columns = array();
1129 1156
 
1130 1157
 		foreach ($indices as $index) {
1131
-			if(!empty($index['db']) && $index['db'] != $this->dbType)
1132
-				continue;
1133
-			if (isset($index['source']) && $index['source'] != 'db')
1134
-			continue;
1158
+			if(!empty($index['db']) && $index['db'] != $this->dbType) {
1159
+							continue;
1160
+			}
1161
+			if (isset($index['source']) && $index['source'] != 'db') {
1162
+						continue;
1163
+			}
1135 1164
 
1136 1165
 			$sql = $this->add_drop_constraint($table, $index);
1137 1166
 
@@ -1221,11 +1250,11 @@  discard block
 block discarded – undo
1221 1250
 		$sql = $this->addColumnSQL($tablename, $fieldDefs);
1222 1251
 		if ($this->isFieldArray($fieldDefs)){
1223 1252
 			$columns = array();
1224
-			foreach ($fieldDefs as $fieldDef)
1225
-				$columns[] = $fieldDef['name'];
1253
+			foreach ($fieldDefs as $fieldDef) {
1254
+							$columns[] = $fieldDef['name'];
1255
+			}
1226 1256
 			$columns = implode(",", $columns);
1227
-		}
1228
-		else {
1257
+		} else {
1229 1258
 			$columns = $fieldDefs['name'];
1230 1259
 		}
1231 1260
 		$msg = "Error adding column(s) $columns on table: $tablename:";
@@ -1249,8 +1278,7 @@  discard block
 block discarded – undo
1249 1278
 				$columns[] = $fieldDef['name'];
1250 1279
 			}
1251 1280
 			$columns = implode(",", $columns);
1252
-		}
1253
-		else {
1281
+		} else {
1254 1282
 			$columns = $newFieldDef['name'];
1255 1283
 		}
1256 1284
 
@@ -1370,7 +1398,9 @@  discard block
 block discarded – undo
1370 1398
 			if(!$is_related_query){
1371 1399
 				foreach ($fields as $fieldDef)
1372 1400
 				{
1373
-					if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') continue;
1401
+					if(isset($fieldDef['source']) && $fieldDef['source'] != 'db' && $fieldDef['source'] != 'custom_fields') {
1402
+					    continue;
1403
+					}
1374 1404
 					$val = $row[$fieldDef['name']];
1375 1405
 
1376 1406
 					//handle auto increment values here only need to do this on insert not create
@@ -1379,8 +1409,7 @@  discard block
 block discarded – undo
1379 1409
 							if(!$built_columns){
1380 1410
 							$columns[] = 'deleted';
1381 1411
 						}
1382
-					}
1383
-					else
1412
+					} else
1384 1413
 					{
1385 1414
 						$type = $fieldDef['type'];
1386 1415
 						if(!empty($fieldDef['custom_type'])){
@@ -1388,28 +1417,32 @@  discard block
 block discarded – undo
1388 1417
 						}
1389 1418
 						// need to do some thing about types of values
1390 1419
 						if($this->dbType == 'mysql' && $val == '' && ($type == 'datetime' ||  $type == 'date' || $type == 'int' || $type == 'currency' || $type == 'decimal')){
1391
-							if(!empty($custom_fields[$fieldDef['name']]))
1392
-								$cstm_values[$fieldDef['name']] = 'null';
1393
-							else
1394
-								$values[$fieldDef['name']] = 'null';
1395
-						}else{
1420
+							if(!empty($custom_fields[$fieldDef['name']])) {
1421
+															$cstm_values[$fieldDef['name']] = 'null';
1422
+							} else {
1423
+															$values[$fieldDef['name']] = 'null';
1424
+							}
1425
+						} else{
1396 1426
 							if(isset($type) && $type=='int') {
1397
-								if(!empty($custom_fields[$fieldDef['name']]))
1398
-									$cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val));
1399
-								else
1400
-									$values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val));
1427
+								if(!empty($custom_fields[$fieldDef['name']])) {
1428
+																	$cstm_values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val));
1429
+								} else {
1430
+																	$values[$fieldDef['name']] = $GLOBALS['db']->quote(from_html($val));
1431
+								}
1401 1432
 							} else {
1402
-								if(!empty($custom_fields[$fieldDef['name']]))
1403
-									$cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'";
1404
-								else
1405
-									$values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'";
1433
+								if(!empty($custom_fields[$fieldDef['name']])) {
1434
+																	$cstm_values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'";
1435
+								} else {
1436
+																	$values[$fieldDef['name']] = "'".$GLOBALS['db']->quote(from_html($val))."'";
1437
+								}
1406 1438
 							}
1407 1439
 						}
1408 1440
 						if(!$built_columns){
1409
-							if(!empty($custom_fields[$fieldDef['name']]))
1410
-								$cstm_columns[] = $fieldDef['name'];
1411
-							else
1412
-								$columns[] = $fieldDef['name'];
1441
+							if(!empty($custom_fields[$fieldDef['name']])) {
1442
+															$cstm_columns[] = $fieldDef['name'];
1443
+							} else {
1444
+															$columns[] = $fieldDef['name'];
1445
+							}
1413 1446
 						}
1414 1447
 					}
1415 1448
 
@@ -1624,7 +1657,9 @@  discard block
 block discarded – undo
1624 1657
 		    $queryresult = $this->query($sql, $dieOnError, $msg);
1625 1658
 		}
1626 1659
 		$this->checkError($msg.' Get One Failed:' . $sql, $dieOnError);
1627
-		if (!$queryresult) return false;
1660
+		if (!$queryresult) {
1661
+		    return false;
1662
+		}
1628 1663
 		$row = $this->fetchByAssoc($queryresult);
1629 1664
 		if(!empty($row)) {
1630 1665
 			return array_shift($row);
@@ -1648,10 +1683,14 @@  discard block
 block discarded – undo
1648 1683
 		$queryresult = $this->query($sql, $dieOnError, $msg);
1649 1684
 		$this->checkError($msg.' Fetch One Failed:' . $sql, $dieOnError);
1650 1685
 
1651
-		if (!$queryresult) return false;
1686
+		if (!$queryresult) {
1687
+		    return false;
1688
+		}
1652 1689
 
1653 1690
 		$row = $this->fetchByAssoc($queryresult);
1654
-		if ( !$row ) return false;
1691
+		if ( !$row ) {
1692
+		    return false;
1693
+		}
1655 1694
 
1656 1695
 		$this->freeResult($queryresult);
1657 1696
 		return $row;
@@ -1708,13 +1747,15 @@  discard block
 block discarded – undo
1708 1747
 	protected function describeField($name, $tablename)
1709 1748
 	{
1710 1749
 		$table = $this->getTableDescription($tablename);
1711
-		if(!empty($table) && isset($table[$name]))
1712
-			return 	$table[$name];
1750
+		if(!empty($table) && isset($table[$name])) {
1751
+					return 	$table[$name];
1752
+		}
1713 1753
 
1714 1754
 		$table = $this->getTableDescription($tablename, true);
1715 1755
 
1716
-		if(isset($table[$name]))
1717
-		return $table[$name];
1756
+		if(isset($table[$name])) {
1757
+				return $table[$name];
1758
+		}
1718 1759
 
1719 1760
 		return array();
1720 1761
 	}
@@ -1768,11 +1809,15 @@  discard block
 block discarded – undo
1768 1809
      */
1769 1810
 	public function concat($table, array $fields, $space = ' ')
1770 1811
 	{
1771
-		if(empty($fields)) return '';
1812
+		if(empty($fields)) {
1813
+		    return '';
1814
+		}
1772 1815
 		$elems = array();
1773 1816
 		$space = $this->quoted($space);
1774 1817
 		foreach ( $fields as $field ) {
1775
-			if(!empty($elems)) $elems[] = $space;
1818
+			if(!empty($elems)) {
1819
+			    $elems[] = $space;
1820
+			}
1776 1821
 			$elems[] = $this->convert("$table.$field", 'IFNULL', array("''"));
1777 1822
 		}
1778 1823
 		$first = array_shift($elems);
@@ -1864,7 +1909,7 @@  discard block
 block discarded – undo
1864 1909
 				}//switch
1865 1910
 			}//foreach
1866 1911
 			return $this->query($query);
1867
-		}else{
1912
+		} else{
1868 1913
 			return false;
1869 1914
 		}
1870 1915
 	}
@@ -1926,20 +1971,30 @@  discard block
 block discarded – undo
1926 1971
         $fields = $bean->getFieldDefinitions();
1927 1972
 		// get column names and values
1928 1973
 		foreach ($fields as $field => $fieldDef) {
1929
-			if (isset($fieldDef['source']) && $fieldDef['source'] != 'db')  continue;
1974
+			if (isset($fieldDef['source']) && $fieldDef['source'] != 'db') {
1975
+			    continue;
1976
+			}
1930 1977
 			// Do not write out the id field on the update statement.
1931 1978
     		// We are not allowed to change ids.
1932
-    		if (empty($fieldDef['name']) || $fieldDef['name'] == $primaryField['name']) continue;
1979
+    		if (empty($fieldDef['name']) || $fieldDef['name'] == $primaryField['name']) {
1980
+    		    continue;
1981
+    		}
1933 1982
 
1934 1983
     		// If the field is an auto_increment field, then we shouldn't be setting it.  This was added
1935 1984
     		// specially for Bugs and Cases which have a number associated with them.
1936
-    		if (!empty($bean->field_name_map[$field]['auto_increment'])) continue;
1985
+    		if (!empty($bean->field_name_map[$field]['auto_increment'])) {
1986
+    		    continue;
1987
+    		}
1937 1988
 
1938 1989
     		//custom fields handle their save separately
1939
-    		if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type']))  continue;
1990
+    		if(isset($bean->field_name_map) && !empty($bean->field_name_map[$field]['custom_type'])) {
1991
+    		    continue;
1992
+    		}
1940 1993
 
1941 1994
     		// no need to clear deleted since we only update not deleted records anyway
1942
-    		if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) continue;
1995
+    		if($fieldDef['name'] == 'deleted' && empty($bean->deleted)) {
1996
+    		    continue;
1997
+    		}
1943 1998
 
1944 1999
     		if(isset($bean->$field)) {
1945 2000
     			$val = from_html($bean->$field);
@@ -1972,8 +2027,10 @@  discard block
 block discarded – undo
1972 2027
     		}
1973 2028
 		}
1974 2029
 
1975
-		if ( sizeof($columns) == 0 )
1976
-			return ""; // no columns set
2030
+		if ( sizeof($columns) == 0 ) {
2031
+					return "";
2032
+		}
2033
+		// no columns set
1977 2034
 
1978 2035
 		// build where clause
1979 2036
 		$where = $this->getWhereClause($bean, $this->updateWhereArray($bean, $where));
@@ -2039,8 +2096,9 @@  discard block
 block discarded – undo
2039 2096
 			$where[] = " $table.$name $op $val";
2040 2097
 		}
2041 2098
 
2042
-		if (!empty($where))
2043
-			return implode(" AND ", $where);
2099
+		if (!empty($where)) {
2100
+					return implode(" AND ", $where);
2101
+		}
2044 2102
 
2045 2103
 		return '';
2046 2104
 	}
@@ -2144,21 +2202,25 @@  discard block
 block discarded – undo
2144 2202
 	public function massageFieldDef(&$fieldDef, $tablename)
2145 2203
 	{
2146 2204
 		if ( !isset($fieldDef['dbType']) ) {
2147
-			if ( isset($fieldDef['dbtype']) )
2148
-				$fieldDef['dbType'] = $fieldDef['dbtype'];
2149
-			else
2150
-				$fieldDef['dbType'] = $fieldDef['type'];
2205
+			if ( isset($fieldDef['dbtype']) ) {
2206
+							$fieldDef['dbType'] = $fieldDef['dbtype'];
2207
+			} else {
2208
+							$fieldDef['dbType'] = $fieldDef['type'];
2209
+			}
2151 2210
 		}
2152 2211
 		$type = $this->getColumnType($fieldDef['dbType'],$fieldDef['name'],$tablename);
2153 2212
 		$matches = array();
2154 2213
         // len can be a number or a string like 'max', for example, nvarchar(max)
2155 2214
         preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*|\w+)\)|)/i', $type, $matches);
2156
-		if ( isset($matches[1][0]) )
2157
-			$fieldDef['type'] = $matches[1][0];
2158
-		if ( isset($matches[2][0]) && empty($fieldDef['len']) )
2159
-			$fieldDef['len'] = $matches[2][0];
2160
-		if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') )
2161
-			$fieldDef['len'] .= ",{$fieldDef['precision']}";
2215
+		if ( isset($matches[1][0]) ) {
2216
+					$fieldDef['type'] = $matches[1][0];
2217
+		}
2218
+		if ( isset($matches[2][0]) && empty($fieldDef['len']) ) {
2219
+					$fieldDef['len'] = $matches[2][0];
2220
+		}
2221
+		if ( !empty($fieldDef['precision']) && is_numeric($fieldDef['precision']) && !strstr($fieldDef['len'],',') ) {
2222
+					$fieldDef['len'] .= ",{$fieldDef['precision']}";
2223
+		}
2162 2224
 		if (!empty($fieldDef['required']) || ($fieldDef['name'] == 'id' && !isset($fieldDef['required'])) ) {
2163 2225
 			$fieldDef['required'] = 'true';
2164 2226
 		}
@@ -2172,8 +2234,9 @@  discard block
 block discarded – undo
2172 2234
 	public function getSelectFieldsFromQuery($selectStatement)
2173 2235
 	{
2174 2236
 		$selectStatement = trim($selectStatement);
2175
-		if (strtoupper(substr($selectStatement, 0, 6)) == "SELECT")
2176
-			$selectStatement = trim(substr($selectStatement, 6));
2237
+		if (strtoupper(substr($selectStatement, 0, 6)) == "SELECT") {
2238
+					$selectStatement = trim(substr($selectStatement, 6));
2239
+		}
2177 2240
 
2178 2241
 		//Due to sql functions existing in many selects, we can't use php explode
2179 2242
 		$fields = array();
@@ -2189,17 +2252,15 @@  discard block
 block discarded – undo
2189 2252
 				$field = $this->getFieldNameFromSelect(trim($selectField));
2190 2253
 				$fields[$field] = $selectField;
2191 2254
 				$selectField = "";
2192
-			}
2193
-			else if ($char == "("){
2255
+			} else if ($char == "("){
2194 2256
 				$level++;
2195 2257
 				$selectField .= $char;
2196
-			}
2197
-			else if($char == ")"){
2258
+			} else if($char == ")"){
2198 2259
 				$level--;
2199 2260
 				$selectField .= $char;
2200 2261
 
2201 2262
 
2202
-			}else{
2263
+			} else{
2203 2264
 				$selectField .= $char;
2204 2265
 			}
2205 2266
 
@@ -2218,18 +2279,19 @@  discard block
 block discarded – undo
2218 2279
 		if(strncasecmp($string, "DISTINCT ", 9) == 0) {
2219 2280
 			$string = substr($string, 9);
2220 2281
 		}
2221
-		if (stripos($string, " as ") !== false)
2222
-			//"as" used for an alias
2282
+		if (stripos($string, " as ") !== false) {
2283
+					//"as" used for an alias
2223 2284
 			return trim(substr($string, strripos($string, " as ") + 4));
2224
-		else if (strrpos($string, " ") != 0)
2225
-			//Space used as a delimiter for an alias
2285
+		} else if (strrpos($string, " ") != 0) {
2286
+					//Space used as a delimiter for an alias
2226 2287
 			return trim(substr($string, strrpos($string, " ")));
2227
-		else if (strpos($string, ".") !== false)
2228
-			//No alias, but a table.field format was used
2288
+		} else if (strpos($string, ".") !== false) {
2289
+					//No alias, but a table.field format was used
2229 2290
 			return substr($string, strpos($string, ".") + 1);
2230
-		else
2231
-			//Give up and assume the whole thing is the field name
2291
+		} else {
2292
+					//Give up and assume the whole thing is the field name
2232 2293
 			return $string;
2294
+		}
2233 2295
 	}
2234 2296
 
2235 2297
 	/**
@@ -2289,8 +2351,9 @@  discard block
 block discarded – undo
2289 2351
 			$aliases[$tableName][] = $table;
2290 2352
 
2291 2353
 			// build part of select for this table
2292
-			if (is_array($cols[$beanID]))
2293
-				foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name'];
2354
+			if (is_array($cols[$beanID])) {
2355
+							foreach ($cols[$beanID] as $def) $select[] = $table.".".$def['name'];
2356
+			}
2294 2357
 
2295 2358
 			// build part of where clause
2296 2359
 			if (is_array($whereClause[$beanID])){
@@ -2322,7 +2385,10 @@  discard block
 block discarded – undo
2322 2385
 		$separator = "";
2323 2386
 		$from = ''; $table_used_in_from = array();
2324 2387
 		foreach ($relations as $table1 => $rightsidearray){
2325
-			if ($table_used_in_from[$table1]) continue; // table has been joined
2388
+			if ($table_used_in_from[$table1]) {
2389
+			    continue;
2390
+			}
2391
+			// table has been joined
2326 2392
 
2327 2393
 			$from .= $separator." ".$table1;
2328 2394
 			$table_used_in_from[$table1] = true;
@@ -2333,7 +2399,9 @@  discard block
 block discarded – undo
2333 2399
 					//choose first alias that does not match
2334 2400
 					// we are doing this because of self joins.
2335 2401
 					// in case of self joins, the same table will have many aliases.
2336
-					if ($table2 != $table1) break;
2402
+					if ($table2 != $table1) {
2403
+					    break;
2404
+					}
2337 2405
 				}
2338 2406
 
2339 2407
 				$col = $tablearray['foreingColumn'];
@@ -2362,11 +2430,13 @@  discard block
 block discarded – undo
2362 2430
 		$tablename = $bean->getTableName();
2363 2431
 		$columns = array();
2364 2432
 		// get column names
2365
-		foreach ($fields as $fieldDef)
2366
-			$columns[] = $fieldDef['name'];
2433
+		foreach ($fields as $fieldDef) {
2434
+					$columns[] = $fieldDef['name'];
2435
+		}
2367 2436
 
2368
-		if (empty($columns))
2369
-			return "";
2437
+		if (empty($columns)) {
2438
+					return "";
2439
+		}
2370 2440
 
2371 2441
 		$columns = implode(",", $columns);
2372 2442
 
@@ -2386,16 +2456,21 @@  discard block
 block discarded – undo
2386 2456
 		// we do not have change a lot of existing code
2387 2457
 		// and add dbtype where type is being used for some special
2388 2458
 		// purposes like referring to foreign table etc.
2389
-		if(!empty($fieldDef['dbType']))
2390
-			return  $fieldDef['dbType'];
2391
-		if(!empty($fieldDef['dbtype']))
2392
-			return  $fieldDef['dbtype'];
2393
-		if (!empty($fieldDef['type']))
2394
-			return  $fieldDef['type'];
2395
-		if (!empty($fieldDef['Type']))
2396
-			return  $fieldDef['Type'];
2397
-		if (!empty($fieldDef['data_type']))
2398
-			return  $fieldDef['data_type'];
2459
+		if(!empty($fieldDef['dbType'])) {
2460
+					return  $fieldDef['dbType'];
2461
+		}
2462
+		if(!empty($fieldDef['dbtype'])) {
2463
+					return  $fieldDef['dbtype'];
2464
+		}
2465
+		if (!empty($fieldDef['type'])) {
2466
+					return  $fieldDef['type'];
2467
+		}
2468
+		if (!empty($fieldDef['Type'])) {
2469
+					return  $fieldDef['Type'];
2470
+		}
2471
+		if (!empty($fieldDef['data_type'])) {
2472
+					return  $fieldDef['data_type'];
2473
+		}
2399 2474
 
2400 2475
 		return null;
2401 2476
 	}
@@ -2453,14 +2528,15 @@  discard block
 block discarded – undo
2453 2528
                                           'clob', 'blob', 'text'))) {
2454 2529
           	    $colType = "$colBaseType(${fieldDef['len']})";
2455 2530
             } elseif(($colBaseType == 'decimal' || $colBaseType == 'float')){
2456
-                  if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision']))
2457
-                      if(strpos($fieldDef['len'],',') === false){
2531
+                  if(!empty($fieldDef['precision']) && is_numeric($fieldDef['precision'])) {
2532
+                                        if(strpos($fieldDef['len'],',') === false){
2458 2533
                           $colType = $colBaseType . "(".$fieldDef['len'].",".$fieldDef['precision'].")";
2459
-                      }else{
2460
-                          $colType = $colBaseType . "(".$fieldDef['len'].")";
2461
-                      }
2462
-                  else
2534
+                  }
2535
+                      } else{
2463 2536
                           $colType = $colBaseType . "(".$fieldDef['len'].")";
2537
+                      } else {
2538
+                                            $colType = $colBaseType . "(".$fieldDef['len'].")";
2539
+                  }
2464 2540
               }
2465 2541
         } else {
2466 2542
             if (in_array($colBaseType, array( 'nvarchar', 'nchar', 'varchar', 'varchar2', 'char'))) {
@@ -2474,19 +2550,18 @@  discard block
 block discarded – undo
2474 2550
         if (!empty($fieldDef['no_default']))
2475 2551
         {
2476 2552
             // nothing to do
2477
-        }
2478
-        elseif (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0)
2553
+        } elseif (isset($fieldDef['default']) && strlen($fieldDef['default']) > 0)
2479 2554
         {
2480 2555
             $default = " DEFAULT ".$this->quoted($fieldDef['default']);
2481
-        }
2482
-        elseif (!isset($default) && $type == 'bool')
2556
+        } elseif (!isset($default) && $type == 'bool')
2483 2557
         {
2484 2558
             $default = " DEFAULT 0 ";
2485 2559
         }
2486 2560
 
2487 2561
 		$auto_increment = '';
2488
-		if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment'])
2489
-			$auto_increment = $this->setAutoIncrement($table , $fieldDef['name']);
2562
+		if(!empty($fieldDef['auto_increment']) && $fieldDef['auto_increment']) {
2563
+					$auto_increment = $this->setAutoIncrement($table , $fieldDef['name']);
2564
+		}
2490 2565
 
2491 2566
 		$required = 'NULL';  // MySQL defaults to NULL, SQL Server defaults to NOT NULL -- must specify
2492 2567
 		//Starting in 6.0, only ID and auto_increment fields will be NOT NULL in the DB.
@@ -2500,8 +2575,9 @@  discard block
 block discarded – undo
2500 2575
 			&& !empty($fieldDef['required'])) {
2501 2576
 			$required =  "NOT NULL";
2502 2577
 		}
2503
-		if ($ignoreRequired)
2504
-			$required = "";
2578
+		if ($ignoreRequired) {
2579
+					$required = "";
2580
+		}
2505 2581
 
2506 2582
 		if ( $return_as_array ) {
2507 2583
 			return array(
@@ -2537,8 +2613,7 @@  discard block
 block discarded – undo
2537 2613
 				}
2538 2614
 			}
2539 2615
 			$columns = implode(",", $columns);
2540
-		}
2541
-		else {
2616
+		} else {
2542 2617
 			$columns = $this->oneColumnSQLRep($fieldDefs,$ignoreRequired, $tablename);
2543 2618
 		}
2544 2619
 
@@ -2760,8 +2835,9 @@  discard block
 block discarded – undo
2760 2835
 	 */
2761 2836
 	public function isFieldArray($defArray)
2762 2837
 	{
2763
-		if ( !is_array($defArray) )
2764
-			return false;
2838
+		if ( !is_array($defArray) ) {
2839
+					return false;
2840
+		}
2765 2841
 
2766 2842
 		if ( isset($defArray['type']) ){
2767 2843
 			// type key exists. May be an array of defs or a simple definition
@@ -2872,11 +2948,9 @@  discard block
 block discarded – undo
2872 2948
                 } else {
2873 2949
                     if (isset($properties['dbType'])) {
2874 2950
                         $field_type=$properties['dbType'];
2875
-                    }
2876
-                    else if(isset($properties['data_type'])) {
2951
+                    } else if(isset($properties['data_type'])) {
2877 2952
                         $field_type=$properties['data_type'];
2878
-                    }
2879
-                    else {
2953
+                    } else {
2880 2954
                         $field_type=$properties['dbtype'];
2881 2955
                     }
2882 2956
                 }
@@ -2901,13 +2975,11 @@  discard block
 block discarded – undo
2901 2975
                             if ($error >= 0.0000000001) {    // Smaller than 10E-10
2902 2976
                                 $change = true;
2903 2977
                             }
2904
-                        }
2905
-                        else if ($this->isBooleanType($field_type)) {
2978
+                        } else if ($this->isBooleanType($field_type)) {
2906 2979
                             if ($this->_getBooleanValue($before_value) != $this->_getBooleanValue($after_value)) {
2907 2980
                                 $change = true;
2908 2981
                             }
2909
-                        }
2910
-                        else {
2982
+                        } else {
2911 2983
                             $change = true;
2912 2984
                         }
2913 2985
                         if ($change) {
@@ -3005,8 +3077,9 @@  discard block
 block discarded – undo
3005 3077
 	protected function _getBooleanValue($val)
3006 3078
 	{
3007 3079
 		//need to put the === sign here otherwise true == 'non empty string'
3008
-		if (empty($val) or $val==='off')
3009
-			return false;
3080
+		if (empty($val) or $val==='off') {
3081
+					return false;
3082
+		}
3010 3083
 
3011 3084
 		return true;
3012 3085
 	}
@@ -3032,8 +3105,9 @@  discard block
 block discarded – undo
3032 3105
      */
3033 3106
 	protected function _emptyValue($val, $type)
3034 3107
 	{
3035
-		if (empty($val))
3036
-			return true;
3108
+		if (empty($val)) {
3109
+					return true;
3110
+		}
3037 3111
 
3038 3112
 		if($this->emptyValue($type) == $val) {
3039 3113
 			return true;
@@ -3050,10 +3124,12 @@  discard block
 block discarded – undo
3050 3124
 			case 'short':
3051 3125
 				return ($val == 0);
3052 3126
 			case 'date':
3053
-				if ($val == '0000-00-00')
3054
-					return true;
3055
-				if ($val == 'NULL')
3056
-					return true;
3127
+				if ($val == '0000-00-00') {
3128
+									return true;
3129
+				}
3130
+				if ($val == 'NULL') {
3131
+									return true;
3132
+				}
3057 3133
 				return false;
3058 3134
 		}
3059 3135
 
@@ -3407,7 +3483,9 @@  discard block
 block discarded – undo
3407 3483
 	 */
3408 3484
 	public function fetchByAssoc($result, $encode = true)
3409 3485
 	{
3410
-	    if (empty($result))	return false;
3486
+	    if (empty($result)) {
3487
+	        return false;
3488
+	    }
3411 3489
 
3412 3490
 	    if(is_int($encode) && func_num_args() == 3) {
3413 3491
 	        // old API: $result, $rowNum, $encode
Please login to merge, or discard this patch.
modules/Campaigns/WizardNewsletter.php 1 patch
Braces   +45 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -80,7 +82,7 @@  discard block
 block discarded – undo
80 82
 
81 83
 if( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==1)  ||  ($focus->campaign_type=='NewsLetter')){
82 84
     echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_NEWSLETTER WIZARD_TITLE'].$focus->name), true, false);
83
-}else{
85
+} else{
84 86
     echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_CAMPAIGN'].$focus->name), true, false);   
85 87
 }
86 88
 
@@ -89,9 +91,15 @@  discard block
 block discarded – undo
89 91
 $ss->assign("MOD", $mod_strings);
90 92
 $ss->assign("APP", $app_strings);
91 93
 
92
-if (isset($_REQUEST['return_module'])) $ss->assign("RETURN_MODULE", $_REQUEST['return_module']);
93
-if (isset($_REQUEST['return_action'])) $ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
94
-if (isset($_REQUEST['return_id'])) $ss->assign("RETURN_ID", $_REQUEST['return_id']);
94
+if (isset($_REQUEST['return_module'])) {
95
+    $ss->assign("RETURN_MODULE", $_REQUEST['return_module']);
96
+}
97
+if (isset($_REQUEST['return_action'])) {
98
+    $ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
99
+}
100
+if (isset($_REQUEST['return_id'])) {
101
+    $ss->assign("RETURN_ID", $_REQUEST['return_id']);
102
+}
95 103
 // handle Create $module then Cancel
96 104
 if (empty($_REQUEST['return_id'])) {
97 105
     $ss->assign("RETURN_ACTION", 'index');
@@ -120,10 +128,10 @@  discard block
 block discarded – undo
120 128
 if( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==1)  ||  ($focus->campaign_type=='NewsLetter')){
121 129
     $campaign_type = 'newsletter';
122 130
     $ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());    
123
-}elseif( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==2)  || ($focus->campaign_type=='Email') ){
131
+} elseif( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==2)  || ($focus->campaign_type=='Email') ){
124 132
     $campaign_type = 'email';
125 133
     $ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
126
-}else{
134
+} else{
127 135
     $campaign_type = 'general';
128 136
 }
129 137
 
@@ -162,8 +170,12 @@  discard block
 block discarded – undo
162 170
 $ss->assign("CAMP_NAME", $focus->name);
163 171
 $ss->assign("CAMP_RECORD", $focus->id);
164 172
 $ss->assign("CAMP_IMPRESSIONS", $focus->impressions);
165
-if (empty($focus->assigned_user_id) && empty($focus->id))  $focus->assigned_user_id = $current_user->id;
166
-if (empty($focus->assigned_name) && empty($focus->id))  $focus->assigned_user_name = $current_user->user_name;
173
+if (empty($focus->assigned_user_id) && empty($focus->id)) {
174
+    $focus->assigned_user_id = $current_user->id;
175
+}
176
+if (empty($focus->assigned_name) && empty($focus->id)) {
177
+    $focus->assigned_user_name = $current_user->user_name;
178
+}
167 179
 $ss->assign("ASSIGNED_USER_OPTIONS", get_select_options_with_id(get_user_array(TRUE, "Active", $focus->assigned_user_id), $focus->assigned_user_id));
168 180
 //$ss->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
169 181
 
@@ -171,10 +183,11 @@  discard block
 block discarded – undo
171 183
 
172 184
 $ss->assign("ASSIGNED_USER_ID", $focus->assigned_user_id );
173 185
 
174
-if((!isset($focus->status)) && (!isset($focus->id)))
186
+if((!isset($focus->status)) && (!isset($focus->id))) {
175 187
     $ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['campaign_status_dom'], 'Planning'));
176
-else
188
+} else {
177 189
     $ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['campaign_status_dom'], $focus->status));
190
+}
178 191
 
179 192
 //hide frequency options if this is not a newsletter
180 193
 if($campaign_type == 'newsletter'){
@@ -182,10 +195,10 @@  discard block
 block discarded – undo
182 195
     $ss->assign("FREQUENCY_LABEL", $mod_strings['LBL_CAMPAIGN_FREQUENCY']);
183 196
     if((!isset($focus->frequency)) && (!isset($focus->id))){
184 197
         $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], 'Monthly'));
185
-    }else{
198
+    } else{
186 199
         $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], $focus->frequency));
187 200
     }
188
-}else{
201
+} else{
189 202
     $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "input type='hidden'");
190 203
     $ss->assign("FREQUENCY_LABEL", '&nbsp;');
191 204
 }
@@ -195,12 +208,11 @@  discard block
 block discarded – undo
195 208
 if(isset($focus->currency_id) && !empty($focus->currency_id)){
196 209
     $selectCurrency = $currency->getSelectOptions($focus->currency_id);
197 210
     $ss->assign("CURRENCY", $selectCurrency);
198
-}
199
-else if($current_user->getPreference('currency') && !isset($focus->id))
211
+} else if($current_user->getPreference('currency') && !isset($focus->id))
200 212
 {
201 213
     $selectCurrency = $currency->getSelectOptions($current_user->getPreference('currency'));
202 214
     $ss->assign("CURRENCY", $selectCurrency);
203
-}else{
215
+} else{
204 216
 
205 217
     $selectCurrency = $currency->getSelectOptions();
206 218
     $ss->assign("CURRENCY", $selectCurrency);
@@ -231,7 +243,7 @@  discard block
 block discarded – undo
231 243
     foreach($OptionsArr as $key=>$val){
232 244
         if($val =='Newsletter' || $val =='Email' || $val =='' ){
233 245
             //do not add   
234
-        }else{
246
+        } else{
235 247
             $myTypeOptionsArr[$key] = $val;
236 248
         }
237 249
     }
@@ -243,7 +255,7 @@  discard block
 block discarded – undo
243 255
         //if the selected flag is set to true, then just populate
244 256
         if($selected){
245 257
             $type_option_html .="<option value='$optionKey' >$optionName</option>";
246
-        }else{//if not selected yet, check to see if this option should be selected
258
+        } else{//if not selected yet, check to see if this option should be selected
247 259
             //if the campaign type is not empty, then select the retrieved type
248 260
             if(!empty($focus->campaign_type)){
249 261
                 //check to see if key matches campaign type
@@ -252,11 +264,11 @@  discard block
 block discarded – undo
252 264
                     $type_option_html .="<option value='$optionKey' selected>$optionName</option>";
253 265
                     //mark as selected for next time
254 266
                     $selected=true;
255
-                }else{
267
+                } else{
256 268
                     //key does not match, just populate
257 269
                     $type_option_html .="<option value='$optionKey' >$optionName</option>";
258 270
                 }
259
-            }else{
271
+            } else{
260 272
             //since the campaign type is empty, then select first one                
261 273
                 $type_option_html .="<option value='$optionKey' selected>$optionName</option>";    
262 274
                 //mark as selected for next time
@@ -267,12 +279,12 @@  discard block
 block discarded – undo
267 279
     //assign the modified dropdown for general campaign creation
268 280
     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $type_option_html);
269 281
     $ss->assign("SHOULD_TYPE_BE_DISABLED", "select");    
270
-}elseif($campaign_type == 'email'){
282
+} elseif($campaign_type == 'email'){
271 283
     //Assign Email as type of campaign being created an disable the select widget
272 284
     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_EMAIL']);
273 285
     $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='Email'");
274 286
     $ss->assign("HIDE_CAMPAIGN_TYPE", true);
275
-}else{
287
+} else{
276 288
     //Assign NewsLetter as type of campaign being created an disable the select widget
277 289
     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_NEWSLETTER']);
278 290
     $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='NewsLetter'");
@@ -300,7 +312,7 @@  discard block
 block discarded – undo
300 312
         $ct_focus = new CampaignTracker();
301 313
         $ct_focus->retrieve($trkr_id);
302 314
       if(isset($ct_focus->tracker_name) && !empty($ct_focus->tracker_name)){
303
-            if($ct_focus->is_optout){$opt = 'checked';}else{$opt = '';}
315
+            if($ct_focus->is_optout){$opt = 'checked';} else{$opt = '';}
304 316
             $trkr_html .= "<div id='existing_trkr".$trkr_count."'> <table width='100%' border='0' cellspacing='0' cellpadding='0'>" ;
305 317
             $trkr_html .= "<tr class='evenListRowS1'><td width='15%'><input name='wiz_step3_is_optout".$trkr_count."' title='".$mod_strings['LBL_EDIT_OPT_OUT'] . $trkr_count ."' id='existing_is_optout". $trkr_count ."' class='checkbox' type='checkbox' $opt  /><input name='wiz_step3_id".$trkr_count."' value='".$ct_focus->id."' id='existing_tracker_id". $trkr_count ."'type='hidden''/></td>";
306 318
             $trkr_html .= "<td width='40%'> <input id='existing_tracker_name". $trkr_count ."' type='text' size='20' maxlength='255' name='wiz_step3_tracker_name". $trkr_count ."' title='".$mod_strings['LBL_EDIT_TRACKER_NAME']. $trkr_count ."' value='".$ct_focus->tracker_name."' ></td>";
@@ -315,7 +327,7 @@  discard block
 block discarded – undo
315 327
     }
316 328
     
317 329
     $trkr_html .= "<div id='no_trackers'></div>";
318
-    }else{
330
+    } else{
319 331
         $trkr_html .= "<div id='no_trackers'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr class='evenListRowS1'><td>".$mod_strings['LBL_NONE']."</td></tr></table></div>";
320 332
     }
321 333
     $ss->assign('EXISTING_TRACKERS', $trkr_html);
@@ -457,7 +469,7 @@  discard block
 block discarded – undo
457 469
 
458 470
 
459 471
 
460
-}else{
472
+} else{
461 473
     //this is not a newlsetter campaign, so fill in target list table
462 474
     //create array for javascript, this will help to display the option text, not the value
463 475
     $dom_txt =' ';
@@ -485,7 +497,7 @@  discard block
 block discarded – undo
485 497
         }
486 498
 
487 499
         $trgt_html  .= "<div id='no_targets'></div>";
488
-    }else{
500
+    } else{
489 501
         $trgt_html  .= "<div id='no_targets'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr class='evenListRowS1'><td>".$mod_strings['LBL_NONE']."</td></tr></table></div>";
490 502
 
491 503
     }
@@ -572,12 +584,11 @@  discard block
 block discarded – undo
572 584
     $ss->assign('NAV_ITEMS',create_wiz_menu_items($_steps,'campaign',$mrkt_string,$summ_url, 'dotlist'));
573 585
     $ss->assign('HIDE_CONTINUE','hidden');
574 586
 
575
-}elseif($campaign_type == 'email'){
587
+} elseif($campaign_type == 'email'){
576 588
     $steps = create_email_steps();
577 589
     if($focus->id) {
578 590
         $summ_url = "index.php?action=WizardHome&module=Campaigns&return_id=" . $focus->id . "&record=" . $focus->id;
579
-    }
580
-    else {
591
+    } else {
581 592
         $summ_url = false;
582 593
     }
583 594
     foreach($steps as $key => $step) {
@@ -588,13 +599,12 @@  discard block
 block discarded – undo
588 599
     $template_id = isset($_REQUEST['template_id']) && $_REQUEST['template_id'] ? $_REQUEST['template_id'] : null;
589 600
     $ss->assign('NAV_ITEMS',create_wiz_menu_items($_steps,'email',$mrkt_string,$summ_url, 'dotlist', $campaign_id, $marketing_id, $template_id));
590 601
     $ss->assign('HIDE_CONTINUE','submit');
591
-}else{
602
+} else{
592 603
     $steps = create_newsletter_steps();
593 604
 
594 605
     if($focus->id) {
595 606
         $summ_url = "index.php?action=WizardHome&module=Campaigns&return_id=" . $focus->id . "&record=" . $focus->id;
596
-    }
597
-    else {
607
+    } else {
598 608
         $summ_url = false;
599 609
     }
600 610
     foreach($steps as $key => $step) {
@@ -696,8 +706,7 @@  discard block
 block discarded – undo
696 706
             preg_match('/\bhref=\'([^\']*)/', $mrkt_string, $matches);
697 707
             if(isset($matches[1])) {
698 708
                 $marketingLink = $matches[1] . ($matches[1] ? '&jump=2' : false);
699
-            }
700
-            else {
709
+            } else {
701 710
                 $marketingLink = false;
702 711
             }
703 712
 
@@ -710,8 +719,7 @@  discard block
 block discarded – undo
710 719
 
711 720
         $nav_html = new DotListWizardMenu($mod_strings, $steps, true);
712 721
 
713
-    }
714
-    else {
722
+    } else {
715 723
         $nav_html = '<table border="0" cellspacing="0" cellpadding="0" width="100%" >';
716 724
         if(isset($steps)  && !empty($steps)){
717 725
             $i=1;
@@ -724,7 +732,7 @@  discard block
 block discarded – undo
724 732
             $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">$mrkt_string</div></td></tr>";
725 733
             $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+2).">".$mod_strings['LBL_NAVIGATION_MENU_SEND_EMAIL']."</div></li>";
726 734
             $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+3).">".$summ_url."</div></td></tr>";
727
-        }else{
735
+        } else{
728 736
             $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">".$summ_url."</div></td></tr>";
729 737
         }
730 738
 
Please login to merge, or discard this patch.